Skip to content

Commit

Permalink
test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed Apr 25, 2024
1 parent a6d5c92 commit b51a4af
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 23 deletions.
13 changes: 9 additions & 4 deletions pkg/cloudprovider/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,9 +750,14 @@ var _ = Describe("CloudProvider", func() {
Tags: map[string]string{
"fakeKey": "fakeValue",
},
Context: lo.ToPtr("fake-context"),
DetailedMonitoring: lo.ToPtr(false),
AMIFamily: lo.ToPtr(v1beta1.AMIFamilyAL2023),
Context: lo.ToPtr("fake-context"),
DetailedMonitoring: lo.ToPtr(false),
AMIFamily: lo.ToPtr(v1beta1.AMIFamilyAL2023),
AMISelectorTerms: []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyAL2023,
},
}},
AssociatePublicIPAddress: lo.ToPtr(false),
MetadataOptions: &v1beta1.MetadataOptions{
HTTPEndpoint: lo.ToPtr("disabled"),
Expand Down Expand Up @@ -800,7 +805,7 @@ var _ = Describe("CloudProvider", func() {
Entry("Tags", v1beta1.EC2NodeClass{Spec: v1beta1.EC2NodeClassSpec{Tags: map[string]string{"keyTag-test-3": "valueTag-test-3"}}}),
Entry("Context", v1beta1.EC2NodeClass{Spec: v1beta1.EC2NodeClassSpec{Context: lo.ToPtr("context-2")}}),
Entry("DetailedMonitoring", v1beta1.EC2NodeClass{Spec: v1beta1.EC2NodeClassSpec{DetailedMonitoring: aws.Bool(true)}}),
Entry("AMIFamily", v1beta1.EC2NodeClass{Spec: v1beta1.EC2NodeClassSpec{AMIFamily: lo.ToPtr(v1beta1.AMIFamilyBottlerocket)}}),
Entry("AMIFamily", v1beta1.EC2NodeClass{Spec: v1beta1.EC2NodeClassSpec{AMIFamily: lo.ToPtr(v1beta1.AMIFamilyCustom)}}),
Entry("InstanceStorePolicy", v1beta1.EC2NodeClass{Spec: v1beta1.EC2NodeClassSpec{InstanceStorePolicy: lo.ToPtr(v1beta1.InstanceStorePolicyRAID0)}}),
Entry("AssociatePublicIPAddress", v1beta1.EC2NodeClass{Spec: v1beta1.EC2NodeClassSpec{AssociatePublicIPAddress: lo.ToPtr(true)}}),
Entry("MetadataOptions HTTPEndpoint", v1beta1.EC2NodeClass{Spec: v1beta1.EC2NodeClassSpec{MetadataOptions: &v1beta1.MetadataOptions{HTTPEndpoint: lo.ToPtr("enabled")}}}),
Expand Down
12 changes: 10 additions & 2 deletions pkg/controllers/nodeclass/status/ami_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ var _ = Describe("NodeClass AMI Status Controller", func() {
},
},
})
nodeClass.Spec.AMISelectorTerms = nil
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyAL2,
},
}}
ExpectApplied(ctx, env.Client, nodeClass)
ExpectReconcileSucceeded(ctx, statusController, client.ObjectKeyFromObject(nodeClass))
nodeClass = ExpectExists(ctx, env.Client, nodeClass)
Expand Down Expand Up @@ -237,7 +241,11 @@ var _ = Describe("NodeClass AMI Status Controller", func() {
fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s/arm64/latest/image_id", version): "ami-id-456",
}
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = nil
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyBottlerocket,
},
}}
awsEnv.EC2API.DescribeImagesOutput.Set(&ec2.DescribeImagesOutput{
Images: []*ec2.Image{
{
Expand Down
62 changes: 51 additions & 11 deletions pkg/providers/amifamily/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ var _ = Describe("AMIProvider", func() {
nodeClass = test.EC2NodeClass()
})
It("should succeed to resolve AMIs (AL2)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyAL2
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyAL2,
},
}}
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2/recommended/image_id", version): amd64AMI,
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2-gpu/recommended/image_id", version): amd64NvidiaAMI,
Expand All @@ -141,7 +145,11 @@ var _ = Describe("AMIProvider", func() {
Expect(amis).To(HaveLen(4))
})
It("should succeed to resolve AMIs (AL2023)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyAL2023
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyAL2023,
},
}}
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2023/x86_64/standard/recommended/image_id", version): amd64AMI,
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2023/arm64/standard/recommended/image_id", version): arm64AMI,
Expand All @@ -151,7 +159,11 @@ var _ = Describe("AMIProvider", func() {
Expect(amis).To(HaveLen(2))
})
It("should succeed to resolve AMIs (Bottlerocket)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyBottlerocket,
},
}}
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s/x86_64/latest/image_id", version): amd64AMI,
fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s-nvidia/x86_64/latest/image_id", version): amd64NvidiaAMI,
Expand All @@ -163,7 +175,11 @@ var _ = Describe("AMIProvider", func() {
Expect(amis).To(HaveLen(6))
})
It("should succeed to resolve AMIs (Ubuntu)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyUbuntu
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyUbuntu,
},
}}
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/canonical/ubuntu/eks/20.04/%s/stable/current/amd64/hvm/ebs-gp2/ami-id", version): amd64AMI,
fmt.Sprintf("/aws/service/canonical/ubuntu/eks/20.04/%s/stable/current/arm64/hvm/ebs-gp2/ami-id", version): arm64AMI,
Expand All @@ -173,7 +189,11 @@ var _ = Describe("AMIProvider", func() {
Expect(amis).To(HaveLen(2))
})
It("should succeed to resolve AMIs (Windows2019)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyWindows2019
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyWindows2019,
},
}}
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/ami-windows-latest/Windows_Server-2019-English-Core-EKS_Optimized-%s/image_id", version): amd64AMI,
}
Expand All @@ -182,7 +202,11 @@ var _ = Describe("AMIProvider", func() {
Expect(amis).To(HaveLen(1))
})
It("should succeed to resolve AMIs (Windows2022)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyWindows2022
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyWindows2022,
},
}}
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/ami-windows-latest/Windows_Server-2022-English-Core-EKS_Optimized-%s/image_id", version): amd64AMI,
}
Expand All @@ -191,14 +215,18 @@ var _ = Describe("AMIProvider", func() {
Expect(amis).To(HaveLen(1))
})
It("should succeed to resolve AMIs (Custom)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyCustom
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{}
amis, err := awsEnv.AMIProvider.Get(ctx, nodeClass, &amifamily.Options{})
Expect(err).ToNot(HaveOccurred())
Expect(amis).To(HaveLen(0))
})
Context("SSM Alias Missing", func() {
It("should succeed to partially resolve AMIs if all SSM aliases don't exist (Al2)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyAL2
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyAL2,
},
}}
// No GPU AMI exists here
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2/recommended/image_id", version): amd64AMI,
Expand All @@ -210,7 +238,11 @@ var _ = Describe("AMIProvider", func() {
Expect(amis).To(HaveLen(2))
})
It("should succeed to partially resolve AMIs if all SSM aliases don't exist (AL2023)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyAL2023
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyAL2023,
},
}}
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2023/x86_64/standard/recommended/image_id", version): amd64AMI,
}
Expand All @@ -219,7 +251,11 @@ var _ = Describe("AMIProvider", func() {
Expect(amis).To(HaveLen(1))
})
It("should succeed to partially resolve AMIs if all SSM aliases don't exist (Bottlerocket)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyBottlerocket,
},
}}
// No GPU AMI exists for AM64 here
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s/x86_64/latest/image_id", version): amd64AMI,
Expand All @@ -232,7 +268,11 @@ var _ = Describe("AMIProvider", func() {
Expect(amis).To(HaveLen(4))
})
It("should succeed to partially resolve AMIs if all SSM aliases don't exist (Ubuntu)", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyUbuntu
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyUbuntu,
},
}}
// No AMD64 AMI exists here
awsEnv.SSMAPI.Parameters = map[string]string{
fmt.Sprintf("/aws/service/canonical/ubuntu/eks/20.04/%s/stable/current/arm64/hvm/ebs-gp2/ami-id", version): arm64AMI,
Expand Down
40 changes: 34 additions & 6 deletions pkg/providers/instancetype/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ var _ = Describe("InstanceTypeProvider", func() {
windowsNodeClass = test.EC2NodeClass(v1beta1.EC2NodeClass{
Spec: v1beta1.EC2NodeClassSpec{
AMIFamily: &v1beta1.AMIFamilyWindows2022,
AMISelectorTerms: []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyWindows2022},
}},
},
})
windowsNodePool = coretest.NodePool(corev1beta1.NodePool{
Expand Down Expand Up @@ -1200,6 +1203,9 @@ var _ = Describe("InstanceTypeProvider", func() {
})
It("should ignore eviction threshold when using Bottlerocket AMI", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyBottlerocket},
}}
nodePool.Spec.Template.Spec.Kubelet = &corev1beta1.KubeletConfiguration{
SystemReserved: map[string]string{
string(v1.ResourceMemory): "20Gi",
Expand Down Expand Up @@ -1566,6 +1572,9 @@ var _ = Describe("InstanceTypeProvider", func() {
instanceInfo, err := awsEnv.EC2API.DescribeInstanceTypesWithContext(ctx, &ec2.DescribeInstanceTypesInput{})
Expect(err).To(BeNil())
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyBottlerocket},
}}
nodePool.Spec.Template.Spec.Kubelet = &corev1beta1.KubeletConfiguration{
PodsPerCore: ptr.Int32(1),
}
Expand Down Expand Up @@ -2010,7 +2019,10 @@ var _ = Describe("InstanceTypeProvider", func() {
})
Context("Ephemeral Storage", func() {
BeforeEach(func() {
nodeClass.Spec.AMIFamily = aws.String(v1beta1.AMIFamilyAL2)
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyAL2
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyAL2},
}}
nodeClass.Spec.BlockDeviceMappings = []*v1beta1.BlockDeviceMapping{
{
DeviceName: aws.String("/dev/xvda"),
Expand All @@ -2021,7 +2033,7 @@ var _ = Describe("InstanceTypeProvider", func() {
}
})
It("should default to EBS defaults when volumeSize is not defined in blockDeviceMappings for custom AMIs", func() {
nodeClass.Spec.AMIFamily = aws.String(v1beta1.AMIFamilyCustom)
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyCustom
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{
{
Tags: map[string]string{
Expand Down Expand Up @@ -2055,7 +2067,10 @@ var _ = Describe("InstanceTypeProvider", func() {
})
})
It("should default to EBS defaults when volumeSize is not defined in blockDeviceMappings for AL2023 Root volume", func() {
nodeClass.Spec.AMIFamily = aws.String(v1beta1.AMIFamilyAL2023)
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyAL2023
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyAL2023},
}}
awsEnv.LaunchTemplateProvider.CABundle = lo.ToPtr("Y2EtYnVuZGxlCg==")
awsEnv.LaunchTemplateProvider.ClusterCIDR.Store(lo.ToPtr("10.100.0.0/16"))
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
Expand All @@ -2071,7 +2086,10 @@ var _ = Describe("InstanceTypeProvider", func() {
})
})
It("should default to EBS defaults when volumeSize is not defined in blockDeviceMappings for Bottlerocket Root volume", func() {
nodeClass.Spec.AMIFamily = aws.String(v1beta1.AMIFamilyBottlerocket)
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyBottlerocket},
}}
nodeClass.Spec.BlockDeviceMappings[0].DeviceName = aws.String("/dev/xvdb")
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
pod := coretest.UnschedulablePod()
Expand All @@ -2087,7 +2105,10 @@ var _ = Describe("InstanceTypeProvider", func() {
})
})
It("should default to EBS defaults when volumeSize is not defined in blockDeviceMappings for Ubuntu Root volume", func() {
nodeClass.Spec.AMIFamily = aws.String(v1beta1.AMIFamilyUbuntu)
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyUbuntu
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyUbuntu},
}}
nodeClass.Spec.BlockDeviceMappings[0].DeviceName = aws.String("/dev/sda1")
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
pod := coretest.UnschedulablePod()
Expand Down Expand Up @@ -2205,7 +2226,14 @@ var _ = Describe("InstanceTypeProvider", func() {
nodeClassChanges := []*v1beta1.EC2NodeClass{
{}, // Testing the base case black EC2NodeClass
{Spec: v1beta1.EC2NodeClassSpec{InstanceStorePolicy: lo.ToPtr(v1beta1.InstanceStorePolicyRAID0)}},
{Spec: v1beta1.EC2NodeClassSpec{AMIFamily: &v1beta1.AMIFamilyUbuntu}},
{
Spec: v1beta1.EC2NodeClassSpec{
AMIFamily: &v1beta1.AMIFamilyUbuntu,
AMISelectorTerms: []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyUbuntu},
}},
},
},
{
Spec: v1beta1.EC2NodeClassSpec{BlockDeviceMappings: []*v1beta1.BlockDeviceMapping{
{
Expand Down
22 changes: 22 additions & 0 deletions pkg/providers/launchtemplate/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ var _ = Describe("LaunchTemplate Provider", func() {
})
It("should default AL2023 block device mappings", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyAL2023
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyAL2023},
}}
awsEnv.LaunchTemplateProvider.CABundle = lo.ToPtr("Y2EtYnVuZGxlCg==")
awsEnv.LaunchTemplateProvider.ClusterCIDR.Store(lo.ToPtr("10.100.0.0/16"))
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
Expand Down Expand Up @@ -634,6 +637,9 @@ var _ = Describe("LaunchTemplate Provider", func() {
})
It("should default bottlerocket second volume with root volume size", func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyBottlerocket},
}}
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
pod := coretest.UnschedulablePod()
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
Expand Down Expand Up @@ -984,6 +990,9 @@ var _ = Describe("LaunchTemplate Provider", func() {
}))

nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyBottlerocket},
}}
amiFamily := amifamily.GetAMIFamily(nodeClass.Spec.AMIFamily, &amifamily.Options{})
it := instancetype.NewInstanceType(ctx,
info,
Expand All @@ -1009,6 +1018,9 @@ var _ = Describe("LaunchTemplate Provider", func() {
}))

nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyBottlerocket},
}}
nodePool.Spec.Template.Spec.Kubelet = &corev1beta1.KubeletConfiguration{MaxPods: lo.ToPtr[int32](110)}
amiFamily := amifamily.GetAMIFamily(nodeClass.Spec.AMIFamily, &amifamily.Options{})
it := instancetype.NewInstanceType(ctx,
Expand Down Expand Up @@ -1291,6 +1303,9 @@ var _ = Describe("LaunchTemplate Provider", func() {
Context("Bottlerocket", func() {
BeforeEach(func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyBottlerocket
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyBottlerocket},
}}
nodePool.Spec.Template.Spec.Kubelet = &corev1beta1.KubeletConfiguration{MaxPods: lo.ToPtr[int32](110)}
})
It("should merge in custom user data", func() {
Expand Down Expand Up @@ -1564,6 +1579,9 @@ var _ = Describe("LaunchTemplate Provider", func() {
Context("AL2023", func() {
BeforeEach(func() {
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyAL2023
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyAL2023},
}}

// base64 encoded version of "ca-bundle" to ensure the nodeadm bootstrap provider can decode successfully
awsEnv.LaunchTemplateProvider.CABundle = lo.ToPtr("Y2EtYnVuZGxlCg==")
Expand Down Expand Up @@ -1755,6 +1773,7 @@ var _ = Describe("LaunchTemplate Provider", func() {
)
It("should fail to create launch templates if cluster CIDR is unresolved", func() {
awsEnv.LaunchTemplateProvider.ClusterCIDR.Store(nil)
fmt.Printf("nodeClass: %s\n", string(lo.Must(json.Marshal(nodeClass))))
ExpectApplied(ctx, env.Client, nodeClass, nodePool)
pod := coretest.UnschedulablePod()
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, prov, pod)
Expand Down Expand Up @@ -2004,6 +2023,9 @@ var _ = Describe("LaunchTemplate Provider", func() {
BeforeEach(func() {
nodePool.Spec.Template.Spec.Requirements = []corev1beta1.NodeSelectorRequirementWithMinValues{{NodeSelectorRequirement: v1.NodeSelectorRequirement{Key: v1.LabelOSStable, Operator: v1.NodeSelectorOpIn, Values: []string{string(v1.Windows)}}}}
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyWindows2022
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{Family: v1beta1.AMIFamilyWindows2022},
}}
nodePool.Spec.Template.Spec.Kubelet = &corev1beta1.KubeletConfiguration{MaxPods: lo.ToPtr[int32](110)}
})
It("should merge and bootstrap with custom user data", func() {
Expand Down
7 changes: 7 additions & 0 deletions pkg/test/nodeclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func EC2NodeClass(overrides ...v1beta1.EC2NodeClass) *v1beta1.EC2NodeClass {
if options.Spec.AMIFamily == nil {
options.Spec.AMIFamily = &v1beta1.AMIFamilyAL2
}
if options.Spec.AMISelectorTerms == nil {
options.Spec.AMISelectorTerms = append(options.Spec.AMISelectorTerms, v1beta1.AMISelectorTerm{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyAL2,
},
})
}
if options.Spec.Role == "" {
options.Spec.Role = "test-role"
options.Status.InstanceProfile = "test-profile"
Expand Down
5 changes: 5 additions & 0 deletions test/pkg/environment/aws/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ func GetTimeStreamAPI(session *session.Session) timestreamwriteiface.TimestreamW
func (env *Environment) DefaultEC2NodeClass() *v1beta1.EC2NodeClass {
nodeClass := test.EC2NodeClass()
nodeClass.Spec.AMIFamily = &v1beta1.AMIFamilyAL2023
nodeClass.Spec.AMISelectorTerms = []v1beta1.AMISelectorTerm{{
EKSOptimized: &v1beta1.EKSOptimized{
Family: v1beta1.AMIFamilyAL2023,
},
}}
nodeClass.Spec.Tags = map[string]string{
"testing/cluster": env.ClusterName,
}
Expand Down
Loading

0 comments on commit b51a4af

Please sign in to comment.