diff options
author | Phillip Cloud <cloud@standard.ai> | 2021-01-23 18:19:50 -0500 |
---|---|---|
committer | Phillip Cloud <cloud@standard.ai> | 2021-01-23 19:44:37 -0500 |
commit | de71f5b50670908026842672aebe2565d239cda0 (patch) | |
tree | 1d961927b2f27c3c985716c8f32bae5f484674d7 /nixos | |
parent | 5ce4ce61746c19f09ae1504a49f3216de6770055 (diff) |
nixos/tests: add test for custom nomad state directory
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/tests/nomad.nix | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/nixos/tests/nomad.nix b/nixos/tests/nomad.nix index bd052152bd65..51b11a8fef90 100644 --- a/nixos/tests/nomad.nix +++ b/nixos/tests/nomad.nix @@ -2,7 +2,7 @@ import ./make-test-python.nix ( { lib, ... }: { name = "nomad"; nodes = { - server = { pkgs, lib, ... }: { + default_server = { pkgs, lib, ... }: { networking = { interfaces.eth1.ipv4.addresses = lib.mkOverride 0 [{ address = "192.168.1.1"; @@ -30,24 +30,68 @@ import ./make-test-python.nix ( enableDocker = false; }; }; + + custom_state_dir_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; + dropPrivileges = false; + + settings = { + data_dir = "/nomad/data/dir"; + server = { + enabled = true; + bootstrap_expect = 1; + }; + }; + + extraSettingsPaths = [ "/etc/nomad.custom.json" ]; + enableDocker = false; + }; + + systemd.services.nomad.serviceConfig.ExecStartPre = "${pkgs.writeShellScript "mk_data_dir" '' + set -euxo pipefail + + ${pkgs.coreutils}/bin/mkdir -p /nomad/data/dir + ''}"; + }; }; testScript = '' - server.wait_for_unit("nomad.service") + def test_nomad_server(server): + 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") - # wait for healthy server - server.wait_until_succeeds( - "[ $(nomad operator raft list-peers | grep true | wc -l) == 1 ]" - ) + # check the datacenter + server.succeed("[ $(nomad server members | grep -o earth | 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") + servers = [default_server, custom_state_dir_server] - # check the datacenter - server.succeed("[ $(nomad server members | grep -o earth | wc -l) == 1 ]") + for server in servers: + test_nomad_server(server) ''; } ) |