Skip to content

Commit

Permalink
Fix race condition in test_redeploy_after_dependency_recovered test c…
Browse files Browse the repository at this point in the history
…ase. (Issue #8518, PR #8532)

# Description

Fix race condition in `test_redeploy_after_dependency_recovered` test case.

Closes #8518

# Self Check:

- [x] Attached issue to pull request
- [x] Changelog entry
- [x] Type annotations are present
- [x] Code is clear and sufficiently documented
- [x] No (preventable) type errors (check using make mypy or make mypy-diff)
- [x] Sufficient test cases (reproduces the bug/tests the requested feature)
- [x] Correct, in line with design
- [ ] ~~End user documentation is included or an issue is created for end-user documentation (add ref to issue here: )~~
- [ ] ~~If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)~~
  • Loading branch information
arnaudsjs authored and inmantaci committed Dec 27, 2024
1 parent 94a7c59 commit aabdfd8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
description: "Fix race condition in test_redeploy_after_dependency_recovered test case."
issue-nr: 8518
issue-repo: inmanta-core
change-type: patch
destination-branches: [master]
29 changes: 18 additions & 11 deletions tests/deploy/e2e/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,17 +1456,24 @@ async def test_redeploy_after_dependency_recovered(resource_container, server, c
# Trigger deploy without incrementing version
await scheduler.deploy_resource(rid1, reason="Deploy rid1", priority=TaskPriority.USER_DEPLOY)

await clienthelper.wait_for_deployed()
assert scheduler._state.resource_state[rid1] == ResourceState(
status=ComplianceStatus.COMPLIANT,
deployment_result=DeploymentResult.DEPLOYED,
blocked=BlockedStatus.NO,
)
assert scheduler._state.resource_state[rid2] == ResourceState(
status=ComplianceStatus.COMPLIANT,
deployment_result=DeploymentResult.DEPLOYED,
blocked=BlockedStatus.NO,
)
async def wait_for_resource_state() -> bool:
if scheduler._state.resource_state[rid1] != ResourceState(
status=ComplianceStatus.COMPLIANT,
deployment_result=DeploymentResult.DEPLOYED,
blocked=BlockedStatus.NO,
):
return False
if scheduler._state.resource_state[rid2] != ResourceState(
status=ComplianceStatus.COMPLIANT,
deployment_result=DeploymentResult.DEPLOYED,
blocked=BlockedStatus.NO,
):
return False
return True

# We can't rely on clienthelper.wait_for_deployed() here to wait until the re-deployment has finished,
# because that method assumes we are deploying a version that hasn't been deployed yet.
await retry_limited(wait_for_resource_state, timeout=10)

# Assert that no new version was created
result = await client.list_versions(tid=environment)
Expand Down

0 comments on commit aabdfd8

Please sign in to comment.