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

[TEST FAILURE] Flaky LazyLoaderRefreshFileMappingTest Test #64567

Closed
cianyleow opened this issue Jun 28, 2023 · 1 comment · Fixed by #64568
Closed

[TEST FAILURE] Flaky LazyLoaderRefreshFileMappingTest Test #64567

cianyleow opened this issue Jun 28, 2023 · 1 comment · Fixed by #64568
Labels
Test-Failure Fix the CI failure ⛈

Comments

@cianyleow
Copy link
Contributor

Please paste the link from the specific build where the failure first started: This occurred in CI for a private fork of the salt repository, but is something that we felt would be useful upstream.

The error seen was related to a mismatch of an assertion between the number of calls to a function and the number of times a lock was acquired.

In our local CI environment, the threading.RLock.__enter__ function is called more often than the _refresh_file_mapping function, which leads to occasional failures (the full text of the issue is below).

tests/unit/test_loader.py:1722 (LazyLoaderRefreshFileMappingTest.test_lazyloader_refresh_file_mapping_called_with_lock_at___init__)
2 != 11

self = <tests.unit.test_loader.LazyLoaderRefreshFileMappingTest testMethod=test_lazyloader_refresh_file_mapping_called_with_lock_at___init__>

    def test_lazyloader_refresh_file_mapping_called_with_lock_at___init__(self):
        func_mock = MagicMock()
        lock_mock = MagicMock()
        lock_mock.__enter__ = MagicMock()
        self.LOADER_CLASS._refresh_file_mapping = func_mock
        with patch("threading.RLock", MagicMock(return_value=lock_mock)):
            loader = self.__init_loader()
        lock_mock.__enter__.assert_called()
        func_mock.assert_called()
>       assert len(func_mock.call_args_list) == len(lock_mock.__enter__.call_args_list)
E       AssertionError: assert 2 == 11
E        +  where 2 = len([call(), call()])
E        +    where [call(), call()] = <MagicMock id='140237436141920'>.call_args_list
E        +  and   11 = len([call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call()])
E        +    where [call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call(),\n call()] = <MagicMock name='mock.__enter__' id='140237435083984'>.call_args_list
E        +      where <MagicMock name='mock.__enter__' id='140237435083984'> = <MagicMock id='140237435272736'>.__enter__

tests/unit/test_loader.py:1732: AssertionError
@cianyleow cianyleow added the Test-Failure Fix the CI failure ⛈ label Jun 28, 2023
@welcome
Copy link

welcome bot commented Jun 28, 2023

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Test-Failure Fix the CI failure ⛈
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant