From 9fe712ce7b2dbd21be91c0271c1779b4d4532312 Mon Sep 17 00:00:00 2001 From: Jon Huhn Date: Mon, 20 Nov 2023 00:03:49 -0600 Subject: [PATCH] test deleting all tags, node labels, and node taints in AKS e2e --- test/e2e/aks_node_labels.go | 31 +++++++++++++++---------- test/e2e/aks_node_taints.go | 27 ++++++++++++++-------- test/e2e/aks_tags.go | 46 +++++++++++++++++++++---------------- 3 files changed, 62 insertions(+), 42 deletions(-) diff --git a/test/e2e/aks_node_labels.go b/test/e2e/aks_node_labels.go index 5655f5ab04d..5ac398c734f 100644 --- a/test/e2e/aks_node_labels.go +++ b/test/e2e/aks_node_labels.go @@ -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()) @@ -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) } diff --git a/test/e2e/aks_node_taints.go b/test/e2e/aks_node_taints.go index 94d96cd9b8a..eacb010ce5c 100644 --- a/test/e2e/aks_node_taints.go +++ b/test/e2e/aks_node_taints.go @@ -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{ { @@ -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) } diff --git a/test/e2e/aks_tags.go b/test/e2e/aks_tags.go index b8f10670260..2b3bc1f90c4 100644 --- a/test/e2e/aks_tags.go +++ b/test/e2e/aks_tags.go @@ -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{ @@ -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 { @@ -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{ @@ -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) }