Skip to content

Commit

Permalink
Add focus and add indentation imported tests
Browse files Browse the repository at this point in the history
Signed-off-by: Parthvi Vala <[email protected]>
  • Loading branch information
valaparthvi committed Jan 28, 2025
1 parent fc6e3a6 commit 68abc38
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 79 deletions.
150 changes: 73 additions & 77 deletions hosted/gke/p1/p1_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,107 +33,103 @@ var _ = Describe("P1Import", func() {
}
})

When("a cluster is created", func() {
When("a cluster is created on cloud console", func() {
BeforeEach(func() {
var err error
err = helper.CreateGKEClusterOnGCloud(zone, clusterName, project, k8sVersion)
err := helper.CreateGKEClusterOnGCloud(zone, clusterName, project, k8sVersion)
Expect(err).To(BeNil())
})

It("User should not be able to import a cluster using an expired GKE creds", func() {
FIt("User should not be able to import a cluster using an expired GKE creds", func() {
testCaseID = 305
expiredCredCheck(cluster, ctx.RancherAdminClient)
})

It("User should not be able to import cluster with invalid GKE creds in Rancher", func() {
FIt("User should not be able to import cluster with invalid GKE creds in Rancher", func() {
testCaseID = 306
invalidCredCheck(cluster, ctx.RancherAdminClient)
})
})

When("a cluster is created and imported", func() {

BeforeEach(func() {
var err error
err = helper.CreateGKEClusterOnGCloud(zone, clusterName, project, k8sVersion)
Expect(err).To(BeNil())
When("the cluster is imported", func() {

cluster, err = helper.ImportGKEHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, zone, project)
Expect(err).To(BeNil())
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient)
Expect(err).To(BeNil())
})

It("should fail to reimport an imported cluster", func() {
testCaseID = 49
_, err := helper.ImportGKEHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, zone, project)
Expect(err).ToNot(BeNil())
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("cluster already exists for GKE cluster [%s] in zone [%s]", clusterName, zone)))
})

It("should be able to update mutable parameter", func() {
testCaseID = 52
By("disabling the services", func() {
updateLoggingAndMonitoringServiceCheck(cluster, ctx.RancherAdminClient, "none", "none")
})
By("enabling the services", func() {
updateLoggingAndMonitoringServiceCheck(cluster, ctx.RancherAdminClient, "monitoring.googleapis.com/kubernetes", "logging.googleapis.com/kubernetes")
BeforeEach(func() {
var err error
cluster, err = helper.ImportGKEHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, zone, project)
Expect(err).To(BeNil())
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient)
Expect(err).To(BeNil())
})
})

It("should be able to update autoscaling", func() {
testCaseID = 53
By("enabling autoscaling", func() {
updateAutoScaling(cluster, ctx.RancherAdminClient, true)
It("should fail to reimport an imported cluster", func() {
testCaseID = 49
_, err := helper.ImportGKEHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, zone, project)
Expect(err).ToNot(BeNil())
Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("cluster already exists for GKE cluster [%s] in zone [%s]", clusterName, zone)))
})
By("disabling autoscalling", func() {
updateAutoScaling(cluster, ctx.RancherAdminClient, false)

It("should be able to update mutable parameter", func() {
testCaseID = 52
By("disabling the services", func() {
updateLoggingAndMonitoringServiceCheck(cluster, ctx.RancherAdminClient, "none", "none")
})
By("enabling the services", func() {
updateLoggingAndMonitoringServiceCheck(cluster, ctx.RancherAdminClient, "monitoring.googleapis.com/kubernetes", "logging.googleapis.com/kubernetes")
})
})
})

It("should be able to reimport a deleted cluster", func() {
testCaseID = 57
err := helper.DeleteGKEHostCluster(cluster, ctx.RancherAdminClient)
Expect(err).To(BeNil())
clusterID := cluster.ID
Eventually(func() error {
_, err := ctx.RancherAdminClient.Management.Cluster.ByID(clusterID)
return err
}, "10s", "1s").ShouldNot(BeNil())
cluster, err = helper.ImportGKEHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, zone, project)
Expect(err).To(BeNil())
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient)
Expect(err).To(BeNil())
})
It("should be able to update autoscaling", func() {
testCaseID = 53
By("enabling autoscaling", func() {
updateAutoScaling(cluster, ctx.RancherAdminClient, true)
})
By("disabling autoscalling", func() {
updateAutoScaling(cluster, ctx.RancherAdminClient, false)
})
})

It("should successfully add a windows nodepool", func() {
testCaseID = 54
var err error
_, err = helper.AddNodePool(cluster, ctx.RancherAdminClient, 1, "WINDOWS_LTSC_CONTAINERD", true, true)
Expect(err).To(BeNil())
})
It("should be able to reimport a deleted cluster", func() {
testCaseID = 57
err := helper.DeleteGKEHostCluster(cluster, ctx.RancherAdminClient)
Expect(err).To(BeNil())
clusterID := cluster.ID
Eventually(func() error {
_, err := ctx.RancherAdminClient.Management.Cluster.ByID(clusterID)
return err
}, "10s", "1s").ShouldNot(BeNil())
cluster, err = helper.ImportGKEHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, zone, project)
Expect(err).To(BeNil())
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient)
Expect(err).To(BeNil())
})

It("updating a cluster to all windows nodepool should fail", func() {
testCaseID = 264
_, err := helper.UpdateCluster(cluster, ctx.RancherAdminClient, func(upgradedCluster *management.Cluster) {
updateNodePoolsList := cluster.GKEConfig.NodePools
for i := 0; i < len(updateNodePoolsList); i++ {
updateNodePoolsList[i].Config.ImageType = "WINDOWS_LTSC_CONTAINERD"
}
It("should successfully add a windows nodepool", func() {
testCaseID = 54
var err error
_, err = helper.AddNodePool(cluster, ctx.RancherAdminClient, 1, "WINDOWS_LTSC_CONTAINERD", true, true)
Expect(err).To(BeNil())
})

upgradedCluster.GKEConfig.NodePools = updateNodePoolsList
It("updating a cluster to all windows nodepool should fail", func() {
testCaseID = 264
_, err := helper.UpdateCluster(cluster, ctx.RancherAdminClient, func(upgradedCluster *management.Cluster) {
updateNodePoolsList := cluster.GKEConfig.NodePools
for i := 0; i < len(updateNodePoolsList); i++ {
updateNodePoolsList[i].Config.ImageType = "WINDOWS_LTSC_CONTAINERD"
}

upgradedCluster.GKEConfig.NodePools = updateNodePoolsList
})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("at least 1 Linux node pool is required"))
})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("at least 1 Linux node pool is required"))
})

It("should be able to update combination mutable parameter", func() {
testCaseID = 56
combinationMutableParameterUpdate(cluster, ctx.RancherAdminClient)
})
It("should be able to update combination mutable parameter", func() {
testCaseID = 56
combinationMutableParameterUpdate(cluster, ctx.RancherAdminClient)
})

It("should successfully update with new cloud credentials", func() {
updateCloudCredentialsCheck(cluster, ctx.RancherAdminClient)
It("should successfully update with new cloud credentials", func() {
updateCloudCredentialsCheck(cluster, ctx.RancherAdminClient)
})
})
})

Expand Down
4 changes: 2 additions & 2 deletions hosted/gke/p1/p1_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ var _ = Describe("P1Provisioning", func() {
Expect(err.Error()).To(ContainSubstring("InvalidFormat"))
})

It("User should not be able to add cluster with invalid GKE creds in Rancher", func() {
FIt("User should not be able to add cluster with invalid GKE creds in Rancher", func() {
testCaseID = 2
invalidCredCheck(cluster, ctx.RancherAdminClient)
})

It("User should not be able to add a cluster using an expired GKE creds", func() {
FIt("User should not be able to add a cluster using an expired GKE creds", func() {
testCaseID = 6
expiredCredCheck(cluster, ctx.RancherAdminClient)
})
Expand Down

0 comments on commit 68abc38

Please sign in to comment.