Migrate rest_tornado saltnado tests to pytest#69704
Open
ggiesen wants to merge 3 commits into
Open
Conversation
Port the AsyncTestCase suite in tests/unit/netapi/rest_tornado/test_saltnado.py to pytest, driving the handler coroutines with the io_loop fixture, and remove the legacy file.
d074452 to
252ec16
Compare
- Bound every io_loop.run_sync call with a 30 second timeout. The legacy gen_test decorator enforced a per-test deadline; run_sync has none by default and the harness fallback timeout is not applied on Windows, so a hang regression (the exact case the infinite-loop guard test exists for) would have consumed the whole job. - Re-raise exceptions from IOLoop callbacks at test teardown via an io_loop fixture wrapper. AsyncTestCase failed a test when a scheduled callback raised; the plain loop only logs, which would let a broken completer pass a test that no longer exercises anything. - Share one handler fixture (conftest.py) instead of three copies of the same mock scaffold, resolving the 2020 TODO carried over from the unittest file, and move test_base_handler.py in from the sibling saltnado directory so the module's unit tests live in one place and consume the same fixture. - Make the two timer-based _disbatch_local tests deterministic by routing the gather timeout through an already-resolved fake sleep, removing a real 2 second wait and a 50 millisecond ordering race. - Drop the dead boop() generators (never iterated; spawn_callback of a bare generator is a no-op), differentiate the two byte-identical disbatch-after-finish tests by asserting the response buffer is not written to, and remove the now-empty legacy tests/unit/netapi packages.
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.
What does this PR do?
Migrates the rest_tornado saltnado test suite from the legacy
tests/unittree to pytest. The 27 tests across the three
AsyncTestCaseclasses(
TestJobNotRunning,TestGetMinionReturns,TestDisbatchLocal) are portedto plain pytest functions under
tests/pytests/unit/netapi/rest_tornado/,driving the handler coroutines with the existing
io_loopfixture(
io_loop.run_sync) instead oftornado.testing.gen_test, and the legacyfile is removed.
Every test is preserved one-for-one with the same mocks, opts, event
sequences and expected values; assertions are converted at equal-or-stronger
strength (
assertIs->is,assertDictEqual->==, etc.). No behaviourof
salt/netapi/rest_tornado/saltnado.pyis changed -- this is tests only.What issues does this PR fix or reference?
Part of the ongoing migration of the legacy
tests/unitsuite to pytest.Previous Behavior
The saltnado handler coroutine tests lived in
tests/unit/netapi/rest_tornado/test_saltnado.pyastornado.testing.AsyncTestCasesubclasses.
New Behavior
The same 27 tests run as pytest functions in
tests/pytests/unit/netapi/rest_tornado/test_saltnado.py. Verified locally:27 passed, and each legacy test was confirmed to have an equal-or-stronger
pytest counterpart before removing the legacy file.
Merge requirements satisfied?
Commits signed with GPG?
No