Skip to content

Commit

Permalink
Report Cloud runs aborted by thresholds with exitcodes.ThresholdsHave…
Browse files Browse the repository at this point in the history
…Failed
  • Loading branch information
joanlopez committed Aug 28, 2024
1 parent 8aa1aca commit a697872
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ func (c *cmdCloud) run(cmd *cobra.Command, args []string) error {
// Although by looking at [ResultStatus] and [RunStatus] isn't self-explanatory,
// the scenario when the test run has finished, but it failed is an exceptional case for those situations
// when thresholds have been crossed (failed). So, we report this situation as such.
if testProgress.RunStatus == cloudapi.RunStatusFinished {
if testProgress.RunStatus == cloudapi.RunStatusFinished ||
testProgress.RunStatus == cloudapi.RunStatusAbortedThreshold {
return errext.WithExitCodeIfNone(errors.New("Thresholds have been crossed"), exitcodes.ThresholdsHaveFailed)
}

Expand Down
21 changes: 21 additions & 0 deletions cmd/tests/cmd_cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,27 @@ func runCloudTests(t *testing.T, setupCmd setupCommandFunc) {
t.Log(stdout)
assert.Contains(t, stdout, `Thresholds have been crossed`)
})

t.Run("TestCloudAbortedThreshold", func(t *testing.T) {
t.Parallel()

progressCallback := func() cloudapi.TestProgressResponse {
return cloudapi.TestProgressResponse{
RunStatusText: "Finished",
RunStatus: cloudapi.RunStatusAbortedThreshold,
ResultStatus: cloudapi.ResultStatusFailed,
Progress: 1.0,
}
}
ts := getSimpleCloudTestState(t, nil, setupCmd, nil, nil, progressCallback)
ts.ExpectedExitCode = int(exitcodes.ThresholdsHaveFailed)

cmd.ExecuteWithGlobalState(ts.GlobalState)

stdout := ts.Stdout.String()
t.Log(stdout)
assert.Contains(t, stdout, `Thresholds have been crossed`)
})
}

func cloudTestStartSimple(tb testing.TB, testRunID int) http.Handler {
Expand Down

0 comments on commit a697872

Please sign in to comment.