Repository navigation
fix(test): make the iOS simulator smoke lane's red/green signal meaningful (#2491) #3336
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
test/integration/ios-simulator-e2e-snapshot-acquisition.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import test from 'node:test'; | ||
|
|
||
| import { assertSimulatorSnapshotAcquisition } from './ios-simulator-e2e/live-snapshot-depth-frontier.ts'; | ||
|
|
||
| // #3328, pinned without a simulator: the depth-frontier scenario accepts either acquisition it | ||
| // can present depth facts from — the AX bridge (which publishes no verdict) or the XCTest runner | ||
| // the route sent the capture to (which always stamps its strategy) — and rejects only a capture | ||
| // whose own typed verdict says it degraded or served nothing. The positives are the exact shapes | ||
| // of the two failing main runs (37145696803, 37459193672), whose healthy `tree` verdict the old | ||
| // assertion failed on the word `tree`. | ||
|
|
||
| const HITTABLE = 'viewport-derived hittability evidence'; | ||
|
|
||
| function capture(quality: unknown): { json?: any } { | ||
| return { | ||
| json: { | ||
| success: true, | ||
| data: { | ||
| nodes: [{ index: 0, depth: 0, hittable: true }], | ||
| ...(quality === undefined ? {} : { snapshotQuality: quality }), | ||
| warnings: [HITTABLE], | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| test('an AX-bridge capture carries no verdict and is accepted', () => { | ||
| assertSimulatorSnapshotAcquisition(capture(undefined), 'regular depth-1 snapshot'); | ||
| }); | ||
|
|
||
| for (const backend of ['tree', 'queries', 'private-ax'] as const) { | ||
| test(`a runner-served capture disclosing the ${backend} strategy is accepted`, () => { | ||
| assertSimulatorSnapshotAcquisition( | ||
| capture({ state: 'healthy', backend, timing: { acquisitionMs: 64.7, presentationMs: 0.09 } }), | ||
| 'regular depth-1 snapshot', | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| for (const reasonCode of ['deferred', 'requested-backend'] as const) { | ||
| test(`a pre-selected-backend recovered verdict (${reasonCode}) is accepted`, () => { | ||
| assertSimulatorSnapshotAcquisition( | ||
| capture({ state: 'recovered', backend: 'private-ax', reasonCode }), | ||
| 'full raw visible-depth snapshot', | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| test('a capture that recovered to another strategy mid-capture is rejected', () => { | ||
| // The closest negative to the pre-selected pair: the same `recovered` state with a degradation | ||
| // code means the strategy the presented depth belongs to failed mid-capture, so the tree the | ||
| // frontier assertions would read is not a comparable view of the screen (#1569). | ||
| for (const reasonCode of ['capture-failed', 'presentation-failed', undefined]) { | ||
| assert.throws( | ||
| () => | ||
| assertSimulatorSnapshotAcquisition( | ||
| capture({ state: 'recovered', backend: 'tree', ...(reasonCode ? { reasonCode } : {}) }), | ||
| 'regular depth-1 snapshot', | ||
| ), | ||
| /fell back to another capture strategy mid-capture/, | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| test('a sparse capture is rejected whatever strategy it names', () => { | ||
| assert.throws( | ||
| () => | ||
| assertSimulatorSnapshotAcquisition( | ||
| capture({ state: 'sparse', backend: 'tree', reasonCode: 'sparse-tree' }), | ||
| 'regular depth-1 snapshot', | ||
| ), | ||
| /no backend served this screen/, | ||
| ); | ||
| }); | ||
|
|
||
| test('a verdict with a state outside the declared vocabulary is rejected', () => { | ||
| // The kernel declares ['healthy', 'recovered', 'sparse'] and the runner's allCases is pinned to | ||
| // the same fixture; a verdict outside that set means the two sides diverged, and certifying | ||
| // depth facts off a tree the lane cannot classify is the same meaningless-green defect as | ||
| // ruling a sparse capture healthy. | ||
| for (const state of ['unknown', 'degraded', undefined]) { | ||
| assert.throws( | ||
| () => | ||
| assertSimulatorSnapshotAcquisition( | ||
| capture({ ...(state === undefined ? {} : { state }), backend: 'tree' }), | ||
| 'regular depth-1 snapshot', | ||
| ), | ||
| /state outside the declared vocabulary/, | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| test('a capture that declares its hittability evidence missing is rejected', () => { | ||
| assert.throws( | ||
| () => | ||
| assertSimulatorSnapshotAcquisition( | ||
| { | ||
| json: { | ||
| success: true, | ||
| data: { | ||
| nodes: [{ index: 0, depth: 0 }], | ||
| warnings: [ | ||
| 'iOS snapshot acquisition does not provide hittability evidence; regular snapshots omit unverified hittability while raw snapshots preserve supplied facts.', | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| 'regular depth-1 snapshot', | ||
| ), | ||
| /must derive hittability/, | ||
| ); | ||
| }); |
74 changes: 74 additions & 0 deletions
74
test/integration/ios-simulator-e2e-step-retry-policy.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import test from 'node:test'; | ||
|
|
||
| import { WAIT_REASONS } from '@agent-device/contracts/wait'; | ||
| import type { CliJsonResult } from './cli-json.ts'; | ||
| import { isObservationPreventedStepMiss } from './ios-simulator-e2e/live-step-retry-policy.ts'; | ||
|
|
||
| // The #2491 retry policy for the iOS live lane, pinned without a simulator: which typed wire | ||
| // verdicts the lane may re-issue one step for, and — the closest negatives — which look close but | ||
| // must fail at once. The pairing of `retriable: true` with an observation-prevented | ||
| // `details.reason` is the whole predicate; neither signal alone activates a re-issue. | ||
|
|
||
| function stepResult(json: unknown, status = 1): CliJsonResult { | ||
| return { json, status, stdout: '', stderr: '' }; | ||
| } | ||
|
|
||
| function waitFailure(reason: string, retriable: boolean | undefined): CliJsonResult { | ||
| return stepResult({ | ||
| error: { | ||
| code: 'COMMAND_FAILED', | ||
| details: { reason }, | ||
| ...(retriable === undefined ? {} : { retriable }), | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| for (const reason of [ | ||
| WAIT_REASONS.captureStalled, | ||
| WAIT_REASONS.runnerRestartExhausted, | ||
| WAIT_REASONS.readinessExhausted, | ||
| ]) { | ||
| test(`${reason} with the product's retriable verdict re-issues the step`, () => { | ||
| assert.equal(isObservationPreventedStepMiss(waitFailure(reason, true)), true); | ||
| }); | ||
| } | ||
|
|
||
| test('an observation-prevented reason without the product retriable verdict does not re-issue', () => { | ||
| // The negative that keeps the predicate keyed on the conjunction: a response carrying the same | ||
| // reason but marked non-retriable (or carrying no verdict) must not buy a re-issue. | ||
| assert.equal( | ||
| isObservationPreventedStepMiss(waitFailure(WAIT_REASONS.captureStalled, false)), | ||
| false, | ||
| ); | ||
| assert.equal( | ||
| isObservationPreventedStepMiss(waitFailure(WAIT_REASONS.captureStalled, undefined)), | ||
| false, | ||
| ); | ||
| }); | ||
|
|
||
| test('a retriable target-absent or deadline-exceeded wait does not re-issue', () => { | ||
| // The screen was readable: the target was not there, or a readable capture consumed the | ||
| // remaining budget. Re-issuing would hide a real absence, so these stay hard failures. | ||
| assert.equal(isObservationPreventedStepMiss(waitFailure(WAIT_REASONS.targetAbsent, true)), false); | ||
| assert.equal( | ||
| isObservationPreventedStepMiss(waitFailure(WAIT_REASONS.deadlineExceeded, true)), | ||
| false, | ||
| ); | ||
| }); | ||
|
|
||
| test('a non-wait retriable failure does not re-issue', () => { | ||
| // A retriable verdict on a response with no wait taxonomy reason (e.g. a leased-busy device on | ||
| // a click) is not evidence that observation of THIS step was prevented. | ||
| assert.equal( | ||
| isObservationPreventedStepMiss( | ||
| stepResult({ error: { code: 'DEVICE_IN_USE', retriable: true } }), | ||
| ), | ||
| false, | ||
| ); | ||
| }); | ||
|
|
||
| test('a successful step result is never a re-attributable miss', () => { | ||
| assert.equal(isObservationPreventedStepMiss(stepResult(undefined, 0)), false); | ||
| assert.equal(isObservationPreventedStepMiss(stepResult(undefined)), false); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
test/integration/ios-simulator-e2e/live-step-retry-policy.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { WAIT_REASONS } from '@agent-device/contracts/wait'; | ||
| import type { CliJsonResult } from '../cli-json.ts'; | ||
|
|
||
| /** | ||
| * The wait verdicts that say the observation itself was prevented — the runner restarted, | ||
| * readiness work (runner start, bridge target discovery) ate the budget, or no capture was ever | ||
| * readable. Each is a lane condition on this host, not an answer about the screen: the product | ||
| * itself publishes all three with `retriable: true` and a "then retry" hint on the wire | ||
| * (`wait-polling.ts`), and they are the observed reds of the smoke lane (run 37356199982's | ||
| * `wait_runner_restart_exhausted` with `readableCaptures: 0`). | ||
| */ | ||
| const OBSERVATION_PREVENTED_WAIT_REASONS: ReadonlySet<string> = new Set([ | ||
| WAIT_REASONS.captureStalled, | ||
| WAIT_REASONS.runnerRestartExhausted, | ||
| WAIT_REASONS.readinessExhausted, | ||
| ]); | ||
|
|
||
| /** | ||
| * Whether one failed E2E step's result says the DEVICE prevented the observation, so re-issuing | ||
| * the same step is a measurement of the same question rather than a second bite at a real defect. | ||
| * | ||
| * Keyed on the conjunction of two typed signals — the wire `retriable` verdict the daemon hoists | ||
| * from its throw sites AND `error.details.reason` from the wait taxonomy — never on error text. | ||
| * Either signal alone is too wide: `retriable` also rides failures the lane must not re-issue | ||
| * blind (e.g. an app the lane itself is expected to have launched via another route), and a reason | ||
| * set copied onto a response the product marks non-retriable would retry a verdict the product | ||
| * says cannot succeed unchanged. The pairing is pinned in | ||
| * `test/integration/ios-simulator-e2e-step-retry-policy.test.ts`. | ||
| * | ||
| * `wait_target_absent` (the screen was readable and simply did not hold the target), | ||
| * `wait_deadline_exceeded` (a readable capture consumed the budget), a wrong assertion value, a | ||
| * runner crash, and any non-wait failure are all non-retriable by this predicate. | ||
| */ | ||
| export function isObservationPreventedStepMiss(result: CliJsonResult): boolean { | ||
| const error = result.json?.error; | ||
| if (!error || result.status === 0) return false; | ||
| return error.retriable === true && OBSERVATION_PREVENTED_WAIT_REASONS.has(error.details?.reason); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.