improve api tests and error output

show only relevant aptly logs if a test fails.
for async tasks, show task output, as it contains the error message.
This commit is contained in:
André Roth
2024-07-16 19:48:04 +02:00
parent 8029305d32
commit 440c3debdc
11 changed files with 278 additions and 175 deletions
+10 -1
View File
@@ -6,19 +6,28 @@ import urllib.parse
import urllib.request
from lib import BaseTest
from api_lib import AptlyStream
class UnixSocketAPITest(BaseTest):
aptly_server = None
socket_path = "/tmp/_aptly_test.sock"
base_url = ("unix://%s" % socket_path)
aptly_out = None
debugOutput = True
def prepare(self):
if self.aptly_server is None:
self.aptly_server = self._start_process("aptly api serve -no-lock -listen=%s" % (self.base_url),)
UnixSocketAPITest.aptly_out = AptlyStream()
self.aptly_server = self._start_process("aptly api serve -no-lock -listen=%s" % (self.base_url), stdout=UnixSocketAPITest.aptly_out, stderr=UnixSocketAPITest.aptly_out)
time.sleep(1)
else:
UnixSocketAPITest.aptly_out.clear()
super(UnixSocketAPITest, self).prepare()
def debug_output(self):
return UnixSocketAPITest.aptly_out.get_contents()
def shutdown(self):
if self.aptly_server is not None:
self.aptly_server.terminate()