summary refs log tree commit diff
path: root/nixos/tests/nomad.nix
diff options
context:
space:
mode:
authorPhillip Cloud <417981+cpcloud@users.noreply.github.com>2021-01-23 17:52:19 -0500
committerGitHub <noreply@github.com>2021-01-23 23:52:19 +0100
commitf1778cd90eea2c3d5dbca3aa55b6351697dad683 (patch)
tree64911b88a17415d38af48c5d4d90433513160bc6 /nixos/tests/nomad.nix
parent1af6e3aeedce4e7c41738f847923daba186adeb9 (diff)
downloadnixpkgs-f1778cd90eea2c3d5dbca3aa55b6351697dad683.tar
nixpkgs-f1778cd90eea2c3d5dbca3aa55b6351697dad683.tar.gz
nixpkgs-f1778cd90eea2c3d5dbca3aa55b6351697dad683.tar.bz2
nixpkgs-f1778cd90eea2c3d5dbca3aa55b6351697dad683.tar.lz
nixpkgs-f1778cd90eea2c3d5dbca3aa55b6351697dad683.tar.xz
nixpkgs-f1778cd90eea2c3d5dbca3aa55b6351697dad683.tar.zst
nixpkgs-f1778cd90eea2c3d5dbca3aa55b6351697dad683.zip
nixos/nomad: add extraSettingsFiles option to nomad service (#109761)
Diffstat (limited to 'nixos/tests/nomad.nix')
-rw-r--r--nixos/tests/nomad.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/nixos/tests/nomad.nix b/nixos/tests/nomad.nix
new file mode 100644
index 00000000000..bd052152bd6
--- /dev/null
+++ b/nixos/tests/nomad.nix
@@ -0,0 +1,53 @@
+import ./make-test-python.nix (
+  { lib, ... }: {
+    name = "nomad";
+    nodes = {
+      server = { pkgs, lib, ... }: {
+        networking = {
+          interfaces.eth1.ipv4.addresses = lib.mkOverride 0 [{
+            address = "192.168.1.1";
+            prefixLength = 16;
+          }];
+        };
+
+        environment.etc."nomad.custom.json".source =
+          (pkgs.formats.json { }).generate "nomad.custom.json" {
+            region = "universe";
+            datacenter = "earth";
+          };
+
+        services.nomad = {
+          enable = true;
+
+          settings = {
+            server = {
+              enabled = true;
+              bootstrap_expect = 1;
+            };
+          };
+
+          extraSettingsPaths = [ "/etc/nomad.custom.json" ];
+          enableDocker = false;
+        };
+      };
+    };
+
+    testScript = ''
+      server.wait_for_unit("nomad.service")
+
+      # wait for healthy server
+      server.wait_until_succeeds(
+          "[ $(nomad operator raft list-peers | grep true | wc -l) == 1 ]"
+      )
+
+      # wait for server liveness
+      server.succeed("[ $(nomad server members | grep -o alive | wc -l) == 1 ]")
+
+      # check the region
+      server.succeed("nomad server members | grep -o universe")
+
+      # check the datacenter
+      server.succeed("[ $(nomad server members | grep -o earth | wc -l) == 1 ]")
+    '';
+  }
+)