]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/admin_socket: support "foo || bar" as command
authorKefu Chai <kchai@redhat.com>
Wed, 2 Jun 2021 14:06:22 +0000 (22:06 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 3 Jun 2021 06:23:46 +0000 (14:23 +0800)
so we can cater the needs of different implementation of osd, i.e.,
classic osd and crimson osd. they offer different set of asock commands.

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/admin_socket.py

index c454d3d0c03ee41d9ab8ca3a67ad6975eaa2c1d4..0d960d1a51f7cafe314e28f138231865b20f4471 100644 (file)
@@ -86,26 +86,36 @@ def _socket_command(ctx, remote, socket_path, command, args):
     """
     testdir = teuthology.get_testdir(ctx)
     max_tries = 120
-    while True:
-        try:
-            out = remote.sh([
-                'sudo',
-                'adjust-ulimits',
-                'ceph-coverage',
-                '{tdir}/archive/coverage'.format(tdir=testdir),
-                'ceph',
-                '--admin-daemon', socket_path,
-                ] + command.split(' ') + args)
-        except CommandFailedError:
-            assert max_tries > 0
-            max_tries -= 1
-            log.info('ceph cli returned an error, command not registered yet?')
+    sub_commands = [c.strip() for c in command.split('||')]
+    ex = None
+    for _ in range(max_tries):
+        for sub_command in sub_commands:
+            try:
+                out = remote.sh([
+                    'sudo',
+                    'adjust-ulimits',
+                    'ceph-coverage',
+                    '{tdir}/archive/coverage'.format(tdir=testdir),
+                    'ceph',
+                    '--admin-daemon', socket_path,
+                    ] + sub_command.split(' ') + args)
+            except CommandFailedError as e:
+                ex = e
+                log.info('ceph cli "%s" returned an error %s, '
+                         'command not registered yet?', sub_command, e)
+            else:
+                log.debug('admin socket command %s returned %s',
+                          sub_command, out)
+                return json.loads(out)
+        else:
+            # exhausted all commands
             log.info('sleeping and retrying ...')
             time.sleep(1)
-            continue
-        break
-    log.debug('admin socket command %s returned %s', command, out)
-    return json.loads(out)
+    else:
+        # i tried max_tries times..
+        assert ex is not None
+        raise ex
+
 
 def _run_tests(ctx, client, tests):
     """