summary refs log tree commit diff
path: root/nixos/tests/nginx.nix
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2023-05-10 05:01:50 +0200
committerPierre Bourdon <delroth@gmail.com>2023-05-10 05:01:50 +0200
commitac4abaa9d521e4bc5ba5ac17ef5ebfda5e712a09 (patch)
tree8516d73f0ff5ff61e016abbc4bcb32addb0a4192 /nixos/tests/nginx.nix
parent49b373958553f8b7fea8795b7bb4ede86057488c (diff)
downloadnixpkgs-ac4abaa9d521e4bc5ba5ac17ef5ebfda5e712a09.tar
nixpkgs-ac4abaa9d521e4bc5ba5ac17ef5ebfda5e712a09.tar.gz
nixpkgs-ac4abaa9d521e4bc5ba5ac17ef5ebfda5e712a09.tar.bz2
nixpkgs-ac4abaa9d521e4bc5ba5ac17ef5ebfda5e712a09.tar.lz
nixpkgs-ac4abaa9d521e4bc5ba5ac17ef5ebfda5e712a09.tar.xz
nixpkgs-ac4abaa9d521e4bc5ba5ac17ef5ebfda5e712a09.tar.zst
nixpkgs-ac4abaa9d521e4bc5ba5ac17ef5ebfda5e712a09.zip
nixos/tests/nginx: fix etag test flakiness
Diffstat (limited to 'nixos/tests/nginx.nix')
-rw-r--r--nixos/tests/nginx.nix18
1 files changed, 13 insertions, 5 deletions
diff --git a/nixos/tests/nginx.nix b/nixos/tests/nginx.nix
index 2a7e0f48d86..8b1f921ec52 100644
--- a/nixos/tests/nginx.nix
+++ b/nixos/tests/nginx.nix
@@ -87,15 +87,23 @@ import ./make-test-python.nix ({ pkgs, ... }: {
         return etag
 
 
-    webserver.wait_for_unit("nginx")
-    webserver.wait_for_open_port(80)
+    def wait_for_nginx_on_port(port):
+        webserver.wait_for_unit("nginx")
+        webserver.wait_for_open_port(port)
+
+
+    # nginx can be ready before multi-user.target, in which case switching to
+    # a different configuration might not realize it needs to restart nginx.
+    webserver.wait_for_unit("multi-user.target")
+
+    wait_for_nginx_on_port(80)
 
     with subtest("check ETag if serving Nix store paths"):
         old_etag = check_etag()
         webserver.succeed(
             "${etagSystem}/bin/switch-to-configuration test >&2"
         )
-        webserver.sleep(1)
+        wait_for_nginx_on_port(80)
         new_etag = check_etag()
         assert old_etag != new_etag
 
@@ -103,7 +111,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
         webserver.succeed(
             "${justReloadSystem}/bin/switch-to-configuration test >&2"
         )
-        webserver.wait_for_open_port(8080)
+        wait_for_nginx_on_port(8080)
         webserver.fail("journalctl -u nginx | grep -q -i stopped")
         webserver.succeed("journalctl -u nginx | grep -q -i reloaded")
 
@@ -111,7 +119,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
         webserver.succeed(
             "${reloadRestartSystem}/bin/switch-to-configuration test >&2"
         )
-        webserver.wait_for_unit("nginx")
+        wait_for_nginx_on_port(80)
         webserver.succeed("journalctl -u nginx | grep -q -i stopped")
 
     with subtest("nixos-rebuild --switch should fail when there are configuration errors"):