[Test] Add test runner option --retain-on-failure to retain tests on failure#7376
Merged
gmarciani merged 1 commit intoMay 18, 2026
Conversation
cdbbf46 to
8ea3a03
Compare
8ea3a03 to
45ab771
Compare
himani2411
reviewed
May 7, 2026
| logging.info("Registered stack %s for retention", stack_arn) | ||
|
|
||
|
|
||
| def _check_or_register_retain(request, test_id): |
Contributor
There was a problem hiding this comment.
I understand you you divided resources and stacks to handle the xdist workers and session level scope.
Can you retain this naming convention in the functions names you are using? It will be easier for the reader to understand the scope.
Contributor
Author
There was a problem hiding this comment.
I agree on changes to improve readability, but I am not getting the specific change you are asking :-)
himani2411
reviewed
May 7, 2026
| for bucket in created_buckets: | ||
| if request.config.getoption("no_delete"): | ||
| logging.info(f"Not deleting S3 bucket {bucket[0]}") | ||
| elif request.config.getoption("retain_on_failure") and is_region_retained(request, bucket[1]): |
Contributor
There was a problem hiding this comment.
[Non-blocking] There's quite a bit of code duplication in this conftest file — not introduced by this PR, but worth cleaning up in a follow-up.
himani2411
reviewed
May 7, 2026
| return False | ||
|
|
||
|
|
||
| def _get_retain_counter_path(request): |
Contributor
There was a problem hiding this comment.
45ab771 to
cce776f
Compare
cce776f to
1e63c7d
Compare
himani2411
approved these changes
May 18, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of changes
Add test runner option
--retain-on-failure [N]to retainNtests on failure.This test feature is useful to capture intermittent failures in a controlled way and retain the broken environments that are affected to facilitate investigations.
A recent example where it was necessary was the intermittent dcv session launcher failure, but it can also useful to capture the intermittent NFS port binding failure.
When the option is active, the test generates two files in the test workspace, that are used to both synchronize processes on the retention decision and also to facilitate the discovery of retained resources for the technician that is invetsigating the failure:
.retain_on_failure_tests: contains the list of failed tests for which resources have been retained..retained_stacks: contains the list of stack ARNs that have been retained.NOTES
Tests
Executed 4 parallel instances of
test_dcv_configurationwith injected failures in all of them in the following scenarios:--retain-on-failure: failures are reported as usual, but no test stack is retained.--retain-on-failure 1: failures are reported as usual, cluster/vpc/iam stack retained for one single test failure.--retain-on-failure 2: failures are reported as usual, cluster/vpc/iam stack retained for two test failures.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.