示例#1
0
    def test_run_in_mainthread(  # pylint: disable=too-many-arguments
            self, remoter_type, host: str, stmt: str, verbose: bool, ignore_status: bool, new_session: bool, retry: int,
            timeout: Union[float, None]):
        kwargs = {
            'verbose': verbose,
            'ignore_status': ignore_status,
            'new_session': new_session,
            'retry': retry,
            'timeout': timeout}
        try:
            expected = LocalCmdRunner().run(stmt, **kwargs)
        except Exception as exc:  # pylint: disable=broad-except
            expected = exc

        if issubclass(remoter_type, (RemoteCmdRunner, RemoteLibSSH2CmdRunner)):
            remoter = remoter_type(hostname=host, user=getpass.getuser(), key_file=self.key_file)
        else:
            remoter = KubernetesCmdRunner(
                FakeKluster('http://127.0.0.1:8001'),
                pod='sct-cluster-gce-minikube-0', container="scylla", namespace="scylla")
        try:
            result = remoter.run(stmt, **kwargs)
        except Exception as exc:  # pylint: disable=broad-except
            result = exc
        remoter._reconnect()
        try:
            result2 = remoter.run(stmt, **kwargs)
        except Exception as exc:  # pylint: disable=broad-except
            result2 = exc
        remoter.stop()

        self._compare_results(expected, result, stmt=stmt, kwargs=kwargs)
        self._compare_results(expected, result2, stmt=stmt, kwargs=kwargs)
示例#2
0
 def _create_and_run_twice_in_same_thread(remoter_type, key_file, stmt, kwargs, paramiko_thread_results):
     if issubclass(remoter_type, (RemoteCmdRunner, RemoteLibSSH2CmdRunner)):
         remoter = remoter_type(hostname='127.0.0.1', user=getpass.getuser(), key_file=key_file)
     else:
         remoter = KubernetesCmdRunner(
             FakeKluster('http://127.0.0.1:8001'),
             pod='sct-cluster-gce-minikube-0', container="scylla", namespace="scylla")
     try:
         result = remoter.run(stmt, **kwargs)
     except Exception as exc:  # pylint: disable=broad-except
         result = exc
     paramiko_thread_results.append(result)
     try:
         result = remoter.run(stmt, **kwargs)
     except Exception as exc:  # pylint: disable=broad-except
         result = exc
     paramiko_thread_results.append(result)
     remoter.stop()