at 25.11-pre 1.3 kB view raw
1{ pkgs, package, ... }: 2let 3 testPath = pkgs.hello; 4in 5{ 6 name = "varnish"; 7 meta = { 8 maintainers = [ ]; 9 }; 10 11 nodes = { 12 varnish = 13 { config, pkgs, ... }: 14 { 15 services.nix-serve = { 16 enable = true; 17 }; 18 19 services.varnish = { 20 inherit package; 21 enable = true; 22 http_address = "0.0.0.0:80"; 23 config = '' 24 vcl 4.0; 25 26 backend nix-serve { 27 .host = "127.0.0.1"; 28 .port = "${toString config.services.nix-serve.port}"; 29 } 30 ''; 31 }; 32 33 networking.firewall.allowedTCPPorts = [ 80 ]; 34 system.extraDependencies = [ testPath ]; 35 }; 36 37 client = 38 { lib, ... }: 39 { 40 nix.settings = { 41 require-sigs = false; 42 substituters = lib.mkForce [ "http://varnish" ]; 43 }; 44 }; 45 }; 46 47 testScript = '' 48 start_all() 49 varnish.wait_for_open_port(80) 50 51 client.wait_until_succeeds("curl -f http://varnish/nix-cache-info"); 52 53 client.wait_until_succeeds("nix-store -r ${testPath}") 54 client.succeed("${testPath}/bin/hello") 55 56 output = varnish.succeed("varnishadm status") 57 print(output) 58 assert "Child in state running" in output, "Unexpected varnishadm response" 59 ''; 60}