Merge pull request #60149 from peterhoeg/u/mosquitto_160

mosquitto: 1.5.8 -> 1.6 + nixos tests
This commit is contained in:
Peter Hoeg 2019-04-24 22:29:08 +08:00 committed by GitHub
commit f81ddbf8e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 9 deletions

View file

@ -144,6 +144,7 @@ in
misc = handleTest ./misc.nix {};
mongodb = handleTest ./mongodb.nix {};
morty = handleTest ./morty.nix {};
mosquitto = handleTest ./mosquitto.nix {};
mpd = handleTest ./mpd.nix {};
mumble = handleTest ./mumble.nix {};
munin = handleTest ./munin.nix {};

69
nixos/tests/mosquitto.nix Normal file
View file

@ -0,0 +1,69 @@
import ./make-test.nix ({ pkgs, ... }:
let
port = 1888;
username = "mqtt";
password = "VERY_secret";
topic = "test/foo";
cmd = bin: pkgs.lib.concatStringsSep " " [
"${pkgs.mosquitto}/bin/mosquitto_${bin}"
"-V mqttv311"
"-h server"
"-p ${toString port}"
"-u ${username}"
"-P '${password}'"
"-t ${topic}"
];
in rec {
name = "mosquitto";
meta = with pkgs.stdenv.lib; {
maintainers = with maintainers; [ peterhoeg ];
};
nodes = let
client = { pkgs, ... }: {
environment.systemPackages = with pkgs; [ mosquitto ];
};
in {
server = { pkgs, ... }: {
networking.firewall.allowedTCPPorts = [ port ];
services.mosquitto = {
inherit port;
enable = true;
host = "0.0.0.0";
checkPasswords = true;
users."${username}" = {
inherit password;
acl = [
"topic readwrite ${topic}"
];
};
};
};
client1 = client;
client2 = client;
};
testScript = let
file = "/tmp/msg";
payload = "wootWOOT";
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->succeed("${cmd "pub"} -m ${payload}");
$server->succeed("grep -q ${payload} ${file}");
$client1->succeed("grep -q ${payload} ${file}");
'';
})

View file

@ -1,19 +1,16 @@
{ stdenv, lib, fetchFromGitHub, fetchpatch, cmake, docbook_xsl, libxslt
, openssl, libuuid, libwebsockets, c-ares, libuv
, systemd ? null }:
, systemd ? null, withSystemd ? stdenv.isLinux }:
let
withSystemd = stdenv.isLinux;
in stdenv.mkDerivation rec {
stdenv.mkDerivation rec {
name = "mosquitto-${version}";
version = "1.5.8";
version = "1.6";
src = fetchFromGitHub {
owner = "eclipse";
repo = "mosquitto";
rev = "v${version}";
sha256 = "1rf8g6fq7g1mhwsajsgvvlynasybgc51v0qg5j6ynsxfh8yi7s6r";
sha256 = "1yvn0yj9hb502lvk2yrshpvrnq2fddjyarnw37ip34mhxynnz5gb";
};
postPatch = ''
@ -38,8 +35,6 @@ in stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake docbook_xsl libxslt ];
enableParallelBuilding = true;
cmakeFlags = [
"-DWITH_THREADING=ON"
"-DWITH_WEBSOCKETS=ON"