nixpkgs-suyu/nixos/tests/uwsgi.nix

53 lines
1.4 KiB
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 ];
};
2020-12-21 00:22:29 +01:00
2019-05-27 23:03:22 +02:00
machine = { pkgs, ... }: {
services.uwsgi.enable = true;
2020-12-21 00:22:29 +01:00
services.uwsgi.plugins = [ "python3" "php" ];
2019-05-27 23:03:22 +02:00
services.uwsgi.instance = {
type = "emperor";
2020-12-21 00:22:29 +01:00
vassals.python = {
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 ];
};
2020-12-21 00:22:29 +01:00
vassals.php = {
type = "normal";
master = true;
workers = 2;
http-socket = ":8001";
http-socket-modifier1 = 14;
php-index = "index.php";
php-docroot = pkgs.writeTextDir "index.php" ''
<?php echo "Hello World\n"; ?>
'';
};
2019-05-27 23:03:22 +02:00
};
};
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-12-21 00:22:29 +01:00
machine.wait_for_open_port(8001)
2020-09-16 17:19:47 +02:00
assert "Hello World" in machine.succeed("curl -fv 127.0.0.1:8000")
2020-12-21 00:22:29 +01:00
assert "Hello World" in machine.succeed("curl -fv 127.0.0.1:8001")
2019-05-27 23:03:22 +02:00
'';
})