-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-93357: Lay the foundation for further work in asyncio.test_streams
: port server cases to IsolatedAsyncioTestCase
#93369
gh-93357: Lay the foundation for further work in asyncio.test_streams
: port server cases to IsolatedAsyncioTestCase
#93369
Conversation
I've made a rewrite of description for both the PR and the issue to explain a target more clearly. |
This is a bit difficult to review since there is a lot of code being refactored. But I will give it a try (is there any other asyncio expert who is interested?). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to click "Submit" :)
Misc/NEWS.d/next/Tests/2022-05-31-09-58-10.gh-issue-93357.GL6KS0.rst
Outdated
Show resolved
Hide resolved
# See http://bugs.python.org/issue35065 | ||
messages = [] | ||
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like .set_exception_handler
is now missing from this test. Is it fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've removed all usages of messages
inter-thread communication list:
-
- messages = [] - self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
-
- self.assertEqual(messages, [])
because the server is now async, lives in a main thread, and needs no intermediary to pass exceptions into a test harness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, thank you for noticing, I've added the clarification as the second paragraph of the first PR comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've skimmed the code and it looks fine to me. Together with the expert reviews you've already received and addressed I think it's ready to merge.
I've read your full plan and once this lands please go ahead with the next steps!
@gvanrossum This change broke ssl bots on main. See https://github.com/python/cpython/actions/runs/3184337370/jobs/5192630200 |
@kumaraditya303 Thank you for reporting; I'm investigating now to fix it ASAP. |
Okay, give us updates as you go along -- IIRC the custom is to revert if no fix has been seen within 24 hours. |
FWIW my guess would be that you can't actually use |
@gvanrossum I've created gh-97896 to fix the break. I'm sorry for the delay; initially I wanted to undo the affected lines but then I ended up with wrapping them into another
|
There's a script that runs all the tests that depend on openssl, turning warnings into errors. I ran it manually like this:
I agree this ought to be part of the standard CI run, this has bitten me multiple times. |
I will open a new issue for it! |
…olatedAsyncioTestCase (python#93369)" This reverts commit ce8fc18.
…_streams: port server cases to IsolatedAsyncioTestCase" (#98015) This PR reverts gh-93369 and gh-97896 because they've made asyncio tests unstable. After these PRs were merged, random GitHub action jobs of random commits started to fail unrelated tests and test framework methods. The reverting is necessary because such shrapnel failures are a symptom of some underlying bug that must be found and fixed first. I had a hope that it's a server overload because we already have extremely rare disc access errors. However, one and a half day passed, and the failures continue to emerge both in PRs and commits. Affected issue: gh-93357. First reported in #97940 (comment). * Revert "gh-93357: Port test cases to IsolatedAsyncioTestCase, part 2 (#97896)" This reverts commit 09aea94. * Revert "gh-93357: Start porting asyncio server test cases to IsolatedAsyncioTestCase (#93369)" This reverts commit ce8fc18.
…yncioTestCase (python#93369) Lay the foundation for further work in `asyncio.test_streams`.
…o.test_streams: port server cases to IsolatedAsyncioTestCase" (python#98015) This PR reverts pythongh-93369 and pythongh-97896 because they've made asyncio tests unstable. After these PRs were merged, random GitHub action jobs of random commits started to fail unrelated tests and test framework methods. The reverting is necessary because such shrapnel failures are a symptom of some underlying bug that must be found and fixed first. I had a hope that it's a server overload because we already have extremely rare disc access errors. However, one and a half day passed, and the failures continue to emerge both in PRs and commits. Affected issue: pythongh-93357. First reported in python#97940 (comment). * Revert "pythongh-93357: Port test cases to IsolatedAsyncioTestCase, part 2 (python#97896)" This reverts commit 09aea94. * Revert "pythongh-93357: Start porting asyncio server test cases to IsolatedAsyncioTestCase (python#93369)" This reverts commit ce8fc18.
This PR removes ad-hoc implementation of async tests by using all relatively new features of standard
IsolatedAsyncIoTestCase
.Edit: this PR also removes
messages
variable used to pass exceptions between a main and a server threads. That's because the server is now async, lives in a main thread, and needs no intermediary to pass exceptions into a test harness.To make changes possible to review, this PR changes a limited set of tests only. Further commits will expand the change further up and down.
For this, a single test class is temporarily split into three parts; two of them (
StreamTests
andStreamTests2
) isolate old cases below and above the upgraded ones, and one (NewStreamTests
) are the updated ones themselves. The reason is because subclassing from both oldtest_utils.TestCase
and newunittest.IsolatedAsyncioTestCase
leads to conflicts aborting each test with RuntimeError: cannot enter context: <...> is already entered.test.test_asyncio.utils.TestCase
withunittest.IsolatedAsyncioTestCase
#93357