Skip to content

Commit

Permalink
add integration tests for al2023
Browse files Browse the repository at this point in the history
  • Loading branch information
TiberiuGC committed Apr 3, 2024
1 parent de74c5b commit 0f3f294
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
33 changes: 31 additions & 2 deletions integration/tests/custom_ami/custom_ami_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestOverrideBootstrap(t *testing.T) {

var (
customAMIAL2 string
customAMIAL2023 string
customAMIBottlerocket string
)

Expand All @@ -47,15 +48,23 @@ var _ = BeforeSuite(func() {

// retrieve AL2 AMI
input := &awsssm.GetParameterInput{
Name: aws.String("/aws/service/eks/optimized-ami/1.22/amazon-linux-2/recommended/image_id"),
Name: aws.String(fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2/recommended/image_id", params.Version)),
}
output, err := ssm.GetParameter(context.Background(), input)
Expect(err).NotTo(HaveOccurred())
customAMIAL2 = *output.Parameter.Value

// retrieve AL2023 AMI
input = &awsssm.GetParameterInput{
Name: aws.String(fmt.Sprintf("/aws/service/eks/optimized-ami/%s/amazon-linux-2023/x86_64/standard/recommended/image_id", params.Version)),
}
output, err = ssm.GetParameter(context.Background(), input)
Expect(err).NotTo(HaveOccurred())
customAMIAL2023 = *output.Parameter.Value

// retrieve Bottlerocket AMI
input = &awsssm.GetParameterInput{
Name: aws.String("/aws/service/bottlerocket/aws-k8s-1.25/x86_64/latest/image_id"),
Name: aws.String(fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s/x86_64/latest/image_id", params.Version)),
}
output, err = ssm.GetParameter(context.Background(), input)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -75,6 +84,26 @@ var _ = BeforeSuite(func() {
var _ = Describe("(Integration) [Test Custom AMI]", func() {
params.LogStacksEventsOnFailure()

Context("al2023 managed and un-managed nodegroups", func() {
It("can create working nodegroups which can join the cluster", func() {
By(fmt.Sprintf("using the following EKS optimised AMI: %s", customAMIAL2023))
content, err := os.ReadFile(filepath.Join("testdata/al2023.yaml"))
Expect(err).NotTo(HaveOccurred())
content = bytes.ReplaceAll(content, []byte("<generated>"), []byte(params.ClusterName))
content = bytes.ReplaceAll(content, []byte("<generated-region>"), []byte(params.Region))
content = bytes.ReplaceAll(content, []byte("<generated-ami>"), []byte(customAMIAL2023))
cmd := params.EksctlCreateCmd.
WithArgs(
"nodegroup",
"--config-file", "-",
"--verbose", "4",
).
WithoutArg("--region", params.Region).
WithStdin(bytes.NewReader(content))
Expect(cmd).To(RunSuccessfully())
})
})

Context("override bootstrap command for managed and un-managed nodegroups", func() {

It("can create a working nodegroup which can join the cluster", func() {
Expand Down
19 changes: 19 additions & 0 deletions integration/tests/custom_ami/testdata/al2023.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

# name is generated
metadata:
name: <generated>
region: <generated-region>

nodeGroups:
- name: unm-al2023
ami: <generated-ami>
amiFamily: AmazonLinux2023
desiredCapacity: 1

managedNodeGroups:
- name: mng-al2023
ami: <generated-ami>
amiFamily: AmazonLinux2023
desiredCapacity: 1
27 changes: 27 additions & 0 deletions integration/tests/managed/managed_nodegroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var _ = Describe("(Integration) Create Managed Nodegroups", func() {

const (
updateConfigNodegroup = "ng-update-config"
al2023Nodegroup = "ng-al2023"
bottlerocketNodegroup = "ng-bottlerocket"
bottlerocketGPUNodegroup = "ng-bottlerocket-gpu"
ubuntuNodegroup = "ng-ubuntu"
Expand Down Expand Up @@ -302,6 +303,32 @@ var _ = Describe("(Integration) Create Managed Nodegroups", func() {
checkNg(bottlerocketGPUNodegroup)
})

It("supports AmazonLinux2023 nodegroups", func() {
clusterConfig := makeClusterConfig()
clusterConfig.ManagedNodeGroups = []*api.ManagedNodeGroup{
{
NodeGroupBase: &api.NodeGroupBase{
Name: al2023Nodegroup,
AMIFamily: "AmazonLinux2023",
},
},
}

By("creating it")
Expect(params.EksctlCreateCmd.
WithArgs(
"nodegroup",
"--config-file", "-",
"--verbose", "4",
).
WithoutArg("--region", params.Region).
WithStdin(clusterutils.Reader(clusterConfig))).
To(RunSuccessfully())

By("ensuring it is healthy")
checkNg(al2023Nodegroup)
})

It("supports bottlerocket and ubuntu nodegroups with additional volumes", func() {
clusterConfig := makeClusterConfig()
clusterConfig.ManagedNodeGroups = []*api.ManagedNodeGroup{
Expand Down

0 comments on commit 0f3f294

Please sign in to comment.