git.iko.soy/typeable/nixpkgs
on master help sign in
nixos: add test for uwsgi
commit8ce93e26b074a159bcfb4f8c86dfa8b2793e1768 authorDaiderd Jordan <daiderd@gmail.com> dateMon 27 May 2019, 23:03 (7 years ago) parent915085c
2 files changed+39
nixos/tests/all-tests.nix+1 nixos/tests/uwsgi.nix+38
nixos/tests/all-tests.nix+1
@@ -246,6 +246,7 @@ in
246246 transmission = handleTest ./transmission.nix {};
247247 udisks2 = handleTest ./udisks2.nix {};
248248 upnp = handleTest ./upnp.nix {};
249+ uwsgi = handleTest ./uwsgi.nix {};
249250 vault = handleTest ./vault.nix {};
250251 virtualbox = handleTestOn ["x86_64-linux"] ./virtualbox.nix {};
251252 wireguard = handleTest ./wireguard {};
nixos/tests/uwsgi.nixnew file+38
@@ -0,0 +1,38 @@
1+import ./make-test.nix ({ pkgs, ... }:
2+{
3+ name = "uwsgi";
4+ meta = with pkgs.stdenv.lib.maintainers; {
5+ maintainers = [ lnl7 ];
6+ };
7+ machine = { pkgs, ... }: {
8+ services.uwsgi.enable = true;
9+ services.uwsgi.plugins = [ "python3" ];
10+ services.uwsgi.instance = {
11+ type = "emperor";
12+ vassals.hello = {
13+ type = "normal";
14+ master = true;
15+ workers = 2;
16+ http = ":8000";
17+ module = "wsgi:application";
18+ chdir = pkgs.writeTextDir "wsgi.py" ''
19+ from flask import Flask
20+ application = Flask(__name__)
21+
22+ @application.route("/")
23+ def hello():
24+ return "Hello World!"
25+ '';
26+ pythonPackages = self: with self; [ flask ];
27+ };
28+ };
29+ };
30+
31+ testScript =
32+ ''
33+ $machine->waitForUnit('multi-user.target');
34+ $machine->waitForUnit('uwsgi.service');
35+ $machine->waitForOpenPort(8000);
36+ $machine->succeed('curl -v 127.0.0.1:8000 | grep "Hello World!"');
37+ '';
38+})