about summary refs log tree commit diff
path: root/nixos/tests/uwsgi.nix
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2019-05-27 23:03:22 +0200
committerDaiderd Jordan <daiderd@gmail.com>2019-05-27 23:03:22 +0200
commit8ce93e26b074a159bcfb4f8c86dfa8b2793e1768 (patch)
tree74651252d75941c7dacdfbf855dd86365409a5e7 /nixos/tests/uwsgi.nix
parent915085c6deb7d16f5e8d9ab5d96b3242e5583972 (diff)
nixos: add test for uwsgi
Diffstat (limited to 'nixos/tests/uwsgi.nix')
-rw-r--r--nixos/tests/uwsgi.nix38
1 files changed, 38 insertions, 0 deletions
diff --git a/nixos/tests/uwsgi.nix b/nixos/tests/uwsgi.nix
new file mode 100644
index 0000000000000..afc03e74ed7e3
--- /dev/null
+++ b/nixos/tests/uwsgi.nix
@@ -0,0 +1,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!"');
+    '';
+})