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

tests: WinError 32 on CI again #1344

Closed
jku opened this issue Apr 9, 2021 · 1 comment · Fixed by #1346
Closed

tests: WinError 32 on CI again #1344

jku opened this issue Apr 9, 2021 · 1 comment · Fixed by #1346
Assignees

Comments

@jku
Copy link
Member

jku commented Apr 9, 2021

While deleting the temporary directory:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process:

While my initial reaction is that this some Windows BS again... maybe there are broken tests. Our test setup is in some cases unnecessarily complex and could hide issues.

Full log from https://github.com/theupdateframework/tuf/pull/1337/checks?check_run_id=2296694965:

2021-04-08T12:27:41.4005743Z ======================================================================
2021-04-08T12:27:41.4007002Z ERROR: test_update (test_multiple_repositories_integration.TestMultipleRepositoriesIntegration)
2021-04-08T12:27:41.4008300Z ----------------------------------------------------------------------
2021-04-08T12:27:41.4009113Z Traceback (most recent call last):
2021-04-08T12:27:41.4011194Z   File "D:\a\tuf\tuf\tests\test_multiple_repositories_integration.py", line 175, in tearDown
2021-04-08T12:27:41.4012361Z     shutil.rmtree(self.temporary_directory)
2021-04-08T12:27:41.4013338Z   File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\shutil.py", line 516, in rmtree
2021-04-08T12:27:41.4014214Z     return _rmtree_unsafe(path, onerror)
2021-04-08T12:27:41.4015136Z   File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\shutil.py", line 395, in _rmtree_unsafe
2021-04-08T12:27:41.4015989Z     _rmtree_unsafe(fullname, onerror)
2021-04-08T12:27:41.4016900Z   File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\shutil.py", line 395, in _rmtree_unsafe
2021-04-08T12:27:41.4018012Z     _rmtree_unsafe(fullname, onerror)
2021-04-08T12:27:41.4018950Z   File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\shutil.py", line 404, in _rmtree_unsafe
2021-04-08T12:27:41.4019860Z     onerror(os.rmdir, path, sys.exc_info())
2021-04-08T12:27:41.4020803Z   File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\shutil.py", line 402, in _rmtree_unsafe
2021-04-08T12:27:41.4021550Z     os.rmdir(path)
2021-04-08T12:27:41.4023055Z PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'D:\\a\\tuf\\tuf\\tests\\tmplg5mtj4n\\TestMultipleRepositoriesIntegration_ziar2llq\\repository_server2'

In the example case the test creates a tempdir using tempfile, then creates another tempdir inside it using unittest_toolbox, then it starts two server processes that use the inner temp dir...

Then when tearing down it calls unittest_toolbox teardown first, which probably deletes the directory while the process is still running. So:

  • Process shutdown should always be the first thing in test teardown
  • test setup should not be as complex as it is

The only flaw in this theory is that the error only comes in line 175 in test_multiple_repositories_integration.py -- how did the original unittest_toolbox..TearDown() succeed on line 164?

@jku
Copy link
Member Author

jku commented Apr 9, 2021

from teodora:

Modified Test Case ignores permission error as a subclass of OSError

This explains why line 164 "succeeds" -- it just quietly fails to remove the directory.

jku pushed a commit to jku/python-tuf that referenced this issue Apr 12, 2021
Make sure test server processes are killed before the temporary
directories are removed.

Let Modified_Testcase handle the top-level temporary directory.
Don't let Modified_testcase handle any subdirectories because:
 * teardown will try to remove them in the wrong order
 * removing the top level is enough

Fixes theupdateframework#1344

Signed-off-by: Jussi Kukkonen <[email protected]>
@jku jku self-assigned this Apr 12, 2021
@jku jku linked a pull request Apr 12, 2021 that will close this issue
@jku jku closed this as completed in #1346 Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant