From 1fa0039a98768aaeafccfa6d2d2e063a17d836fb Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Wed, 8 Mar 2023 09:38:00 -0500 Subject: [PATCH] qa: fix background exit condition This change causes the program to exit gracefully when stdin is closed rather than with a Python exception. Signed-off-by: Patrick Donnelly --- qa/tasks/cephfs/mount.py | 4 +++- qa/tasks/cephfs/test_client_limits.py | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index cc1cb4a6230f4..2b9acf1a475d1 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -1231,8 +1231,10 @@ class CephFSMount(object): path = os.path.join(abs_path, fname) handles.append(open(path, 'w')) - while True: + print("waiting with handles open", file=sys.stderr) + while os.read(0, 4096) != b"": time.sleep(1) + print("stdin closed, goodbye!", file=sys.stderr) """).format(abs_path=abs_path, count=count) rproc = self._run_python(pyscript) diff --git a/qa/tasks/cephfs/test_client_limits.py b/qa/tasks/cephfs/test_client_limits.py index c8cf0785ba150..836f81af1642a 100644 --- a/qa/tasks/cephfs/test_client_limits.py +++ b/qa/tasks/cephfs/test_client_limits.py @@ -75,7 +75,8 @@ class TestClientLimits(CephFSTestCase): # When the client closes the files, it should retain only as many caps as allowed # under the SESSION_RECALL policy log.info("Terminating process holding files open") - self.mount_a._kill_background(open_proc) + open_proc.stdin.close() + open_proc.wait() # The remaining caps should comply with the numbers sent from MDS in SESSION_RECALL message, # which depend on the caps outstanding, cache size and overall ratio @@ -124,7 +125,7 @@ class TestClientLimits(CephFSTestCase): self.assertGreaterEqual(open_files, mds_min_caps_per_client) mount_a_client_id = self.mount_a.get_global_id() - self.mount_a.open_n_background("subdir", open_files) + p = self.mount_a.open_n_background("subdir", open_files) # Client should now hold: # `open_files` caps for the open files @@ -148,6 +149,8 @@ class TestClientLimits(CephFSTestCase): pass else: raise RuntimeError("expected no client recall warning") + p.stdin.close() + p.wait() def test_cap_acquisition_throttle_readdir(self): """ -- 2.39.5