nixos/tests/prosody: fix test prosody-mysql

This commit is contained in:
Izorkin 2025-08-15 20:03:52 +03:00
parent 3c5b611ee8
commit e69f11b797
No known key found for this signature in database
GPG Key ID: 1436C1B3F3679F09
2 changed files with 31 additions and 42 deletions

View File

@ -2,37 +2,28 @@ let
cert = cert =
pkgs: pkgs:
pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } '' pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=example.com/CN=uploads.example.com/CN=conference.example.com' -days 36500 openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 365 \
-subj '/C=GB/CN=example.com' -addext "subjectAltName = DNS:example.com,DNS:uploads.example.com,DNS:conference.example.com"
mkdir -p $out mkdir -p $out
cp key.pem cert.pem $out cp key.pem cert.pem $out
''; '';
# Creates and set password for the 2 xmpp test users.
#
# Doing that in a bash script instead of doing that in the test
# script allow us to easily provision the users when running that
# test interactively.
createUsers = createUsers =
pkgs: pkgs:
pkgs.writeScriptBin "create-prosody-users" '' pkgs.writeShellScriptBin "create-prosody-users" ''
#!${pkgs.bash}/bin/bash
set -e set -e
# Creates and set password for the 2 xmpp test users.
#
# Doing that in a bash script instead of doing that in the test
# script allow us to easily provision the users when running that
# test interactively.
prosodyctl register cthon98 example.com nothunter2 prosodyctl register cthon98 example.com nothunter2
prosodyctl register azurediamond example.com hunter2 prosodyctl register azurediamond example.com hunter2
''; '';
# Deletes the test users.
delUsers = delUsers =
pkgs: pkgs:
pkgs.writeScriptBin "delete-prosody-users" '' pkgs.writeShellScriptBin "delete-prosody-users" ''
#!${pkgs.bash}/bin/bash
set -e set -e
# Deletes the test users.
#
# Doing that in a bash script instead of doing that in the test
# script allow us to easily provision the users when running that
# test interactively.
prosodyctl deluser cthon98@example.com prosodyctl deluser cthon98@example.com
prosodyctl deluser azurediamond@example.com prosodyctl deluser azurediamond@example.com
''; '';
@ -49,20 +40,20 @@ import ../make-test-python.nix {
}: }:
{ {
security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ]; security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
console.keyMap = "fr-bepo";
networking.extraHosts = '' networking.extraHosts = ''
${nodes.server.config.networking.primaryIPAddress} example.com ${nodes.server.networking.primaryIPAddress} example.com
${nodes.server.config.networking.primaryIPAddress} conference.example.com ${nodes.server.networking.primaryIPAddress} conference.example.com
${nodes.server.config.networking.primaryIPAddress} uploads.example.com ${nodes.server.networking.primaryIPAddress} uploads.example.com
''; '';
environment.systemPackages = [ environment.systemPackages = [
(pkgs.callPackage ./xmpp-sendmessage.nix { (pkgs.callPackage ./xmpp-sendmessage.nix {
connectTo = nodes.server.config.networking.primaryIPAddress; connectTo = nodes.server.networking.primaryIPAddress;
}) })
]; ];
}; };
server = server =
{ config, pkgs, ... }: { nodes, pkgs, ... }:
{ {
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: { (self: super: {
@ -72,11 +63,10 @@ import ../make-test-python.nix {
}) })
]; ];
security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ]; security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
console.keyMap = "fr-bepo";
networking.extraHosts = '' networking.extraHosts = ''
${config.networking.primaryIPAddress} example.com ${nodes.server.networking.primaryIPAddress} example.com
${config.networking.primaryIPAddress} conference.example.com ${nodes.server.networking.primaryIPAddress} conference.example.com
${config.networking.primaryIPAddress} uploads.example.com ${nodes.server.networking.primaryIPAddress} uploads.example.com
''; '';
networking.firewall.enable = false; networking.firewall.enable = false;
environment.systemPackages = [ environment.systemPackages = [
@ -98,7 +88,7 @@ import ../make-test-python.nix {
domain = "conference.example.com"; domain = "conference.example.com";
} }
]; ];
uploadHttp = { httpFileShare = {
domain = "uploads.example.com"; domain = "uploads.example.com";
}; };
extraConfig = '' extraConfig = ''
@ -131,16 +121,15 @@ import ../make-test-python.nix {
}; };
}; };
testScript = testScript = _: ''
{ nodes, ... }: # Check with mysql storage
'' start_all()
# Check with mysql storage mysql.wait_for_unit("mysql.service")
mysql.wait_for_unit("mysql.service") server.wait_for_unit("prosody.service")
server.wait_for_unit("prosody.service") server.succeed('prosodyctl status | grep "Prosody is running"')
server.succeed('prosodyctl status | grep "Prosody is running"')
server.succeed("create-prosody-users") server.succeed("create-prosody-users")
client.succeed("send-message") client.succeed("send-message")
server.succeed("delete-prosody-users") server.succeed("delete-prosody-users")
''; '';
} }

View File

@ -453,7 +453,7 @@ in
luarocksConfig = lib.recursiveUpdate oa.luarocksConfig { luarocksConfig = lib.recursiveUpdate oa.luarocksConfig {
variables = { variables = {
MYSQL_INCDIR = "${lib.getDev libmysqlclient}/include/"; MYSQL_INCDIR = "${lib.getDev libmysqlclient}/include/";
MYSQL_LIBDIR = "${lib.getLib libmysqlclient}/lib/"; MYSQL_LIBDIR = "${lib.getLib libmysqlclient}/lib//mysql/";
}; };
}; };
buildInputs = oa.buildInputs ++ [ buildInputs = oa.buildInputs ++ [