Skip to content

Commit a8d06fc

Browse files
committed
Review feedback
1 parent b22cee5 commit a8d06fc

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

lib/pbench/server/cache_manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ def extract(tarball_path: Path, path: str) -> Inventory:
600600

601601
elapsed = time.time() - start
602602
if elapsed > Tarball.TAR_EXEC_TIMEOUT:
603+
# No signs of life from the subprocess. Kill it to ensure that
604+
# the Python runtime can clean it up after we leave, and report
605+
# the failure.
606+
tarproc.kill()
603607
raise subprocess.TimeoutExpired(
604608
cmd=tar_command,
605609
timeout=elapsed,

lib/pbench/test/unit/server/test_cache_manager.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def fake_get_metadata(_tb_path):
7474
return {"pbench": {"date": "2002-05-16T00:00:00"}, "run": {"controller": "ABC"}}
7575

7676

77+
MEMBER_NOT_FOUND_MSG = b"mock-tar: metadata.log: Not found in mock-archive"
78+
CANNOT_OPEN_MSG = b"mock-tar: /mock/result.tar.xz: Cannot open: No such mock-file or mock-directory"
79+
80+
7781
class TestCacheManager:
7882
def test_create(self, server_config, make_logger):
7983
"""
@@ -955,25 +959,9 @@ def mock_find_dataset(_self, dataset: str) -> MockTarball:
955959
# Loop/sleep twice, then success
956960
("/usr/bin/tar", False, 2, b"[test]", None, 0, b""),
957961
# Member path failure
958-
(
959-
"/usr/bin/tar",
960-
False,
961-
0,
962-
b"",
963-
1,
964-
1,
965-
b"mock-tar: metadata.log: Not found in mock-archive",
966-
),
962+
("/usr/bin/tar", False, 0, b"", 1, 1, MEMBER_NOT_FOUND_MSG),
967963
# Archive access failure
968-
(
969-
"/usr/bin/tar",
970-
False,
971-
0,
972-
b"",
973-
1,
974-
1,
975-
b"mock-tar: /mock/result.tar.xz: Cannot open: No such mock-file or mock-directory",
976-
),
964+
("/usr/bin/tar", False, 0, b"", 1, 1, CANNOT_OPEN_MSG),
977965
# Unexpected failure
978966
("/usr/bin/tar", False, 0, b"", 1, 1, b"mock-tar: bolt out of the blue!"),
979967
# Hang, never returning output nor an exit code
@@ -1058,6 +1046,7 @@ def mock_shutil_which(
10581046
except CacheExtractBadPath as exc:
10591047
assert tar_path
10601048
assert not popen_fail
1049+
assert stderr_contents == MEMBER_NOT_FOUND_MSG
10611050
assert str(exc) == f"Unable to extract {path} from {tar.name}"
10621051
except subprocess.TimeoutExpired as exc:
10631052
assert tar_path
@@ -1071,6 +1060,7 @@ def mock_shutil_which(
10711060
else:
10721061
assert not popen_fail
10731062
msg = f"Unexpected error from {tar_path}: {stderr_contents.decode()!r}"
1063+
assert stderr_contents != MEMBER_NOT_FOUND_MSG
10741064
assert str(exc) == f"An error occurred while unpacking {tar}: {msg}"
10751065
except ValueError:
10761066
assert tar_path

0 commit comments

Comments
 (0)