Skip to content

feat(test): run a test suite and wait for it in one command (COR-15957) - #52

Closed
sanasarjanjughazyan wants to merge 5 commits into
masterfrom
san/run-suite-wait/COR-15957
Closed

sanasarjanjughazyan wants to merge 5 commits into
masterfrom
san/run-suite-wait/COR-15957

Conversation

@sanasarjanjughazyan

@sanasarjanjughazyan sanasarjanjughazyan commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Adds --wait to vf test run create-suite, so one command runs every test, a set of tests or the tests in some folders, waits until every run has finished, and exits non-zero unless every run passed. Linear: COR-15957. The API side shipped in creator-app #24901, and the last regeneration added create-suite, wait-suite and test folder list.

What changes

  • --wait starts the suite, then waits for it in 45-second calls to the suite wait endpoint (the API caps one wait at 120 seconds) until every run has finished.
  • --max-wait caps the total wait, 30 minutes by default. When it runs out, the suite keeps running, and the error names the vf test run wait-suite command to keep waiting and the cancel command to stop the runs.
  • Output: progress on stderr (the bulkID when the suite starts, then a line like 1 of 4 passed, 1 failed, 2 still going whenever the counts change). The final wait result (counts, and the runs that did not pass with their failed checks) goes to stdout in whatever --output-format is set.
  • Exit code: 0 only when every run passed. 1 when a run failed or was canceled, or when --max-wait ran out. In agent mode those come as the usual error envelope, test_suite_failed or test_suite_unfinished, with hints, and progress comes as JSON events on stderr (started with the bulkID, waiting, retrying), like vf auth login, so all of stderr parses as JSON.
  • A wait that hits a 5xx, a 429, no answer or an answer cut off mid-body is retried up to 3 times, 5 seconds apart, so one dropped request does not end a long wait.
  • Once the suite has started, every failure names the wait-suite command that picks it up again, never "retry the command", which would start a second suite. An API error such as a 401 keeps its usual error_type, status_code and hints, and gets the resume command added. A failure after --max-wait has run out reports the last answer as unfinished. An answer that decodes to nothing stops the wait instead of being polled. Hints carry --server-url when it was passed, shell-quoted.
  • In agent mode, stderr is JSON from start to finish: anything not reported explicitly goes through one guard that renders it as the error envelope.
  • Each wait asks the API to hold for less when --timeout (flag, env or config) would otherwise cut the request off first.
  • --test-ids and --folder-ids also take comma-separated IDs, with or without --wait. They are generated as repeatable string arrays, so --test-ids a,b used to send the single ID "a,b" and get a 404.
  • IDs typed into the interactive prompt are split on commas too.
  • Before the suite starts (with --dry-run too), --wait checks --max-wait, refuses a --timeout under 10 seconds since no wait fits in it, and parses and compiles --jq, which would otherwise fail only after the whole wait.
  • Without --wait the generated command runs unchanged. --max-wait without --wait is refused.
  • --usage lists --wait and --max-wait, in vf --usage and every schema between it and create-suite --usage.
  • The token-format warning prints once per process rather than once per client, since --wait builds a client per wait so OAuth tokens refresh.

Logic lives in a new hand-written internal/cli/test/run/createsuite_wait.go. The generated createsuite.go gets one line (addCreateSuiteWait(cmd)), which wraps its RunE. The new hand-written internal/usage/extra_flags.go adds hand-written flags to the generated --usage schemas.

Unchanged: a flag value cobra cannot parse (--max-wait abc) still prints cobra's plain error, the same as for every vf command, before anything is sent.

The per-wait deadline is set on the context, because the generated operations.WithOperationTimeout checks for retry support instead of timeout support, so it refuses every operation without retries, WaitSuite included.

Tests

  • New test/run-suite-wait.test.ts (mock API), 22 tests. They cover:
    • Waiting through an unfinished answer and exiting 0; exiting 1 with the failed checks printed; --max-wait running out, with the keep-waiting hint.
    • Retries: a retried 502 and a retried cut-off answer. A 503 that outlasts the retries ends with the resume hint, not "retry the command". A failure after --max-wait reports the last answer.
    • Agent mode, where stderr has to be only JSON: progress events and the envelope; 401 and 404 keeping authentication_error / not_found plus the resume hint; an empty or null answer; a create answer with no bulkID; invalid flag values (--max-wait, --timeout, --jq); --wait --dry-run with a bad body.
    • Flags: --jq refused before start (syntax and unknown function); --wait checks under --dry-run; --usage at three levels; comma-separated --test-ids and --folder-ids.
    • These also catch a regeneration that drops the hook line.
  • New createsuite_wait_test.go: ID splitting, shell quoting of hint values, per-wait length within the API's 5 to 120 seconds and within --timeout, which errors are retried, the progress line.
  • gofmt -l . clean; go test ./... passes; behaviour tests (VF_SKIP_INTEGRATION_TESTS=1 yarn test): 127 passed; yarn oxlint: no new warnings.
  • An independent review traced every error return and stderr write in agent mode, with repros against a mock server. Its findings are fixed and covered above.
  • go vet ./... fails only on generated SDK files with unexported constant fields. It fails the same way on master (the Vet step is red on the last three master runs), and go vet is clean on the changed package.
  • Live against a dev env: a folder suite (1 run) and two tests passed as --test-ids a,b, both with --wait. Both finished in under 35 seconds and exited 0.
  • Not run: speakeasy run, to re-check that the hook line survives regeneration. The behaviour tests fail if it does not.

Copilot AI balanced review requested due to automatic review settings November 25, 2026 17:55
@linear-code

linear-code Bot commented Nov 25, 2026

Copy link
Copy Markdown

COR-15957

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved deadline and timeout handling can exceed --max-wait, falsely report success, or leave queued runs behind, while unnormalized interactive IDs can cause invalid requests.

3 open issues
1 file not reviewed
  • internal/cli/test/run/createsuite.go: Generated file
What changed in this PR

Adds a single-command workflow for starting test suites and waiting for results, supporting CI checks and agent-driven testing.

Changes:

  • Adds --wait and --max-wait, with retry handling, progress output, and suite-based exit status.
  • Supports comma-separated test and folder IDs.
  • Adds mock-API behavior tests and Go unit tests for the waiting helpers.
File Description
test/​run-suite-wait.test.ts Tests suite outcomes, retries, wait limits, agent output, and ID parsing.
internal/​cli/​test/​run/​createsuite.go Hooks the generated command into the custom waiting logic.
internal/​cli/​test/​run/​createsuite_wait.go Implements waiting, progress, outcome reporting, and ID normalization.
internal/​cli/​test/​run/​createsuite_wait_test.go Tests ID splitting, wait durations, retry classification, and progress text.

Review effort: Balanced

…d keep retries within --max-wait (COR-15957)

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Agent-mode stderr includes human-readable output that breaks JSON consumers, and truncated responses are not retried, prematurely ending waits for running suites.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Retry truncated responses and network errors

internal/​cli/​test/​run/​createsuite_wait.go:339

A connection dropped after response headers is not retried: WaitSuite propagates a wrapped io.ErrUnexpectedEOF from ConsumeRawBody, which this classifier rejects. A single truncated response—including a 502—therefore ends the wait while the suite keeps running. Import io and net, extend the classifier to recognize io.ErrUnexpectedEOF and net.Error, and cover a truncated response in the mock tests.

3 resolved since last review
1 file not reviewed
  • internal/cli/test/run/createsuite.go: Generated file

Review effort: Balanced

…try cut-off answers (COR-15957)

Co-authored-by: Cursor <cursoragent@cursor.com>
@sanasarjanjughazyan

Copy link
Copy Markdown
Contributor Author

Also from the review overview ("previously missed"): a wait whose answer was cut off mid-body (io.ErrUnexpectedEOF from reading the body) is now retried, as is any net.Error. Fixed in fd89c71, with a Go case and a mock test that sends headers and half a body, then drops the connection.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Long-running suite monitoring can stop when OAuth tokens expire, and several agent-mode flag validation errors return plain text instead of the expected JSON error envelope.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Return validation errors in the agent JSON envelope

internal/​cli/​test/​run/​createsuite_wait.go:102

In agent mode, --max-wait without --wait returns plain text, so parsing stderr as JSON fails. The same issue affects nonpositive --max-wait values at line 159 and a too-short --timeout at lines 168–169. Route all three validation errors through suiteError with invalid_flag_value so they produce the usual error envelope.

Medium severity Refresh OAuth credentials before each wait

internal/​cli/​test/​run/​createsuite_wait.go:255

The SDK resolves OAuth credentials only when client.NewClient runs, so this loop keeps sending the original access token. If that token expires during a long suite, the next wait returns a non-retryable 401 and monitoring stops despite an available refresh token. Rebuild the configured client before each wait so oauth.AccessToken can refresh while preserving flag/environment token overrides.

1 resolved since last review
1 file not reviewed
  • internal/cli/test/run/createsuite.go: Generated file

Review effort: Balanced

…redentials for each wait (COR-15957)

Co-authored-by: Cursor <cursoragent@cursor.com>
@sanasarjanjughazyan

Copy link
Copy Markdown
Contributor Author

Both "previously missed" issues from the latest review are fixed in 00b4d3a:

  • Validation errors in agent mode: --max-wait without --wait, a --max-wait of zero or less, and a --timeout under 10s now go through suiteError as invalid_flag_value (the type flagerrors.go uses), each with a hint. In agent mode they come as the usual envelope. A new behaviour test checks that each produces exactly one JSON envelope on stderr and sends no request.
  • OAuth refresh during a long wait: the loop now builds the client before each wait, which is when credentials are resolved. An OAuth access token that expires mid-suite is refreshed, as it is for any vf command, while --token and VF_TOKEN still win. Checked live against a dev env.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Some wait failures bypass the agent-mode error renderer, causing prose to appear in stderr after JSON progress events; these errors need structured rendering and regression coverage.

1 open issue
1 file not reviewed
  • internal/cli/test/run/createsuite.go: Generated file

Review effort: Balanced

…mable (COR-15957)

- Every failure in agent mode reaches stderr as a JSON envelope, after the
  progress events; anything not reported explicitly is caught by one guard.
- After the suite starts, failures say how to keep waiting (wait-suite)
  instead of to rerun, which would start a second suite. API errors keep
  their error_type, status_code and hints.
- A wait answer that decodes to nothing stops instead of being polled until
  --max-wait; a failure after --max-wait reports the last answer.
- --max-wait, --timeout and --jq (parsed and compiled) are checked before the
  suite starts, under --dry-run too.
- Hints carry --server-url and are shell-quoted; the token warning prints
  once per process; --usage lists --wait and --max-wait at every level.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human review is needed to assess JSON-output violations, duplicate-suite risks after ambiguous creation failures, and expired deadlines from non-positive configured timeouts.

No open issues 🎉

1 resolved since last review
1 file not reviewed
  • internal/cli/test/run/createsuite.go: Generated file

Review effort: Balanced

sanasarjanjughazyan commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Nov 26, 4:01 PM UTC: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Nov 26, 4:01 PM UTC: sanasarjanjughazyan added this pull request to the Graphite merge queue.
  • Nov 26, 4:02 PM UTC: CI is running for this pull request on a draft pull request (#54) due to your merge queue CI optimization settings.
  • Nov 26, 4:03 PM UTC: Merged by the Graphite merge queue via draft PR: #54.

@graphite-app graphite-app Bot closed this Nov 26, 2026
@graphite-app
graphite-app Bot deleted the san/run-suite-wait/COR-15957 branch November 26, 2026 16:03
@graphite-app graphite-app Bot removed the merge label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants