nixos/h2o: wait for open ports in tests

Hydra can sometimes timeout here. It’s a better practice anyhow.

Changed files
+24 -9
nixos
+13 -6
nixos/tests/web-servers/h2o/basic.nix
···
};
};
-
testScript = # python
''
server.wait_for_unit("h2o.service")
-
http_hello_world_body = server.succeed("curl --fail-with-body 'http://${domain.HTTP}:${builtins.toString port.HTTP}/hello_world.txt'")
assert "${sawatdi_chao_lok}" in http_hello_world_body
-
tls_hello_world_head = server.succeed("curl -v --head --compressed --http2 --tlsv1.3 --fail-with-body 'https://${domain.TLS}:${builtins.toString port.TLS}/hello_world.rst'").lower()
assert "http/2 200" in tls_hello_world_head
assert "server: h2o" in tls_hello_world_head
assert "content-type: text/x-rst" in tls_hello_world_head
-
tls_hello_world_body = server.succeed("curl -v --http2 --tlsv1.3 --compressed --fail-with-body 'https://${domain.TLS}:${builtins.toString port.TLS}/hello_world.rst'")
assert "${sawatdi_chao_lok}" in tls_hello_world_body
tls_hello_world_head_redirected = server.succeed("curl -v --head --fail-with-body 'http://${domain.TLS}:${builtins.toString port.HTTP}/hello_world.rst'").lower()
assert "redirected" in tls_hello_world_head_redirected
-
server.fail("curl --location --max-redirs 0 'http://${domain.TLS}:${builtins.toString port.HTTP}/hello_world.rst'")
-
tls_hello_world_body_redirected = server.succeed("curl -v --location --fail-with-body 'http://${domain.TLS}:${builtins.toString port.HTTP}/hello_world.rst'")
assert "${sawatdi_chao_lok}" in tls_hello_world_body_redirected
'';
}
···
};
};
+
testScript =
+
let
+
portStrHTTP = builtins.toString port.HTTP;
+
portStrTLS = builtins.toString port.TLS;
+
in
+
# python
''
server.wait_for_unit("h2o.service")
+
server.wait_for_open_port(${portStrHTTP})
+
server.wait_for_open_port(${portStrTLS})
+
http_hello_world_body = server.succeed("curl --fail-with-body 'http://${domain.HTTP}:${portStrHTTP}/hello_world.txt'")
assert "${sawatdi_chao_lok}" in http_hello_world_body
+
tls_hello_world_head = server.succeed("curl -v --head --compressed --http2 --tlsv1.3 --fail-with-body 'https://${domain.TLS}:${portStrTLS}/hello_world.rst'").lower()
assert "http/2 200" in tls_hello_world_head
assert "server: h2o" in tls_hello_world_head
assert "content-type: text/x-rst" in tls_hello_world_head
+
tls_hello_world_body = server.succeed("curl -v --http2 --tlsv1.3 --compressed --fail-with-body 'https://${domain.TLS}:${portStrTLS}/hello_world.rst'")
assert "${sawatdi_chao_lok}" in tls_hello_world_body
tls_hello_world_head_redirected = server.succeed("curl -v --head --fail-with-body 'http://${domain.TLS}:${builtins.toString port.HTTP}/hello_world.rst'").lower()
assert "redirected" in tls_hello_world_head_redirected
+
server.fail("curl --location --max-redirs 0 'http://${domain.TLS}:${portStrHTTP}/hello_world.rst'")
+
tls_hello_world_body_redirected = server.succeed("curl -v --location --fail-with-body 'http://${domain.TLS}:${portStrHTTP}/hello_world.rst'")
assert "${sawatdi_chao_lok}" in tls_hello_world_body_redirected
'';
}
+8 -3
nixos/tests/web-servers/h2o/mruby.nix
···
};
};
-
testScript = # python
''
server.wait_for_unit("h2o.service")
-
hello_world = server.succeed("curl --fail-with-body http://${domain}:${builtins.toString port}/hello_world")
assert "${sawatdi_chao_lok}" in hello_world
-
file_handler = server.succeed("curl --fail-with-body http://${domain}:${builtins.toString port}/file_handler")
assert "FILE_HANDLER" in file_handler
'';
}
···
};
};
+
testScript =
+
let
+
portStr = builtins.toString port;
+
in
+
# python
''
server.wait_for_unit("h2o.service")
+
server.wait_for_open_port(${portStr})
+
hello_world = server.succeed("curl --fail-with-body http://${domain}:${portStr}/hello_world")
assert "${sawatdi_chao_lok}" in hello_world
+
file_handler = server.succeed("curl --fail-with-body http://${domain}:${portStr}/file_handler")
assert "FILE_HANDLER" in file_handler
'';
}
+3
nixos/tests/web-servers/h2o/tls-recommendations.nix
···
curl_max_tls1_2_old_cipher ="curl -v --tlsv1.0 --tls-max 1.2 --ciphers 'ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256' 'https://${domain}:${portStr}/'"
server_modern.wait_for_unit("h2o.service")
modern_response = server_modern.succeed(curl_basic)
assert "Hello, modern!" in modern_response
modern_head = server_modern.succeed(curl_head)
···
server_modern.fail(curl_max_tls1_2)
server_intermediate.wait_for_unit("h2o.service")
intermediate_response = server_intermediate.succeed(curl_basic)
assert "Hello, intermediate!" in intermediate_response
intermediate_head = server_modern.succeed(curl_head)
···
server_intermediate.fail(curl_max_tls1_2_old_cipher)
server_old.wait_for_unit("h2o.service")
old_response = server_old.succeed(curl_basic)
assert "Hello, old!" in old_response
old_head = server_modern.succeed(curl_head)
···
curl_max_tls1_2_old_cipher ="curl -v --tlsv1.0 --tls-max 1.2 --ciphers 'ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256' 'https://${domain}:${portStr}/'"
server_modern.wait_for_unit("h2o.service")
+
server_modern.wait_for_open_port(${portStr})
modern_response = server_modern.succeed(curl_basic)
assert "Hello, modern!" in modern_response
modern_head = server_modern.succeed(curl_head)
···
server_modern.fail(curl_max_tls1_2)
server_intermediate.wait_for_unit("h2o.service")
+
server_intermediate.wait_for_open_port(${portStr})
intermediate_response = server_intermediate.succeed(curl_basic)
assert "Hello, intermediate!" in intermediate_response
intermediate_head = server_modern.succeed(curl_head)
···
server_intermediate.fail(curl_max_tls1_2_old_cipher)
server_old.wait_for_unit("h2o.service")
+
server_old.wait_for_open_port(${portStr})
old_response = server_old.succeed(curl_basic)
assert "Hello, old!" in old_response
old_head = server_modern.succeed(curl_head)