mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-06 03:57:52 +09:00
test(kubernetes): cover the default md0 node group render
Assert that an empty nodeGroups renders the built-in md0 group via the kubernetes.nodeGroups helper else-branch (the behaviour that makes md0 removable): the default md0 MachineDeployment is emitted and the default 20Gi system disk flows through. A minimal VirtualMachineClusterInstancetype plus dummy CAPI objects are registered so the per-group instanceType lookup and the old-template preservation LISTs resolve under helm-unittest. Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
1 file changed
+88
@@ -0,0 +1,88 @@
|
||||
suite: default md0 node group rendering
|
||||
|
||||
# When nodeGroups is left empty (chart default `nodeGroups: {}`), the
|
||||
# kubernetes.nodeGroups helper must emit the built-in md0 group — this is the
|
||||
# else-branch that makes md0 removable (an operator can drop md0 from their own
|
||||
# nodeGroups) while a cluster that sets nothing still gets the default topology.
|
||||
# A minimal VirtualMachineClusterInstancetype is mocked so the per-group
|
||||
# instanceType lookup (u1.medium) returns non-nil; with no spec the template
|
||||
# falls back to the default kubelet reservations, which is all this test needs.
|
||||
|
||||
templates:
|
||||
- templates/cluster.yaml
|
||||
|
||||
kubernetesProvider:
|
||||
scheme:
|
||||
"instancetype.kubevirt.io/v1beta1/VirtualMachineClusterInstancetype":
|
||||
gvr:
|
||||
group: instancetype.kubevirt.io
|
||||
version: v1beta1
|
||||
resource: virtualmachineclusterinstancetypes
|
||||
namespaced: false
|
||||
"cluster.x-k8s.io/v1beta1/MachineSet":
|
||||
gvr:
|
||||
group: cluster.x-k8s.io
|
||||
version: v1beta1
|
||||
resource: machinesets
|
||||
namespaced: true
|
||||
"infrastructure.cluster.x-k8s.io/v1alpha1/KubevirtMachineTemplate":
|
||||
gvr:
|
||||
group: infrastructure.cluster.x-k8s.io
|
||||
version: v1alpha1
|
||||
resource: kubevirtmachinetemplates
|
||||
namespaced: true
|
||||
objects:
|
||||
- kind: VirtualMachineClusterInstancetype
|
||||
apiVersion: instancetype.kubevirt.io/v1beta1
|
||||
metadata:
|
||||
name: u1.medium
|
||||
# Dummy CAPI objects so the MachineSet / KubevirtMachineTemplate LIST kinds
|
||||
# are registered with the fake client. Shaped to be ignored by the
|
||||
# old-template preservation loop (MachineSet infraRef is not a
|
||||
# KubevirtMachineTemplate; the KubevirtMachineTemplate has no Cluster owner).
|
||||
- kind: MachineSet
|
||||
apiVersion: cluster.x-k8s.io/v1beta1
|
||||
metadata:
|
||||
name: ignored-ms
|
||||
namespace: tenant-test
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
infrastructureRef:
|
||||
kind: Other
|
||||
name: ignored
|
||||
- kind: KubevirtMachineTemplate
|
||||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
|
||||
metadata:
|
||||
name: ignored-kmt
|
||||
namespace: tenant-test
|
||||
|
||||
tests:
|
||||
- it: renders the default md0 group when nodeGroups is empty
|
||||
release:
|
||||
name: test-k8s
|
||||
namespace: tenant-test
|
||||
set:
|
||||
_namespace:
|
||||
etcd: etcd
|
||||
ingress: nginx
|
||||
host: example.com
|
||||
_cluster:
|
||||
cluster-domain: cozy.local
|
||||
# nodeGroups intentionally left at the chart default ({}) so the helper
|
||||
# emits the built-in md0.
|
||||
asserts:
|
||||
# The default md0 MachineDeployment renders (helper else-branch).
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: test-k8s-md0
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: MachineDeployment
|
||||
# Default values flow through (e.g. the built-in 20Gi system disk).
|
||||
- equal:
|
||||
path: spec.template.spec.virtualMachineTemplate.spec.dataVolumeTemplates[0].spec.storage.resources.requests.storage
|
||||
value: "20Gi"
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: KubevirtMachineTemplate
|
||||
Reference in new issue
Block a user