Esempio n. 1
0
def test_hardlink_optimization(dvc, tmp_dir, ssh_server):
    port = ssh_server.test_creds["port"]
    user = ssh_server.test_creds["username"]

    config = {
        "url": SSHMocked.get_url(user, port),
        "port": port,
        "user": user,
        "keyfile": ssh_server.test_creds["key_filename"],
    }
    remote = SSHRemote(dvc, config)

    from_info = remote.path_info / "empty"
    to_info = remote.path_info / "link"

    with remote.open(from_info, "wb"):
        pass

    if os.name == "nt":
        link_path = "c:" + to_info.path.replace("/", "\\")
    else:
        link_path = to_info.path

    remote.tree.hardlink(from_info, to_info)
    assert not System.is_hardlink(link_path)
Esempio n. 2
0
def test_ssh_host_override_from_config(mock_file, mock_exists, dvc, config,
                                       expected_host):
    remote = SSHRemote(dvc, config)

    mock_exists.assert_called_with(SSHRemote.ssh_config_filename())
    mock_file.assert_called_with(SSHRemote.ssh_config_filename())
    assert remote.path_info.host == expected_host
Esempio n. 3
0
def get_remote(repo, **kwargs):
    tree = get_cloud_tree(repo, **kwargs)
    if tree.scheme == "local":
        return LocalRemote(tree)
    if tree.scheme == "ssh":
        return SSHRemote(tree)
    return Remote(tree)
Esempio n. 4
0
def test_url(dvc):
    user = "******"
    host = "123.45.67.89"
    port = 1234
    path = "/path/to/dir"

    # URL ssh://[user@]host.xz[:port]/path
    url = f"ssh://{user}@{host}:{port}{path}"
    config = {"url": url}

    remote = SSHRemote(dvc, config)
    assert remote.path_info == url

    # SCP-like URL ssh://[user@]host.xz:/absolute/path
    url = f"ssh://{user}@{host}:{path}"
    config = {"url": url}

    remote = SSHRemote(dvc, config)
    assert remote.tree.path_info == url
Esempio n. 5
0
def test_url(dvc):
    user = "******"
    host = "123.45.67.89"
    port = 1234
    path = "/path/to/dir"

    # URL ssh://[user@]host.xz[:port]/path
    url = "ssh://{}@{}:{}{}".format(user, host, port, path)
    config = {"url": url}

    remote = SSHRemote(dvc, config)
    assert remote.path_info == url

    # SCP-like URL ssh://[user@]host.xz:/absolute/path
    url = "ssh://{}@{}:{}".format(user, host, path)
    config = {"url": url}

    remote = SSHRemote(dvc, config)
    assert remote.path_info == url
Esempio n. 6
0
def test_no_path(dvc):
    config = {"url": "ssh://127.0.0.1"}
    remote = SSHRemote(dvc, config)
    assert remote.tree.path_info.path == ""
Esempio n. 7
0
def test_ssh_gss_auth(mock_file, mock_exists, dvc, config, expected_gss_auth):
    remote = SSHRemote(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert remote.tree.gss_auth == expected_gss_auth
Esempio n. 8
0
def test_ssh_keyfile(mock_file, mock_exists, dvc, config, expected_keyfile):
    remote = SSHRemote(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert remote.tree.keyfile == expected_keyfile
Esempio n. 9
0
def test_ssh_port(mock_file, mock_exists, dvc, config, expected_port):
    remote = SSHRemote(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert remote.path_info.port == expected_port