jupyter / terminado

Terminals served by tornado websockets
http://terminado.readthedocs.org/en/latest/
BSD 2-Clause "Simplified" License
365 stars 94 forks source link

Odd test failure in restricted build environment #208

Closed smu-ggl closed 1 year ago

smu-ggl commented 1 year ago

Hi.

I'm trying to build the Debian (0.17.0-1) package in a somewhat restricted environment. And for the life of me, I can't figure out what makes these tests fail. The build environment should only differ from my physical system in its restricted network setup (only certain domain names resolve, only certain hosts reachable even though the build environment does have a default route).

AFAICT, the test only does things that should work (set up a local service, use that in tests). However, it breaks. I'd appreciate any help you can give figuring out why.

Tornado is Debian package version 6.2.0-1 - But as said, the same versions used, the tests succeed when run on a machine that should be equivalent to the build environment, except for the network setup. Python is 3.10 in both successful and unsuccessful cases. Patch from https://github.com/jupyter/terminado/issues/84 is present in both cases as well. So that seems related, but not the complete reason.

============================= test session starts ==============================
platform linux -- Python 3.10.8, pytest-7.1.2, pluggy-1.0.0+repack
rootdir: /<<PKGBUILDDIR>>, configfile: pyproject.toml
collected 9 items

terminado/tests/basic_test.py ..FF.F.FF                                  [100%]

=================================== FAILURES ===================================
______________________ NamedTermTests.test_max_terminals _______________________

self = <terminado.tests.basic_test.NamedTermTests testMethod=test_max_terminals>

    @tornado.testing.gen_test
    @pytest.mark.skipif("linux" not in platform, reason="It only works on Linux")
    async def test_max_terminals(self):
        urls = ["/named/%d" % i for i in range(MAX_TERMS + 1)]
        tms = await self.get_term_clients(urls[:MAX_TERMS])
>       _ = await self.get_pids(tms)

terminado/tests/basic_test.py:254: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
terminado/tests/basic_test.py:147: in get_pids
    pid = await tm.get_pid()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <terminado.tests.basic_test.TestTermClient object at 0x7f40f4b48f40>

    async def get_pid(self):
        """Get process ID of terminal shell process"""
        await self.read_stdout()  # Clear out any pending
        await self.write_stdin("echo $$\r")
        (stdout, extra) = await self.read_stdout()
        if os.name == "nt":
            match = re.search(r"echo \$\$\\.*?\\r\\n(\d+)", repr(stdout))
            assert match is not None
            pid = int(match.groups()[0])
        else:
>           pid = int(stdout.split("\r")[2])
E           ValueError: invalid literal for int() with base 10: '\n\x1b[?2004l'

terminado/tests/basic_test.py:120: ValueError
------------------------------ Captured log call -------------------------------
WARNING  tornado.general:autoreload.py:128 tornado.autoreload started more than once in the same process
________________________ NamedTermTests.test_namespace _________________________

self = <terminado.tests.basic_test.NamedTermTests testMethod=test_namespace>

    @tornado.testing.gen_test
    async def test_namespace(self):
        names = ["/named/1"] * 2 + ["/named/2"] * 2
        tms = await self.get_term_clients(names)
>       pids = await self.get_pids(tms)

terminado/tests/basic_test.py:237: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
terminado/tests/basic_test.py:147: in get_pids
    pid = await tm.get_pid()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <terminado.tests.basic_test.TestTermClient object at 0x7f40f4b667a0>

    async def get_pid(self):
        """Get process ID of terminal shell process"""
        await self.read_stdout()  # Clear out any pending
        await self.write_stdin("echo $$\r")
        (stdout, extra) = await self.read_stdout()
        if os.name == "nt":
            match = re.search(r"echo \$\$\\.*?\\r\\n(\d+)", repr(stdout))
            assert match is not None
            pid = int(match.groups()[0])
        else:
>           pid = int(stdout.split("\r")[2])
E           ValueError: invalid literal for int() with base 10: '\n\x1b[?2004l'

terminado/tests/basic_test.py:120: ValueError
------------------------------ Captured log call -------------------------------
WARNING  tornado.general:autoreload.py:128 tornado.autoreload started more than once in the same process
_____________________ SingleTermTests.test_single_process ______________________

self = <terminado.tests.basic_test.SingleTermTests testMethod=test_single_process>

    @tornado.testing.gen_test
    async def test_single_process(self):
        tms = await self.get_term_clients(["/single", "/single"])
>       pids = await self.get_pids(tms)

terminado/tests/basic_test.py:266: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
terminado/tests/basic_test.py:147: in get_pids
    pid = await tm.get_pid()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <terminado.tests.basic_test.TestTermClient object at 0x7f40f4b23730>

    async def get_pid(self):
        """Get process ID of terminal shell process"""
        await self.read_stdout()  # Clear out any pending
        await self.write_stdin("echo $$\r")
        (stdout, extra) = await self.read_stdout()
        if os.name == "nt":
            match = re.search(r"echo \$\$\\.*?\\r\\n(\d+)", repr(stdout))
            assert match is not None
            pid = int(match.groups()[0])
        else:
>           pid = int(stdout.split("\r")[2])
E           ValueError: invalid literal for int() with base 10: '\n\x1b[?2004l'

terminado/tests/basic_test.py:120: ValueError
------------------------------ Captured log call -------------------------------
WARNING  tornado.general:autoreload.py:128 tornado.autoreload started more than once in the same process
______________________ UniqueTermTests.test_max_terminals ______________________

self = <terminado.tests.basic_test.UniqueTermTests testMethod=test_max_terminals>

    @tornado.testing.gen_test
    @pytest.mark.skipif("linux" not in platform, reason="It only works on Linux")
    async def test_max_terminals(self):
        tms = await self.get_term_clients(["/unique"] * MAX_TERMS)
>       pids = await self.get_pids(tms)

terminado/tests/basic_test.py:286: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
terminado/tests/basic_test.py:147: in get_pids
    pid = await tm.get_pid()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <terminado.tests.basic_test.TestTermClient object at 0x7f40f4b64850>

    async def get_pid(self):
        """Get process ID of terminal shell process"""
        await self.read_stdout()  # Clear out any pending
        await self.write_stdin("echo $$\r")
        (stdout, extra) = await self.read_stdout()
        if os.name == "nt":
            match = re.search(r"echo \$\$\\.*?\\r\\n(\d+)", repr(stdout))
            assert match is not None
            pid = int(match.groups()[0])
        else:
>           pid = int(stdout.split("\r")[2])
E           ValueError: invalid literal for int() with base 10: '\n\x1b[?2004l'

terminado/tests/basic_test.py:120: ValueError
------------------------------ Captured log call -------------------------------
WARNING  tornado.general:autoreload.py:128 tornado.autoreload started more than once in the same process
____________________ UniqueTermTests.test_unique_processes _____________________

self = <terminado.tests.basic_test.UniqueTermTests testMethod=test_unique_processes>

    @tornado.testing.gen_test
    async def test_unique_processes(self):
        tms = await self.get_term_clients(["/unique", "/unique"])
>       pids = await self.get_pids(tms)

terminado/tests/basic_test.py:279: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
terminado/tests/basic_test.py:147: in get_pids
    pid = await tm.get_pid()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <terminado.tests.basic_test.TestTermClient object at 0x7f40f4a69960>

    async def get_pid(self):
        """Get process ID of terminal shell process"""
        await self.read_stdout()  # Clear out any pending
        await self.write_stdin("echo $$\r")
        (stdout, extra) = await self.read_stdout()
        if os.name == "nt":
            match = re.search(r"echo \$\$\\.*?\\r\\n(\d+)", repr(stdout))
            assert match is not None
            pid = int(match.groups()[0])
        else:
>           pid = int(stdout.split("\r")[2])
E           ValueError: invalid literal for int() with base 10: '\n\x1b[?2004l'

terminado/tests/basic_test.py:120: ValueError
------------------------------ Captured log call -------------------------------
WARNING  tornado.general:autoreload.py:128 tornado.autoreload started more than once in the same process
=============================== warnings summary ===============================
../../../../../../usr/lib/python3/dist-packages/_pytest/config/__init__.py:1252
  /usr/lib/python3/dist-packages/_pytest/config/__init__.py:1252: PytestConfigWarning: Unknown config option: timeout

    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

terminado/tests/basic_test.py:305
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py:305: PytestUnknownMarkWarning: Unknown pytest.mark.timeout - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.timeout(timeout=ASYNC_TEST_TIMEOUT, method="thread")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================= slowest 10 durations =============================
6.36s call     .pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py::CommonTests::test_basic_command
2.34s call     .pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py::UniqueTermTests::test_max_terminals
2.34s call     .pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py::NamedTermTests::test_max_terminals
2.32s call     .pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py::UniqueTermTests::test_large_io_doesnt_hang
2.23s call     .pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py::NamedTermTests::test_namespace
2.23s call     .pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py::UniqueTermTests::test_unique_processes
2.12s call     .pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py::SingleTermTests::test_single_process
0.35s call     .pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py::CommonTests::test_basic
0.11s call     .pybuild/cpython3_3.10_terminado/build/terminado/tests/basic_test.py::NamedTermTests::test_new

(1 durations < 0.005s hidden.  Use -vv to show these durations.)
=========================== short test summary info ============================
FAILED terminado/tests/basic_test.py::NamedTermTests::test_max_terminals - Va...
FAILED terminado/tests/basic_test.py::NamedTermTests::test_namespace - ValueE...
FAILED terminado/tests/basic_test.py::SingleTermTests::test_single_process - ...
FAILED terminado/tests/basic_test.py::UniqueTermTests::test_max_terminals - V...
FAILED terminado/tests/basic_test.py::UniqueTermTests::test_unique_processes
=================== 5 failed, 4 passed, 2 warnings in 20.72s ===================
smu-ggl commented 1 year ago

Seems like this is an actual duplicate of issue84