]> www.average.org Git - loctrkd.git/commitdiff
Fix test when servers crash; less logging
authorEugene Crosser <crosser@average.org>
Thu, 8 Dec 2022 11:43:36 +0000 (12:43 +0100)
committerEugene Crosser <crosser@average.org>
Thu, 8 Dec 2022 11:43:36 +0000 (12:43 +0100)
loctrkd/collector.py
test/common.py

index 5c1c34e25f68ee876cbf3bc8f82c866ed646397b..216134e57850d96d762286f23db43cafd9ea78c7 100644 (file)
@@ -44,7 +44,7 @@ class Client:
         else:
             rest = b""
         if rest:
-            log.warning(
+            log.info(
                 "%d bytes in buffer on close: %s", len(rest), rest[:64].hex()
             )
 
@@ -85,7 +85,7 @@ class Client:
             if isinstance(elem, bytes):
                 msgs.append((when, self.addr, elem))
             else:
-                log.warning(
+                log.info(
                     "%s from fd %d (IMEI %s)",
                     elem,
                     self.sock.fileno(),
index a31ff094d9d806ebfa5b1572d49587a2a20c7bd8..17446a55f807311aab059fb6beabbbd9bb0fb80e 100644 (file)
@@ -4,7 +4,7 @@ from configparser import ConfigParser, SectionProxy
 from contextlib import closing, ExitStack
 from http.server import HTTPServer, SimpleHTTPRequestHandler
 from importlib import import_module
-from logging import DEBUG, StreamHandler
+from logging import DEBUG, StreamHandler, WARNING
 from multiprocessing import Process
 from os import kill, unlink
 from signal import SIGINT
@@ -79,6 +79,8 @@ class TestWithServers(TestCase):
             if verbose:
                 cls.log.addHandler(StreamHandler(stderr))
                 cls.log.setLevel(DEBUG)
+            else:
+                cls.log.setLevel(WARNING)
             p = Process(target=cls.runserver, args=(self.conf,), kwargs=kwargs)
             p.start()
             self.children.append((srvname, p))
@@ -96,17 +98,17 @@ class TestWithServers(TestCase):
             p.start()
             self.children.append(("httpd", p))
         sleep(1)
+        for srvname, p in self.children:
+            self.assertTrue(
+                p.is_alive(),
+                f"{srvname} did not start, exit code {p.exitcode}",
+            )
 
     def tearDown(self) -> None:
         for srvname, p in self.children:
             if p.pid is not None:
                 kill(p.pid, SIGINT)
             p.join()
-            self.assertEqual(
-                p.exitcode,
-                0,
-                f"{srvname} terminated with return code {p.exitcode}",
-            )
         for sfx in (
             "",
             ".pub",
@@ -119,6 +121,12 @@ class TestWithServers(TestCase):
                 unlink(self.tmpfilebase + sfx)
             except OSError:
                 pass
+        for srvname, p in self.children:
+            self.assertEqual(
+                p.exitcode,
+                0,
+                f"{srvname} terminated with exit code {p.exitcode}",
+            )
 
 
 class Fuzz(TestWithServers):