Unverified Commit 558e5bfe authored by 7c6f434c's avatar 7c6f434c Committed by GitHub
Browse files

nixos/tests/prosody: fix test prosody-mysql (#434022)

parents 67d5342a e69f11b7
Loading
Loading
Loading
Loading
+30 −41
Original line number Diff line number Diff line
@@ -2,37 +2,28 @@ let
  cert =
    pkgs:
    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
      cp key.pem cert.pem $out
    '';
  createUsers =
    pkgs:
    pkgs.writeScriptBin "create-prosody-users" ''
      #!${pkgs.bash}/bin/bash
      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.

  createUsers =
    pkgs:
    pkgs.writeShellScriptBin "create-prosody-users" ''
      set -e
      prosodyctl register cthon98 example.com nothunter2
      prosodyctl register azurediamond example.com hunter2
    '';
  # Deletes the test users.
  delUsers =
    pkgs:
    pkgs.writeScriptBin "delete-prosody-users" ''
      #!${pkgs.bash}/bin/bash
    pkgs.writeShellScriptBin "delete-prosody-users" ''
      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 azurediamond@example.com
    '';
@@ -49,20 +40,20 @@ import ../make-test-python.nix {
      }:
      {
        security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
        console.keyMap = "fr-bepo";
        networking.extraHosts = ''
          ${nodes.server.config.networking.primaryIPAddress} example.com
          ${nodes.server.config.networking.primaryIPAddress} conference.example.com
          ${nodes.server.config.networking.primaryIPAddress} uploads.example.com
          ${nodes.server.networking.primaryIPAddress} example.com
          ${nodes.server.networking.primaryIPAddress} conference.example.com
          ${nodes.server.networking.primaryIPAddress} uploads.example.com
        '';
        environment.systemPackages = [
          (pkgs.callPackage ./xmpp-sendmessage.nix {
            connectTo = nodes.server.config.networking.primaryIPAddress;
            connectTo = nodes.server.networking.primaryIPAddress;
          })
        ];
      };

    server =
      { config, pkgs, ... }:
      { nodes, pkgs, ... }:
      {
        nixpkgs.overlays = [
          (self: super: {
@@ -72,11 +63,10 @@ import ../make-test-python.nix {
          })
        ];
        security.pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
        console.keyMap = "fr-bepo";
        networking.extraHosts = ''
          ${config.networking.primaryIPAddress} example.com
          ${config.networking.primaryIPAddress} conference.example.com
          ${config.networking.primaryIPAddress} uploads.example.com
          ${nodes.server.networking.primaryIPAddress} example.com
          ${nodes.server.networking.primaryIPAddress} conference.example.com
          ${nodes.server.networking.primaryIPAddress} uploads.example.com
        '';
        networking.firewall.enable = false;
        environment.systemPackages = [
@@ -98,7 +88,7 @@ import ../make-test-python.nix {
              domain = "conference.example.com";
            }
          ];
          uploadHttp = {
          httpFileShare = {
            domain = "uploads.example.com";
          };
          extraConfig = ''
@@ -131,10 +121,9 @@ import ../make-test-python.nix {
      };
  };

  testScript =
    { nodes, ... }:
    ''
  testScript = _: ''
    # Check with mysql storage
    start_all()
    mysql.wait_for_unit("mysql.service")
    server.wait_for_unit("prosody.service")
    server.succeed('prosodyctl status | grep "Prosody is running"')
+1 −1
Original line number Diff line number Diff line
@@ -453,7 +453,7 @@ in
    luarocksConfig = lib.recursiveUpdate oa.luarocksConfig {
      variables = {
        MYSQL_INCDIR = "${lib.getDev libmysqlclient}/include/";
        MYSQL_LIBDIR = "${lib.getLib libmysqlclient}/lib/";
        MYSQL_LIBDIR = "${lib.getLib libmysqlclient}/lib//mysql/";
      };
    };
    buildInputs = oa.buildInputs ++ [