]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: fix background exit condition
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 8 Mar 2023 14:38:00 +0000 (09:38 -0500)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 1 Aug 2023 15:16:02 +0000 (11:16 -0400)
This change causes the program to exit gracefully when stdin is closed
rather than with a Python exception.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
qa/tasks/cephfs/mount.py
qa/tasks/cephfs/test_client_limits.py

index cc1cb4a6230f4ccf29c3c4a97ee2bc51d1990f96..2b9acf1a475d1a71cd51367c52e68daa8ddb51f2 100644 (file)
@@ -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)
index c8cf0785ba150cfbe7f3a976bd4b91f4d4a8ba58..836f81af1642aada64271d26d6231007d3dc7f47 100644 (file)
@@ -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):
         """