|
38 | 38 | _should_test_gcp, |
39 | 39 | _should_test_hdfs, |
40 | 40 | _should_test_ssh, |
41 | | - get_ssh_url, |
| 41 | + get_ssh_url_mocked, |
42 | 42 | S3, |
43 | 43 | TEST_AWS_REPO_BUCKET, |
44 | 44 | TEST_GCP_REPO_BUCKET, |
@@ -1611,30 +1611,46 @@ def test(self): |
1611 | 1611 | assert evaluation[2].relpath == "E.dvc" |
1612 | 1612 |
|
1613 | 1613 |
|
1614 | | -def test_ssh_dir_out(tmp_dir, dvc): |
1615 | | - if not _should_test_ssh(): |
1616 | | - pytest.skip() |
1617 | | - |
| 1614 | +@pytest.mark.skipif( |
| 1615 | + os.name == "nt", |
| 1616 | + reason="external output scenario is not supported on Windows", |
| 1617 | +) |
| 1618 | +def test_ssh_dir_out(tmp_dir, dvc, ssh_server): |
1618 | 1619 | tmp_dir.gen({"foo": "foo content"}) |
1619 | 1620 |
|
1620 | 1621 | # Set up remote and cache |
1621 | | - remote_url = get_ssh_url() |
| 1622 | + user = ssh_server.test_creds["username"] |
| 1623 | + port = ssh_server.port |
| 1624 | + keyfile = ssh_server.test_creds["key_filename"] |
| 1625 | + |
| 1626 | + remote_url = get_ssh_url_mocked(user, port) |
1622 | 1627 | assert main(["remote", "add", "upstream", remote_url]) == 0 |
| 1628 | + assert main(["remote", "modify", "upstream", "keyfile", keyfile]) == 0 |
1623 | 1629 |
|
1624 | | - cache_url = get_ssh_url() |
| 1630 | + cache_url = get_ssh_url_mocked(user, port) |
1625 | 1631 | assert main(["remote", "add", "sshcache", cache_url]) == 0 |
1626 | 1632 | assert main(["config", "cache.ssh", "sshcache"]) == 0 |
| 1633 | + assert main(["remote", "modify", "sshcache", "keyfile", keyfile]) == 0 |
1627 | 1634 |
|
1628 | 1635 | # Recreating to reread configs |
1629 | 1636 | repo = DvcRepo(dvc.root_dir) |
1630 | 1637 |
|
| 1638 | + # To avoid "WARNING: UNPROTECTED PRIVATE KEY FILE" from ssh |
| 1639 | + os.chmod(keyfile, 0o600) |
| 1640 | + |
| 1641 | + (tmp_dir / "script.py").write_text( |
| 1642 | + "import sys, pathlib\n" |
| 1643 | + "path = pathlib.Path(sys.argv[1])\n" |
| 1644 | + "dir_out = path / 'dir-out'\n" |
| 1645 | + "dir_out.mkdir()\n" |
| 1646 | + "(dir_out / '1.txt').write_text('1')\n" |
| 1647 | + "(dir_out / '2.txt').write_text('2')\n" |
| 1648 | + ) |
| 1649 | + |
1631 | 1650 | url_info = URLInfo(remote_url) |
1632 | | - mkdir_cmd = "mkdir dir-out;cd dir-out;echo 1 > 1.txt; echo 2 > 2.txt" |
1633 | 1651 | repo.run( |
1634 | | - cmd="ssh {netloc} 'cd {path};{cmd}'".format( |
1635 | | - netloc=url_info.netloc, path=url_info.path, cmd=mkdir_cmd |
1636 | | - ), |
1637 | | - outs=[(url_info / "dir-out").url], |
| 1652 | + cmd="python {} {}".format(tmp_dir / "script.py", url_info.path), |
| 1653 | + outs=["remote://upstream/dir-out"], |
1638 | 1654 | deps=["foo"], # add a fake dep to not consider this a callback |
1639 | 1655 | ) |
1640 | 1656 |
|
|
0 commit comments