]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/vstart_runner: inherit methods instead of duplicating them 38481/head
authorRishabh Dave <ridave@redhat.com>
Tue, 8 Dec 2020 05:17:52 +0000 (10:47 +0530)
committerRishabh Dave <ridave@redhat.com>
Mon, 2 Aug 2021 06:07:49 +0000 (11:37 +0530)
Inherit methods run_ceph_w(), run_cluster_cmd(), raw_cluster_cmd() and
raw_cluster_cmd_result() from ceph_manager.CephManager in
vstart_runner.LocalCephManager instead of duplicating them.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/vstart_runner.py

index 5b68167b0b6d86903f4f1c952e5b45952770e221..6597129a1d8427e2095d8048ba734b2126ac1f1e 100644 (file)
@@ -47,11 +47,10 @@ from IPy import IP
 import unittest
 import platform
 import logging
-import shlex
 
 from unittest import suite, loader
 
-from teuthology.orchestra.run import Raw, quote
+from teuthology.orchestra.run import Raw, quote, PIPE
 from teuthology.orchestra.daemon import DaemonGroup
 from teuthology.orchestra.remote import Remote
 from teuthology.config import config as teuth_config
@@ -465,6 +464,8 @@ class LocalRemote(object):
             # as long as the input buffer is "small"
             if isinstance(stdin, str):
                 subproc.stdin.write(stdin.encode())
+            elif stdin == subprocess.PIPE or stdin == PIPE:
+                pass
             else:
                 subproc.stdin.write(stdin)
 
@@ -788,19 +789,12 @@ class LocalCephManager(CephManager):
         # methods to work though.
         self.pools = {}
 
-    def find_remote(self, daemon_type, daemon_id):
-        """
-        daemon_type like 'mds', 'osd'
-        daemon_id like 'a', '0'
-        """
-        return LocalRemote()
-
-    def run_ceph_w(self, watch_channel=None):
-        """
-        :param watch_channel: Specifies the channel to be watched.
-                              This can be 'cluster', 'audit', ...
-        :type watch_channel: str
-        """
+        # NOTE: These variables are being overriden here so that parent class
+        # can pick it up.
+        self.cephadm = False
+        self.rook = False
+        self.testdir = None
+        self.run_cluster_cmd_prefix = [CEPH_CMD]
         # XXX: Ceph API test CI job crashes because "ceph -w" process launched
         # by run_ceph_w() crashes when shell is set to True.
         # See https://tracker.ceph.com/issues/49644.
@@ -811,43 +805,14 @@ class LocalCephManager(CephManager):
         # it necessary to pass "shell" parameter to run() method. This leads
         # to incompatibility with the method teuthology.orchestra.run's run()
         # since it doesn't accept "shell" as parameter.
-        args = ['exec', 'sudo', CEPH_CMD, "-w"]
-        if watch_channel is not None:
-            args.append("--watch-channel")
-            args.append(watch_channel)
-        proc = self.controller.run(args=args, wait=False, stdout=StringIO())
-        return proc
+        self.run_ceph_w_prefix = ['exec', 'sudo', CEPH_CMD]
 
-    def run_cluster_cmd(self, **kwargs):
-        """
-        Run a Ceph command and the object representing the process for the
-        command.
-
-        Accepts arguments same as teuthology.orchestra.remote.run().
-        """
-        if isinstance(kwargs['args'], str):
-            kwargs['args'] = shlex.split(kwargs['args'])
-        kwargs['args'] = [CEPH_CMD] + list(kwargs['args'])
-        return self.controller.run(**kwargs)
-
-    def raw_cluster_cmd(self, *args, **kwargs) -> str:
-        """
-        args like ["osd", "dump"}
-        return stdout string
-        """
-        if kwargs.get('args') is None and args:
-            kwargs['args'] = args
-        kwargs['stdout'] = kwargs.pop('stdout', StringIO())
-        return self.run_cluster_cmd(**kwargs).stdout.getvalue()
-
-    def raw_cluster_cmd_result(self, *args, **kwargs):
+    def find_remote(self, daemon_type, daemon_id):
         """
-        like raw_cluster_cmd but don't check status, just return rc
+        daemon_type like 'mds', 'osd'
+        daemon_id like 'a', '0'
         """
-        if kwargs.get('args') is None and args:
-            kwargs['args'] = args
-        kwargs['check_status'] = False
-        return self.run_cluster_cmd(**kwargs).exitstatus
+        return LocalRemote()
 
     def admin_socket(self, daemon_type, daemon_id, command, check_status=True,
                      timeout=None, stdout=None):