Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/mosquitto: make the tests run #63716

Merged
merged 1 commit into from Aug 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 26 additions & 7 deletions nixos/tests/mosquitto.nix
Expand Up @@ -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}");
'';
})