Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #60149 from peterhoeg/u/mosquitto_160
Browse files Browse the repository at this point in the history
mosquitto: 1.5.8 -> 1.6 + nixos tests
  • Loading branch information
peterhoeg committed Apr 24, 2019
2 parents 28a95c4 + c5af9fd commit f81ddbf
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 9 deletions.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Expand Up @@ -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 {};
Expand Down
69 changes: 69 additions & 0 deletions nixos/tests/mosquitto.nix
@@ -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}");
'';
})
13 changes: 4 additions & 9 deletions pkgs/servers/mqtt/mosquitto/default.nix
@@ -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 = ''
Expand All @@ -38,8 +35,6 @@ in stdenv.mkDerivation rec {

nativeBuildInputs = [ cmake docbook_xsl libxslt ];

enableParallelBuilding = true;

cmakeFlags = [
"-DWITH_THREADING=ON"
"-DWITH_WEBSOCKETS=ON"
Expand Down

0 comments on commit f81ddbf

Please sign in to comment.