silly-queen-7197
06/09/2023, 2:02 AMruntime_package_dependencies
in my python_tests
and this is working well. If I run ./pants test ::
it works locally. However it fails in CI with the error message AssertionError: assert 'Received SIGTERM, shutting down\n' in ''
. What's strange is that this was happening locally until it just didn't. Who knew that if you tried the same thing 5x times in a row it'd eventually start working...
There's similar logic for SIGINTs and if I run the pex directly I can confirm that the logs are indeed being written (I've checked stdout and stderr in the test and they're both empty strings).
Any idea where the output is going?silly-queen-7197
06/09/2023, 2:06 AMprehistoric-lunch-78313
06/09/2023, 2:10 AMsilly-queen-7197
06/09/2023, 2:12 AMenough-analyst-54434
06/09/2023, 2:12 AMenough-analyst-54434
06/09/2023, 2:12 AMsilly-queen-7197
06/09/2023, 2:12 AMenough-analyst-54434
06/09/2023, 2:13 AMenough-analyst-54434
06/09/2023, 2:14 AMprehistoric-lunch-78313
06/09/2023, 2:27 AMPopen.communicate()
to get stderr?silly-queen-7197
06/09/2023, 2:28 AMsilly-queen-7197
06/09/2023, 2:29 AMos.kill(process.pid, signal.SIGTERM)
time.sleep(1)
if process.poll() is None:
pytest.fail("Process did not exit on SIGTERM")
which should probably be enoughsilly-queen-7197
06/09/2023, 2:30 AM_, stderr = process.communicate()
stderr = stderr.decode("utf-8")
assert "Received SIGTERM, shutting down\n" in stderr
so I don't fool myself
Edit -
Looks like I can actually
_, stderr = process.communicate()
instead of sleeping as it waits for process to terminate.silly-queen-7197
06/09/2023, 3:59 AM''
it's something like 'Ignoring the following environment variables in Pex venv mode:\n_ _PEX_EXTRA_SYS_PATH__=.:archipelago/src:workflows/src\n\n'
silly-queen-7197
06/09/2023, 4:00 AMexecution_mode="venv"
from my pex_binary
I see `''`s locally. There are a few tests and there are other stderrs like Traceback (most recent call last):\n File "/Users/yjabri/.pex/installed_wheels/55a395cdfd3f3dd3f649131d41f97c17b4ed8....py3-none-any.whl/pyasn1/type/univ.py", line 2201, in __init__\n def __init__(self, **kwargs):\nKeyboardInterrupt\n
silly-queen-7197
06/09/2023, 4:13 AM./__run.sh
works...enough-analyst-54434
06/09/2023, 4:17 AMenough-analyst-54434
06/09/2023, 4:17 AMenough-analyst-54434
06/09/2023, 4:18 AMenough-analyst-54434
06/09/2023, 4:20 AMenough-analyst-54434
06/09/2023, 4:20 AMsilly-queen-7197
06/09/2023, 4:32 AMpython_sources(
name="tests0",
)
pex_binary(
name="foobar",
dependencies=[
"workflows/tests/dummy_cron_listener.py:tests0",
"workflows/tests/dummy_http_listener.py:tests0",
]
)
python_tests(
dependencies=[
"workflows/tests/dummy_cron_listener.py:tests0",
"workflows/tests/dummy_http_listener.py:tests0",
],
runtime_package_dependencies=[
":foobar"
]
)
and my test looks like
subprocess.Popen(["workflows.tests/foobar.pex", "-c", ""])
process = subprocess.Popen(
["workflows.tests/foobar.pex", "workflows/tests/dummy_cron_listener.py"],
stderr=subprocess.PIPE,
# env=env,
)
time.sleep(1)
... rest of the test
silly-queen-7197
06/09/2023, 4:32 AMAssertionError: assert 'Received SIGTERM, shutting down\n' in ''
enough-analyst-54434
06/09/2023, 4:37 AMenough-analyst-54434
06/09/2023, 4:38 AMenough-analyst-54434
06/09/2023, 4:38 AMenough-analyst-54434
06/09/2023, 4:39 AMsilly-queen-7197
06/09/2023, 4:40 AM@pytest.mark.skip("Unable to get this to work in CI")
silly-queen-7197
06/09/2023, 5:08 AMexperimental_shell_command(
name="hack",
command="PEX_TOOLS=1 python workflows.tests/foobar.pex venv --compile ./tmp/foobar",
tools=[],
dependencies=[":foobar"],
outputs=["./tmp/", "foobar"],
)
and then use ./tmp/foobar/bin/python
?silly-queen-7197
06/09/2023, 5:08 AMsilly-queen-7197
06/09/2023, 5:09 AMpython_test
I have
runtime_package_dependencies=[
":hack"
]
but I'm grasping at strawssilly-queen-7197
06/09/2023, 6:15 AMexperimental_shell_command(
name="hack",
command="PEX_TOOLS=1 python3 ../../workflows.tests/foobar.pex venv --compile ./tmp/foobar",
tools=["bash", "python3"],
dependencies=[":foobar"],
outputs=["./tmp/"],
)
python_tests(
dependencies=[
":hack",
"workflows/tests/dummy_cron_listener.py:tests0",
"workflows/tests/dummy_http_listener.py:tests0",
],
runtime_package_dependencies=[
":foobar"
]
)
but Error expanding output globs: Failed to read link "/private/var/folders/m8/cmsvrd417n39w5xjzjhmnznm0000gq/T/pants-sandbox-Z779e0/workflows/tests/tmp/foobar/bin/python3.10": Absolute symlink: "/opt/homebrew/opt/python@3.10/bin/python3.10"