nixpkgs-suyu/nixos/tests/uwsgi.nix

39 lines
1,002 B
Nix
Raw Normal View History

2019-11-24 19:12:14 +01:00
import ./make-test-python.nix ({ pkgs, ... }:
2019-05-27 23:03:22 +02:00
{
name = "uwsgi";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ lnl7 ];
};
machine = { pkgs, ... }: {
services.uwsgi.enable = true;
services.uwsgi.plugins = [ "python3" ];
2019-05-27 23:03:22 +02:00
services.uwsgi.instance = {
type = "emperor";
vassals.hello = {
2019-05-27 23:03:22 +02:00
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 =
''
2019-11-24 19:12:14 +01:00
machine.wait_for_unit("multi-user.target")
machine.wait_for_unit("uwsgi.service")
machine.wait_for_open_port(8000)
2020-09-16 17:19:47 +02:00
assert "Hello World" in machine.succeed("curl -fv 127.0.0.1:8000")
2019-05-27 23:03:22 +02:00
'';
})