mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
remote: do not swallow exceptions by ssh pool
This commit is contained in:
@@ -13,6 +13,7 @@ def ssh_connection(*conn_args, **conn_kwargs):
|
||||
yield conn
|
||||
except BaseException:
|
||||
conn.close()
|
||||
raise
|
||||
else:
|
||||
pool.release(conn)
|
||||
|
||||
|
||||
+7
-6
@@ -83,17 +83,18 @@ key_path = os.path.join(here, "{0}.key".format(user))
|
||||
def ssh_server():
|
||||
users = {user: key_path}
|
||||
with mockssh.Server(users) as s:
|
||||
s.test_creds = {
|
||||
"host": s.host,
|
||||
"port": s.port,
|
||||
"username": user,
|
||||
"key_filename": key_path,
|
||||
}
|
||||
yield s
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ssh(ssh_server):
|
||||
yield SSHConnection(
|
||||
ssh_server.host,
|
||||
username=user,
|
||||
port=ssh_server.port,
|
||||
key_filename=key_path,
|
||||
)
|
||||
yield SSHConnection(**ssh_server.test_creds)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -31,8 +31,6 @@ from dvc.utils import file_md5
|
||||
from dvc.utils.stage import load_stage_file, dump_stage_file
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
from tests.conftest import user
|
||||
from tests.conftest import key_path
|
||||
from tests.utils import spy
|
||||
|
||||
|
||||
@@ -460,10 +458,11 @@ class TestRemoteSSHMocked(TestDataCloudBase):
|
||||
self.method_name = request.function.__name__
|
||||
|
||||
def _get_url(self):
|
||||
user = self.ssh_server.test_creds["username"]
|
||||
return get_ssh_url_mocked(user, self.ssh_server.port)
|
||||
|
||||
def _get_keyfile(self):
|
||||
return key_path
|
||||
return self.ssh_server.test_creds["key_filename"]
|
||||
|
||||
def _should_test(self):
|
||||
return True
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import pytest
|
||||
|
||||
from dvc.remote.ssh.pool import ssh_connection
|
||||
|
||||
|
||||
def test_doesnt_swallow_errors(ssh_server):
|
||||
class MyError(Exception):
|
||||
pass
|
||||
|
||||
with pytest.raises(MyError), ssh_connection(**ssh_server.test_creds):
|
||||
raise MyError
|
||||
Reference in New Issue
Block a user