Skip to content

Commit

Permalink
test: fix beta scale test (#4939)
Browse files Browse the repository at this point in the history
Co-authored-by: njtran <njtran@amazon.com>
  • Loading branch information
njtran and njtran committed Oct 26, 2023
1 parent b1d1588 commit 38d4c95
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/suites/alpha/scale/deprovisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var _ = Describe("Deprovisioning", Label(debug.NoWatch), Label(debug.NoEvents),
Values: []string{string(v1.Linux)},
},
{
Key: "karpenter.k8s.aws/instance-hypervisor",
Key: v1alpha1.LabelInstanceHypervisor,
Operator: v1.NodeSelectorOpIn,
Values: []string{"nitro"},
},
Expand Down
15 changes: 11 additions & 4 deletions test/suites/beta/scale/deprovisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/aws/karpenter/pkg/apis/v1beta1"
"github.com/aws/karpenter/pkg/controllers/interruption/messages"
"github.com/aws/karpenter/pkg/controllers/interruption/messages/scheduledchange"
awstest "github.com/aws/karpenter/pkg/test"
"github.com/aws/karpenter/pkg/utils"
"github.com/aws/karpenter/test/pkg/debug"
"github.com/aws/karpenter/test/pkg/environment/aws"
Expand Down Expand Up @@ -82,6 +83,11 @@ var _ = Describe("Deprovisioning", Label(debug.NoWatch), Label(debug.NoEvents),
nodeClass = env.DefaultEC2NodeClass()
nodePool = env.DefaultNodePool(nodeClass)
nodePool.Spec.Limits = nil
test.ReplaceRequirements(nodePool, v1.NodeSelectorRequirement{
Key: v1beta1.LabelInstanceHypervisor,
Operator: v1.NodeSelectorOpIn,
Values: []string{"nitro"},
})
deploymentOptions = test.DeploymentOptions{
PodOptions: test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Expand Down Expand Up @@ -142,7 +148,8 @@ var _ = Describe("Deprovisioning", Label(debug.NoWatch), Label(debug.NoEvents),
nodePoolMap := map[string]*corev1beta1.NodePool{}
// Generate all the nodePools for multi-deprovisioning
for _, v := range disruptionMethods {
np := nodePool.DeepCopy()
np := test.NodePool()
np.Spec = *nodePool.Spec.DeepCopy()
np.Spec.Template.Spec.Taints = []v1.Taint{
{
Key: deprovisioningTypeKey,
Expand Down Expand Up @@ -175,8 +182,8 @@ var _ = Describe("Deprovisioning", Label(debug.NoWatch), Label(debug.NoEvents),

// Create a separate nodeClass for drift so that we can change the nodeClass later without it affecting
// the other nodePools
driftNodeClass := nodeClass.DeepCopy()
driftNodeClass.Name = test.RandomName()
driftNodeClass := awstest.EC2NodeClass()
driftNodeClass.Spec = *nodeClass.Spec.DeepCopy()
nodePoolMap[driftValue].Spec.Template.Spec.NodeClassRef = &corev1beta1.NodeClassReference{
Name: driftNodeClass.Name,
}
Expand Down Expand Up @@ -222,7 +229,7 @@ var _ = Describe("Deprovisioning", Label(debug.NoWatch), Label(debug.NoEvents),

// Create a nodePool for expiration so that expiration can do replacement
nodePoolMap[noExpirationValue] = test.NodePool()
nodePoolMap[noExpirationValue].Spec = nodePoolMap[expirationValue].Spec
nodePoolMap[noExpirationValue].Spec = *nodePoolMap[expirationValue].Spec.DeepCopy()

// Enable consolidation, emptiness, and expiration
nodePoolMap[consolidationValue].Spec.Disruption.ConsolidateAfter = nil
Expand Down
5 changes: 5 additions & 0 deletions test/suites/beta/scale/provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ var _ = Describe("Provisioning", Label(debug.NoWatch), Label(debug.NoEvents), fu
nodeClass = env.DefaultEC2NodeClass()
nodePool = env.DefaultNodePool(nodeClass)
nodePool.Spec.Limits = nil
test.ReplaceRequirements(nodePool, v1.NodeSelectorRequirement{
Key: v1beta1.LabelInstanceHypervisor,
Operator: v1.NodeSelectorOpIn,
Values: []string{"nitro"},
})
deployment = test.Deployment(test.DeploymentOptions{
PodOptions: test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Expand Down

0 comments on commit 38d4c95

Please sign in to comment.