Anyone here familiar with using TCP/IP sockets dur...
# development
c
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
(Semi related I was hoping to mock the network calls in our tests, because network calls in unit tests can be unreliable.)
c
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
How does it fail in CI? Do you have any logs?
c
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
I’d check whether the test server actually bound its port.
c
(the version linked passes in CI, as I don’t attempt the network call if the backend didn’t start properly)|
f
is the GraphQL server a BuiltinGoal?
c
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
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
well, there’s just one parametrization in there, so no, don’t think so (great idea, though)
this all works fine locally..
b
FWIW I don't think pytest does any parallelization. All that comes from extra plugins.
👍 1
f
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
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
We have lots of tests that bind TCP ports and never had any problems with GHA firewalling anything.
💯 1
c
right, ok. thanks. good to know.
will implement my unit tests first, and circle back to the integration test later..