git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/tests/prosodyMysql: add check work prosody with MySQL database
commitbb4816d41c2aa43723529ef7bcf081f845c86180 authorIzorkin <izorkin@elven.pw> dateSat 15 Jun 2019, 12:58 (7 years ago) parente328ea9
2 files changed+70
nixos/tests/all-tests.nix+1 nixos/tests/xmpp/prosody-mysql.nix+69
nixos/tests/all-tests.nix+1
@@ -210,6 +210,7 @@ in
210210 prometheus2 = handleTest ./prometheus-2.nix {};
211211 prometheus-exporters = handleTest ./prometheus-exporters.nix {};
212212 prosody = handleTest ./xmpp/prosody.nix {};
213+ prosodyMysql = handleTest ./xmpp/prosody-mysql.nix {};
213214 proxy = handleTest ./proxy.nix {};
214215 quagga = handleTest ./quagga.nix {};
215216 quake3 = handleTest ./quake3.nix {};
nixos/tests/xmpp/prosody-mysql.nixnew file+69
@@ -0,0 +1,69 @@
1+import ../make-test.nix {
2+ name = "prosody-mysql";
3+
4+ nodes = {
5+ client = { nodes, pkgs, ... }: {
6+ environment.systemPackages = [
7+ (pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = nodes.server.config.networking.primaryIPAddress; })
8+ ];
9+ };
10+ server = { config, pkgs, ... }: {
11+ networking.extraHosts = ''
12+ ${config.networking.primaryIPAddress} example.com
13+ '';
14+ networking.firewall.enable = false;
15+ services.prosody = {
16+ enable = true;
17+ # TODO: use a self-signed certificate
18+ c2sRequireEncryption = false;
19+ extraConfig = ''
20+ storage = "sql"
21+ sql = {
22+ driver = "MySQL";
23+ database = "prosody";
24+ host = "mysql";
25+ port = 3306;
26+ username = "prosody";
27+ password = "password123";
28+ };
29+ '';
30+ virtualHosts.test = {
31+ domain = "example.com";
32+ enabled = true;
33+ };
34+ };
35+ };
36+ mysql = { config, pkgs, ... }: {
37+ networking.firewall.enable = false;
38+ services.mysql = {
39+ enable = true;
40+ initialScript = pkgs.writeText "mysql_init.sql" ''
41+ CREATE DATABASE prosody;
42+ CREATE USER 'prosody'@'server' IDENTIFIED BY 'password123';
43+ GRANT ALL PRIVILEGES ON prosody.* TO 'prosody'@'server';
44+ FLUSH PRIVILEGES;
45+ '';
46+ package = pkgs.mariadb;
47+ };
48+ };
49+ };
50+
51+ testScript = { nodes, ... }: ''
52+ $mysql->waitForUnit('mysql.service');
53+ $server->waitForUnit('prosody.service');
54+ $server->succeed('prosodyctl status') =~ /Prosody is running/;
55+
56+ # set password to 'nothunter2' (it's asked twice)
57+ $server->succeed('yes nothunter2 | prosodyctl adduser cthon98@example.com');
58+ # set password to 'y'
59+ $server->succeed('yes | prosodyctl adduser azurediamond@example.com');
60+ # correct password to 'hunter2'
61+ $server->succeed('yes hunter2 | prosodyctl passwd azurediamond@example.com');
62+
63+ $client->succeed("send-message");
64+
65+ $server->succeed('prosodyctl deluser cthon98@example.com');
66+ $server->succeed('prosodyctl deluser azurediamond@example.com');
67+ '';
68+}
69+