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

Fix flaky test generated by warnings #10332

Closed
twisted-trac opened this issue Apr 12, 2022 · 1 comment
Closed

Fix flaky test generated by warnings #10332

twisted-trac opened this issue Apr 12, 2022 · 1 comment

Comments

@twisted-trac
Copy link

twisted-trac commented Apr 12, 2022

adiroiban's avatar @adiroiban reported
Trac ID trac#10332
Type defect
Created 2022-04-12 12:09:21Z

I think that we need to run a warning check at the end of each test to detect which test generates a warning

On Windows, the tests are generating warnings that are not checked.

inside t.i.test.test_posixbase on Windows

There is also t.t.teste_twisted test_setUidSameAsCurrentUid

If one test wants to check for the warnings, it will receive all the previous "unuexpected" warnings.

See a test run here https://dev.azure.com/twistedmatrix/twisted/_build/results?buildId=4668&view=logs&j=a9f5be88-9f44-53f4-896b-687d3085a015&t=50e42789-57d9-5d74-e8a4-3a4e15f86668&l=16003

Note that test fails at test_delayedCall but most probably the warning was generated by another test.

Not sure if this is a bug with the way the tests are written and not waiting for cleanup, or there is a bug on Windows

[ERROR]
Traceback (most recent call last):
  File "D:\a\1\s\.tox\alldeps-withcov-windows\lib\site-packages\twisted\internet\test\test_posixbase.py", line 55, in tearDown
    len(warnings), 0, f"Warnings found at the end of the test:\n{warnings}"
  File "D:\a\1\s\.tox\alldeps-withcov-windows\lib\site-packages\twisted\trial\_synctest.py", line 422, in assertEqual
    super().assertEqual(first, second, msg)
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\unittest\case.py", line 852, in assertEqual
    assertion_func(first, second, msg=msg)
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\unittest\case.py", line 845, in _baseAssertEqual
    raise self.failureException(msg)
twisted.trial.unittest.FailTest: 2 != 0 : Warnings found at the end of the test:
[{'message': "unclosed <socket.socket fd=1380, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53451), raddr=('127.0.0.1', 53450)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\internet\\defer.py', 'lineno': 497}, {'message': "unclosed <socket.socket fd=1512, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53450), raddr=('127.0.0.1', 53451)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\internet\\defer.py', 'lineno': 497}]

twisted.internet.test.test_posixbase.IterationTimeoutTests.test_delayedCall
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "D:\a\1\s\.tox\alldeps-withcov-windows\lib\site-packages\twisted\internet\test\test_posixbase.py", line 55, in tearDown
    len(warnings), 0, f"Warnings found at the end of the test:\n{warnings}"
  File "D:\a\1\s\.tox\alldeps-withcov-windows\lib\site-packages\twisted\trial\_synctest.py", line 422, in assertEqual
    super().assertEqual(first, second, msg)
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\unittest\case.py", line 852, in assertEqual
    assertion_func(first, second, msg=msg)
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\unittest\case.py", line 845, in _baseAssertEqual
    raise self.failureException(msg)
twisted.trial.unittest.FailTest: 10 != 0 : Warnings found at the end of the test:
[{'message': "unclosed <socket.socket fd=1280, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53457), raddr=('127.0.0.1', 53456)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}, {'message': "unclosed <socket.socket fd=1512, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53456), raddr=('127.0.0.1', 53457)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}, {'message': "unclosed <socket.socket fd=1444, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53459), raddr=('127.0.0.1', 53458)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}, {'message': "unclosed <socket.socket fd=1324, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53458), raddr=('127.0.0.1', 53459)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}, {'message': "unclosed <socket.socket fd=1380, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53461), raddr=('127.0.0.1', 53460)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}, {'message': "unclosed <socket.socket fd=1300, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53460), raddr=('127.0.0.1', 53461)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}, {'message': "unclosed <socket.socket fd=1416, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53465), raddr=('127.0.0.1', 53464)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}, {'message': "unclosed <socket.socket fd=1248, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53464), raddr=('127.0.0.1', 53465)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}, {'message': "unclosed <socket.socket fd=1240, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53467), raddr=('127.0.0.1', 53466)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}, {'message': "unclosed <socket.socket fd=420, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 53466), raddr=('127.0.0.1', 53467)>", 'category': <class 'ResourceWarning'>, 'filename': 'D:\\a\\1\\s\\.tox\\alldeps-withcov-windows\\lib\\site-packages\\twisted\\trial\\_asynctest.py', 'lineno': 110}]

Searchable metadata
trac-id__10332 10332
type__defect defect
reporter__adiroiban adiroiban
priority__normal normal
milestone__None None
branch__ 
branch_author__ 
status__new new
resolution__None None
component__core core
keywords__None None
time__1649765361197019 1649765361197019
changetime__1649765361197019 1649765361197019
version__None None
owner__None None

@adiroiban adiroiban changed the title Fix flaky test inside t.i.test.test_posixbase on Windows Fix flaky test generated by warnings Jul 2, 2023
@adiroiban
Copy link
Member

I forgot that I have created this ticket.

I am working to fix this in #12018

Closing this as #12018 should fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants