Skip to content

Commit 28e4357

Browse files
committed
make assertions more explicit
1 parent dfdbd6c commit 28e4357

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

test/e2e/clusterclass_rollout.go

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,12 @@ func assertClusterObjects(ctx context.Context, clusterProxy framework.ClusterPro
260260

261261
// ControlPlane
262262
assertControlPlane(g, clusterClassObjects, clusterObjects, cluster, clusterClass)
263-
assertControlPlaneMachines(g, clusterObjects)
263+
assertControlPlaneMachines(g, clusterObjects, cluster)
264264

265265
// MachineDeployments
266266
assertMachineDeployments(g, clusterClassObjects, clusterObjects, cluster, clusterClass)
267267
assertMachineSets(g, clusterObjects, cluster)
268-
assertMachineSetsMachines(g, clusterObjects)
268+
assertMachineSetsMachines(g, clusterObjects, cluster)
269269

270270
By("All cluster objects have the right labels, annotations and selectors")
271271
}, 10*time.Second, 1*time.Second).Should(Succeed())
@@ -375,7 +375,7 @@ func assertControlPlane(g Gomega, clusterClassObjects clusterClassObjects, clust
375375
))
376376
}
377377

378-
func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects) {
378+
func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects, cluster *clusterv1.Cluster) {
379379
controlPlaneMachineTemplateMetadata := mustMetadata(contract.ControlPlane().MachineTemplate().Metadata().Get(clusterObjects.ControlPlane))
380380
controlPlaneInfrastructureMachineTemplateTemplateMetadata := mustMetadata(contract.InfrastructureMachineTemplate().Template().Metadata().Get(clusterObjects.ControlPlaneInfrastructureMachineTemplate))
381381

@@ -384,6 +384,7 @@ func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects) {
384384
g.Expect(machine.Labels).To(BeEquivalentTo(
385385
union(
386386
map[string]string{
387+
clusterv1.ClusterNameLabel: cluster.Name,
387388
clusterv1.MachineControlPlaneLabel: "",
388389
clusterv1.MachineControlPlaneNameLabel: clusterObjects.ControlPlane.GetName(),
389390
},
@@ -405,6 +406,7 @@ func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects) {
405406
g.Expect(infrastructureMachine.GetLabels()).To(BeEquivalentTo(
406407
union(
407408
map[string]string{
409+
clusterv1.ClusterNameLabel: cluster.Name,
408410
clusterv1.MachineControlPlaneLabel: "",
409411
clusterv1.MachineControlPlaneNameLabel: clusterObjects.ControlPlane.GetName(),
410412
},
@@ -428,6 +430,7 @@ func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects) {
428430
g.Expect(bootstrapConfig.GetLabels()).To(BeEquivalentTo(
429431
union(
430432
map[string]string{
433+
clusterv1.ClusterNameLabel: cluster.Name,
431434
clusterv1.MachineControlPlaneLabel: "",
432435
clusterv1.MachineControlPlaneNameLabel: clusterObjects.ControlPlane.GetName(),
433436
},
@@ -589,8 +592,11 @@ func assertMachineSets(g Gomega, clusterObjects clusterObjects, cluster *cluster
589592
g.Expect(machineSet.Labels).To(BeEquivalentTo(
590593
union(
591594
map[string]string{
592-
clusterv1.MachineDeploymentNameLabel: machineDeployment.Name,
593-
clusterv1.MachineDeploymentUniqueLabel: machineTemplateHash,
595+
clusterv1.ClusterNameLabel: cluster.Name,
596+
clusterv1.ClusterTopologyOwnedLabel: "",
597+
clusterv1.ClusterTopologyMachineDeploymentNameLabel: mdTopology.Name,
598+
clusterv1.MachineDeploymentNameLabel: machineDeployment.Name,
599+
clusterv1.MachineDeploymentUniqueLabel: machineTemplateHash,
594600
},
595601
machineDeployment.Spec.Template.Labels,
596602
),
@@ -619,7 +625,10 @@ func assertMachineSets(g Gomega, clusterObjects clusterObjects, cluster *cluster
619625
g.Expect(machineSet.Spec.Template.Labels).To(BeEquivalentTo(
620626
union(
621627
map[string]string{
622-
clusterv1.MachineDeploymentUniqueLabel: machineTemplateHash,
628+
clusterv1.ClusterNameLabel: cluster.Name,
629+
clusterv1.ClusterTopologyOwnedLabel: "",
630+
clusterv1.ClusterTopologyMachineDeploymentNameLabel: mdTopology.Name,
631+
clusterv1.MachineDeploymentUniqueLabel: machineTemplateHash,
623632
},
624633
machineDeployment.Spec.Template.Labels,
625634
),
@@ -631,21 +640,28 @@ func assertMachineSets(g Gomega, clusterObjects clusterObjects, cluster *cluster
631640
}
632641
}
633642

634-
func assertMachineSetsMachines(g Gomega, clusterObjects clusterObjects) {
643+
func assertMachineSetsMachines(g Gomega, clusterObjects clusterObjects, cluster *clusterv1.Cluster) {
635644
for _, machineDeployment := range clusterObjects.MachineDeployments {
645+
mdTopology := getMDTopology(cluster, machineDeployment)
636646
infrastructureMachineTemplate := clusterObjects.InfrastructureMachineTemplateByMachineDeployment[machineDeployment.Name]
637647
infrastructureMachineTemplateTemplateMetadata := mustMetadata(contract.InfrastructureMachineTemplate().Template().Metadata().Get(infrastructureMachineTemplate))
638648
bootstrapConfigTemplate := clusterObjects.BootstrapConfigTemplateByMachineDeployment[machineDeployment.Name]
639649
bootstrapConfigTemplateTemplateMetadata := mustMetadata(contract.BootstrapConfigTemplate().Template().Metadata().Get(bootstrapConfigTemplate))
640650

641651
for _, machineSet := range clusterObjects.MachineSetsByMachineDeployment[machineDeployment.Name] {
652+
machineTemplateHash := machineSet.Labels[clusterv1.MachineDeploymentUniqueLabel]
653+
642654
for _, machine := range clusterObjects.MachinesByMachineSet[machineSet.Name] {
643655
// MachineDeployment MachineSet Machine.metadata
644656
g.Expect(machine.Labels).To(BeEquivalentTo(
645657
union(
646658
map[string]string{
647-
clusterv1.MachineDeploymentNameLabel: machineDeployment.Name,
648-
clusterv1.MachineSetNameLabel: machineSet.Name,
659+
clusterv1.ClusterNameLabel: cluster.Name,
660+
clusterv1.ClusterTopologyOwnedLabel: "",
661+
clusterv1.ClusterTopologyMachineDeploymentNameLabel: mdTopology.Name,
662+
clusterv1.MachineDeploymentNameLabel: machineDeployment.Name,
663+
clusterv1.MachineSetNameLabel: machineSet.Name,
664+
clusterv1.MachineDeploymentUniqueLabel: machineTemplateHash,
649665
},
650666
machineSet.Spec.Template.Labels,
651667
),
@@ -659,8 +675,12 @@ func assertMachineSetsMachines(g Gomega, clusterObjects clusterObjects) {
659675
g.Expect(infrastructureMachine.GetLabels()).To(BeEquivalentTo(
660676
union(
661677
map[string]string{
662-
clusterv1.MachineDeploymentNameLabel: machineDeployment.Name,
663-
clusterv1.MachineSetNameLabel: machineSet.Name,
678+
clusterv1.ClusterNameLabel: cluster.Name,
679+
clusterv1.ClusterTopologyOwnedLabel: "",
680+
clusterv1.ClusterTopologyMachineDeploymentNameLabel: mdTopology.Name,
681+
clusterv1.MachineDeploymentNameLabel: machineDeployment.Name,
682+
clusterv1.MachineSetNameLabel: machineSet.Name,
683+
clusterv1.MachineDeploymentUniqueLabel: machineTemplateHash,
664684
},
665685
machineSet.Spec.Template.Labels,
666686
infrastructureMachineTemplateTemplateMetadata.Labels,
@@ -682,8 +702,12 @@ func assertMachineSetsMachines(g Gomega, clusterObjects clusterObjects) {
682702
g.Expect(bootstrapConfig.GetLabels()).To(BeEquivalentTo(
683703
union(
684704
map[string]string{
685-
clusterv1.MachineDeploymentNameLabel: machineDeployment.Name,
686-
clusterv1.MachineSetNameLabel: machineSet.Name,
705+
clusterv1.ClusterNameLabel: cluster.Name,
706+
clusterv1.ClusterTopologyOwnedLabel: "",
707+
clusterv1.ClusterTopologyMachineDeploymentNameLabel: mdTopology.Name,
708+
clusterv1.MachineDeploymentNameLabel: machineDeployment.Name,
709+
clusterv1.MachineSetNameLabel: machineSet.Name,
710+
clusterv1.MachineDeploymentUniqueLabel: machineTemplateHash,
687711
},
688712
machineSet.Spec.Template.Labels,
689713
bootstrapConfigTemplateTemplateMetadata.Labels,

0 commit comments

Comments
 (0)