nixpkgs/nixos/tests/uwsgi.nix

39 lines
1002 B
Nix
Raw Normal View History

2019-11-24 18:12:14 +00:00
import ./make-test-python.nix ({ pkgs, ... }:
2019-05-27 22:03:22 +01:00
{
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 =
''
2019-11-24 18:12:14 +00:00
machine.wait_for_unit("multi-user.target")
machine.wait_for_unit("uwsgi.service")
machine.wait_for_open_port(8000)
2020-09-16 16:19:47 +01:00
assert "Hello World" in machine.succeed("curl -fv 127.0.0.1:8000")
2019-05-27 22:03:22 +01:00
'';
})