at master 1.9 kB view raw
1# A test that containerdConfigTemplate settings get written to containerd/config.toml 2import ../make-test-python.nix ( 3 { 4 pkgs, 5 lib, 6 k3s, 7 ... 8 }: 9 let 10 nodeName = "test"; 11 in 12 { 13 name = "${k3s.name}-containerd-config"; 14 nodes.machine = 15 { ... }: 16 { 17 environment.systemPackages = [ pkgs.jq ]; 18 # k3s uses enough resources the default vm fails. 19 virtualisation.memorySize = 1536; 20 virtualisation.diskSize = 4096; 21 22 services.k3s = { 23 enable = true; 24 package = k3s; 25 # Slightly reduce resource usage 26 extraFlags = [ 27 "--disable coredns" 28 "--disable local-storage" 29 "--disable metrics-server" 30 "--disable servicelb" 31 "--disable traefik" 32 "--node-name ${nodeName}" 33 ]; 34 containerdConfigTemplate = '' 35 # Base K3s config 36 {{ template "base" . }} 37 38 # MAGIC COMMENT 39 ''; 40 }; 41 }; 42 43 testScript = # python 44 '' 45 start_all() 46 machine.wait_for_unit("k3s") 47 # wait until the node is ready 48 machine.wait_until_succeeds(r"""kubectl get node ${nodeName} -ojson | jq -e '.status.conditions[] | select(.type == "Ready") | .status == "True"'""") 49 # test whether the config template file contains the magic comment 50 out=machine.succeed("cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl") 51 t.assertIn("MAGIC COMMENT", out, "the containerd config template does not contain the magic comment") 52 # test whether the config file contains the magic comment 53 out=machine.succeed("cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml") 54 t.assertIn("MAGIC COMMENT", out, "the containerd config does not contain the magic comment") 55 ''; 56 57 meta.maintainers = lib.teams.k3s.members; 58 } 59)