diff --git a/index.alpha.html b/index.alpha.html new file mode 100644 index 0000000..4a58007 --- /dev/null +++ b/index.alpha.html @@ -0,0 +1 @@ +alpha diff --git a/index.bravo.html b/index.bravo.html new file mode 100644 index 0000000..652d57d --- /dev/null +++ b/index.bravo.html @@ -0,0 +1 @@ +bravo diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..61973d0 --- /dev/null +++ b/nginx.conf @@ -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; + } + +} \ No newline at end of file diff --git a/tests.nix b/tests.nix index 285d9c1..58ba811 100644 --- a/tests.nix +++ b/tests.nix @@ -6,6 +6,7 @@ with import { inherit system pkgs; }; let registry = import ./static_registry/default.nix; + nginx_image = registry.nginx.nginx_7d0cdcc60a96; in { mytest = makeTest { @@ -15,23 +16,40 @@ in virtualisation.cores = 4; virtualisation.memorySize = 1024; - foo.bar.enable = true; - docker-containers.nginx = let - image = registry.nginx.nginx_7d0cdcc60a96; - in + docker-networks.web = { + usedBy = [ "nginx_alpha" "nginx_bravo" ]; + }; + docker-containers.nginx_alpha = { - image = image.tag; - imageFile = image.image; + 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.service") + 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") + machine.wait_until_succeeds("curl http://localhost:8181 | grep alpha") + machine.wait_until_succeeds("curl http://localhost:8181/bravo | grep bravo") ''; }; }