Fix race condition in test case envs dir deletion (#8438)#8440
Closed
Fix race condition in test case envs dir deletion (#8438)#8440
Conversation
…ories_on_server` test case. (PR #8438) # Description Fix race condition in `test_environment_delete_removes_env_directories_on_server` test case. The registration of the compile request happens asynchronously with respect to the `notify_change()` API call. So the `is_compiling()` API call can happen before the compile request is created or before the compilation has started. ``` 02:45:43 __________ test_environment_delete_removes_env_directories_on_server ___________ 02:45:43 02:45:43 server = <inmanta.server.protocol.Server object at 0x7f67cc481c50> 02:45:43 client = <inmanta.protocol.endpoints.Client object at 0x7f67cc786610> 02:45:43 02:45:43 async def test_environment_delete_removes_env_directories_on_server( 02:45:43 server, 02:45:43 client, 02:45:43 ) -> None: 02:45:43 """ 02:45:43 Make sure the environment_delete endpoint deletes the environment directory on the server. 02:45:43 """ 02:45:43 state_dir: Optional[str] = config.Config.get("config", "state-dir") 02:45:43 assert state_dir is not None 02:45:43 env_dir = py.path.local(state_dir).join("server", "environments") 02:45:43 02:45:43 result = await client.create_project("env-test") 02:45:43 assert result.code == 200 02:45:43 project_id = result.result["project"]["id"] 02:45:43 02:45:43 result = await client.create_environment(project_id=project_id, name="env1") 02:45:43 assert result.code == 200 02:45:43 env_id = result.result["environment"]["id"] 02:45:43 02:45:43 result: Result = await client.notify_change(env_id) 02:45:43 assert result.code == 200 02:45:43 02:45:43 async def wait_for_compile() -> bool: 02:45:43 result = await client.is_compiling(env_id) 02:45:43 return result.code == 204 02:45:43 02:45:43 await utils.retry_limited(wait_for_compile, 15) 02:45:43 02:45:43 > assert os.path.exists(os.path.join(env_dir, env_id)) 02:45:43 E AssertionError: assert False 02:45:43 E + where False = <function exists at 0x7f680b8b7420>('/tmp/tmpmm37oya2/server/environments/a75c6da0-c84b-4ab7-b1d9-b661c109bc96') 02:45:43 E + where <function exists at 0x7f680b8b7420> = <module 'posixpath' (frozen)>.exists 02:45:43 E + where <module 'posixpath' (frozen)> = os.path 02:45:43 E + and '/tmp/tmpmm37oya2/server/environments/a75c6da0-c84b-4ab7-b1d9-b661c109bc96' = <function join at 0x7f6809a305e0>(local('/tmp/tmpmm37oya2/server/environments'), 'a75c6da0-c84b-4ab7-b1d9-b661c109bc96') 02:45:43 E + where <function join at 0x7f6809a305e0> = <module 'posixpath' (frozen)>.join 02:45:43 E + where <module 'posixpath' (frozen)> = os.path 02:45:43 02:45:43 tests/server/test_compilerservice.py:1979: AssertionError ``` # Self Check - [ ] ~~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~~ - [ ] ~~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)~~
9 tasks
Contributor
Author
|
Merged into branches iso7 in e5acdec |
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.
Pull request opened by the merge tool on behalf of #8438