Skip to content

Commit

Permalink
OCM-8739 | test: fix for cluster configure file error
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraj7 committed Oct 8, 2024
1 parent 402028c commit 797359a
Show file tree
Hide file tree
Showing 8 changed files with 549 additions and 561 deletions.
56 changes: 0 additions & 56 deletions tests/e2e/hcp_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package e2e

import (
"fmt"
"strings"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand All @@ -13,7 +11,6 @@ import (
"github.com/openshift/rosa/tests/utils/config"
"github.com/openshift/rosa/tests/utils/constants"
"github.com/openshift/rosa/tests/utils/exec/rosacli"
"github.com/openshift/rosa/tests/utils/helper"
"github.com/openshift/rosa/tests/utils/profilehandler"
)

Expand Down Expand Up @@ -365,57 +362,4 @@ var _ = Describe("HCP cluster testing",
Expect(clusterDesc.OperatorIAMRoles).To(HaveEach(MatchRegexp("arn:aws:iam::[0-9]{12}:role/.+")))
Expect(clusterDesc.State).To(Equal(constants.Ready))
})

It("ROSA CLI cluster creation should show install/uninstall logs - [id:75534]",
labels.Critical,
labels.Runtime.Day1Supplemental,
func() {
clusterName := helper.GenerateRandomName("ocp-75534", 2)
flags, err := profilehandler.GenerateClusterCreateFlags(customProfile, rosaClient)
Expect(err).ToNot(HaveOccurred())

command := "rosa create cluster --cluster-name " + clusterName + " " + strings.Join(flags, " ")
rosalCommand := config.GenerateCommand(command)

stdout, err := rosaClient.Runner.RunCMD(strings.Split(rosalCommand.GetFullCommand(), " "))
Expect(err).To(BeNil())
Expect(stdout.String()).To(ContainSubstring(fmt.Sprintf("Cluster '%s' has been created", clusterName)))

By("wait for 5 minutes to install logs show up")
time.Sleep(5 * time.Minute)

By("Check the install logs of the hypershift cluster")
output, err := clusterService.InstallLog(clusterName)
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Version", clusterName))
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Release image is valid", clusterName))

By("Check the install logs of the hypershift cluster with flag --watch")
output, err = clusterService.InstallLog(clusterName, "--watch")
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Version", clusterName))
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Release image is valid", clusterName))
Expect(output.String()).Should(ContainSubstring("Cluster '%s' is now ready", clusterName))

By("Delete the Hypershift cluster")
output, err = clusterService.DeleteCluster(clusterName, "-y")
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("Cluster '%s' will start uninstalling now", clusterName))

By("wait for 2 minutes to uninstall logs show up")
time.Sleep(2 * time.Minute)

By("Check the uninstall log of the hosted cluster")
output, err = clusterService.UnInstallLog(clusterName)
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Reconciliation completed successfully",
clusterName))

By("Check the uninstall log of the hosted cluster with flag --watch")
output, err = clusterService.UnInstallLog(clusterName, "--watch")
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Reconciliation completed successfully",
clusterName))
Expect(output.String()).Should(ContainSubstring("Cluster '%s' completed uninstallation", clusterName))
})
})
16 changes: 8 additions & 8 deletions tests/e2e/hcp_machine_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var _ = Describe("HCP Machine Pool", labels.Feature.Machinepool, func() {
var (
rosaClient *rosacli.Client
machinePoolService rosacli.MachinePoolService
clusterConfig *config.ClusterConfig
profile *ph.Profile
isMultiArch bool
)
Expand All @@ -40,10 +39,6 @@ var _ = Describe("HCP Machine Pool", labels.Feature.Machinepool, func() {
rosaClient = rosacli.NewClient()
machinePoolService = rosaClient.MachinePool

By("Retrieve Cluster config")
clusterConfig, err = config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

By("Skip testing if the cluster is not a HCP cluster")
hostedCluster, err := rosaClient.Cluster.IsHostedCPCluster(clusterID)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -633,12 +628,17 @@ var _ = Describe("HCP Machine Pool", labels.Feature.Machinepool, func() {
It("creation in local zone subnet - [id:71319]",
labels.Medium, labels.Runtime.Day2,
func() {
var vpcClient *vpc_client.VPC
var err error

By("Retrieve cluster config")
clusterConfig, err := config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

By("Prepare a subnet out of the cluster creation subnet")
subnets := helper.ParseCommaSeparatedStrings(clusterConfig.Subnets.PrivateSubnetIds)

By("Build vpc client to find a local zone for subnet preparation")
var vpcClient *vpc_client.VPC
var err error
vpcClient, err = vpc_client.GenerateVPCBySubnet(subnets[0], clusterConfig.Region)
Expect(err).ToNot(HaveOccurred())

Expand Down Expand Up @@ -678,7 +678,7 @@ var _ = Describe("HCP Machine Pool", labels.Feature.Machinepool, func() {
versionService := rosaClient.Version

By("Retrieve cluster config")
clusterConfig, err = config.ParseClusterProfile()
clusterConfig, err := config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

By("without machinepool")
Expand Down
30 changes: 8 additions & 22 deletions tests/e2e/rosa_autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,27 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() {
var rosaClient *rosacli.Client
var clusterService rosacli.ClusterService
var clusterConfig *config.ClusterConfig
var hostedCluster bool
var err error

BeforeEach(func() {
Expect(clusterID).ToNot(BeEmpty(), "Cluster ID is empty, please export the env variable CLUSTER_ID")
rosaClient = rosacli.NewClient()
clusterService = rosaClient.Cluster

hostedCluster, err = clusterService.IsHostedCPCluster(clusterID)
Expect(err).ToNot(HaveOccurred())

clusterConfig, err = config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())
})

Describe("creation testing", func() {
BeforeEach(func() {
hostedCluster, err := clusterService.IsHostedCPCluster(clusterID)
Expect(err).ToNot(HaveOccurred())

clusterConfig, err = config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

By("Skip testing if the cluster is not a Classic cluster")
if hostedCluster {
SkipNotClassic()
}

})

It("create/describe/edit/delete cluster autoscaler by rosacli - [id:67275]",
Expand Down Expand Up @@ -242,9 +243,6 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() {

It("for hcp cluster",
func() {
hostedCluster, err := clusterService.IsHostedCPCluster(clusterID)
Expect(err).ToNot(HaveOccurred())

if !hostedCluster {
SkipNotHosted()
}
Expand Down Expand Up @@ -312,12 +310,6 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() {

It("for classic non-autoscaler cluster",
func() {
clusterConfig, err := config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

hostedCluster, err := clusterService.IsHostedCPCluster(clusterID)
Expect(err).ToNot(HaveOccurred())

if hostedCluster {
SkipNotClassic()
}
Expand Down Expand Up @@ -651,12 +643,6 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() {
It("create/describe/edit/delete autoscaler for autoscaler enabled cluster - [id:74468]",
labels.Medium, labels.Runtime.Day1Post,
func() {
hostedCluster, err := clusterService.IsHostedCPCluster(clusterID)
Expect(err).ToNot(HaveOccurred())

clusterConfig, err := config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

if hostedCluster {
SkipNotClassic()
}
Expand Down
88 changes: 70 additions & 18 deletions tests/e2e/test_rosacli_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ var _ = Describe("Edit cluster",
rosaClient *rosacli.Client
clusterService rosacli.ClusterService
// upgradeService rosacli.UpgradeService
clusterConfig *config.ClusterConfig
profile *profilehandler.Profile
profile *profilehandler.Profile
)

BeforeEach(func() {
Expand All @@ -52,11 +51,6 @@ var _ = Describe("Edit cluster",
clusterService = rosaClient.Cluster
// upgradeService = rosaClient.Upgrade

By("Load the original cluster config")
var err error
clusterConfig, err = config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

By("Load the profile")
profile = profilehandler.LoadProfileYamlFileByENV()
})
Expand Down Expand Up @@ -202,6 +196,10 @@ var _ = Describe("Edit cluster",
It("can disable workload monitoring on/off - [id:45159]",
labels.High, labels.Runtime.Day2,
func() {
By("Load the original cluster config")
clusterConfig, err := config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

By("Check the cluster UWM is in expected status")
output, err := clusterService.DescribeCluster(clusterID)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -398,6 +396,10 @@ var _ = Describe("Edit cluster",

It("can edit proxy successfully - [id:46308]", labels.High, labels.Runtime.Day2,
func() {
By("Load the original cluster config")
clusterConfig, err := config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

var verifyProxy = func(httpProxy string, httpsProxy string, noProxy string, caFile string) {
clusterDescription, err := clusterService.DescribeClusterAndReflect(clusterID)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -433,7 +435,7 @@ var _ = Describe("Edit cluster",
updateHttpsProxy := "https://example.com"
updatedNoProxy := "example.com"
updatedCA := ""
_, err := clusterService.EditCluster(clusterID,
_, err = clusterService.EditCluster(clusterID,
"--http-proxy", updateHttpProxy,
"--https-proxy", updateHttpsProxy,
"--no-proxy", updatedNoProxy,
Expand Down Expand Up @@ -490,8 +492,6 @@ var _ = Describe("Edit cluster validation should", labels.Feature.Cluster, func(
rosaClient *rosacli.Client
clusterService rosacli.ClusterService
upgradeService rosacli.UpgradeService
clusterConfig *config.ClusterConfig
profile *profilehandler.Profile
)

BeforeEach(func() {
Expand All @@ -503,14 +503,6 @@ var _ = Describe("Edit cluster validation should", labels.Feature.Cluster, func(
rosaClient = rosacli.NewClient()
clusterService = rosaClient.Cluster
upgradeService = rosaClient.Upgrade

By("Load the original cluster config")
var err error
clusterConfig, err = config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

By("Load the profile")
profile = profilehandler.LoadProfileYamlFileByENV()
})

AfterEach(func() {
Expand Down Expand Up @@ -644,6 +636,13 @@ var _ = Describe("Edit cluster validation should", labels.Feature.Cluster, func(

It("can validate cluster proxy well - [id:46310]", labels.Medium, labels.Runtime.Day2,
func() {
By("Load the original cluster config")
clusterConfig, err := config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

By("Load the profile")
profile := profilehandler.LoadProfileYamlFileByENV()

By("Edit cluster with invalid http_proxy set")
if !profile.ClusterConfig.BYOVPC {
output, err := clusterService.EditCluster(clusterID,
Expand Down Expand Up @@ -3528,6 +3527,59 @@ var _ = Describe("HCP cluster creation supplemental testing",
Expect(clusterID).ToNot(BeNil())
})

It("ROSA CLI cluster creation should show install/uninstall logs - [id:75534]",
labels.Critical,
labels.Runtime.Day1Supplemental,
func() {
clusterName := helper.GenerateRandomName("ocp-75534", 2)
flags, err := profilehandler.GenerateClusterCreateFlags(customProfile, rosaClient)
Expect(err).ToNot(HaveOccurred())

command := "rosa create cluster --cluster-name " + clusterName + " " + strings.Join(flags, " ")
rosalCommand := config.GenerateCommand(command)

stdout, err := rosaClient.Runner.RunCMD(strings.Split(rosalCommand.GetFullCommand(), " "))
Expect(err).To(BeNil())
Expect(stdout.String()).To(ContainSubstring(fmt.Sprintf("Cluster '%s' has been created", clusterName)))

By("wait for 5 minutes to install logs show up")
time.Sleep(5 * time.Minute)

By("Check the install logs of the hypershift cluster")
output, err := clusterService.InstallLog(clusterName)
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Version", clusterName))
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Release image is valid", clusterName))

By("Check the install logs of the hypershift cluster with flag --watch")
output, err = clusterService.InstallLog(clusterName, "--watch")
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Version", clusterName))
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Release image is valid", clusterName))
Expect(output.String()).Should(ContainSubstring("Cluster '%s' is now ready", clusterName))

By("Delete the Hypershift cluster")
output, err = clusterService.DeleteCluster(clusterName, "-y")
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("Cluster '%s' will start uninstalling now", clusterName))

By("wait for 2 minutes to uninstall logs show up")
time.Sleep(2 * time.Minute)

By("Check the uninstall log of the hosted cluster")
output, err = clusterService.UnInstallLog(clusterName)
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Reconciliation completed successfully",
clusterName))

By("Check the uninstall log of the hosted cluster with flag --watch")
output, err = clusterService.UnInstallLog(clusterName, "--watch")
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Reconciliation completed successfully",
clusterName))
Expect(output.String()).Should(ContainSubstring("Cluster '%s' completed uninstallation", clusterName))
})

It("Check single AZ hosted cluster can be created - [id:54413]",
labels.Critical, labels.Runtime.Day1Supplemental,
func() {
Expand Down
Loading

0 comments on commit 797359a

Please sign in to comment.