From: Eugene Crosser Date: Sun, 19 Jun 2022 20:51:36 +0000 (+0200) Subject: test: adjust sleeps and drains when daemons run X-Git-Tag: 0.99~7 X-Git-Url: http://www.average.org/gitweb/?p=loctrkd.git;a=commitdiff_plain;h=f1aaeb01f6fdf514b83e21f815c3c2407fb2e351 test: adjust sleeps and drains when daemons run --- diff --git a/test/common.py b/test/common.py index 1388585..38c59d5 100644 --- a/test/common.py +++ b/test/common.py @@ -63,7 +63,6 @@ class TestWithServers(TestCase): sleep(1) def tearDown(self) -> None: - sleep(1) for srvname, p in self.children: if p.pid is not None: kill(p.pid, SIGINT) diff --git a/test/test_fuzz.py b/test/test_fuzz.py index 6be5348..a5fba68 100644 --- a/test/test_fuzz.py +++ b/test/test_fuzz.py @@ -27,7 +27,7 @@ class Fuzz(TestWithServers): sleep(1) # give collector some time send_and_drain(self.sock, None) self.sock.close() - print("finished fuzzing") + sleep(1) # Let the server close their side super().tearDown() def test_stream(self) -> None: diff --git a/test/test_storage.py b/test/test_storage.py index 0c5e260..889446d 100644 --- a/test/test_storage.py +++ b/test/test_storage.py @@ -2,7 +2,7 @@ from random import Random from socket import getaddrinfo, socket, AF_INET6, SOCK_STREAM -from sqlite3 import connect +from sqlite3 import connect, Row from time import sleep import unittest from .common import send_and_drain, TestWithServers @@ -23,19 +23,19 @@ class Storage(TestWithServers): def tearDown(self) -> None: sleep(1) # give collector some time - send_and_drain(self.sock, None) - self.sock.close() super().tearDown() def test_storage(self) -> None: buf = b"xx\r\x01\x03Y3\x90w\x19q\x85\x05\r\n" send_and_drain(self.sock, buf) + self.sock.close() # TODO: make a proper sequence + sleep(1) + print("checking database") with connect(self.conf.get("storage", "dbfn")) as db: - c = db.cursor() - c.execute("select * from events") - events = [dict(row) for row in c] - print(events) + db.row_factory = Row + for row in db.execute("select * from events"): + print(dict(row)) if __name__ == "__main__":