Skip to content

Commit

Permalink
Automate Qase 153, 151, and 87 (#241)
Browse files Browse the repository at this point in the history
* Automate Qase 153, 151, and 87

Signed-off-by: Parthvi Vala <[email protected]>

* Remove focus

Signed-off-by: Parthvi Vala <[email protected]>

* Add issue ref

Signed-off-by: Parthvi Vala <[email protected]>

* Requested changes: use ASCII

Co-authored-by: Parthvi Vala <[email protected]>
Co-authored-by: Tomas Hehejik <[email protected]>
Signed-off-by: Parthvi Vala <[email protected]>

* Fix sequential upgrade test

Signed-off-by: Parthvi Vala <[email protected]>

* Add focus

Signed-off-by: Parthvi Vala <[email protected]>

* Update hosted/eks/p1/p1_provisioning_test.go

Co-authored-by: Chandan Pinjani <[email protected]>
Signed-off-by: Parthvi Vala <[email protected]>

* Remove focus

Signed-off-by: Parthvi Vala <[email protected]>

---------

Signed-off-by: Parthvi Vala <[email protected]>
Signed-off-by: Parthvi Vala <[email protected]>
Co-authored-by: Tomas Hehejik <[email protected]>
Co-authored-by: Chandan Pinjani <[email protected]>
  • Loading branch information
3 people authored Jan 24, 2025
1 parent eba7b38 commit 5c029b1
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 13 deletions.
6 changes: 3 additions & 3 deletions hosted/eks/helper/helper_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func ScaleNodeGroup(cluster *management.Cluster, client *rancher.Client, nodeCou
// if checkClusterConfig is true, it validates the update
func UpdateLogging(cluster *management.Cluster, client *rancher.Client, loggingTypes []string, checkClusterConfig bool) (*management.Cluster, error) {
upgradedCluster := cluster
*upgradedCluster.EKSConfig.LoggingTypes = loggingTypes
upgradedCluster.EKSConfig.LoggingTypes = &loggingTypes

cluster, err := client.Management.Cluster.Update(cluster, &upgradedCluster)
Expect(err).To(BeNil())
Expand All @@ -335,8 +335,8 @@ func UpdateLogging(cluster *management.Cluster, client *rancher.Client, loggingT
// if checkClusterConfig is true, it validates the update
func UpdateAccess(cluster *management.Cluster, client *rancher.Client, publicAccess, privateAccess bool, checkClusterConfig bool) (*management.Cluster, error) {
upgradedCluster := cluster
*upgradedCluster.EKSConfig.PublicAccess = publicAccess
*upgradedCluster.EKSConfig.PrivateAccess = privateAccess
upgradedCluster.EKSConfig.PublicAccess = &publicAccess
upgradedCluster.EKSConfig.PrivateAccess = &privateAccess

cluster, err := client.Management.Cluster.Update(cluster, &upgradedCluster)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,8 @@ func commonchecks(ctx *helpers.RancherContext, cluster *management.Cluster, clus
cluster, err = helper.UpgradeClusterKubernetesVersion(cluster, *latestVersion, ctx.RancherAdminClient, true)
Expect(err).To(BeNil())

var useEksctl bool
if helpers.IsImport {
useEksctl = true
}
By("upgrading the NodeGroups", func() {
cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, *latestVersion, ctx.RancherAdminClient, true, true, useEksctl)
cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, *latestVersion, ctx.RancherAdminClient, true, true, helpers.IsImport)
Expect(err).To(BeNil())
})
})
Expand Down
6 changes: 1 addition & 5 deletions hosted/eks/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,8 @@ func p0upgradeK8sVersionChecks(cluster *management.Cluster, client *rancher.Clie
Expect(err).To(BeNil())
})

var useEksctl bool
if helpers.IsImport {
useEksctl = true
}
By("upgrading the NodeGroups", func() {
cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, upgradeToVersion, client, true, true, useEksctl)
cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, upgradeToVersion, client, true, true, helpers.IsImport)
Expect(err).To(BeNil())
})
}
Expand Down
17 changes: 17 additions & 0 deletions hosted/eks/p1/p1_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ var _ = Describe("P1Import", func() {
updateTagsAndLabels(cluster, ctx.RancherAdminClient)
})

It("Add a nodegroup in EKS -> Syncs to Rancher -> Update cluster, the nodegroup is intact", func() {
testCaseID = 87
nodepoolcount := len(cluster.EKSStatus.UpstreamSpec.NodeGroups)
err := helper.AddNodeGroupOnAWS(namegen.AppendRandomString("ng"), clusterName, region)
Expect(err).To(BeNil())
Eventually(func() bool {
cluster, err = ctx.RancherAdminClient.Management.Cluster.ByID(cluster.ID)
Expect(err).To(BeNil())
return len(cluster.EKSStatus.UpstreamSpec.NodeGroups) == nodepoolcount+1
}, "10m", "7s").Should(BeTrue(), "Timed out while waiting for rancher to sync")
cluster, err = helper.UpdateLogging(cluster, ctx.RancherAdminClient, []string{"authenticator"}, true)
Expect(err).To(BeNil())

// verify that the nodegroups are intact
Expect(cluster.EKSStatus.UpstreamSpec.NodeGroups).To(HaveLen(nodepoolcount + 1))
})

Context("Reimporting/Editing a cluster with invalid config", func() {
It("Reimport a cluster to Rancher should fail", func() {
testCaseID = 101
Expand Down
68 changes: 68 additions & 0 deletions hosted/eks/p1/p1_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3"
"github.com/rancher/shepherd/extensions/clusters"
"github.com/rancher/shepherd/extensions/clusters/eks"
namegen "github.com/rancher/shepherd/pkg/namegenerator"

Expand Down Expand Up @@ -168,6 +169,25 @@ var _ = Describe("P1Provisioning", func() {
Expect(amiID).To(Or(Equal("AL2_x86_64_GPU"), Equal("AL2023_x86_64_NVIDIA")))
})

XIt("Deploy a cluster with Public/Priv access then disable Public access", func() {
// https://github.com/rancher/eks-operator/issues/752#issuecomment-2609144199
testCaseID = 151
createFunc := func(clusterConfig *eks.ClusterConfig) {
clusterConfig.PublicAccess = pointer.Bool(true)
clusterConfig.PrivateAccess = pointer.Bool(true)
}
var err error
cluster, err = helper.CreateEKSHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, k8sVersion, region, createFunc)
Expect(err).To(BeNil())
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient)
Expect(err).To(BeNil())

cluster, err = helper.UpdateAccess(cluster, ctx.RancherAdminClient, false, true, true)
Expect(err).To(BeNil())

helpers.ClusterIsReadyChecks(cluster, ctx.RancherAdminClient, clusterName)
})

Context("Upgrade testing", func() {
var upgradeToVersion string

Expand Down Expand Up @@ -206,6 +226,54 @@ var _ = Describe("P1Provisioning", func() {
updateClusterInUpdatingState(cluster, ctx.RancherAdminClient, upgradeToVersion)
})
})

When("a cluster is created with multiple nodegroups", func() {
BeforeEach(func() {
var err error
createFunc := func(clusterConfig *eks.ClusterConfig) {
*clusterConfig, err = helper.AddNodeGroupToConfig(*clusterConfig, 4)
Expect(err).To(BeNil())
}
cluster, err = helper.CreateEKSHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, k8sVersion, region, createFunc)
Expect(err).To(BeNil())
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient)
Expect(err).To(BeNil())
})

It("Update k8s version of node groups - sequential & simultaneous upgrade of multiple node groups", func() {
testCaseID = 153
var err error
cluster, err = helper.UpgradeClusterKubernetesVersion(cluster, upgradeToVersion, ctx.RancherAdminClient, true)
Expect(err).To(BeNil())

// upgrade 2 nodegroups simultaneously
updateFunc := func(cluster *management.Cluster) {
nodeGroups := cluster.EKSConfig.NodeGroups
for i := 0; i <= 1; i++ {
nodeGroups[i].Version = &upgradeToVersion
}
}
cluster, err = helper.UpdateCluster(cluster, ctx.RancherAdminClient, updateFunc)
Expect(err).To(BeNil())
err = clusters.WaitClusterToBeUpgraded(ctx.RancherAdminClient, cluster.ID)
Expect(err).To(BeNil())
Eventually(func() bool {
cluster, err = ctx.RancherAdminClient.Management.Cluster.ByID(cluster.ID)
Expect(err).To(BeNil())
nodeGroups := cluster.EKSStatus.UpstreamSpec.NodeGroups
for i := 0; i <= 1; i++ {
if nodeGroups[i].Version == nil || *nodeGroups[i].Version != upgradeToVersion {
return false
}
}
return true
}, "10m", "7s").Should(BeTrue())

// upgrade the remaining nodegroups
cluster, err = helper.UpgradeNodeKubernetesVersion(cluster, upgradeToVersion, ctx.RancherAdminClient, true, true, false)
Expect(err).To(BeNil())
})
})
})

When("a cluster is created", func() {
Expand Down

0 comments on commit 5c029b1

Please sign in to comment.