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

Backport loader contexts 3000 #399

Closed
wants to merge 5 commits into from

Conversation

agraul
Copy link
Member

@agraul agraul commented Jul 7, 2021

What does this PR do?

Backport of saltstack/salt#56513, saltstack/salt#58862, saltstack/salt#58630 and saltstack/salt#58853. I tried to revert all changes breaking Python2 compatibility. I hope I didn't miss anything.

I also added the slowTest definition from saltstack/salt#56872, but I didn't cherry pick the commit since that changes a ton of unrelated tests.

agraul and others added 5 commits July 7, 2021 17:40
Skips a test unless SLOW_TESTS env variable is set to something other
than false.
(cherry picked from commit 5c15def)

Honor loaded_base_name

(cherry picked from commit 26b5714)

Ensure thin_dir is available.

(cherry picked from commit 23906b6)

ensure master_tops is available.

(cherry picked from commit 9590157)

Need to ensure cachedir and fsclient are preserved throughout the call.

(cherry picked from commit d94d96f)

override get_new_ioloop for TestEventListener

(cherry picked from commit 82202c6)

Increase self.wait timeout in the test_clean_by_request to 30 seconds.

(cherry picked from commit 0508a3f)

bump timeouts up to 60 seconds.

(cherry picked from commit ad8ab60)

Removing the timeouts from self.wait.  Bumping up the sleep before yielding the eventpublisher_process from 2 seconds to 8 seconds.

(cherry picked from commit 84de52d)

Revert "override get_new_ioloop for TestEventListener"

This reverts commit ab39a52260ba61722b808ffd5b03ceee7960ca3e.

(cherry picked from commit 59d8076)

Add global lazyloader test

(cherry picked from commit 5078637)
This is done in two stages, first, the module instance in `sys.modules` is set to `None`.
Then at a second stage, when creating a loader with the same namespace, it's actually removed from `sys.modules`.

The reason for this two stage cleanup procedure is because this function might get called during the GC collection cycle and trigger https://bugs.python.org/issue40327

We seem to specially trigger this during the CI test runs with `coverage.py` tracking
the code usage:

    Traceback (most recent call last):
      File "/urs/lib64/python3.6/site-packages/coverage/multiproc.py", line 37, in _bootstrap
        cov.start()
      File "/urs/lib64/python3.6/site-packages/coverage/control.py", line 527, in start
        self._init_for_start()
      File "/urs/lib64/python3.6/site-packages/coverage/control.py", line 455, in _init_for_start
        concurrency=concurrency,
      File "/urs/lib64/python3.6/site-packages/coverage/collector.py", line 111, in __init__
        self.origin = short_stack()
      File "/urs/lib64/python3.6/site-packages/coverage/debug.py", line 157, in short_stack
        stack = inspect.stack()[limit:skip:-1]
      File "/usr/lib64/python3.6/inspect.py", line 1501, in stack
        return getouterframes(sys._getframe(1), context)
      File "/usr/lib64/python3.6/inspect.py", line 1478, in getouterframes
        frameinfo = (frame,) + getframeinfo(frame, context)
      File "/usr/lib64/python3.6/inspect.py", line 1452, in getframeinfo
        lines, lnum = findsource(frame)
      File "/usr/lib64/python3.6/inspect.py", line 780, in findsource
        module = getmodule(object, file)
      File "/usr/lib64/python3.6/inspect.py", line 732, in getmodule
        for modname, module in list(sys.modules.items()):
    RuntimeError: dictionary changed size during iteration

(cherry picked from commit a6921d6)
(cherry picked from commit df44efccaedbc0b5d4969ed4e2af22e1885d7da3)

Slow test fixes

(cherry picked from commit ada1176e1689f263b13c0afe022eb8a5cd26f6cd)

Use patch_if to clean up tests

(cherry picked from commit dab4e96b89eeab9643361135ab7900a912c2721a)

Add more tests and better docstrings

(cherry picked from commit 54d959f888a0011e7c4d4b009d4d48b55fa4a22b)

Fix test_loader_globals case

(cherry picked from commit ea4d8681a1d385e985881609b5470127bf796e89)

Fix typo

(cherry picked from commit e703f3961e2d9c56d04e59d90f1d98a90a796111)

Combine isinstance checks

(cherry picked from commit dd2232dfa7fa6064317235a9b0249039b677a94f)

Syntax cleanup

(cherry picked from commit af1b9b2b2780944cfb6c578256fe80ed87bcbcce)

Make sure test fails without loader changes

(cherry picked from commit d358c8b0e644fec424fed677095ceb91c397a300)

Make sure boto apigateway tests pass under pytest

(cherry picked from commit df756700a0c06bfce04b70b553e9a115b2ecfd08)

fix pre-commit issues

(cherry picked from commit a34cde93194c7fcca9360e624e7a019d33740347)

Fix older pytest runs

(cherry picked from commit 2661472c542c68459b7e9a3d00fb3432bda96b9c)
@agraul agraul requested review from meaksh and vzhestkov July 7, 2021 15:46
@agraul
Copy link
Member Author

agraul commented Jul 7, 2021

We need to add contextvars to our CI image, the test failure is caused by the missing dependency.

@agraul agraul closed this Jan 26, 2022
@SchoolGuy SchoolGuy deleted the backport-loader-contexts-3000 branch September 12, 2022 11:10
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 this pull request may close these issues.

4 participants