|
| 1 | +suite: per-node-group worker image source (image.builtin / image.factory) |
| 2 | + |
| 3 | +# Exercises the disk-system source selection in templates/cluster.yaml: |
| 4 | +# - image omitted / image.factory -> HTTP import from the Image Factory; |
| 5 | +# - image.builtin -> CDI clone of the golden DataVolume in |
| 6 | +# cozy-public (talos-worker-<schematicID>-<version>). |
| 7 | +# The golden DataVolume and the CAPI LIST kinds are mocked via kubernetesProvider; |
| 8 | +# lookup() is otherwise empty under `helm template`. The default talos.* is |
| 9 | +# schematicID ce4c98…/v1.13.6, so the default golden name is |
| 10 | +# talos-worker-ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515-v1.13.6. |
| 11 | + |
| 12 | +templates: |
| 13 | + - templates/cluster.yaml |
| 14 | + |
| 15 | +kubernetesProvider: |
| 16 | + scheme: |
| 17 | + "instancetype.kubevirt.io/v1beta1/VirtualMachineClusterInstancetype": |
| 18 | + gvr: {group: instancetype.kubevirt.io, version: v1beta1, resource: virtualmachineclusterinstancetypes} |
| 19 | + namespaced: false |
| 20 | + "cluster.x-k8s.io/v1beta1/MachineSet": |
| 21 | + gvr: {group: cluster.x-k8s.io, version: v1beta1, resource: machinesets} |
| 22 | + namespaced: true |
| 23 | + "infrastructure.cluster.x-k8s.io/v1alpha1/KubevirtMachineTemplate": |
| 24 | + gvr: {group: infrastructure.cluster.x-k8s.io, version: v1alpha1, resource: kubevirtmachinetemplates} |
| 25 | + namespaced: true |
| 26 | + "cdi.kubevirt.io/v1beta1/DataVolume": |
| 27 | + gvr: {group: cdi.kubevirt.io, version: v1beta1, resource: datavolumes} |
| 28 | + namespaced: true |
| 29 | + objects: |
| 30 | + - kind: VirtualMachineClusterInstancetype |
| 31 | + apiVersion: instancetype.kubevirt.io/v1beta1 |
| 32 | + metadata: {name: u1.medium} |
| 33 | + # Dummy CAPI objects so the MachineSet / KubevirtMachineTemplate LIST kinds |
| 34 | + # (old-template-preservation loop) are registered with the fake client. |
| 35 | + - kind: MachineSet |
| 36 | + apiVersion: cluster.x-k8s.io/v1beta1 |
| 37 | + metadata: {name: ignored-ms, namespace: tenant-test} |
| 38 | + spec: {template: {spec: {infrastructureRef: {kind: Other, name: ignored}}}} |
| 39 | + - kind: KubevirtMachineTemplate |
| 40 | + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 |
| 41 | + metadata: {name: ignored-kmt, namespace: tenant-test} |
| 42 | + # The golden for the default talos.* (present, so builtin clones succeed). |
| 43 | + # storage 6Gi mirrors the catalog default, so the diskSize>=golden guard has |
| 44 | + # a size to compare against. |
| 45 | + - kind: DataVolume |
| 46 | + apiVersion: cdi.kubevirt.io/v1beta1 |
| 47 | + metadata: |
| 48 | + name: talos-worker-ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515-v1.13.6 |
| 49 | + namespace: cozy-public |
| 50 | + spec: |
| 51 | + storage: |
| 52 | + resources: |
| 53 | + requests: |
| 54 | + storage: 6Gi |
| 55 | + |
| 56 | +tests: |
| 57 | + - it: image omitted imports over HTTP from the cluster talos.* factory (back-compat) |
| 58 | + set: |
| 59 | + _namespace: {etcd: true, ingress: true, host: example.com} |
| 60 | + _cluster: {cluster-domain: cozy.local} |
| 61 | + nodeGroups: |
| 62 | + md0: |
| 63 | + minReplicas: 1 |
| 64 | + maxReplicas: 3 |
| 65 | + instanceType: u1.medium |
| 66 | + diskSize: 20Gi |
| 67 | + roles: [ingress-nginx] |
| 68 | + asserts: |
| 69 | + - equal: |
| 70 | + path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].spec.source.http.url |
| 71 | + value: https://factory.talos.dev/image/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515/v1.13.6/openstack-amd64.raw.xz |
| 72 | + documentSelector: {path: kind, value: KubevirtMachineTemplate} |
| 73 | + - equal: |
| 74 | + path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].metadata.annotations |
| 75 | + value: |
| 76 | + cdi.kubevirt.io/storage.usePopulator: "false" |
| 77 | + documentSelector: {path: kind, value: KubevirtMachineTemplate} |
| 78 | + |
| 79 | + - it: empty image.factory imports over HTTP from the cluster talos.* factory |
| 80 | + set: |
| 81 | + _namespace: {etcd: true, ingress: true, host: example.com} |
| 82 | + _cluster: {cluster-domain: cozy.local} |
| 83 | + nodeGroups: |
| 84 | + md0: |
| 85 | + minReplicas: 1 |
| 86 | + maxReplicas: 3 |
| 87 | + instanceType: u1.medium |
| 88 | + diskSize: 20Gi |
| 89 | + roles: [ingress-nginx] |
| 90 | + image: |
| 91 | + factory: {} |
| 92 | + asserts: |
| 93 | + - equal: |
| 94 | + path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].spec.source.http.url |
| 95 | + value: https://factory.talos.dev/image/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515/v1.13.6/openstack-amd64.raw.xz |
| 96 | + documentSelector: {path: kind, value: KubevirtMachineTemplate} |
| 97 | + |
| 98 | + - it: image.factory overrides import from the given mirror / schematic / version |
| 99 | + set: |
| 100 | + _namespace: {etcd: true, ingress: true, host: example.com} |
| 101 | + _cluster: {cluster-domain: cozy.local} |
| 102 | + nodeGroups: |
| 103 | + md0: |
| 104 | + minReplicas: 1 |
| 105 | + maxReplicas: 3 |
| 106 | + instanceType: u1.medium |
| 107 | + diskSize: 20Gi |
| 108 | + roles: [ingress-nginx] |
| 109 | + image: |
| 110 | + factory: |
| 111 | + imageFactoryURL: https://mirror.internal |
| 112 | + schematicID: deadbeef |
| 113 | + version: v1.14.0 |
| 114 | + asserts: |
| 115 | + - equal: |
| 116 | + path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].spec.source.http.url |
| 117 | + value: https://mirror.internal/image/deadbeef/v1.14.0/openstack-amd64.raw.xz |
| 118 | + documentSelector: {path: kind, value: KubevirtMachineTemplate} |
| 119 | + |
| 120 | + - it: empty image.builtin clones the cluster-default golden and omits usePopulator |
| 121 | + set: |
| 122 | + _namespace: {etcd: true, ingress: true, host: example.com} |
| 123 | + _cluster: {cluster-domain: cozy.local} |
| 124 | + nodeGroups: |
| 125 | + md0: |
| 126 | + minReplicas: 1 |
| 127 | + maxReplicas: 3 |
| 128 | + instanceType: u1.medium |
| 129 | + diskSize: 20Gi |
| 130 | + roles: [ingress-nginx] |
| 131 | + image: |
| 132 | + builtin: {} |
| 133 | + asserts: |
| 134 | + - equal: |
| 135 | + path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].spec.source.pvc.namespace |
| 136 | + value: cozy-public |
| 137 | + documentSelector: {path: kind, value: KubevirtMachineTemplate} |
| 138 | + - equal: |
| 139 | + path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].spec.source.pvc.name |
| 140 | + value: talos-worker-ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515-v1.13.6 |
| 141 | + documentSelector: {path: kind, value: KubevirtMachineTemplate} |
| 142 | + - notExists: |
| 143 | + path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].metadata.annotations |
| 144 | + documentSelector: {path: kind, value: KubevirtMachineTemplate} |
| 145 | + |
| 146 | + - it: image.builtin with an explicit schematicID/version clones that golden |
| 147 | + set: |
| 148 | + _namespace: {etcd: true, ingress: true, host: example.com} |
| 149 | + _cluster: {cluster-domain: cozy.local} |
| 150 | + nodeGroups: |
| 151 | + md0: |
| 152 | + minReplicas: 1 |
| 153 | + maxReplicas: 3 |
| 154 | + instanceType: u1.medium |
| 155 | + diskSize: 20Gi |
| 156 | + roles: [ingress-nginx] |
| 157 | + image: |
| 158 | + builtin: |
| 159 | + schematicID: ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515 |
| 160 | + version: v1.13.6 |
| 161 | + asserts: |
| 162 | + - equal: |
| 163 | + path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].spec.source.pvc.name |
| 164 | + value: talos-worker-ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515-v1.13.6 |
| 165 | + documentSelector: {path: kind, value: KubevirtMachineTemplate} |
| 166 | + |
| 167 | + - it: image.builtin fails the render when the requested golden is absent |
| 168 | + set: |
| 169 | + _namespace: {etcd: true, ingress: true, host: example.com} |
| 170 | + _cluster: {cluster-domain: cozy.local} |
| 171 | + nodeGroups: |
| 172 | + md0: |
| 173 | + minReplicas: 1 |
| 174 | + maxReplicas: 3 |
| 175 | + instanceType: u1.medium |
| 176 | + diskSize: 20Gi |
| 177 | + roles: [ingress-nginx] |
| 178 | + image: |
| 179 | + builtin: |
| 180 | + schematicID: doesnotexist |
| 181 | + version: v9.9.9 |
| 182 | + asserts: |
| 183 | + - failedTemplate: |
| 184 | + errorPattern: 'image\.builtin requested golden DataVolume "talos-worker-doesnotexist-v9\.9\.9" not found in cozy-public' |
| 185 | + |
| 186 | + - it: setting both image.builtin and image.factory fails the render |
| 187 | + set: |
| 188 | + _namespace: {etcd: true, ingress: true, host: example.com} |
| 189 | + _cluster: {cluster-domain: cozy.local} |
| 190 | + nodeGroups: |
| 191 | + md0: |
| 192 | + minReplicas: 1 |
| 193 | + maxReplicas: 3 |
| 194 | + instanceType: u1.medium |
| 195 | + diskSize: 20Gi |
| 196 | + roles: [ingress-nginx] |
| 197 | + image: |
| 198 | + builtin: {} |
| 199 | + factory: {} |
| 200 | + asserts: |
| 201 | + - failedTemplate: |
| 202 | + errorPattern: 'set only one of image\.builtin or image\.factory' |
| 203 | + |
| 204 | + - it: image.builtin fails when the worker diskSize is smaller than the golden storage |
| 205 | + set: |
| 206 | + _namespace: {etcd: true, ingress: true, host: example.com} |
| 207 | + _cluster: {cluster-domain: cozy.local} |
| 208 | + nodeGroups: |
| 209 | + md0: |
| 210 | + minReplicas: 1 |
| 211 | + maxReplicas: 3 |
| 212 | + instanceType: u1.medium |
| 213 | + diskSize: 4Gi |
| 214 | + roles: [ingress-nginx] |
| 215 | + image: |
| 216 | + builtin: {} |
| 217 | + asserts: |
| 218 | + - failedTemplate: |
| 219 | + errorPattern: 'diskSize 4Gi is smaller than golden image .* storage 6Gi' |
| 220 | + |
| 221 | + # Regression guard for the no-worker-roll invariant: an image-omitted group must |
| 222 | + # render a KubevirtMachineTemplate whose content-hash name is stable. If a future |
| 223 | + # change to the image-selection block alters the rendered KMT, this pinned hash |
| 224 | + # rotates and forces a conscious update — the signal that existing workers would |
| 225 | + # roll. The fixture matches the reconcile-Job hash test in talos_templates_test.yaml. |
| 226 | + - it: image-omitted group keeps a stable KubevirtMachineTemplate content hash |
| 227 | + release: |
| 228 | + name: test-k8s |
| 229 | + namespace: tenant-test |
| 230 | + set: |
| 231 | + _namespace: {etcd: true, ingress: true, host: example.com} |
| 232 | + _cluster: {cluster-domain: cozy.local} |
| 233 | + nodeGroups: |
| 234 | + md0: |
| 235 | + minReplicas: 0 |
| 236 | + maxReplicas: 10 |
| 237 | + instanceType: "" |
| 238 | + diskSize: 20Gi |
| 239 | + roles: [worker] |
| 240 | + resources: |
| 241 | + cpu: 8 |
| 242 | + memory: 16Gi |
| 243 | + kubelet: {} |
| 244 | + gpus: [] |
| 245 | + asserts: |
| 246 | + - equal: |
| 247 | + path: metadata.name |
| 248 | + value: test-k8s-md0-767d86 |
| 249 | + documentSelector: {path: kind, value: KubevirtMachineTemplate} |
0 commit comments