59a0a3844c
PR Test AMD / cancel-on-close (push) Has been skipped
PR Test NVIDIA ARM / scan (push) Has been skipped
PR Test NVIDIA / cancel-on-close (push) Has been skipped
PR Test AMD / scan (push) Has been skipped
PR Test NVIDIA ARM / cancel-on-close (push) Has been skipped
PR Test NVIDIA / scan (push) Has been skipped
Release Docker Images / build (cu129-torch-2.11.0) (push) Has been skipped
Release Docker Images / build (cu130-torch-2.11.0) (push) Has been skipped
Release PyPI / publish (push) Has been skipped
Scheduler Python Test / test (push) Successful in 27m19s
Docs / build (push) Successful in 28m8s
Scheduler C++ Test / test (push) Successful in 28m19s
Scheduler C++ Test / test-flat (push) Successful in 28m18s
Docs / deploy (push) Has been cancelled
PR Test AMD / finish (push) Has been cancelled
PR Test NVIDIA / finish (push) Has been cancelled
PR Test NVIDIA ARM / finish (push) Has been cancelled
PR Test NVIDIA ARM / ${{ matrix.name }} (${{ matrix.runner }}) (push) Has been cancelled
PR Test AMD / ${{ matrix.name }} (${{ matrix.runner }}) (push) Has been cancelled
PR Test NVIDIA / ${{ matrix.name }} (${{ matrix.runner }}) (push) Has been cancelled
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
import signal
|
|
|
|
import process_group_manager as pgm
|
|
from process_group_manager import ProcessGroupManager
|
|
|
|
|
|
def test_cleanup_stale_kills_all_persisted_process_groups(tmp_path, monkeypatch):
|
|
monkeypatch.setattr(pgm, "_PGID_DIR", tmp_path)
|
|
monkeypatch.setattr(pgm.time, "sleep", lambda _seconds: None)
|
|
|
|
killed = []
|
|
monkeypatch.setattr(
|
|
pgm.os,
|
|
"killpg",
|
|
lambda pgid, sig: killed.append((pgid, sig)),
|
|
)
|
|
|
|
pgm._add_pgid("gb200-runner", 111)
|
|
pgm._add_pgid("gb200-runner", 222)
|
|
|
|
manager = ProcessGroupManager("gb200-runner")
|
|
manager.cleanup_stale()
|
|
|
|
assert killed == [
|
|
(111, signal.SIGTERM),
|
|
(222, signal.SIGTERM),
|
|
(111, signal.SIGKILL),
|
|
(222, signal.SIGKILL),
|
|
]
|
|
assert not pgm._pgid_path("gb200-runner").exists()
|
|
|
|
|
|
def test_terminate_all_kills_persisted_process_groups_without_tracked_parents(
|
|
tmp_path, monkeypatch
|
|
):
|
|
monkeypatch.setattr(pgm, "_PGID_DIR", tmp_path)
|
|
monkeypatch.setattr(pgm.time, "sleep", lambda _seconds: None)
|
|
|
|
killed = []
|
|
monkeypatch.setattr(
|
|
pgm.os,
|
|
"killpg",
|
|
lambda pgid, sig: killed.append((pgid, sig)),
|
|
)
|
|
|
|
pgm._add_pgid("gb200-runner", 111)
|
|
pgm._add_pgid("gb200-runner", 222)
|
|
|
|
manager = ProcessGroupManager("gb200-runner")
|
|
manager.terminate_all()
|
|
|
|
assert killed == [
|
|
(111, signal.SIGTERM),
|
|
(222, signal.SIGTERM),
|
|
(111, signal.SIGKILL),
|
|
(222, signal.SIGKILL),
|
|
]
|
|
assert not pgm._pgid_path("gb200-runner").exists()
|