From ae55978bbfd1dd3a904ed7d29aba815dbcace231 Mon Sep 17 00:00:00 2001 From: Tyler Levy Conde Date: Tue, 3 Sep 2024 14:07:28 -0600 Subject: [PATCH] Improve testing --- tests/helpers/cmd.py | 10 +++++++--- tests/helpers/container.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/helpers/cmd.py b/tests/helpers/cmd.py index f971558..d13c6c6 100644 --- a/tests/helpers/cmd.py +++ b/tests/helpers/cmd.py @@ -1,6 +1,6 @@ async def run(hub, subcommand: str, target: str = "*", *args): with hub.test.container.roster() as rf: - command = f"{hub.lib.sys.executable} -m soluble --no-host-keys -i --log-level=debug --salt-config-dir {hub.test.SALT_CONFIG_DIR} -R {rf} {subcommand} '{target}' {' '.join(args)}" + command = f"{hub.lib.sys.executable} -m soluble -i --no-host-keys --hard-crash --log-level=debug --salt-config-dir {hub.test.SALT_CONFIG_DIR} -R {rf} {subcommand} '{target}' {' '.join(args)}" print(f"Running command: {command}") # Run the command asynchronously @@ -9,10 +9,14 @@ async def run(hub, subcommand: str, target: str = "*", *args): stdout=hub.lib.asyncio.subprocess.PIPE, ) - await hub.lib.asyncio.sleep(2) + await hub.lib.asyncio.sleep(0) # Capture the stdout and stderr - stdout, _ = await process.communicate() + try: + stdout, _ = await process.communicate() + except KeyboardInterrupt: + process.terminate() + raise hub.lib.pytest.fail("Received interrupt") # Decode the output stdout = stdout.decode() diff --git a/tests/helpers/container.py b/tests/helpers/container.py index 9de7afc..220d878 100644 --- a/tests/helpers/container.py +++ b/tests/helpers/container.py @@ -30,7 +30,7 @@ async def create(hub, username: str = "root", password: str = "pass"): target_name = f"soluble_agent_{hub.lib.uuid.uuid4()}" container = client.containers.run( - "python:3.10-slim", + "python:3.10", command=[ "/bin/sh", "-c",