Skip to content

Commit 5a0f54c

Browse files
committed
e2e test to check labels on Machines created by RKE2ControlPlane
1 parent 63b0ccf commit 5a0f54c

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

test/e2e/data/infrastructure/cluster-template-docker-updated.yaml

+9-5
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,15 @@ spec:
117117
kubeAPIServer:
118118
extraArgs:
119119
- --anonymous-auth=true
120-
infrastructureRef:
121-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
122-
kind: DockerMachineTemplate
123-
name: "${CLUSTER_NAME}-control-plane"
124-
nodeDrainTimeout: 30s
120+
machineTemplate:
121+
metadata:
122+
labels:
123+
key: value
124+
infrastructureRef:
125+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
126+
kind: DockerMachineTemplate
127+
name: "${CLUSTER_NAME}-control-plane"
128+
nodeDrainTimeout: 30s
125129
---
126130
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
127131
kind: DockerMachineTemplate

test/e2e/data/infrastructure/cluster-template-docker.yaml

+9-5
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,15 @@ spec:
118118
kubeAPIServer:
119119
extraArgs:
120120
- --anonymous-auth=true
121-
infrastructureRef:
122-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
123-
kind: DockerMachineTemplate
124-
name: "${CLUSTER_NAME}-control-plane"
125-
nodeDrainTimeout: 30s
121+
machineTemplate:
122+
metadata:
123+
labels:
124+
key: value
125+
infrastructureRef:
126+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
127+
kind: DockerMachineTemplate
128+
name: "${CLUSTER_NAME}-control-plane"
129+
nodeDrainTimeout: 30s
126130
---
127131
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
128132
kind: DockerMachineTemplate

test/e2e/helpers.go

+14
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,20 @@ func WaitForRKE2ControlPlaneMachinesToExist(ctx context.Context, input WaitForRK
369369
}
370370
return count, nil
371371
}, intervals...).Should(Equal(int(*input.ControlPlane.Spec.Replicas)), "Timed out waiting for %d control plane machines to exist", int(*input.ControlPlane.Spec.Replicas))
372+
373+
controlPlaneMachineTemplateLabels := input.ControlPlane.Spec.MachineTemplate.ObjectMeta.Labels
374+
375+
// check if machines owned by RKE2ControlPlane have the labels provided in .spec.machineTemplate.metadata.labels
376+
machineList := &clusterv1.MachineList{}
377+
err := input.Lister.List(ctx, machineList, inClustersNamespaceListOption, matchClusterListOption)
378+
Expect(err).To(BeNil(), "failed to list the machines")
379+
380+
for _, machine := range machineList.Items {
381+
machineLabels := machine.ObjectMeta.Labels
382+
for k := range controlPlaneMachineTemplateLabels {
383+
Expect(machineLabels[k]).To(Equal(controlPlaneMachineTemplateLabels[k]))
384+
}
385+
}
372386
}
373387

374388
// WaitForControlPlaneToBeReadyInput is the input for WaitForControlPlaneToBeReady.

0 commit comments

Comments
 (0)