move nginx test to seperate directory

This commit is contained in:
Maximilian Güntner
2020-06-20 19:25:48 +02:00
parent 8925fea5dc
commit 1ee7b14c69
8 changed files with 9 additions and 2 deletions

1
tests/index.alpha.html Normal file
View File

@@ -0,0 +1 @@
alpha

1
tests/index.bravo.html Normal file
View File

@@ -0,0 +1 @@
bravo

23
tests/nginx.conf Normal file
View File

@@ -0,0 +1,23 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm;
server_name _;
location /alpha {
proxy_pass http://nginx_alpha/index.html;
}
location /bravo {
proxy_pass http://nginx_bravo/index.html;
}
location / {
try_files $uri $uri/ =404;
}
}

1
tests/result Symbolic link
View File

@@ -0,0 +1 @@
/nix/store/xrls5la280q72grq3rvx44z95xqscyjy-vm-test-run-unnamed

View File

@@ -0,0 +1,5 @@
{
nginx = {
nginx_7d0cdcc60a96 = { image = "${/home/max/code/nixos/docker/tests/static_registry/nginx/7d0cdcc60a96.tar.gz}"; tag = "nginx:7d0cdcc60a96"; };
};
}

View File

@@ -0,0 +1 @@
FROM nginx:1.19-alpine

55
tests/tests.nix Normal file
View File

@@ -0,0 +1,55 @@
{ system ? builtins.currentSystem
, pkgs ? import <nixpkgs> { inherit system; }
}:
with import <nixpkgs/nixos/lib/testing-python.nix> { inherit system pkgs; };
let
registry = import ./static_registry/default.nix;
nginx_image = registry.nginx.nginx_7d0cdcc60a96;
in
{
nginx = makeTest {
machine = { ... }: {
imports = [ ../default.nix ];
virtualisation.cores = 4;
virtualisation.memorySize = 1024;
docker-networks.web = {
usedBy = [ "nginx_alpha" "nginx_bravo" ];
};
docker-containers.nginx_alpha =
{
image = nginx_image.tag;
imageFile = nginx_image.image;
extraDockerOptions = [ "--network=web" ];
ports = ["8181:80"];
volumes = [
"${./nginx.conf}:/etc/nginx/conf.d/default.conf:ro"
"${./index.alpha.html}:/var/www/html/index.html:ro"
];
};
docker-containers.nginx_bravo =
{
image = nginx_image.tag;
imageFile = nginx_image.image;
extraDockerOptions = [ "--network=web" ];
volumes = [
"${./nginx.conf}:/etc/nginx/conf.d/default.conf:ro"
"${./index.bravo.html}:/var/www/html/index.html:ro"
];
};
};
testScript = ''
machine.start()
machine.wait_for_unit("docker-nginx_alpha.service")
machine.wait_for_unit("docker-nginx_bravo.service")
machine.wait_for_open_port(8181)
machine.wait_until_succeeds("curl http://localhost:8181 | grep alpha")
machine.wait_until_succeeds("curl http://localhost:8181/bravo | grep bravo")
'';
};
}