|
| 1 | +suite: default md0 node group rendering |
| 2 | + |
| 3 | +# When nodeGroups is left empty (chart default `nodeGroups: {}`), the |
| 4 | +# kubernetes.nodeGroups helper must emit the built-in md0 group — this is the |
| 5 | +# else-branch that makes md0 removable (an operator can drop md0 from their own |
| 6 | +# nodeGroups) while a cluster that sets nothing still gets the default topology. |
| 7 | +# A minimal VirtualMachineClusterInstancetype is mocked so the per-group |
| 8 | +# instanceType lookup (u1.medium) returns non-nil; with no spec the template |
| 9 | +# falls back to the default kubelet reservations, which is all this test needs. |
| 10 | + |
| 11 | +templates: |
| 12 | + - templates/cluster.yaml |
| 13 | + |
| 14 | +kubernetesProvider: |
| 15 | + scheme: |
| 16 | + "instancetype.kubevirt.io/v1beta1/VirtualMachineClusterInstancetype": |
| 17 | + gvr: |
| 18 | + group: instancetype.kubevirt.io |
| 19 | + version: v1beta1 |
| 20 | + resource: virtualmachineclusterinstancetypes |
| 21 | + namespaced: false |
| 22 | + "cluster.x-k8s.io/v1beta1/MachineSet": |
| 23 | + gvr: |
| 24 | + group: cluster.x-k8s.io |
| 25 | + version: v1beta1 |
| 26 | + resource: machinesets |
| 27 | + namespaced: true |
| 28 | + "infrastructure.cluster.x-k8s.io/v1alpha1/KubevirtMachineTemplate": |
| 29 | + gvr: |
| 30 | + group: infrastructure.cluster.x-k8s.io |
| 31 | + version: v1alpha1 |
| 32 | + resource: kubevirtmachinetemplates |
| 33 | + namespaced: true |
| 34 | + objects: |
| 35 | + - kind: VirtualMachineClusterInstancetype |
| 36 | + apiVersion: instancetype.kubevirt.io/v1beta1 |
| 37 | + metadata: |
| 38 | + name: u1.medium |
| 39 | + # Dummy CAPI objects so the MachineSet / KubevirtMachineTemplate LIST kinds |
| 40 | + # are registered with the fake client. Shaped to be ignored by the |
| 41 | + # old-template preservation loop (MachineSet infraRef is not a |
| 42 | + # KubevirtMachineTemplate; the KubevirtMachineTemplate has no Cluster owner). |
| 43 | + - kind: MachineSet |
| 44 | + apiVersion: cluster.x-k8s.io/v1beta1 |
| 45 | + metadata: |
| 46 | + name: ignored-ms |
| 47 | + namespace: tenant-test |
| 48 | + spec: |
| 49 | + template: |
| 50 | + spec: |
| 51 | + infrastructureRef: |
| 52 | + kind: Other |
| 53 | + name: ignored |
| 54 | + - kind: KubevirtMachineTemplate |
| 55 | + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 |
| 56 | + metadata: |
| 57 | + name: ignored-kmt |
| 58 | + namespace: tenant-test |
| 59 | + |
| 60 | +tests: |
| 61 | + - it: renders the default md0 group when nodeGroups is empty |
| 62 | + release: |
| 63 | + name: test-k8s |
| 64 | + namespace: tenant-test |
| 65 | + set: |
| 66 | + _namespace: |
| 67 | + etcd: etcd |
| 68 | + ingress: nginx |
| 69 | + host: example.com |
| 70 | + _cluster: |
| 71 | + cluster-domain: cozy.local |
| 72 | + # nodeGroups intentionally left at the chart default ({}) so the helper |
| 73 | + # emits the built-in md0. |
| 74 | + asserts: |
| 75 | + # The default md0 MachineDeployment renders (helper else-branch). |
| 76 | + - equal: |
| 77 | + path: metadata.name |
| 78 | + value: test-k8s-md0 |
| 79 | + documentSelector: |
| 80 | + path: kind |
| 81 | + value: MachineDeployment |
| 82 | + # Default values flow through (e.g. the built-in 20Gi system disk). |
| 83 | + - equal: |
| 84 | + path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].spec.storage.resources.requests.storage |
| 85 | + value: "20Gi" |
| 86 | + documentSelector: |
| 87 | + path: kind |
| 88 | + value: KubevirtMachineTemplate |
0 commit comments