about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/uwsgi.nix
blob: afc03e74ed7e309e7f04647537f3db6f753ed4b5 (plain) (blame)
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
33
34
35
36
37
38
import ./make-test.nix ({ pkgs, ... }:
{
  name = "uwsgi";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ lnl7 ];
  };
  machine = { pkgs, ... }: {
    services.uwsgi.enable = true;
    services.uwsgi.plugins = [ "python3" ];
    services.uwsgi.instance = {
      type = "emperor";
      vassals.hello = {
        type = "normal";
        master = true;
        workers = 2;
        http = ":8000";
        module = "wsgi:application";
        chdir = pkgs.writeTextDir "wsgi.py" ''
          from flask import Flask
          application = Flask(__name__)

          @application.route("/")
          def hello():
              return "Hello World!"
        '';
        pythonPackages = self: with self; [ flask ];
      };
    };
  };

  testScript =
    ''
      $machine->waitForUnit('multi-user.target');
      $machine->waitForUnit('uwsgi.service');
      $machine->waitForOpenPort(8000);
      $machine->succeed('curl -v 127.0.0.1:8000 | grep "Hello World!"');
    '';
})