From 0805d9b14c531f8c3bc207977f4f645e5fb2259e Mon Sep 17 00:00:00 2001 From: Jigisha Patil <89548848+jigisha620@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:13:10 -0800 Subject: [PATCH] test: Fix E2E test for release-v0.32.x (#5566) --- test/suites/alpha/drift/suite_test.go | 4 ++-- test/suites/alpha/expiration/suite_test.go | 2 +- test/suites/alpha/integration/scheduling_test.go | 11 ++++++++--- test/suites/beta/drift/suite_test.go | 4 ++-- test/suites/beta/expiration/suite_test.go | 2 +- test/suites/beta/integration/scheduling_test.go | 6 +++++- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/test/suites/alpha/drift/suite_test.go b/test/suites/alpha/drift/suite_test.go index 98c73de39946..c80d6613d613 100644 --- a/test/suites/alpha/drift/suite_test.go +++ b/test/suites/alpha/drift/suite_test.go @@ -388,9 +388,9 @@ var _ = Describe("Drift", Label("AWS"), func() { startingMachineState := env.EventuallyExpectCreatedMachineCount("==", int(numPods)) env.EventuallyExpectCreatedNodeCount("==", int(numPods)) - // Drift the machine with bad configuration + // Drift the nodeClaim with bad configuration that will not register a NodeClaim parameter, err := env.SSMAPI.GetParameter(&ssm.GetParameterInput{ - Name: awssdk.String("/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs"), + Name: awssdk.String("/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs"), }) Expect(err).ToNot(HaveOccurred()) nodeTemplate.Spec.AMISelector = map[string]string{"aws::ids": *parameter.Parameter.Value} diff --git a/test/suites/alpha/expiration/suite_test.go b/test/suites/alpha/expiration/suite_test.go index e0caac5efd7f..8d0e15a2c5da 100644 --- a/test/suites/alpha/expiration/suite_test.go +++ b/test/suites/alpha/expiration/suite_test.go @@ -223,7 +223,7 @@ var _ = Describe("Expiration", func() { // Set a configuration that will not register a machine parameter, err := env.SSMAPI.GetParameter(&ssm.GetParameterInput{ - Name: lo.ToPtr("/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs"), + Name: lo.ToPtr("/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs"), }) Expect(err).ToNot(HaveOccurred()) nodeTemplate.Spec.AMISelector = map[string]string{"aws::ids": *parameter.Parameter.Value} diff --git a/test/suites/alpha/integration/scheduling_test.go b/test/suites/alpha/integration/scheduling_test.go index f07fbabb3cf4..c67bf7896be5 100644 --- a/test/suites/alpha/integration/scheduling_test.go +++ b/test/suites/alpha/integration/scheduling_test.go @@ -18,8 +18,6 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" "github.com/samber/lo" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,6 +25,9 @@ import ( "k8s.io/apimachinery/pkg/util/sets" "knative.dev/pkg/ptr" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/aws/karpenter-core/pkg/apis/v1alpha5" "github.com/aws/karpenter-core/pkg/test" "github.com/aws/karpenter/pkg/apis/v1alpha1" @@ -356,6 +357,7 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() { TopologyKey: v1.LabelTopologyZone, WhenUnsatisfiable: v1.DoNotSchedule, LabelSelector: &metav1.LabelSelector{MatchLabels: podLabels}, + MinDomains: lo.ToPtr(int32(3)), }, }, }, @@ -363,7 +365,10 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() { env.ExpectCreated(provisioner, provider, deployment) env.EventuallyExpectHealthyPodCount(labels.SelectorFromSet(podLabels), 3) - env.ExpectCreatedNodeCount("==", 3) + // Karpenter will launch three nodes, however if all three nodes don't get register with the cluster at the same time, two pods will be placed on one node. + // This can result in a case where all 3 pods are healthy, while there are only two created nodes. + // In that case, we still expect to eventually have three nodes. + env.EventuallyExpectNodeCount("==", 3) }) It("should provision a node using a provisioner with higher priority", func() { provisionerLowPri := test.Provisioner(test.ProvisionerOptions{ diff --git a/test/suites/beta/drift/suite_test.go b/test/suites/beta/drift/suite_test.go index 207420a8cd0b..05889d1af189 100644 --- a/test/suites/beta/drift/suite_test.go +++ b/test/suites/beta/drift/suite_test.go @@ -467,9 +467,9 @@ var _ = Describe("Drift", Label("AWS"), func() { startingNodeClaimState := env.EventuallyExpectCreatedNodeClaimCount("==", int(numPods)) env.EventuallyExpectCreatedNodeCount("==", int(numPods)) - // Drift the nodeClaim with bad configuration + // Drift the nodeClaim with bad configuration that will not register a NodeClaim parameter, err := env.SSMAPI.GetParameter(&ssm.GetParameterInput{ - Name: awssdk.String("/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs"), + Name: awssdk.String("/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs"), }) Expect(err).ToNot(HaveOccurred()) nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{ID: *parameter.Parameter.Value}} diff --git a/test/suites/beta/expiration/suite_test.go b/test/suites/beta/expiration/suite_test.go index 0b21e210d7fb..daff04e616dd 100644 --- a/test/suites/beta/expiration/suite_test.go +++ b/test/suites/beta/expiration/suite_test.go @@ -211,7 +211,7 @@ var _ = Describe("Expiration", func() { // Set a configuration that will not register a NodeClaim parameter, err := env.SSMAPI.GetParameter(&ssm.GetParameterInput{ - Name: lo.ToPtr("/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs"), + Name: lo.ToPtr("/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs"), }) Expect(err).ToNot(HaveOccurred()) nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{ diff --git a/test/suites/beta/integration/scheduling_test.go b/test/suites/beta/integration/scheduling_test.go index 365936087fef..5869b6a8be36 100644 --- a/test/suites/beta/integration/scheduling_test.go +++ b/test/suites/beta/integration/scheduling_test.go @@ -346,6 +346,7 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() { TopologyKey: v1.LabelTopologyZone, WhenUnsatisfiable: v1.DoNotSchedule, LabelSelector: &metav1.LabelSelector{MatchLabels: podLabels}, + MinDomains: lo.ToPtr(int32(3)), }, }, }, @@ -353,7 +354,10 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() { env.ExpectCreated(nodeClass, nodePool, deployment) env.EventuallyExpectHealthyPodCount(labels.SelectorFromSet(podLabels), 3) - env.ExpectCreatedNodeCount("==", 3) + // Karpenter will launch three nodes, however if all three nodes don't get register with the cluster at the same time, two pods will be placed on one node. + // This can result in a case where all 3 pods are healthy, while there are only two created nodes. + // In that case, we still expect to eventually have three nodes. + env.EventuallyExpectNodeCount("==", 3) }) It("should provision a node using a NodePool with higher priority", func() { nodePoolLowPri := test.NodePool(corev1beta1.NodePool{