grafana/k6 · error

97

97

Error message

The test has failed

What it means

The terminal-outcome branch after a cloud run: thresholds did not fail, but testProgress.TestFailed() is true, so k6 returns 'The test has failed' with exit code 97 (CloudTestRunFailed). It means the cloud service itself reported the run as failed (as opposed to a local problem or a threshold breach).

Source

Thrown at internal/cmd/cloud.go:393

	// Stop progress rendering before printing final status to avoid ghost bars.
	progressCancel()
	progressBarWG.Wait()

	if testProgress == nil {
		//nolint:staticcheck
		return errext.WithExitCodeIfNone(errors.New("Test progress error"), exitcodes.CloudFailedToGetProgress)
	}

	c.printTestStatus(testProgress.FormatStatus())

	if testProgress.ThresholdsFailed() {
		//nolint:staticcheck
		return errext.WithExitCodeIfNone(errors.New("Thresholds have been crossed"), exitcodes.ThresholdsHaveFailed)
	}
	if testProgress.TestFailed() {
		//nolint:staticcheck
		return errext.WithExitCodeIfNone(errors.New("The test has failed"), exitcodes.CloudTestRunFailed)
	}

	return nil
}

func (c *cmdCloud) printTestStatus(status string) {
	if !c.gs.Flags.Quiet {
		valueColor := getColor(c.gs.Flags.NoColor || !c.gs.Stdout.IsTTY, color.FgCyan)
		printToStdout(c.gs, fmt.Sprintf(
			"     test status: %s\n", valueColor.Sprint(status),
		))
	} else {
		c.gs.Logger.WithField("run_status", status).Debug("Test finished")
	}
}

func (c *cmdCloud) flagSet() *pflag.FlagSet {
	flags := pflag.NewFlagSet("", pflag.ContinueOnError)

View on GitHub (pinned to 93accf6570)

Solutions

  1. Read the 'test status:' line printed just above the error and open the run in Grafana Cloud for the abort/failure reason
  2. Check the cloud logs stream (k6 prints them by default) for script-level errors that failed the run
  3. Verify account quota/limits if the status indicates a limit-enforced stop
  4. Re-run once infrastructure or script issues identified in the UI are addressed
Defensive patterns

Strategy: validation

Validate before calling

# before re-running, confirm the previous run's failure reason
# (open the printed test run URL / Grafana Cloud UI) so the same abort does not recur

Try / catch

err := runK6("cloud", "run", "script.js")
if exitCode(err) == 97 { // exitcodes.CloudTestRunFailed
    // the service reported the run failed: fetch the run URL and inspect
    // logs/status before retrying; do not blind-retry in CI
}

Prevention

When it happens

Trigger: The final TestProgress for the run carries a failed status — e.g. the run errored or was aborted server-side, aborted from the UI, or hit a cloud-side limit/quota. The printed 'test status:' line immediately before the error shows the concrete status string.

Common situations: Run aborted by an operator or automation in the Grafana Cloud UI; cloud-side errors such as script runtime errors flagged by the service; quota/limit-enforced aborts; infrastructure issues on the cloud runners.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/3b6c5cefa3e685fc. Report an issue: GitHub.