{Core} Fix: test_credscache_good_error_on_file_corruption
fails when run in parallel with other tests
#17477
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.
Symptom
Fix:
test_credscache_good_error_on_file_corruption
fails when run in parallel with other testsCI failure:
https://dev.azure.com/azure-sdk/playground/_build/results?buildId=806624&view=logs&j=abe8eae2-a613-5a65-3eeb-3e8a13573181&t=ff49c02d-6a40-524c-c9b1-98f6bb13c7f4&l=2248
Root cause
The test
test_credscache_good_error_on_file_corruption
assumes~/.azure/accessTokens.json
exists when it is run. If there is no~/.azure/accessTokens.json
,azure-cli/src/azure-cli-core/azure/cli/core/_profile.py
Line 109 in 50ccb24
evaluates to
False
, thus bypassing the code under test, causing failure.This can also be repoed by deleting
~/.azure/accessTokens.json
and only runningtest_credscache_good_error_on_file_corruption
:⚠ In parallel testing, the existence of
~/.azure/accessTokens.json
is not guaranteed, so the failure.Change
Also patch
os.path.isfile
to make the test isolated from the underlying file system.