Skip to content

Commit

Permalink
Merge pull request #4295 from nojnhuh/aks-delete-fields
Browse files Browse the repository at this point in the history
test deleting all tags, node labels, and node taints in AKS e2e
  • Loading branch information
k8s-ci-robot authored Nov 29, 2023
2 parents 82786b8 + a8a1f0f commit 3ef2291
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 47 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ require (
go.opentelemetry.io/otel/trace v1.21.0
go.uber.org/mock v0.3.0
golang.org/x/crypto v0.15.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
golang.org/x/mod v0.14.0
golang.org/x/text v0.14.0
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -182,7 +183,6 @@ require (
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sync v0.4.0 // indirect
Expand Down
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
50 changes: 26 additions & 24 deletions test/e2e/aks_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"golang.org/x/exp/maps"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
Expand Down Expand Up @@ -107,10 +108,10 @@ func AKSAdditionalTagsSpec(ctx context.Context, inputGetter func() AKSAdditional
}, inputGetter().WaitForUpdate...).Should(Succeed())

By("Creating tags for control plane")
expectedTags = infrav1.Tags{
"test": "tag",
"another": "value",
}
// Preserve "creationTimestamp" so the RG cleanup doesn't fire on this cluster during this test.
expectedTags = maps.Clone(initialTags)
expectedTags["test"] = "tag"
expectedTags["another"] = "value"
Eventually(func(g Gomega) {
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(infraControlPlane), infraControlPlane)).To(Succeed())
infraControlPlane.Spec.AdditionalTags = expectedTags
Expand All @@ -129,16 +130,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 +181,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 +215,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 3ef2291

Please sign in to comment.