generalize remotelog to "remote" and offer remote.iter_output method

This commit is contained in:
holger krekel
2023-10-16 20:02:08 +02:00
parent 334f86f56f
commit ecdaf60e11
3 changed files with 8 additions and 8 deletions

View File

@@ -182,15 +182,15 @@ def cmfactory(request, gencreds, tmpdir, data, maildomain):
@pytest.fixture
def remotelog(sshdomain):
return RemoteLog(sshdomain)
def remote(sshdomain):
return Remote(sshdomain)
class RemoteLog:
class Remote:
def __init__(self, sshdomain):
self.sshdomain = sshdomain
def iter(self, logcmd=""):
def iter_output(self, logcmd=""):
getjournal = f"journalctl -f" if not logcmd else logcmd
self.popen = subprocess.Popen(
["ssh", f"root@{self.sshdomain}", getjournal],

View File

@@ -1,5 +1,5 @@
def test_remotelog(remotelog, imap_or_smtp):
lineproducer = remotelog.iter(imap_or_smtp.logcmd)
def test_remote(remote, imap_or_smtp):
lineproducer = remote.iter_output(imap_or_smtp.logcmd)
imap_or_smtp.connect()
assert imap_or_smtp.name in next(lineproducer)

View File

@@ -19,7 +19,7 @@ class TestEndToEndDeltaChat:
assert msg2.text == "message0"
@pytest.mark.slow
def test_exceed_quota(self, cmfactory, lp, tmpdir, remotelog):
def test_exceed_quota(self, cmfactory, lp, tmpdir, remote):
"""This is a very slow test as it needs to upload >100MB of mail data
before quota is exceeded, and thus depends on the speed of the upload.
"""
@@ -48,7 +48,7 @@ class TestEndToEndDeltaChat:
addr = ac2.get_config("addr").lower()
saved_ok = 0
for line in remotelog.iter("journalctl -f -u dovecot"):
for line in remote.iter_output("journalctl -f -u dovecot"):
if addr not in line:
# print(line)
continue