about summary refs log tree commit diff
path: root/nixos/tests/nginx.nix
diff options
context:
space:
mode:
authorDanylo Hlynskyi <abcz2.uprola@gmail.com>2020-01-05 00:39:23 +0200
committerGitHub <noreply@github.com>2020-01-05 00:39:23 +0200
commitcef68c4580f1d5bb648d0c7ce969f696fa1a2459 (patch)
tree335bc06603fc20a69a68033b243308185e118582 /nixos/tests/nginx.nix
parent4c9e280001518328ae3be74cf80cb7b6e3017952 (diff)
downloadnixlib-cef68c4580f1d5bb648d0c7ce969f696fa1a2459.tar
nixlib-cef68c4580f1d5bb648d0c7ce969f696fa1a2459.tar.gz
nixlib-cef68c4580f1d5bb648d0c7ce969f696fa1a2459.tar.bz2
nixlib-cef68c4580f1d5bb648d0c7ce969f696fa1a2459.tar.lz
nixlib-cef68c4580f1d5bb648d0c7ce969f696fa1a2459.tar.xz
nixlib-cef68c4580f1d5bb648d0c7ce969f696fa1a2459.tar.zst
nixlib-cef68c4580f1d5bb648d0c7ce969f696fa1a2459.zip
nixos/nginx: don't hide nginx config errors on nixos-rebuild --switch with reload enabled (#76179)
nixos/nginx: don't hide nginx config errors on nixos-rebuild --switch
with reload enabled

Closes https://github.com/NixOS/nixpkgs/issues/73455
Diffstat (limited to 'nixos/tests/nginx.nix')
-rw-r--r--nixos/tests/nginx.nix20
1 files changed, 19 insertions, 1 deletions
diff --git a/nixos/tests/nginx.nix b/nixos/tests/nginx.nix
index 55d2c9309084..7358800a6763 100644
--- a/nixos/tests/nginx.nix
+++ b/nixos/tests/nginx.nix
@@ -7,7 +7,7 @@
 import ./make-test-python.nix ({ pkgs, ... }: {
   name = "nginx";
   meta = with pkgs.stdenv.lib.maintainers; {
-    maintainers = [ mbbx6spp ];
+    maintainers = [ mbbx6spp danbst ];
   };
 
   nodes = {
@@ -59,6 +59,11 @@ import ./make-test-python.nix ({ pkgs, ... }: {
         {
           services.nginx.package = pkgs.nginxUnstable;
         }
+
+        {
+          services.nginx.package = pkgs.nginxUnstable;
+          services.nginx.virtualHosts."!@$$(#*%".locations."~@#*$*!)".proxyPass = ";;;";
+        }
       ];
     };
 
@@ -68,6 +73,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
     etagSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-1";
     justReloadSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-2";
     reloadRestartSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-3";
+    reloadWithErrorsSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-4";
   in ''
     url = "http://localhost/index.html"
 
@@ -110,5 +116,17 @@ import ./make-test-python.nix ({ pkgs, ... }: {
         )
         webserver.wait_for_unit("nginx")
         webserver.succeed("journalctl -u nginx | grep -q -i stopped")
+
+    with subtest("nixos-rebuild --switch should fail when there are configuration errors"):
+        webserver.fail(
+            "${reloadWithErrorsSystem}/bin/switch-to-configuration test >&2"
+        )
+        webserver.succeed("[[ $(systemctl is-failed nginx-config-reload) == failed ]]")
+        webserver.succeed("[[ $(systemctl is-failed nginx) == active ]]")
+        # just to make sure operation is idempotent. During development I had a situation
+        # when first time it shows error, but stops showing it on subsequent rebuilds
+        webserver.fail(
+            "${reloadWithErrorsSystem}/bin/switch-to-configuration test >&2"
+        )
   '';
 })