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)
def test_ssh_dir_out(tmp_dir, dvc, ssh_server): tmp_dir.gen({"foo": "foo content"}) # Set up remote and cache user = ssh_server.test_creds["username"] port = ssh_server.port keyfile = ssh_server.test_creds["key_filename"] remote_url = SSHMocked.get_url(user, port) assert main(["remote", "add", "upstream", remote_url]) == 0 assert main(["remote", "modify", "upstream", "keyfile", keyfile]) == 0 cache_url = SSHMocked.get_url(user, port) assert main(["remote", "add", "sshcache", cache_url]) == 0 assert main(["config", "cache.ssh", "sshcache"]) == 0 assert main(["remote", "modify", "sshcache", "keyfile", keyfile]) == 0 # Recreating to reread configs repo = DvcRepo(dvc.root_dir) # To avoid "WARNING: UNPROTECTED PRIVATE KEY FILE" from ssh os.chmod(keyfile, 0o600) (tmp_dir / "script.py").write_text( "import sys, pathlib\n" "path = pathlib.Path(sys.argv[1])\n" "dir_out = path / 'dir-out'\n" "dir_out.mkdir()\n" "(dir_out / '1.txt').write_text('1')\n" "(dir_out / '2.txt').write_text('2')\n" ) url_info = URLInfo(remote_url) repo.run( cmd="python {} {}".format(tmp_dir / "script.py", url_info.path), outs=["remote://upstream/dir-out"], deps=["foo"], # add a fake dep to not consider this a callback ) repo.reproduce("dir-out.dvc") repo.reproduce("dir-out.dvc", force=True)