summaryrefslogtreecommitdiffstats
path: root/nixos/tests/nginx-dynamic-modules.nix
blob: 608e95e62f24dd63e142aebf904bff823b6f6da9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
  name = "nginx-dynamic-modules";

  nodes.machine =
    { pkgs, ... }:
    {
      services.nginx = {
        enable = true;
        additionalModules = [ (pkgs.nginxModules.echo // { dynamic = true; }) ];
        virtualHosts."localhost".locations."/".extraConfig = ''
          echo "dynamic-module-ok";
        '';
      };
    };

  testScript =
    { nodes, ... }:
    let
      cfg = nodes.machine.services.nginx;
    in
    ''
      machine.wait_for_unit("nginx")
      machine.wait_for_open_port(80)

      machine.succeed("ls ${cfg.package}/modules/*.so")
      machine.succeed("grep -F load_module ${cfg.package}/etc/nginx/dynamic-modules.conf")

      # The echo directive only exists once nginx has dlopen'd the .so.
      response = machine.wait_until_succeeds("curl -fsS http://127.0.0.1/")
      assert "dynamic-module-ok" in response, response
    '';
}