Loading nixos/tests/k3s/auto-deploy-charts.nix +4 −4 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ import ../make-test-python.nix ( machine.succeed("test -e /var/lib/rancher/k3s/server/manifests/advanced.yaml") # check that the timeout is set correctly, select only the first doc in advanced.yaml advancedManifest = json.loads(machine.succeed("yq -o json 'select(di == 0)' /var/lib/rancher/k3s/server/manifests/advanced.yaml")) assert advancedManifest["spec"]["timeout"] == "69s", f"unexpected value for spec.timeout: {advancedManifest["spec"]["timeout"]}" t.assertEqual(advancedManifest["spec"]["timeout"], "69s", "unexpected value for spec.timeout") # wait for test jobs to complete machine.wait_until_succeeds("kubectl wait --for=condition=complete job/hello", timeout=180) machine.wait_until_succeeds("kubectl wait --for=condition=complete job/values-file", timeout=180) Loading @@ -145,9 +145,9 @@ import ../make-test-python.nix ( values_file_output = machine.succeed("kubectl logs -l batch.kubernetes.io/job-name=values-file") advanced_output = machine.succeed("kubectl -n test logs -l batch.kubernetes.io/job-name=advanced") # strip the output to remove trailing whitespaces assert hello_output.rstrip() == "Hello, world!", f"unexpected output of hello job: {hello_output}" assert values_file_output.rstrip() == "Hello, file!", f"unexpected output of values file job: {values_file_output}" assert advanced_output.rstrip() == "advanced hello", f"unexpected output of advanced job: {advanced_output}" t.assertEqual(hello_output.rstrip(), "Hello, world!", "unexpected output of hello job") t.assertEqual(values_file_output.rstrip(), "Hello, file!", "unexpected output of values file job") t.assertEqual(advanced_output.rstrip(), "advanced hello", "unexpected output of advanced job") # wait for bundled traefik deployment machine.wait_until_succeeds("kubectl -n kube-system rollout status deployment traefik", timeout=180) ''; Loading nixos/tests/k3s/auto-deploy.nix +16 −17 Original line number Diff line number Diff line Loading @@ -99,7 +99,8 @@ import ../make-test-python.nix ( }; }; testScript = '' testScript = # python '' start_all() machine.wait_for_unit("k3s") Loading @@ -116,8 +117,6 @@ import ../make-test-python.nix ( machine.wait_until_succeeds("kubectl get ns foo") machine.wait_until_succeeds("kubectl wait --for=condition=complete job/hello") machine.fail("kubectl get ns absent") machine.shutdown() ''; meta.maintainers = lib.teams.k3s.members; Loading nixos/tests/k3s/containerd-config.nix +13 −12 Original line number Diff line number Diff line Loading @@ -40,17 +40,18 @@ import ../make-test-python.nix ( }; }; testScript = '' testScript = # python '' start_all() machine.wait_for_unit("k3s") # wait until the node is ready machine.wait_until_succeeds(r"""kubectl get node ${nodeName} -ojson | jq -e '.status.conditions[] | select(.type == "Ready") | .status == "True"'""") # test whether the config template file contains the magic comment out=machine.succeed("cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl") assert "MAGIC COMMENT" in out, "the containerd config template does not contain the magic comment" t.assertIn("MAGIC COMMENT", out, "the containerd config template does not contain the magic comment") # test whether the config file contains the magic comment out=machine.succeed("cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml") assert "MAGIC COMMENT" in out, "the containerd config does not contain the magic comment" t.assertIn("MAGIC COMMENT", out, "the containerd config does not contain the magic comment") ''; meta.maintainers = lib.teams.k3s.members; Loading nixos/tests/k3s/etcd.nix +27 −30 Original line number Diff line number Diff line Loading @@ -82,7 +82,8 @@ import ../make-test-python.nix ( }; }; testScript = '' testScript = # python '' with subtest("should start etcd"): etcd.start() etcd.wait_for_unit("etcd.service") Loading Loading @@ -117,10 +118,6 @@ import ../make-test-python.nix ( with subtest("should not have a secret in database"): etcd.wait_until_fails("[[ $(etcdctl get /registry/secrets/default/nixossecret | head -c1 | wc -c) -ne 0 ]]") with subtest("should shutdown k3s and etcd"): k3s.shutdown() etcd.shutdown() ''; meta.maintainers = etcd.meta.maintainers ++ lib.teams.k3s.members; Loading nixos/tests/k3s/kubelet-config.nix +21 −25 Original line number Diff line number Diff line Loading @@ -47,7 +47,8 @@ import ../make-test-python.nix ( }; }; testScript = '' testScript = # python '' import json start_all() Loading @@ -63,16 +64,11 @@ import ../make-test-python.nix ( kubelet_config=json.loads(machine.succeed("curl http://127.0.0.1:8001/api/v1/nodes/${nodeName}/proxy/configz | jq '.kubeletconfig'")) with subtest("Kubelet config values are set correctly"): assert kubelet_config["shutdownGracePeriod"] == "${shutdownGracePeriod}", \ f"unexpected value for shutdownGracePeriod: {kubelet_config["shutdownGracePeriod"]}" assert kubelet_config["shutdownGracePeriodCriticalPods"] == "${shutdownGracePeriodCriticalPods}", \ f"unexpected value for shutdownGracePeriodCriticalPods: {kubelet_config["shutdownGracePeriodCriticalPods"]}" assert kubelet_config["podsPerCore"] == ${toString podsPerCore}, \ f"unexpected value for podsPerCore: {kubelet_config["podsPerCore"]}" assert kubelet_config["memoryThrottlingFactor"] == ${toString memoryThrottlingFactor}, \ f"unexpected value for memoryThrottlingFactor: {kubelet_config["memoryThrottlingFactor"]}" assert kubelet_config["containerLogMaxSize"] == "${containerLogMaxSize}", \ f"unexpected value for containerLogMaxSize: {kubelet_config["containerLogMaxSize"]}" t.assertEqual(kubelet_config["shutdownGracePeriod"], "${shutdownGracePeriod}") t.assertEqual(kubelet_config["shutdownGracePeriodCriticalPods"], "${shutdownGracePeriodCriticalPods}") t.assertEqual(kubelet_config["podsPerCore"], ${toString podsPerCore}) t.assertEqual(kubelet_config["memoryThrottlingFactor"], ${toString memoryThrottlingFactor}) t.assertEqual(kubelet_config["containerLogMaxSize"],"${containerLogMaxSize}") ''; meta.maintainers = lib.teams.k3s.members; Loading Loading
nixos/tests/k3s/auto-deploy-charts.nix +4 −4 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ import ../make-test-python.nix ( machine.succeed("test -e /var/lib/rancher/k3s/server/manifests/advanced.yaml") # check that the timeout is set correctly, select only the first doc in advanced.yaml advancedManifest = json.loads(machine.succeed("yq -o json 'select(di == 0)' /var/lib/rancher/k3s/server/manifests/advanced.yaml")) assert advancedManifest["spec"]["timeout"] == "69s", f"unexpected value for spec.timeout: {advancedManifest["spec"]["timeout"]}" t.assertEqual(advancedManifest["spec"]["timeout"], "69s", "unexpected value for spec.timeout") # wait for test jobs to complete machine.wait_until_succeeds("kubectl wait --for=condition=complete job/hello", timeout=180) machine.wait_until_succeeds("kubectl wait --for=condition=complete job/values-file", timeout=180) Loading @@ -145,9 +145,9 @@ import ../make-test-python.nix ( values_file_output = machine.succeed("kubectl logs -l batch.kubernetes.io/job-name=values-file") advanced_output = machine.succeed("kubectl -n test logs -l batch.kubernetes.io/job-name=advanced") # strip the output to remove trailing whitespaces assert hello_output.rstrip() == "Hello, world!", f"unexpected output of hello job: {hello_output}" assert values_file_output.rstrip() == "Hello, file!", f"unexpected output of values file job: {values_file_output}" assert advanced_output.rstrip() == "advanced hello", f"unexpected output of advanced job: {advanced_output}" t.assertEqual(hello_output.rstrip(), "Hello, world!", "unexpected output of hello job") t.assertEqual(values_file_output.rstrip(), "Hello, file!", "unexpected output of values file job") t.assertEqual(advanced_output.rstrip(), "advanced hello", "unexpected output of advanced job") # wait for bundled traefik deployment machine.wait_until_succeeds("kubectl -n kube-system rollout status deployment traefik", timeout=180) ''; Loading
nixos/tests/k3s/auto-deploy.nix +16 −17 Original line number Diff line number Diff line Loading @@ -99,7 +99,8 @@ import ../make-test-python.nix ( }; }; testScript = '' testScript = # python '' start_all() machine.wait_for_unit("k3s") Loading @@ -116,8 +117,6 @@ import ../make-test-python.nix ( machine.wait_until_succeeds("kubectl get ns foo") machine.wait_until_succeeds("kubectl wait --for=condition=complete job/hello") machine.fail("kubectl get ns absent") machine.shutdown() ''; meta.maintainers = lib.teams.k3s.members; Loading
nixos/tests/k3s/containerd-config.nix +13 −12 Original line number Diff line number Diff line Loading @@ -40,17 +40,18 @@ import ../make-test-python.nix ( }; }; testScript = '' testScript = # python '' start_all() machine.wait_for_unit("k3s") # wait until the node is ready machine.wait_until_succeeds(r"""kubectl get node ${nodeName} -ojson | jq -e '.status.conditions[] | select(.type == "Ready") | .status == "True"'""") # test whether the config template file contains the magic comment out=machine.succeed("cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl") assert "MAGIC COMMENT" in out, "the containerd config template does not contain the magic comment" t.assertIn("MAGIC COMMENT", out, "the containerd config template does not contain the magic comment") # test whether the config file contains the magic comment out=machine.succeed("cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml") assert "MAGIC COMMENT" in out, "the containerd config does not contain the magic comment" t.assertIn("MAGIC COMMENT", out, "the containerd config does not contain the magic comment") ''; meta.maintainers = lib.teams.k3s.members; Loading
nixos/tests/k3s/etcd.nix +27 −30 Original line number Diff line number Diff line Loading @@ -82,7 +82,8 @@ import ../make-test-python.nix ( }; }; testScript = '' testScript = # python '' with subtest("should start etcd"): etcd.start() etcd.wait_for_unit("etcd.service") Loading Loading @@ -117,10 +118,6 @@ import ../make-test-python.nix ( with subtest("should not have a secret in database"): etcd.wait_until_fails("[[ $(etcdctl get /registry/secrets/default/nixossecret | head -c1 | wc -c) -ne 0 ]]") with subtest("should shutdown k3s and etcd"): k3s.shutdown() etcd.shutdown() ''; meta.maintainers = etcd.meta.maintainers ++ lib.teams.k3s.members; Loading
nixos/tests/k3s/kubelet-config.nix +21 −25 Original line number Diff line number Diff line Loading @@ -47,7 +47,8 @@ import ../make-test-python.nix ( }; }; testScript = '' testScript = # python '' import json start_all() Loading @@ -63,16 +64,11 @@ import ../make-test-python.nix ( kubelet_config=json.loads(machine.succeed("curl http://127.0.0.1:8001/api/v1/nodes/${nodeName}/proxy/configz | jq '.kubeletconfig'")) with subtest("Kubelet config values are set correctly"): assert kubelet_config["shutdownGracePeriod"] == "${shutdownGracePeriod}", \ f"unexpected value for shutdownGracePeriod: {kubelet_config["shutdownGracePeriod"]}" assert kubelet_config["shutdownGracePeriodCriticalPods"] == "${shutdownGracePeriodCriticalPods}", \ f"unexpected value for shutdownGracePeriodCriticalPods: {kubelet_config["shutdownGracePeriodCriticalPods"]}" assert kubelet_config["podsPerCore"] == ${toString podsPerCore}, \ f"unexpected value for podsPerCore: {kubelet_config["podsPerCore"]}" assert kubelet_config["memoryThrottlingFactor"] == ${toString memoryThrottlingFactor}, \ f"unexpected value for memoryThrottlingFactor: {kubelet_config["memoryThrottlingFactor"]}" assert kubelet_config["containerLogMaxSize"] == "${containerLogMaxSize}", \ f"unexpected value for containerLogMaxSize: {kubelet_config["containerLogMaxSize"]}" t.assertEqual(kubelet_config["shutdownGracePeriod"], "${shutdownGracePeriod}") t.assertEqual(kubelet_config["shutdownGracePeriodCriticalPods"], "${shutdownGracePeriodCriticalPods}") t.assertEqual(kubelet_config["podsPerCore"], ${toString podsPerCore}) t.assertEqual(kubelet_config["memoryThrottlingFactor"], ${toString memoryThrottlingFactor}) t.assertEqual(kubelet_config["containerLogMaxSize"],"${containerLogMaxSize}") ''; meta.maintainers = lib.teams.k3s.members; Loading