Skip to content

Commit c237a7a

Browse files
authored
Fix flaky executor timeout test (#356)
This gives the test a longer timeout to ensure that we've reached `runSteps` when the timeout kicks in, even on slow CI machines. And it changes the "sleep" to a power-nap-sleep-loop so that we only have to wait 100ms until the test returns.
1 parent 84583d3 commit c237a7a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

internal/campaigns/executor_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,15 @@ func TestExecutor_Integration(t *testing.T) {
8888
{repo: srcCLIRepo, files: map[string]string{"README.md": "line 1"}},
8989
},
9090
steps: []Step{
91-
{Run: `sleep 1`, Container: "alpine:13"},
91+
// This needs to be a loop, because when a process goes to sleep
92+
// it's not interruptible, meaning that while it will receive SIGKILL
93+
// it won't exit until it had its full night of sleep.
94+
// So.
95+
// Instead we take short powernaps.
96+
{Run: `while true; do echo "zZzzZ" && sleep 0.05; done`, Container: "alpine:13"},
9297
},
93-
executorTimeout: 20 * time.Millisecond,
94-
wantErrInclude: "execution in github.com/sourcegraph/src-cli failed: Timeout reached. Execution took longer than 20ms.",
98+
executorTimeout: 100 * time.Millisecond,
99+
wantErrInclude: "execution in github.com/sourcegraph/src-cli failed: Timeout reached. Execution took longer than 100ms.",
95100
},
96101
}
97102

0 commit comments

Comments
 (0)