simple test for docker network using reverse proxy
This commit is contained in:
1
index.alpha.html
Normal file
1
index.alpha.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
alpha
|
||||||
1
index.bravo.html
Normal file
1
index.bravo.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
bravo
|
||||||
23
nginx.conf
Normal file
23
nginx.conf
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
34
tests.nix
34
tests.nix
@@ -6,6 +6,7 @@ with import <nixpkgs/nixos/lib/testing-python.nix> { inherit system pkgs; };
|
|||||||
|
|
||||||
let
|
let
|
||||||
registry = import ./static_registry/default.nix;
|
registry = import ./static_registry/default.nix;
|
||||||
|
nginx_image = registry.nginx.nginx_7d0cdcc60a96;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
mytest = makeTest {
|
mytest = makeTest {
|
||||||
@@ -15,23 +16,40 @@ in
|
|||||||
virtualisation.cores = 4;
|
virtualisation.cores = 4;
|
||||||
virtualisation.memorySize = 1024;
|
virtualisation.memorySize = 1024;
|
||||||
|
|
||||||
foo.bar.enable = true;
|
|
||||||
|
|
||||||
docker-containers.nginx = let
|
docker-networks.web = {
|
||||||
image = registry.nginx.nginx_7d0cdcc60a96;
|
usedBy = [ "nginx_alpha" "nginx_bravo" ];
|
||||||
in
|
};
|
||||||
|
docker-containers.nginx_alpha =
|
||||||
{
|
{
|
||||||
image = image.tag;
|
image = nginx_image.tag;
|
||||||
imageFile = image.image;
|
imageFile = nginx_image.image;
|
||||||
|
extraDockerOptions = [ "--network=web" ];
|
||||||
ports = ["8181:80"];
|
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 = ''
|
testScript = ''
|
||||||
machine.start()
|
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_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")
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user