Skip to content

Commit 6507be1

Browse files
committed
Review feedback
1 parent b22cee5 commit 6507be1

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-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: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ 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 = (
79+
b"mock-tar: /mock/result.tar.xz: Cannot open: No such mock-file or mock-directory"
80+
)
81+
82+
7783
class TestCacheManager:
7884
def test_create(self, server_config, make_logger):
7985
"""
@@ -955,25 +961,9 @@ def mock_find_dataset(_self, dataset: str) -> MockTarball:
955961
# Loop/sleep twice, then success
956962
("/usr/bin/tar", False, 2, b"[test]", None, 0, b""),
957963
# 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-
),
964+
("/usr/bin/tar", False, 0, b"", 1, 1, MEMBER_NOT_FOUND_MSG),
967965
# 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-
),
966+
("/usr/bin/tar", False, 0, b"", 1, 1, CANNOT_OPEN_MSG),
977967
# Unexpected failure
978968
("/usr/bin/tar", False, 0, b"", 1, 1, b"mock-tar: bolt out of the blue!"),
979969
# Hang, never returning output nor an exit code
@@ -1058,6 +1048,7 @@ def mock_shutil_which(
10581048
except CacheExtractBadPath as exc:
10591049
assert tar_path
10601050
assert not popen_fail
1051+
assert stderr_contents == MEMBER_NOT_FOUND_MSG
10611052
assert str(exc) == f"Unable to extract {path} from {tar.name}"
10621053
except subprocess.TimeoutExpired as exc:
10631054
assert tar_path
@@ -1071,6 +1062,7 @@ def mock_shutil_which(
10711062
else:
10721063
assert not popen_fail
10731064
msg = f"Unexpected error from {tar_path}: {stderr_contents.decode()!r}"
1065+
assert stderr_contents != MEMBER_NOT_FOUND_MSG
10741066
assert str(exc) == f"An error occurred while unpacking {tar}: {msg}"
10751067
except ValueError:
10761068
assert tar_path

0 commit comments

Comments
 (0)