Skip to content

gh-101384: add socket timeout to ThreadedVSOCKSocketStreamTest and skip it on WSL #101419

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

Merged
merged 6 commits into from
Feb 17, 2024

Conversation

peterjpxie
Copy link
Contributor

@peterjpxie peterjpxie commented Jan 30, 2023

1/ Add socket server timeout to ThreadedVSOCKSocketStreamTest so that it does not hang on client connection failure, e.g. on WSL.

After adding the timeout, it was able to fail on this test and continue as follows.

./python -m test -v test.test_socket2
======================================================================
ERROR: testStream (test.test_socket2.ThreadedVSOCKSocketStreamTest.testStream)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peter/repo/cpython/Lib/test/test_socket2.py", line 376, in _setUp
    self.__setUp()
  File "/home/peter/repo/cpython/Lib/test/test_socket2.py", line 522, in setUp
    self.conn, self.connaddr = self.serv.accept()
                               ^^^^^^^^^^^^^^^^^^
  File "/home/peter/repo/cpython/Lib/socket.py", line 295, in accept
    fd, addr = self._accept()
               ^^^^^^^^^^^^^^
TimeoutError: timed out

======================================================================
ERROR: testStream (test.test_socket2.ThreadedVSOCKSocketStreamTest.testStream)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peter/repo/cpython/Lib/test/test_socket2.py", line 364, in raise_queued_exception
    raise self.queue.get()
  File "/home/peter/repo/cpython/Lib/test/test_socket2.py", line 388, in clientRun
    self.clientSetUp()
  File "/home/peter/repo/cpython/Lib/test/test_socket2.py", line 535, in clientSetUp
    self.cli.connect((cid, VSOCKPORT))
OSError: [Errno 101] Network is unreachable

----------------------------------------------------------------------
Ran 724 tests in 41.724s

FAILED (errors=2, skipped=65)
test test.test_socket2 failed
test.test_socket2 failed (2 errors) in 41.8 sec

== Tests result: FAILURE ==

1 test failed:
    test.test_socket2

Total duration: 41.9 sec
Tests result: FAILURE

2/ Furthermore, as it does not work on WSL (OSError: [Errno 101] Network is unreachable), skip it on WSL.

This works on VMware workstation for communication between VM guests and host.

3/ With all the changes, this is the summary of tests on different platforms:

  • VMware station guest VM ubuntu: Passed
  • Normal ubuntu server: Skipped
  • WSL ubuntu: Skipped

@bedevere-bot bedevere-bot added awaiting review tests Tests in the Lib/test dir labels Jan 30, 2023
@peterjpxie peterjpxie changed the title add socket timeout to ThreadedVSOCKSocketStreamTest and skip it on WSL gh-101384: add socket timeout to ThreadedVSOCKSocketStreamTest and skip it on WSL Jan 30, 2023
@peterjpxie
Copy link
Contributor Author

Hi @ncoghlan ,@tiran , @caavery

I was wondering if any of you can help review this PR. It is about vsock and I found you were involved in the initial vsock support PR #2489.

Thanks & Regards

Peter

@arhadthedev
Copy link
Member

@giampaolo, @gpshead (as networking experts)

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@serhiy-storchaka
Copy link
Member

A NEWS entry is not required here.

@serhiy-storchaka serhiy-storchaka merged commit 9fd420f into python:main Feb 17, 2024
@miss-islington-app
Copy link

Thanks @peterjpxie for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 17, 2024
…and skip it on WSL (pythonGH-101419)

(cherry picked from commit 9fd420f)

Co-authored-by: Peter Jiping Xie <peter.jp.xie@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Feb 17, 2024

GH-115585 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 17, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 17, 2024
…and skip it on WSL (pythonGH-101419)

(cherry picked from commit 9fd420f)

Co-authored-by: Peter Jiping Xie <peter.jp.xie@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Feb 17, 2024

GH-115586 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Feb 17, 2024
serhiy-storchaka pushed a commit that referenced this pull request Feb 17, 2024
… and skip it on WSL (GH-101419) (GH-115586)

(cherry picked from commit 9fd420f)

Co-authored-by: Peter Jiping Xie <peter.jp.xie@gmail.com>
serhiy-storchaka pushed a commit that referenced this pull request Feb 17, 2024
… and skip it on WSL (GH-101419) (GH-115585)

(cherry picked from commit 9fd420f)

Co-authored-by: Peter Jiping Xie <peter.jp.xie@gmail.com>
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this pull request Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants