Skip to content

Commit

Permalink
test deleting all tags, node labels, and node taints in AKS e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
nojnhuh committed Nov 20, 2023
1 parent 63df74f commit 9fe712c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 42 deletions.
31 changes: 19 additions & 12 deletions test/e2e/aks_node_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,24 @@ func AKSNodeLabelsSpec(ctx context.Context, inputGetter func() AKSNodeLabelsSpec
}
}

Byf("Creating node labels for machine pool %s", mp.Name)
Byf("Deleting all node labels for machine pool %s", mp.Name)
expectedLabels = nil
var initialLabels map[string]string
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
initialLabels = ammp.Spec.NodeLabels
ammp.Spec.NodeLabels = expectedLabels
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkLabels, input.WaitForUpdate...).Should(Succeed())

Byf("Creating node labels for machine pool %s", mp.Name)
expectedLabels = map[string]string{
"test": "label",
"another": "value",
}
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
initialLabels = ammp.Spec.NodeLabels
ammp.Spec.NodeLabels = expectedLabels
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, input.WaitForUpdate...).Should(Succeed())
Expand All @@ -120,16 +129,14 @@ func AKSNodeLabelsSpec(ctx context.Context, inputGetter func() AKSNodeLabelsSpec
}, input.WaitForUpdate...).Should(Succeed())
Eventually(checkLabels, input.WaitForUpdate...).Should(Succeed())

if initialLabels != nil {
Byf("Restoring initial node labels for machine pool %s", mp.Name)
expectedLabels = initialLabels
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
ammp.Spec.NodeLabels = expectedLabels
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, input.WaitForUpdate...).Should(Succeed())
Eventually(checkLabels, input.WaitForUpdate...).Should(Succeed())
}
Byf("Restoring initial node labels for machine pool %s", mp.Name)
expectedLabels = initialLabels
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
ammp.Spec.NodeLabels = expectedLabels
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, input.WaitForUpdate...).Should(Succeed())
Eventually(checkLabels, input.WaitForUpdate...).Should(Succeed())
}(mp)
}

Expand Down
27 changes: 17 additions & 10 deletions test/e2e/aks_node_taints.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ func AKSNodeTaintsSpec(ctx context.Context, inputGetter func() AKSNodeTaintsSpec
}
}

Byf("Deleting all node taints for machine pool %s", mp.Name)
expectedTaints = nil
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
ammp.Spec.Taints = expectedTaints
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkTaints, input.WaitForUpdate...).Should(Succeed())

Byf("Creating taints for machine pool %s", mp.Name)
expectedTaints = infrav1.Taints{
{
Expand Down Expand Up @@ -127,16 +136,14 @@ func AKSNodeTaintsSpec(ctx context.Context, inputGetter func() AKSNodeTaintsSpec
}, input.WaitForUpdate...).Should(Succeed())
Eventually(checkTaints, input.WaitForUpdate...).Should(Succeed())

if initialTaints != nil {
Byf("Restoring initial taints for machine pool %s", mp.Name)
expectedTaints = initialTaints
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
ammp.Spec.Taints = expectedTaints
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, input.WaitForUpdate...).Should(Succeed())
Eventually(checkTaints, input.WaitForUpdate...).Should(Succeed())
}
Byf("Restoring initial taints for machine pool %s", mp.Name)
expectedTaints = initialTaints
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
ammp.Spec.Taints = expectedTaints
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, input.WaitForUpdate...).Should(Succeed())
Eventually(checkTaints, input.WaitForUpdate...).Should(Succeed())
}(mp)
}

Expand Down
46 changes: 26 additions & 20 deletions test/e2e/aks_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ func AKSAdditionalTagsSpec(ctx context.Context, inputGetter func() AKSAdditional
}
}

By("Deleting all tags for control plane")
expectedTags = nil
var initialTags infrav1.Tags
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(infraControlPlane), infraControlPlane)).To(Succeed())
initialTags = infraControlPlane.Spec.AdditionalTags
infraControlPlane.Spec.AdditionalTags = expectedTags
g.Expect(mgmtClient.Update(ctx, infraControlPlane)).To(Succeed())
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkTags, input.WaitForUpdate...).Should(Succeed())

By("Creating tags for control plane")
expectedTags = infrav1.Tags{
Expand All @@ -129,16 +134,14 @@ func AKSAdditionalTagsSpec(ctx context.Context, inputGetter func() AKSAdditional
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkTags, input.WaitForUpdate...).Should(Succeed())

if initialTags != nil {
By("Restoring initial tags for control plane")
expectedTags = initialTags
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(infraControlPlane), infraControlPlane)).To(Succeed())
infraControlPlane.Spec.AdditionalTags = expectedTags
g.Expect(mgmtClient.Update(ctx, infraControlPlane)).To(Succeed())
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkTags, input.WaitForUpdate...).Should(Succeed())
}
By("Restoring initial tags for control plane")
expectedTags = initialTags
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(infraControlPlane), infraControlPlane)).To(Succeed())
infraControlPlane.Spec.AdditionalTags = expectedTags
g.Expect(mgmtClient.Update(ctx, infraControlPlane)).To(Succeed())
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkTags, input.WaitForUpdate...).Should(Succeed())
}()

for _, mp := range input.MachinePools {
Expand Down Expand Up @@ -182,11 +185,16 @@ func AKSAdditionalTagsSpec(ctx context.Context, inputGetter func() AKSAdditional
}
}

Byf("Deleting all tags for machine pool %s", mp.Name)
expectedTags = nil
var initialTags infrav1.Tags
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
initialTags = ammp.Spec.AdditionalTags
ammp.Spec.AdditionalTags = expectedTags
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkTags, input.WaitForUpdate...).Should(Succeed())

Byf("Creating tags for machine pool %s", mp.Name)
expectedTags = infrav1.Tags{
Expand All @@ -211,16 +219,14 @@ func AKSAdditionalTagsSpec(ctx context.Context, inputGetter func() AKSAdditional
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkTags, input.WaitForUpdate...).Should(Succeed())

if initialTags != nil {
Byf("Restoring initial tags for machine pool %s", mp.Name)
expectedTags = initialTags
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
ammp.Spec.AdditionalTags = expectedTags
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkTags, input.WaitForUpdate...).Should(Succeed())
}
Byf("Restoring initial tags for machine pool %s", mp.Name)
expectedTags = initialTags
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(ammp), ammp)).To(Succeed())
ammp.Spec.AdditionalTags = expectedTags
g.Expect(mgmtClient.Update(ctx, ammp)).To(Succeed())
}, inputGetter().WaitForUpdate...).Should(Succeed())
Eventually(checkTags, input.WaitForUpdate...).Should(Succeed())
}(mp)
}

Expand Down

0 comments on commit 9fe712c

Please sign in to comment.