Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 38 additions & 18 deletions hack/provider_update_ci/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ import (
)

const (
fakeModeEnv = "DEVSY_PROVIDER_UPDATE_CI_FAKE_MODE"
cliModeEnv = "DEVSY_PROVIDER_UPDATE_CI_RUN_CLI"
fakeExitEnv = "DEVSY_PROVIDER_UPDATE_CI_FAKE_EXIT"
attemptsEnv = "DEVSY_PROVIDER_UPDATE_CI_ATTEMPTS_FILE"
largeLineEnv = "DEVSY_PROVIDER_UPDATE_CI_LARGE_LINE"
fakeGoBasename = "go"
missingMode = "missing"
skipMode = "skip"
noPassMode = "no-pass"
multipleMode = "multiple"
crashOnceMode = "crash-once"
crashTwiceMode = "crash-twice"
crashFailMode = "crash-after-failure"
fakeModeEnv = "DEVSY_PROVIDER_UPDATE_CI_FAKE_MODE"
cliModeEnv = "DEVSY_PROVIDER_UPDATE_CI_RUN_CLI"
fakeExitEnv = "DEVSY_PROVIDER_UPDATE_CI_FAKE_EXIT"
attemptsEnv = "DEVSY_PROVIDER_UPDATE_CI_ATTEMPTS_FILE"
largeLineEnv = "DEVSY_PROVIDER_UPDATE_CI_LARGE_LINE"
fakeGoBasename = "go"
missingMode = "missing"
skipMode = "skip"
noPassMode = "no-pass"
multipleMode = "multiple"
crashOnceMode = "crash-once"
crashTwiceMode = "crash-twice"
crashThriceMode = "crash-thrice"
crashFailMode = "crash-after-failure"
)

var fixtureTests = []testID{
Expand All @@ -49,7 +50,12 @@ var fakeCaseExceptions = map[string]map[int][]string{
},
}

var fakeCrashCounts = map[string]int{crashOnceMode: 1, crashTwiceMode: 2, crashFailMode: 1}
var fakeCrashCounts = map[string]int{
crashOnceMode: 1,
crashTwiceMode: 2,
crashThriceMode: 3,
crashFailMode: 1,
}

func TestMain(m *testing.M) {
if isFakeGoInvocation(os.Args[0]) {
Expand Down Expand Up @@ -358,19 +364,33 @@ func TestCLIRetriesRuntimeCrashOnce(t *testing.T) {
if got := countAttempts(t, attempts); got != 2 {
t.Fatalf("attempts = %d, want 2", got)
}
if !strings.Contains(stderr, "::warning::") || !strings.Contains(stderr, "attempt 2 of 2") {
if !strings.Contains(stderr, "::warning::") || !strings.Contains(stderr, "attempt 2 of 3") {
t.Fatalf("retry warning missing: %q", stderr)
}
}

func TestCLIFailsWhenRuntimeCrashRepeats(t *testing.T) {
func TestCLIRetriesTwoRuntimeCrashes(t *testing.T) {
attempts := setUpFakeGoWithAttempts(t, crashTwiceMode, "0")
_, stderr, code := runCLIProcess(t, "--artifacts-dir", t.TempDir())
if code != 0 {
t.Fatalf("CLI failed after two recoverable crashes: %q", stderr)
}
if got := countAttempts(t, attempts); got != 3 {
t.Fatalf("attempts = %d, want 3", got)
}
if !strings.Contains(stderr, "attempt 3 of 3") {
t.Fatalf("retry warning missing: %q", stderr)
}
}

func TestCLIFailsWhenRuntimeCrashRepeats(t *testing.T) {
attempts := setUpFakeGoWithAttempts(t, crashThriceMode, "0")
_, _, code := runCLIProcess(t, "--artifacts-dir", t.TempDir())
if code != 2 {
t.Fatalf("CLI exit code = %d, want 2", code)
}
if got := countAttempts(t, attempts); got != 2 {
t.Fatalf("attempts = %d, want 2", got)
if got := countAttempts(t, attempts); got != 3 {
t.Fatalf("attempts = %d, want 3", got)
}
}

Expand Down
4 changes: 2 additions & 2 deletions hack/provider_update_ci/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

const (
maxTestAttempts = 2
maxTestAttempts = 3
windowsAccessViolated = 0xc0000005
)

Expand All @@ -19,7 +19,7 @@ var runtimeFatalPrefixes = []string{
"panic: (interface {}) 0x",
}

// runGoTestsWithRetry reruns the tests once when the Go runtime itself crashed.
// runGoTestsWithRetry reruns the tests up to twice when the Go runtime itself crashed.
// Windows/amd64 AMX runners corrupt the heap when an exception frame overflows
// the goroutine stack reserve (golang/go#81238, unfixed). Remove this retry once
// a released Go toolchain contains the upstream fix.
Expand Down
Loading