Merge pull request #63716 from peterhoeg/f/mosquitto
nixos/mosquitto: make the tests run
This commit is contained in:
commit
16bd66818a
1 changed files with 26 additions and 7 deletions
|
@ -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}");
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue