From 691da63cbaf24fd3ef01a32195fa7f88d2546861 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Sat, 15 Jun 2019 12:16:28 +0300 Subject: [PATCH 1/4] nixos/tests: move ejabberd and prosody test to xmpp folder --- nixos/tests/all-tests.nix | 4 ++-- nixos/tests/{ => xmpp}/ejabberd.nix | 2 +- nixos/tests/{ => xmpp}/prosody.nix | 2 +- nixos/tests/{ => xmpp}/xmpp-sendmessage.nix | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename nixos/tests/{ => xmpp}/ejabberd.nix (99%) rename nixos/tests/{ => xmpp}/prosody.nix (97%) rename nixos/tests/{ => xmpp}/xmpp-sendmessage.nix (100%) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 912e4f552313..c00cf30e91e0 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -73,7 +73,7 @@ in #ec2-config = (handleTestOn ["x86_64-linux"] ./ec2.nix {}).boot-ec2-config or {}; ec2-nixops = (handleTestOn ["x86_64-linux"] ./ec2.nix {}).boot-ec2-nixops or {}; ecryptfs = handleTest ./ecryptfs.nix {}; - ejabberd = handleTest ./ejabberd.nix {}; + ejabberd = handleTest ./xmpp/ejabberd.nix {}; elk = handleTestOn ["x86_64-linux"] ./elk.nix {}; env = handleTest ./env.nix {}; etcd = handleTestOn ["x86_64-linux"] ./etcd.nix {}; @@ -209,7 +209,7 @@ in prometheus = handleTest ./prometheus.nix {}; prometheus2 = handleTest ./prometheus-2.nix {}; prometheus-exporters = handleTest ./prometheus-exporters.nix {}; - prosody = handleTest ./prosody.nix {}; + prosody = handleTest ./xmpp/prosody.nix {}; proxy = handleTest ./proxy.nix {}; quagga = handleTest ./quagga.nix {}; quake3 = handleTest ./quake3.nix {}; diff --git a/nixos/tests/ejabberd.nix b/nixos/tests/xmpp/ejabberd.nix similarity index 99% rename from nixos/tests/ejabberd.nix rename to nixos/tests/xmpp/ejabberd.nix index 0691dfe780d2..7eb566b54685 100644 --- a/nixos/tests/ejabberd.nix +++ b/nixos/tests/xmpp/ejabberd.nix @@ -1,4 +1,4 @@ -import ./make-test.nix ({ pkgs, ... }: { +import ../make-test.nix ({ pkgs, ... }: { name = "ejabberd"; meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ ajs124 ]; diff --git a/nixos/tests/prosody.nix b/nixos/tests/xmpp/prosody.nix similarity index 97% rename from nixos/tests/prosody.nix rename to nixos/tests/xmpp/prosody.nix index a39bae7898dc..3241cee79c9a 100644 --- a/nixos/tests/prosody.nix +++ b/nixos/tests/xmpp/prosody.nix @@ -1,4 +1,4 @@ -import ./make-test.nix { +import ../make-test.nix { name = "prosody"; machine = { pkgs, ... }: { diff --git a/nixos/tests/xmpp-sendmessage.nix b/nixos/tests/xmpp/xmpp-sendmessage.nix similarity index 100% rename from nixos/tests/xmpp-sendmessage.nix rename to nixos/tests/xmpp/xmpp-sendmessage.nix From e328ea9c11cd4316428db385c43ede2a8b8aa874 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Sat, 15 Jun 2019 12:41:50 +0300 Subject: [PATCH 2/4] nixos/tests/prosody: checking work prosody through local network --- nixos/tests/xmpp/prosody.nix | 52 +++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/nixos/tests/xmpp/prosody.nix b/nixos/tests/xmpp/prosody.nix index 3241cee79c9a..8331c7b6d331 100644 --- a/nixos/tests/xmpp/prosody.nix +++ b/nixos/tests/xmpp/prosody.nix @@ -1,38 +1,46 @@ import ../make-test.nix { name = "prosody"; - machine = { pkgs, ... }: { - services.prosody = { - enable = true; - # TODO: use a self-signed certificate - c2sRequireEncryption = false; - extraConfig = '' - storage = "sql" + nodes = { + client = { nodes, pkgs, ... }: { + environment.systemPackages = [ + (pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = nodes.server.config.networking.primaryIPAddress; }) + ]; + }; + server = { config, pkgs, ... }: { + networking.extraHosts = '' + ${config.networking.primaryIPAddress} example.com ''; - virtualHosts.test = { - domain = "example.com"; - enabled = true; + networking.firewall.enable = false; + services.prosody = { + enable = true; + # TODO: use a self-signed certificate + c2sRequireEncryption = false; + extraConfig = '' + storage = "sql" + ''; + virtualHosts.test = { + domain = "example.com"; + enabled = true; + }; }; }; - environment.systemPackages = [ - (pkgs.callPackage ./xmpp-sendmessage.nix {}) - ]; }; - testScript = '' - $machine->waitForUnit('prosody.service'); - $machine->succeed('prosodyctl status') =~ /Prosody is running/; + testScript = { nodes, ... }: '' + $server->waitForUnit('prosody.service'); + $server->succeed('prosodyctl status') =~ /Prosody is running/; # set password to 'nothunter2' (it's asked twice) - $machine->succeed('yes nothunter2 | prosodyctl adduser cthon98@example.com'); + $server->succeed('yes nothunter2 | prosodyctl adduser cthon98@example.com'); # set password to 'y' - $machine->succeed('yes | prosodyctl adduser azurediamond@example.com'); + $server->succeed('yes | prosodyctl adduser azurediamond@example.com'); # correct password to 'hunter2' - $machine->succeed('yes hunter2 | prosodyctl passwd azurediamond@example.com'); + $server->succeed('yes hunter2 | prosodyctl passwd azurediamond@example.com'); - $machine->succeed("send-message"); + $client->succeed("send-message"); - $machine->succeed('prosodyctl deluser cthon98@example.com'); - $machine->succeed('prosodyctl deluser azurediamond@example.com'); + $server->succeed('prosodyctl deluser cthon98@example.com'); + $server->succeed('prosodyctl deluser azurediamond@example.com'); ''; } From bb4816d41c2aa43723529ef7bcf081f845c86180 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Sat, 15 Jun 2019 12:58:00 +0300 Subject: [PATCH 3/4] nixos/tests/prosodyMysql: add check work prosody with MySQL database --- nixos/tests/all-tests.nix | 1 + nixos/tests/xmpp/prosody-mysql.nix | 69 ++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 nixos/tests/xmpp/prosody-mysql.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index c00cf30e91e0..1391a537f32f 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -210,6 +210,7 @@ in prometheus2 = handleTest ./prometheus-2.nix {}; prometheus-exporters = handleTest ./prometheus-exporters.nix {}; prosody = handleTest ./xmpp/prosody.nix {}; + prosodyMysql = handleTest ./xmpp/prosody-mysql.nix {}; proxy = handleTest ./proxy.nix {}; quagga = handleTest ./quagga.nix {}; quake3 = handleTest ./quake3.nix {}; diff --git a/nixos/tests/xmpp/prosody-mysql.nix b/nixos/tests/xmpp/prosody-mysql.nix new file mode 100644 index 000000000000..5e9dba2abe53 --- /dev/null +++ b/nixos/tests/xmpp/prosody-mysql.nix @@ -0,0 +1,69 @@ +import ../make-test.nix { + name = "prosody-mysql"; + + nodes = { + client = { nodes, pkgs, ... }: { + environment.systemPackages = [ + (pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = nodes.server.config.networking.primaryIPAddress; }) + ]; + }; + server = { config, pkgs, ... }: { + networking.extraHosts = '' + ${config.networking.primaryIPAddress} example.com + ''; + networking.firewall.enable = false; + services.prosody = { + enable = true; + # TODO: use a self-signed certificate + c2sRequireEncryption = false; + extraConfig = '' + storage = "sql" + sql = { + driver = "MySQL"; + database = "prosody"; + host = "mysql"; + port = 3306; + username = "prosody"; + password = "password123"; + }; + ''; + virtualHosts.test = { + domain = "example.com"; + enabled = true; + }; + }; + }; + mysql = { config, pkgs, ... }: { + networking.firewall.enable = false; + services.mysql = { + enable = true; + initialScript = pkgs.writeText "mysql_init.sql" '' + CREATE DATABASE prosody; + CREATE USER 'prosody'@'server' IDENTIFIED BY 'password123'; + GRANT ALL PRIVILEGES ON prosody.* TO 'prosody'@'server'; + FLUSH PRIVILEGES; + ''; + package = pkgs.mariadb; + }; + }; + }; + + testScript = { nodes, ... }: '' + $mysql->waitForUnit('mysql.service'); + $server->waitForUnit('prosody.service'); + $server->succeed('prosodyctl status') =~ /Prosody is running/; + + # set password to 'nothunter2' (it's asked twice) + $server->succeed('yes nothunter2 | prosodyctl adduser cthon98@example.com'); + # set password to 'y' + $server->succeed('yes | prosodyctl adduser azurediamond@example.com'); + # correct password to 'hunter2' + $server->succeed('yes hunter2 | prosodyctl passwd azurediamond@example.com'); + + $client->succeed("send-message"); + + $server->succeed('prosodyctl deluser cthon98@example.com'); + $server->succeed('prosodyctl deluser azurediamond@example.com'); + ''; +} + From 89c69bfb797885c3bb84c19e18f6f2c515550a10 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Thu, 20 Jun 2019 10:58:44 +0300 Subject: [PATCH 4/4] prosody: fix work after update luadbi packages --- nixos/tests/xmpp/prosody-mysql.nix | 8 ++++++++ pkgs/top-level/all-packages.nix | 1 + 2 files changed, 9 insertions(+) diff --git a/nixos/tests/xmpp/prosody-mysql.nix b/nixos/tests/xmpp/prosody-mysql.nix index 5e9dba2abe53..62b4a17421e5 100644 --- a/nixos/tests/xmpp/prosody-mysql.nix +++ b/nixos/tests/xmpp/prosody-mysql.nix @@ -8,6 +8,14 @@ import ../make-test.nix { ]; }; server = { config, pkgs, ... }: { + nixpkgs.overlays = [ + (self: super: { + prosody = super.prosody.override { + withDBI = true; + withExtraLibs = [ pkgs.luaPackages.luadbi-mysql ]; + }; + }) + ]; networking.extraHosts = '' ${config.networking.primaryIPAddress} example.com ''; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 889684d3fa94..4c30b8c7bc82 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14193,6 +14193,7 @@ in prosody = callPackage ../servers/xmpp/prosody { # _compat can probably be removed on next minor version after 0.10.0 lua5 = lua5_2_compat; + withExtraLibs = [ luaPackages.luadbi-sqlite3 ]; inherit (lua52Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luadbi; };