diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2010-01-11 15:58:15 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2010-01-11 15:58:15 +0000 |
commit | 73bdc861b7232e57c800bcf64ed549aefc941271 (patch) | |
tree | cc5da8aef2019e1fb4cc35de3ec9221caeaa1e96 /tests/proxy.nix | |
parent | ee005424bf57df6bcba873c0de3980ea41390172 (diff) | |
download | nixpkgs-73bdc861b7232e57c800bcf64ed549aefc941271.tar nixpkgs-73bdc861b7232e57c800bcf64ed549aefc941271.tar.gz nixpkgs-73bdc861b7232e57c800bcf64ed549aefc941271.tar.bz2 nixpkgs-73bdc861b7232e57c800bcf64ed549aefc941271.tar.lz nixpkgs-73bdc861b7232e57c800bcf64ed549aefc941271.tar.xz nixpkgs-73bdc861b7232e57c800bcf64ed549aefc941271.tar.zst nixpkgs-73bdc861b7232e57c800bcf64ed549aefc941271.zip |
* Added a test for a simple load-balancing web server. The tests
verify whether the reverse proxy works correctly if the back-ends go down and come up. (Moved from the varia repo.) svn path=/nixos/trunk/; revision=19356
Diffstat (limited to 'tests/proxy.nix')
-rw-r--r-- | tests/proxy.nix | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/tests/proxy.nix b/tests/proxy.nix new file mode 100644 index 00000000000..81833060d43 --- /dev/null +++ b/tests/proxy.nix @@ -0,0 +1,94 @@ +{ pkgs, ... }: + +let + + backend = + { config, pkgs, ... }: + + { + services.sshd.enable = true; + + services.httpd.enable = true; + services.httpd.adminAddr = "foo@example.org"; + services.httpd.documentRoot = "${pkgs.valgrind}/share/doc/valgrind/html"; + }; + +in + +{ + + nodes = + { proxy = + { config, pkgs, nodes, ... }: + + { + services.httpd.enable = true; + services.httpd.adminAddr = "bar@example.org"; + services.httpd.extraModules = ["proxy_balancer"]; + + services.httpd.extraConfig = + '' + ExtendedStatus on + + <Location /server-status> + Order deny,allow + Allow from all + SetHandler server-status + </Location> + + <Proxy balancer://cluster> + Allow from all + BalancerMember http://${nodes.backend1.config.networking.hostName} retry=0 + BalancerMember http://${nodes.backend2.config.networking.hostName} retry=0 + </Proxy> + + ProxyStatus full + ProxyPass /server-status ! + ProxyPass / balancer://cluster/ + ProxyPassReverse / balancer://cluster/ + + # For testing; don't want to wait forever for dead backend servers. + ProxyTimeout 5 + ''; + }; + + backend1 = backend; + backend2 = backend; + + client = { config, pkgs, ... }: { }; + }; + + testScript = + '' + startAll; + + $proxy->waitForJob("httpd"); + $backend1->waitForJob("httpd"); + $backend2->waitForJob("httpd"); + + # With the back-ends up, the proxy should work. + $client->mustSucceed("curl --fail http://proxy/"); + + $client->mustSucceed("curl --fail http://proxy/server-status"); + + # Block the first back-end. + $backend1->block; + + # The proxy should still work. + $client->mustSucceed("curl --fail http://proxy/"); + + $client->mustSucceed("curl --fail http://proxy/"); + + # Block the second back-end. + $backend2->block; + + # Now the proxy should fail as well. + $client->mustFail("curl --fail http://proxy/"); + + # But if the second back-end comes back, the proxy should start + # working again. + $backend2->unblock; + $client->mustSucceed("curl --fail http://proxy/"); + ''; + +} |