diff options
author | Peter Hoeg <peter@hoeg.com> | 2019-08-13 22:45:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-13 22:45:38 +0800 |
commit | 16bd66818a1056a6bdbe5cc545c7e7ec32bb9939 (patch) | |
tree | 71108f1930dc09d642a9fea49383bd108ba14f62 | |
parent | 7a29431da9a3aa91d6e26517d5b354d1d1be7767 (diff) | |
parent | bab2a01ce8fdd63767a102b540e3276f5cd4d6f6 (diff) | |
download | nixlib-16bd66818a1056a6bdbe5cc545c7e7ec32bb9939.tar nixlib-16bd66818a1056a6bdbe5cc545c7e7ec32bb9939.tar.gz nixlib-16bd66818a1056a6bdbe5cc545c7e7ec32bb9939.tar.bz2 nixlib-16bd66818a1056a6bdbe5cc545c7e7ec32bb9939.tar.lz nixlib-16bd66818a1056a6bdbe5cc545c7e7ec32bb9939.tar.xz nixlib-16bd66818a1056a6bdbe5cc545c7e7ec32bb9939.tar.zst nixlib-16bd66818a1056a6bdbe5cc545c7e7ec32bb9939.zip |
Merge pull request #63716 from peterhoeg/f/mosquitto
nixos/mosquitto: make the tests run
-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 86b7f9c044d8..bd5447de15ff 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}"); ''; }) |