Skip to content

Commit c4e7ed2

Browse files
author
Alan Christie
committed
fix: Better timeout handling and memory setting fix
1 parent 8e3e358 commit c4e7ed2

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/jote/compose.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def run(
257257
cwd = os.getcwd()
258258
os.chdir(execution_directory)
259259

260+
timeout: bool = False
260261
try:
261262
# Run the container, and then cleanup.
262263
# If a test environment is set then we pass in these values to the
@@ -293,12 +294,23 @@ def run(
293294
timeout=240,
294295
check=False,
295296
)
297+
except: # pylint: disable=bare-except
298+
timeout = True
296299
finally:
297300
os.chdir(cwd)
298301

299-
print(f"# Compose: Executed (exit code {test.returncode})")
300-
301-
return test.returncode, test.stdout.decode("utf-8"), test.stderr.decode("utf-8")
302+
if timeout:
303+
print("# Compose: ERROR - Test timeout")
304+
return_code: int = -911
305+
test_stdout: str = ""
306+
test_stderr: str = ""
307+
else:
308+
print(f"# Compose: Executed (exit code {test.returncode})")
309+
return_code = test.returncode
310+
test_stdout = test.stdout.decode("utf-8")
311+
test_stderr = test.stderr.decode("utf-8")
312+
313+
return return_code, test_stdout, test_stderr
302314

303315
def delete(self) -> None:
304316
"""Deletes a test directory created by 'create()'."""

src/jote/jote.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,10 @@ def _run_a_test(
768768
job_image = f"{job_definition.image.name}:{job_definition.image.tag}"
769769
job_image_memory: str = job_definition.image["memory"]
770770
if job_image_memory is None:
771-
job_image_memory = "1Gi"
771+
job_image_memory = "1G"
772+
elif job_image_memory.lower().endswith("i"):
773+
# Strip trailing kubernetes 'i' - not liked by compose
774+
job_image_memory = job_image_memory[:-1]
772775
job_image_cores: int = job_definition.image["cores"]
773776
if job_image_cores is None:
774777
job_image_cores = 1

0 commit comments

Comments
 (0)