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 <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2023-03-08 09:38:00 -05:00
parent 1962322f59
commit 1fa0039a98
No known key found for this signature in database
GPG Key ID: FA47FD0B0367D313
2 changed files with 8 additions and 3 deletions

View 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)

View 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):
"""