Skip to content

Commit b507051

Browse files
test(cli): cover long runner exec commands (#1154)
* test(cli): cover long runner exec commands Run a 10,000-character argument through the existing end-to-end runner test to cover the remote bootstrap path. * test(cli): require exact long exec output * test(cli): verify exact long exec argument Check the complete argument and argument count so the E2E test detects corruption or duplication.
1 parent 65a28cb commit b507051

1 file changed

Lines changed: 28 additions & 13 deletions

File tree

projects/fal/tests/e2e/test_apps.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ def test_exec_runner(host: api.FalServerlessHost, test_sleep_app: str):
20242024
assert len(runners) == 1
20252025
runner_id = runners[0].runner_id
20262026

2027-
proc = subprocess.Popen(
2027+
short_command = subprocess.run(
20282028
[
20292029
"python",
20302030
"-m",
@@ -2036,20 +2036,35 @@ def test_exec_runner(host: api.FalServerlessHost, test_sleep_app: str):
20362036
"echo",
20372037
"hello",
20382038
],
2039-
stdin=subprocess.PIPE,
2040-
stdout=subprocess.PIPE,
2041-
stderr=subprocess.PIPE,
2039+
capture_output=True,
2040+
timeout=10,
2041+
check=False,
20422042
)
2043+
assert short_command.returncode == 0, short_command.stderr.decode()
2044+
assert b"hello" in short_command.stdout
20432045

2044-
try:
2045-
stdout, stderr = proc.communicate(timeout=10)
2046-
assert (
2047-
b"hello" in stdout
2048-
), f"Expected 'hello' in output, got: {stdout.decode()}"
2049-
finally:
2050-
if proc.poll() is None:
2051-
proc.kill()
2052-
proc.wait()
2046+
long_argument = "x" * 10_000
2047+
long_command = subprocess.run(
2048+
[
2049+
"python",
2050+
"-m",
2051+
"fal",
2052+
"runners",
2053+
"exec",
2054+
runner_id,
2055+
"--",
2056+
"/usr/bin/env",
2057+
"python",
2058+
"-c",
2059+
'import sys; print(len(sys.argv), sys.argv[1] == "x" * 10_000)',
2060+
long_argument,
2061+
],
2062+
capture_output=True,
2063+
timeout=10,
2064+
check=False,
2065+
)
2066+
assert long_command.returncode == 0, long_command.stderr.decode()
2067+
assert long_command.stdout.strip() == b"2 True"
20532068

20542069

20552070
def test_container_app_client(test_container_app: str):

0 commit comments

Comments
 (0)