about summary refs log tree commit diff
path: root/nixos/tests/mosquitto.nix
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2021-10-24 19:11:45 +0200
committerpennae <github@quasiparticle.net>2021-10-24 19:22:13 +0200
commit81175b442f4e4e3c9c8aa807b92047f73647458e (patch)
tree213f158cbbdd0d462dc7acf95cabd3cf5a9454d6 /nixos/tests/mosquitto.nix
parent1d60f1fd82aa696fc22bbaf6814c169c800bc2b7 (diff)
nixos/mosquitto: refactor test a little
Diffstat (limited to 'nixos/tests/mosquitto.nix')
-rw-r--r--nixos/tests/mosquitto.nix19
1 files changed, 6 insertions, 13 deletions
diff --git a/nixos/tests/mosquitto.nix b/nixos/tests/mosquitto.nix
index eb47e97ba04b0..bcca5372eaefa 100644
--- a/nixos/tests/mosquitto.nix
+++ b/nixos/tests/mosquitto.nix
@@ -136,9 +136,8 @@ in {
     def publish(args, user, topic="${topic}", port=${toString port}):
         return "{} {}".format(mosquitto_cmd("pub", user, topic, port), args)
 
-
     def subscribe(args, user, topic="${topic}", port=${toString port}):
-        return "{} -C 1 {}".format(mosquitto_cmd("sub", user, topic, port), args)
+        return "{} -W 5 -C 1 {}".format(mosquitto_cmd("sub", user, topic, port), args)
 
     def parallel(*fns):
         from threading import Thread
@@ -150,17 +149,15 @@ in {
     start_all()
     server.wait_for_unit("mosquitto.service")
 
-    def check_passwords():
+    with subtest("check passwords"):
         client1.succeed(publish("-m test", "password_store"))
         client1.succeed(publish("-m test", "password_file"))
         client1.succeed(publish("-m test", "hashed_store"))
         client1.succeed(publish("-m test", "hashed_file"))
 
-    check_passwords()
-
-    def check_acl():
+    with subtest("check acl"):
         client1.succeed(subscribe("", "reader", topic="$SYS/#"))
-        client1.fail(subscribe("-W 5", "writer", topic="$SYS/#"))
+        client1.fail(subscribe("", "writer", topic="$SYS/#"))
 
         parallel(
             lambda: client1.succeed(subscribe("-i 3688cdd7-aa07-42a4-be22-cb9352917e40", "reader")),
@@ -170,15 +167,13 @@ in {
             ])
 
         parallel(
-            lambda: client1.fail(subscribe("-W 5 -i 24ff16a2-ae33-4a51-9098-1b417153c712", "reader")),
+            lambda: client1.fail(subscribe("-i 24ff16a2-ae33-4a51-9098-1b417153c712", "reader")),
             lambda: [
                 server.wait_for_console_text("24ff16a2-ae33-4a51-9098-1b417153c712"),
                 client2.succeed(publish("-m test", "reader"))
             ])
 
-    check_acl()
-
-    def check_tls():
+    with subtest("check tls"):
         client1.succeed(
             subscribe(
                 "--cafile ${snakeOil}/ca.crt "
@@ -187,7 +182,5 @@ in {
                 topic="$SYS/#",
                 port=${toString tlsPort},
                 user="no_such_user"))
-
-    check_tls()
   '';
 })