Skip to content
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

feat: experimental retries #27930

Merged
merged 58 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f6821e0
chore: set up feature/test-burn-in feature branch
AtofStryker Jul 24, 2023
02ef3a3
Merge branch 'develop' of github.com:cypress-io/cypress into feature/…
AtofStryker Jul 26, 2023
ba1a119
Merge pull request #27400 from cypress-io/chore/merge-develop-into-te…
AtofStryker Jul 26, 2023
c428443
feat: add burnIn Configuration option (currently a no-op) (#27377)
AtofStryker Jul 26, 2023
ef84f03
feat: add new experimental retries configuration (#27412)
AtofStryker Aug 1, 2023
334a955
Merge branch 'develop' into feature/test-burn-in
AtofStryker Aug 11, 2023
209b719
fix cache invalidation [run ci]
astone123 Aug 14, 2023
a802904
Merge branch 'develop' of https://github.com/cypress-io/cypress into …
AtofStryker Aug 16, 2023
f919931
Merge pull request #27538 from cypress-io/chore/merge-develop-test-bu…
AtofStryker Aug 17, 2023
cc0dd8a
Merge branch 'develop' of https://github.com/cypress-io/cypress into …
AtofStryker Sep 5, 2023
bb5046c
fix snapshot added in v13 for module api to include test burn in expe…
AtofStryker Sep 6, 2023
d08a7fa
chore: fix merge conflict
AtofStryker Sep 6, 2023
62e6e11
Merge pull request #27751 from cypress-io/chore/merge-develop
AtofStryker Sep 6, 2023
f4804dd
Merge branch 'develop' of https://github.com/cypress-io/cypress into …
AtofStryker Sep 8, 2023
0fbfc28
Merge pull request #27777 from cypress-io/chore/merge-develop-burnin
AtofStryker Sep 8, 2023
ae3df1a
chore: add burnInTestAction capability (#27768)
mabela416 Sep 12, 2023
a1ad9ca
feat: implement experimental retries (#27826)
AtofStryker Sep 27, 2023
5e8deb7
Revert "feat: add burnIn Configuration option (currently a no-op) (#2…
AtofStryker Sep 28, 2023
cde15d0
Revert "chore: add burnInTestAction capability (#27768)"
AtofStryker Sep 28, 2023
c5abc90
chore: run snapshot and binary jobs against experimental retries feat…
AtofStryker Sep 28, 2023
376c00f
Merge branch 'develop' of https://github.com/cypress-io/cypress into …
AtofStryker Sep 28, 2023
f866c5c
chore: add changelog entry (wip)
AtofStryker Sep 28, 2023
83842a6
Revert "fix snapshot added in v13 for module api to include test burn…
AtofStryker Sep 28, 2023
9799c53
Fix system tests
MuazOthman Oct 4, 2023
eb794a3
Merge branch 'develop' into feature/experimental-retries
MuazOthman Oct 4, 2023
fe367d6
Clear CircleCI cache
MuazOthman Oct 4, 2023
0fecba0
Normalize retries config for test execution
MuazOthman Oct 5, 2023
1b15b2a
Fixed some unit tests
MuazOthman Oct 11, 2023
cd738a3
update snapshots for newer test metadata
cacieprins Oct 12, 2023
d38d1f1
Fix cy-in-cy snapshots
MuazOthman Oct 12, 2023
13691b5
update snapshots
cacieprins Oct 13, 2023
b1c6147
bump cache version
cacieprins Oct 13, 2023
57057fd
Merge branch 'develop' into feature/experimental-retries
cacieprins Oct 16, 2023
8533173
Merge branch 'develop' into feature/experimental-retries
cacieprins Oct 17, 2023
2d1df6c
chore: ensure legacy retry overrides work; reject exp. retries overri…
cacieprins Oct 18, 2023
769a10e
Merge branch 'develop' into feature/experimental-retries
cacieprins Oct 18, 2023
6fb19bf
Merge branch 'develop' into feature/experimental-retries
cacieprins Oct 19, 2023
665db2e
update changelog
cacieprins Oct 19, 2023
a488c27
flip if statement in experimental retries option validation
cacieprins Oct 20, 2023
31e8ba7
refactor invalid experimental retry override for more useful error msg
cacieprins Oct 20, 2023
d71a46c
revert testConfigOverrides snapshot
cacieprins Oct 20, 2023
6e589f8
update snapshots for test override sys test
cacieprins Oct 20, 2023
48c6734
Update packages/config/src/validation.ts
cacieprins Oct 20, 2023
e89d821
succinct changelog entry; links to docs for details
cacieprins Oct 23, 2023
067c265
testConfigOverride system test snapshots
cacieprins Oct 23, 2023
4b0f9a2
Update .github/workflows/update_v8_snapshot_cache.yml
cacieprins Oct 23, 2023
386af08
Update cli/CHANGELOG.md
cacieprins Oct 23, 2023
0800b5f
Update packages/driver/src/cypress.ts
cacieprins Oct 23, 2023
711b548
updating cache-version
mschile Oct 23, 2023
b459aba
improve typescript usage when appending experimental retry options to…
cacieprins Oct 23, 2023
9c54013
Revert "improve typescript usage when appending experimental retry op…
cacieprins Oct 23, 2023
577ae49
refactor test config override validation for experimental retry subkeys
cacieprins Oct 24, 2023
1a17cad
account for error throw differences in browsers in system tests
cacieprins Oct 24, 2023
0ca0b19
Merge branch 'develop' into feature/experimental-retries
cacieprins Oct 24, 2023
8d44661
Merge branch 'develop' into feature/experimental-retries
cacieprins Oct 25, 2023
69e0761
bump circle cache
cacieprins Oct 25, 2023
5e85168
bump circle cache again
cacieprins Oct 25, 2023
d66f980
Merge branch 'develop' into feature/experimental-retries
cacieprins Oct 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ mainBuildFilters: &mainBuildFilters
- develop
- /^release\/\d+\.\d+\.\d+$/
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- 'update-v8-snapshot-cache-on-develop'
- 'feature/experimental-retries'
- 'publish-binary'
- 'chore/update_electron25_and_node18'

Expand All @@ -41,17 +43,14 @@ macWorkflowFilters: &darwin-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'chore/update_electron25_and_node18', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>

- equal: [ 'feature/experimental-retries', << pipeline.git.branch >> ]
linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'jordanpowell88/update-angular-tsconfig-path', << pipeline.git.branch >> ]
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'feature/experimental-retries', << pipeline.git.branch >> ]
- equal: [ 'publish-binary', << pipeline.git.branch >> ]
- equal: [ 'chore/update_electron25_and_node18', << pipeline.git.branch >> ]
- matches:
Expand All @@ -76,7 +75,7 @@ windowsWorkflowFilters: &windows-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'chore/update_electron25_and_node18', << pipeline.git.branch >> ]
- equal: [ 'feature/experimental-retries', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -146,7 +145,7 @@ commands:
name: Set environment variable to determine whether or not to persist artifacts
command: |
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "publish-binary" && "$CIRCLE_BRANCH" != "update-v8-snapshot-cache-on-develop" && "$CIRCLE_BRANCH" != "chore/update_electron25_and_node18" ]]; then
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "publish-binary" && "$CIRCLE_BRANCH" != "update-v8-snapshot-cache-on-develop" && "$CIRCLE_BRANCH" != "feature/experimental-retries" ]]; then
export SHOULD_PERSIST_ARTIFACTS=true
fi' >> "$BASH_ENV"
# You must run `setup_should_persist_artifacts` command and be using bash before running this command
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update_v8_snapshot_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
push:
branches:
- 'release/**'
- 'feature/experimental-retries'
cacieprins marked this conversation as resolved.
Show resolved Hide resolved
workflow_dispatch:
inputs:
branch:
Expand Down
14 changes: 13 additions & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
## 13.3.1
## 13.4.0

_Released 10/03/2023 (PENDING)_

**Features:**

- Users can now specify different retry options with the `experimentalRetries` configuration. These configuration options can be useful when detecting flake and figuring out under what conditions you would like to pass a retried test. The `retries` configuration option includes two new keys, `experimentalStrategy` and `experimentalOptions`. The first, `experimentalStrategy`, can be one of two options:
- `detect-flake-and-pass-on-threshold`
- `detect-flake-but-always-fail`

`detect-flake-and-pass-on-threshold` is similar to how retries work today. Users will be able to specify a retry limit and specify a required number of passes needed in order for that test to be marked as passed. Today, that limit is `1`, but users can set the limit to whatever they'd like with this strategy by specifying the `experimentalOptions.passesRequired` key in their global configuration. This can be useful if a test is retrying and is known to be flaky, but you want to make sure that the test can at least pass a certain threshold in order to be marked as passed overall, which might help in confidence that the test is just flaky and the failure is not considered legitimate. It's important to note that if the `passesRequired` can not be achieved by the remaining retries of the test, the test will stop retrying and the test will be marked as a failure.

The other, `detect-flake-but-always-fail`, will always mark a test that enters retries as failed, regardless of how many retried attempts pass. There is an option here, called `experimentalOptions.stopIfAnyPassed`, that will stop the test retries if any retry attempt passes. Without this option, you might want to see what the probability that your test might pass (similar to `detect-flake-and-pass-on-threshold`, but mark the test as failed as you might not want to mark any detected flaky test as a passed test.

Both of these strategies require the `experimentalOptions.maxRetries` option to be set, which will be the maximum number of retries a test might run. Addressed in [#27930](https://github.com/cypress-io/cypress/pull/27930).

cacieprins marked this conversation as resolved.
Show resolved Hide resolved
**Bugfixes:**

- Fixed an issue where requests were correlated in the wrong order in the proxy. This could cause an issue where the wrong request is used for `cy.intercept` or assets (e.g. stylesheets or images) may not properly be available in Test Replay. Addressed in [#27892](https://github.com/cypress-io/cypress/pull/27892).
Expand Down
26 changes: 25 additions & 1 deletion cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2851,6 +2851,30 @@ declare namespace Cypress {
certs: PEMCert[] | PFXCert[]
}

type RetryStrategyWithModeSpecs = RetryStrategy & {
openMode: boolean; // defaults to false
runMode: boolean; // defaults to true
}

type RetryStrategy =
| RetryStrategyDetectFlakeAndPassOnThresholdType
| RetryStrategyDetectFlakeButAlwaysFailType

interface RetryStrategyDetectFlakeAndPassOnThresholdType {
experimentalStrategy: "detect-flake-and-pass-on-threshold"
experimentalOptions?: {
maxRetries: number; // defaults to 2 if experimentalOptions is not provided, must be a whole number > 0
passesRequired: number; // defaults to 2 if experimentalOptions is not provided, must be a whole number > 0 and <= maxRetries
}
}

interface RetryStrategyDetectFlakeButAlwaysFailType {
experimentalStrategy: "detect-flake-but-always-fail"
experimentalOptions?: {
maxRetries: number; // defaults to 2 if experimentalOptions is not provided, must be a whole number > 0
stopIfAnyPassed: boolean; // defaults to false if experimentalOptions is not provided
}
}
interface ResolvedConfigOptions<ComponentDevServerOpts = any> {
/**
* Url used as prefix for [cy.visit()](https://on.cypress.io/visit) or [cy.request()](https://on.cypress.io/request) command's url
Expand Down Expand Up @@ -3122,7 +3146,7 @@ declare namespace Cypress {
* To enable test retries only in runMode, set e.g. `{ openMode: null, runMode: 2 }`
* @default null
*/
retries: Nullable<number | { runMode?: Nullable<number>, openMode?: Nullable<number> }>
retries: Nullable<number | ({ runMode?: Nullable<number>, openMode?: Nullable<number> }) | RetryStrategyWithModeSpecs>
/**
* Enables including elements within the shadow DOM when using querying
* commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.config.{js,ts,mjs,cjs},
Expand Down
33 changes: 33 additions & 0 deletions cli/types/tests/cypress-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,39 @@ namespace CypressLocalStorageTests {
cy.clearAllSessionStorage({ log: 'true' }) // $ExpectError
}

namespace CypressRetriesSpec {
Cypress.config('retries', {
openMode: 0,
runMode: 1
})

Cypress.config('retries', {
openMode: false,
runMode: false,
experimentalStrategy: "detect-flake-and-pass-on-threshold",
experimentalOptions: {
maxRetries: 2,
passesRequired: 2
}
})

Cypress.config('retries', {
openMode: false,
runMode: false,
experimentalStrategy: "detect-flake-but-always-fail",
experimentalOptions: {
maxRetries: 2,
stopIfAnyPassed: true
}
})

Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: "detect-flake-and-pass-on-threshold", experimentalOptions: { maxRetries: 2} }) // $ExpectError
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: "detect-flake-but-always-fail", experimentalOptions: { maxRetries: 2} }) // $ExpectError

Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: "detect-flake-and-pass-on-threshold", experimentalOptions: { passesRequired: 2} }) // $ExpectError
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: "detect-flake-but-always-fail", experimentalOptions: { stopIfAnyPassed: true} }) // $ExpectError
}

namespace CypressTraversalTests {
cy.wrap({}).prevUntil('a') // $ExpectType Chainable<JQuery<HTMLAnchorElement>>
cy.wrap({}).prevUntil('#myItem') // $ExpectType Chainable<JQuery<HTMLElement>>
Expand Down
Loading
Loading