diff options
Diffstat (limited to 'nixos/tests/mosquitto.nix')
-rw-r--r-- | nixos/tests/mosquitto.nix | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/nixos/tests/mosquitto.nix b/nixos/tests/mosquitto.nix index 86b7f9c044d89..bd5447de15ff7 100644 --- a/nixos/tests/mosquitto.nix +++ b/nixos/tests/mosquitto.nix @@ -49,21 +49,40 @@ in rec { testScript = let file = "/tmp/msg"; - payload = "wootWOOT"; + sub = args: + "(${cmd "sub"} -C 1 ${args} | tee ${file} &)"; in '' startAll; $server->waitForUnit("mosquitto.service"); $server->fail("test -f ${file}"); - $server->execute("(${cmd "sub"} -C 1 | tee ${file} &)"); - $client1->fail("test -f ${file}"); - $client1->execute("(${cmd "sub"} -C 1 | tee ${file} &)"); + $client2->fail("test -f ${file}"); + + + # QoS = 0, so only one subscribers should get it + $server->execute("${sub "-q 0"}"); + + # we need to give the subscribers some time to connect + $client2->execute("sleep 5"); + $client2->succeed("${cmd "pub"} -m FOO -q 0"); + + $server->waitUntilSucceeds("grep -q FOO ${file}"); + $server->execute("rm ${file}"); + + + # QoS = 1, so both subscribers should get it + $server->execute("${sub "-q 1"}"); + $client1->execute("${sub "-q 1"}"); - $client2->succeed("${cmd "pub"} -m ${payload}"); + # we need to give the subscribers some time to connect + $client2->execute("sleep 5"); + $client2->succeed("${cmd "pub"} -m BAR -q 1"); - $server->succeed("grep -q ${payload} ${file}"); + $server->waitUntilSucceeds("grep -q BAR ${file}"); + $server->execute("rm ${file}"); - $client1->succeed("grep -q ${payload} ${file}"); + $client1->waitUntilSucceeds("grep -q BAR ${file}"); + $client1->execute("rm ${file}"); ''; }) |