test(ci): isolate app race partitions

This commit is contained in:
克谨
2026-08-12 22:46:05 +08:00
parent 221e42b103
commit 6bf78f1783
6 changed files with 181 additions and 11 deletions
+8 -5
View File
@@ -1182,13 +1182,16 @@ func TestChangelogPRFastPathWorkflowContract(t *testing.T) {
t.Fatal("Code Admission workflow missing race test job boundaries")
}
raceJob := admission[raceStart:raceEnd]
// Full race shards use a dynamic package-level timeout: default/floor 12m,
// with app/cli/smoke raised to 15m for NewRootCommand / Schema assembly under
// -race on slower hosted runners.
// The app shard uses independently bounded test processes so process-global
// command registries are released before the Schema assembly peak. Other full
// race shards retain the dynamic package timeout: default/floor 12m, with
// cli/smoke raised to 15m on slower hosted runners.
for _, want := range []string{
`if [ "$TEST_SHARD" = "app" ]; then`,
`test "${#packages[@]}" -eq 1`,
`./scripts/ci/run-app-race-tests.sh run "${packages[0]}"`,
"timeout_budget=12m",
`if [ "$TEST_SHARD" = "app" ] ||`,
`[ "$TEST_SHARD" = "cli" ] ||`,
`if [ "$TEST_SHARD" = "cli" ] ||`,
`[ "$TEST_SHARD" = "smoke" ]; then`,
"timeout_budget=15m",
`go test -v -race -count=1 -timeout="$timeout_budget" "${packages[@]}"`,
+19
View File
@@ -47,6 +47,25 @@ func TestCITestPackagePlanRoutesPublicTestSuites(t *testing.T) {
}
}
func TestCIAppRacePartitionsCoverTopLevelTestsExactlyOnce(t *testing.T) {
root := testPackagePlanRoot(t)
packages := strings.Fields(runTestPackagePlan(t, root, "list", "app"))
if len(packages) != 1 {
t.Fatalf("app package shard = %v, want exactly one package", packages)
}
script := filepath.Join(root, "scripts", "ci", "run-app-race-tests.sh")
cmd := exec.Command("sh", script, "verify", packages[0])
cmd.Dir = root
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("%s verify %s failed: %v\n%s", script, packages[0], err, output)
}
if !strings.Contains(string(output), "top-level tests exactly once") {
t.Fatalf("verify output = %q, want exact coverage summary", output)
}
}
func TestCITestPackagePlanFailsClosedWhenGoListFails(t *testing.T) {
root := testPackagePlanRoot(t)
fakeBin := t.TempDir()