Skip to content

Commit

Permalink
test: Fix E2E test for release-v0.32.x (#5566)
Browse files Browse the repository at this point in the history
  • Loading branch information
jigisha620 authored Jan 31, 2024
1 parent 1d7f91c commit 0805d9b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/suites/alpha/drift/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion test/suites/alpha/expiration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
11 changes: 8 additions & 3 deletions test/suites/alpha/integration/scheduling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ 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"
"k8s.io/apimachinery/pkg/labels"
"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"
Expand Down Expand Up @@ -356,14 +357,18 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() {
TopologyKey: v1.LabelTopologyZone,
WhenUnsatisfiable: v1.DoNotSchedule,
LabelSelector: &metav1.LabelSelector{MatchLabels: podLabels},
MinDomains: lo.ToPtr(int32(3)),
},
},
},
})

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{
Expand Down
4 changes: 2 additions & 2 deletions test/suites/beta/drift/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion test/suites/beta/expiration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
6 changes: 5 additions & 1 deletion test/suites/beta/integration/scheduling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,18 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() {
TopologyKey: v1.LabelTopologyZone,
WhenUnsatisfiable: v1.DoNotSchedule,
LabelSelector: &metav1.LabelSelector{MatchLabels: podLabels},
MinDomains: lo.ToPtr(int32(3)),
},
},
},
})

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{
Expand Down

0 comments on commit 0805d9b

Please sign in to comment.