10000 Prevent race between Ended & Interrupted exec states by joanlopez · Pull Request #4665 · grafana/k6 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Prevent race between Ended & Interrupted exec states #4665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025

Conversation

joanlopez
Copy link
Contributor
@joanlopez joanlopez commented Apr 1, 2025

What?

It only marks the test as "ended" (lib.ExecutionStatusEnded, by calling e.state.MarkEnded()) when it hasn't been aborted.

Why?

import exec from 'k6/execution';

export default function () {
  exec.test.abort();
}

With the current flow, in particular scenarios like the one above, the test goes through lib.ExecutionStatusRunning, then lib.ExecutionStatusEnded, and finally ExecutionStatusInterrupted, which isn't technically correct because from an external standpoint, another process using the K6 API to check the status (e.g., k6 TC) can temporally see it as successfully finished (e.g., lib.ExecutionStatusEnded).

This is likely the reason why integration tests have been intermittently failing for long, especially:

  • TestAbortTestVUDefault
  • and TestTheErrorOnPushMetricTest,

which are aborted, and expect:

test.ExpectTestRunStatuses(cloudapi.RunStatusInitializing, cloudapi.RunStatusRunning, cloudapi.RunStatusAbortedUser)

but sometimes get cloudapi.RunStatusFinished.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

N/A

@joanlopez joanlopez self-assigned this Apr 1, 2025
@joanlopez joanlopez requested a review from a team as a code owner April 1, 2025 21:51
@joanlopez joanlopez requested review from mstoykov and inancgumus and removed request for a team April 1, 2025 21:51
@joanlopez joanlopez force-pushed the ended-interrupted-race branch from 0e4f2a4 to 3e404d0 8000 Compare April 1, 2025 22:21
@joanlopez joanlopez added this to the v1.0.0 milestone Apr 1, 2025
@joanlopez joanlopez force-pushed the ended-interrupted-race branch from 3e404d0 to cbcaae8 Compare April 1, 2025 22:33
@joanlopez joanlopez marked this pull request as draft April 1, 2025 22:50
@joanlopez joanlopez marked this pull request as ready for review April 3, 2025 14:59
@joanlopez joanlopez merged commit 20369d7 into master Apr 7, 2025
28 checks passed
@joanlopez joanlopez deleted the ended-interrupted-race branch April 7, 2025 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0