def _require_ssh(self) -> None: # connect if self._ssh_client is None: self._ssh_client = connection.connect_ssh(self._host, self._ssh_port, self._ssh_username, self._ssh_password, self._ssh_public_key) # lookup stdout_list: typing.List[bytes] = [] stderr_list: typing.List[bytes] = [] if connection.run_ssh(self._ssh_client, [ *self._ssh_command_prefix, 'python3', '-m', 'ck.clickhouse.lookup', ], iteration.empty_in(), iteration.collect_out(stdout_list), iteration.collect_out(stderr_list))(): raise exception.ShellError(self._host, b''.join(stderr_list).decode()) ( self._ssh_default_data_dir, self._ssh_binary_file, ) = b''.join(stdout_list).decode().splitlines()
def test_connection_ssh_benchmark( benchmark: pytest_benchmark.fixture.BenchmarkFixture) -> None: ck.LocalSession(stop=True, start=True) ssh_client = connection.connect_ssh('localhost', 22) def run() -> None: connection.run_ssh( ssh_client, [clickhouse.binary_file(), 'client'], iteration.given_in([b'select number from numbers(1000000)']), iteration.ignore_out(), iteration.empty_out())() benchmark(run)
def test_connection_ssh() -> None: ck.LocalSession(stop=True, start=True) ssh_client = connection.connect_ssh('localhost', 22) stdout_list: typing.List[bytes] = [] status = connection.run_ssh(ssh_client, [clickhouse.binary_file(), 'client'], iteration.given_in([b'select 1']), iteration.collect_out(stdout_list), iteration.empty_out())() assert stdout_list == [b'1\n'] assert status == 0