Ejemplo n.º 1
0
def test_multi_runner(mock_targets, tmpdir, sshd_manager):
    """ sanity checks that a remote command can be run
    """
    runner = ssh_client.AsyncSshClient(getpass.getuser(), sshd_manager.key,
                                       mock_targets)
    result = runner.run_command(
        'run', ['touch', os.path.join(str(tmpdir), '$RANDOM')])
    for cmd in result:
        assert cmd['returncode'] == 0
Ejemplo n.º 2
0
def get_client(cluster: onprem.OnpremCluster,
               node_type: str,
               ssh: ssh_client.SshClient,
               parallelism: int = None) -> ssh_client.AsyncSshClient:
    """ Returns an async client for a given Host generator property of cluster
    """
    targets = [host.public_ip for host in getattr(cluster, node_type)]
    if parallelism is None:
        parallelism = len(targets)
    return ssh_client.AsyncSshClient(ssh.user,
                                     ssh.key,
                                     targets,
                                     parallelism=parallelism,
                                     process_timeout=1200)
Ejemplo n.º 3
0
def test_scp(tunnel_args, sshd_manager, tmpdir):
    """ tests that recursive copy works by chaining commands that will fail if copy doesnt work
    """
    runner = ssh_client.AsyncSshClient(
        tunnel_args['user'], sshd_manager.key,
        ['127.0.0.1:' + str(tunnel_args['port'])])
    local_path = tmpdir.join('scp_input_files')
    local_path.ensure(dir=True)
    nested_dir = local_path.join('nested')
    nested_dir.ensure(dir=True)
    nested_dir.join('foo').ensure()
    remote_dir = tmpdir.join('scp_output_files')
    remote_file_path = remote_dir.join('nested').join('foo')
    assert not remote_file_path.check()
    result = runner.run_command('copy', str(local_path), str(remote_dir), True)
    for cmd in result:
        assert cmd['returncode'] == 0
    result = runner.run_command('run', ['test', '-f', str(remote_file_path)])
    for cmd in result:
        assert cmd['returncode'] == 0