https://pantsbuild.org/ logo
c

curved-television-6568

06/08/2022, 9:29 AM
Anyone here familiar with using TCP/IP sockets during tests in our CI runs? I have an integration test for the GraphQL API that works locally, but in CI it doesn’t seem to work. (I’ve opted to short-cut this particular test for now, but will revisit again)
b

bitter-ability-32190

06/08/2022, 10:25 AM
(Semi related I was hoping to mock the network calls in our tests, because network calls in unit tests can be unreliable.)
c

curved-television-6568

06/08/2022, 10:26 AM
For the unit tests, I plan to use mock stuff, but this was for an integration test, so kind of takes away the test to mock it there 😛
😂 1
f

fast-nail-55400

06/08/2022, 2:15 PM
How does it fail in CI? Do you have any logs?
c

curved-television-6568

06/08/2022, 2:18 PM
Yup: https://github.com/pantsbuild/pants/runs/6740649892?check_suite_focus=true
Copy code
E           requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=7908): Max retries exceeded with url: /graphql (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3234661f90>: Failed to establish a new connection: [Errno 111] Connection refused'))
/home/runner/.cache/pants/named_caches/pex_root/venvs/s/aad82963/venv/lib/python3.7/site-packages/requests/adapters.py:519: ConnectionError
Next step would be to print the output from the
handle
in case there was any… for this test: https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/explorer/integration_test.py#L37
f

fast-nail-55400

06/08/2022, 2:21 PM
I’d check whether the test server actually bound its port.
c

curved-television-6568

06/08/2022, 2:21 PM
(the version linked passes in CI, as I don’t attempt the network call if the backend didn’t start properly)|
f

fast-nail-55400

06/08/2022, 2:22 PM
is the GraphQL server a BuiltinGoal?
c

curved-television-6568

06/08/2022, 2:22 PM
It seems it didn’t, so that check wouldn’t tell me much? are you suggesting that the selected port is not available, though perhaps..?
yeah, builtin
f

fast-nail-55400

06/08/2022, 2:23 PM
you marked the test with
pytest.mark.parametrize
, is pytest executing each paramterized test in parallel?
and they all try to bind the same port
c

curved-television-6568

06/08/2022, 2:24 PM
well, there’s just one parametrization in there, so no, don’t think so (great idea, though)
this all works fine locally..
b

bitter-ability-32190

06/08/2022, 2:26 PM
FWIW I don't think pytest does any parallelization. All that comes from extra plugins.
👍 1
f

fast-nail-55400

06/08/2022, 2:28 PM
I’d suggest dumping logs from that pants process. Just spawn two threads to read from the process stdout/stderr respectively and dump to the console.
👍 1
c

curved-television-6568

06/08/2022, 2:29 PM
yeah, that’ll be the next step debugging it..
was kind of hoping there was some obvious thing, like telling GHA to allow a certain port for use or some such.
f

fast-nail-55400

06/08/2022, 2:30 PM
We have lots of tests that bind TCP ports and never had any problems with GHA firewalling anything.
💯 1
c

curved-television-6568

06/08/2022, 2:30 PM
right, ok. thanks. good to know.
will implement my unit tests first, and circle back to the integration test later..