Skip to content

Commit

Permalink
Add a test for Ctrl+C when k6 is paused
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Jan 30, 2023
1 parent 396f84b commit 60c1026
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cmd/tests/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,27 @@ func TestAbortedByInterruptDuringVUInit(t *testing.T) {
assert.Contains(t, stdOut, `level=error msg="test run was aborted because k6 received a 'interrupt' signal"`)
}

func TestAbortedByInterruptWhenPaused(t *testing.T) {
t.Parallel()
script := `export default function () {};`
ts := getSimpleCloudOutputTestState(
t, script, []string{"-v", "--log-output=stdout", "--paused"},
cloudapi.RunStatusAbortedUser, cloudapi.ResultStatusPassed, exitcodes.ExternalAbort,
)
asyncWaitForStdoutAndStopTestWithInterruptSignal(
t, ts, 10, time.Second, "Execution is paused, waiting for resume or interrupt...",
)
cmd.ExecuteWithGlobalState(ts.GlobalState)

stdOut := ts.Stdout.String()
t.Log(stdOut)

assert.Contains(t, stdOut, `level=debug msg="Stopping k6 in response to signal..." sig=interrupt`)
assert.Contains(t, stdOut, `level=debug msg="Metrics emission of VUs and VUsMax metrics stopped"`)
assert.Contains(t, stdOut, `level=debug msg="Sending test finished" output=cloud ref=111 run_status=5 tainted=false`)
assert.Contains(t, stdOut, `level=error msg="test run was aborted because k6 received a 'interrupt' signal"`)
}

func TestAbortedByScriptInitError(t *testing.T) {
t.Parallel()
script := `
Expand Down

0 comments on commit 60c1026

Please sign in to comment.