Merge pull request #63716 from peterhoeg/f/mosquitto

nixos/mosquitto: make the tests run
This commit is contained in:
Peter Hoeg 2019-08-13 22:45:38 +08:00 committed by GitHub
commit 16bd66818a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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}");
$client2->succeed("${cmd "pub"} -m ${payload}");
$server->succeed("grep -q ${payload} ${file}");
# QoS = 0, so only one subscribers should get it
$server->execute("${sub "-q 0"}");
$client1->succeed("grep -q ${payload} ${file}");
# 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"}");
# we need to give the subscribers some time to connect
$client2->execute("sleep 5");
$client2->succeed("${cmd "pub"} -m BAR -q 1");
$server->waitUntilSucceeds("grep -q BAR ${file}");
$server->execute("rm ${file}");
$client1->waitUntilSucceeds("grep -q BAR ${file}");
$client1->execute("rm ${file}");
'';
})