Skip to content

Commit

Permalink
OCM-11260 | ci: Move constants and rename common-helper package
Browse files Browse the repository at this point in the history
  • Loading branch information
radtriste committed Sep 20, 2024
1 parent c38480c commit 844632c
Show file tree
Hide file tree
Showing 46 changed files with 438 additions and 437 deletions.
18 changes: 9 additions & 9 deletions tests/ci/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"strings"

"github.com/openshift/rosa/tests/utils/common"
"github.com/openshift/rosa/tests/utils/helper"
. "github.com/openshift/rosa/tests/utils/log"
)

Expand Down Expand Up @@ -61,15 +61,15 @@ func init() {
currentDir, _ := os.Getwd()
project := "rosa"

Test.TestProfile = common.ReadENVWithDefaultValue("TEST_PROFILE", "")
Test.RootDir = common.ReadENVWithDefaultValue("WORKSPACE", strings.SplitAfter(currentDir, project)[0])
Test.YAMLProfilesDir = common.ReadENVWithDefaultValue("TEST_PROFILE_DIR",
Test.TestProfile = helper.ReadENVWithDefaultValue("TEST_PROFILE", "")
Test.RootDir = helper.ReadENVWithDefaultValue("WORKSPACE", strings.SplitAfter(currentDir, project)[0])
Test.YAMLProfilesDir = helper.ReadENVWithDefaultValue("TEST_PROFILE_DIR",
path.Join(Test.RootDir, "tests", "ci", "data", "profiles"))
Test.OutputDir = common.ReadENVWithDefaultValue("SHARED_DIR",
Test.OutputDir = helper.ReadENVWithDefaultValue("SHARED_DIR",
path.Join(Test.RootDir, "tests", "output", Test.TestProfile))
Test.ResourcesDir = common.ReadENVWithDefaultValue("RESOURCES_DIR",
Test.ResourcesDir = helper.ReadENVWithDefaultValue("RESOURCES_DIR",
path.Join(Test.RootDir, "tests", "ci", "data", "resources"))
Test.ArtifactDir = common.ReadENVWithDefaultValue("ARTIFACT_DIR", Test.OutputDir)
Test.ArtifactDir = helper.ReadENVWithDefaultValue("ARTIFACT_DIR", Test.OutputDir)
err := os.MkdirAll(Test.OutputDir, 0777)
if err != nil {
Logger.Errorf("Meet error %s when create output dirs", err.Error())
Expand All @@ -95,11 +95,11 @@ func init() {
Test.ProxySSHPemFile = "ocm-test-proxy"
Test.ProxyCABundleFile = path.Join(Test.OutputDir, "proxy-bundle.ca")

waitingTime, err := strconv.Atoi(common.ReadENVWithDefaultValue("CLUSTER_TIMEOUT", "60"))
waitingTime, err := strconv.Atoi(helper.ReadENVWithDefaultValue("CLUSTER_TIMEOUT", "60"))
if err != nil {
panic(fmt.Errorf("env variable CLUSTER_TIMEOUT must be set to an integer"))
}
waitSetupClusterReady, _ := strconv.ParseBool(common.ReadENVWithDefaultValue("WAIT_SETUP_CLUSTER_READY", "true"))
waitSetupClusterReady, _ := strconv.ParseBool(helper.ReadENVWithDefaultValue("WAIT_SETUP_CLUSTER_READY", "true"))
Test.GlobalENV = &GlobalENVVariables{
ChannelGroup: os.Getenv("CHANNEL_GROUP"),
Version: os.Getenv("VERSION"),
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/classic_tuning_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
. "github.com/onsi/gomega"

"github.com/openshift/rosa/tests/ci/labels"
"github.com/openshift/rosa/tests/utils/common"
"github.com/openshift/rosa/tests/utils/exec/rosacli"
"github.com/openshift/rosa/tests/utils/helper"
)

var _ = Describe("Tuning Config(s) on Classic cluster", labels.Feature.TuningConfigs, func() {
Expand Down Expand Up @@ -39,7 +39,7 @@ var _ = Describe("Tuning Config(s) on Classic cluster", labels.Feature.TuningCon
labels.Medium, labels.Runtime.Day2,
func() {
tuningConfigService := rosaClient.TuningConfig
tcName := common.GenerateRandomName("tuned01", 2)
tcName := helper.GenerateRandomName("tuned01", 2)
tcSpec := rosacli.NewTuningConfigSpecRootStub(tcName, 25, 10)

By("Create tuning config should fail")
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/dummy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
. "github.com/onsi/gomega"

ciConfig "github.com/openshift/rosa/tests/ci/config"
"github.com/openshift/rosa/tests/utils/common"
"github.com/openshift/rosa/tests/utils/config"
"github.com/openshift/rosa/tests/utils/exec/rosacli"
"github.com/openshift/rosa/tests/utils/helper"
. "github.com/openshift/rosa/tests/utils/log"
"github.com/openshift/rosa/tests/utils/profilehandler"
)
Expand Down Expand Up @@ -44,7 +44,7 @@ var _ = Describe("ROSA CLI Test", func() {
})
It("TestRemovingFunc", func() {
s := strings.Split("", ",")
s = common.RemoveFromStringSlice(s, "")
s = helper.RemoveFromStringSlice(s, "")
fmt.Println(len(s))
})
})
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

"github.com/openshift/rosa/tests/ci/config"
"github.com/openshift/rosa/tests/ci/labels"
"github.com/openshift/rosa/tests/utils/common"
utilConfig "github.com/openshift/rosa/tests/utils/config"
"github.com/openshift/rosa/tests/utils/exec/occli"
"github.com/openshift/rosa/tests/utils/exec/rosacli"
"github.com/openshift/rosa/tests/utils/helper"
"github.com/openshift/rosa/tests/utils/log"
"github.com/openshift/rosa/tests/utils/profilehandler"
)
Expand Down Expand Up @@ -59,7 +59,7 @@ var _ = Describe("Cluster preparation", labels.Feature.Cluster, func() {
output, err := client.BreakGlassCredential.GetIssuedCredential(clusterID, i.ID)
Expect(err).ToNot(HaveOccurred())
Expect(output.String()).ToNot(BeEmpty())
_, err = common.CreateFileWithContent(kubeconfigFile, output.String())
_, err = helper.CreateFileWithContent(kubeconfigFile, output.String())
Expect(err).ToNot(HaveOccurred())
break
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/hcp_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

ciConfig "github.com/openshift/rosa/tests/ci/config"
"github.com/openshift/rosa/tests/ci/labels"
"github.com/openshift/rosa/tests/utils/common/constants"
"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/profilehandler"
)
Expand Down
26 changes: 13 additions & 13 deletions tests/e2e/hcp_external_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
. "github.com/onsi/gomega"

"github.com/openshift/rosa/tests/ci/labels"
"github.com/openshift/rosa/tests/utils/common"
"github.com/openshift/rosa/tests/utils/exec/rosacli"
"github.com/openshift/rosa/tests/utils/helper"
)

var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider, func() {
Expand Down Expand Up @@ -61,9 +61,9 @@ var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider,
userNameList := []string{}

reqBody := map[string][]string{
"full": {"--username", common.GenerateRandomName("userName1", 2), "--expiration", "15m"},
"full": {"--username", helper.GenerateRandomName("userName1", 2), "--expiration", "15m"},
"emptyUsername": {"--expiration", "15m"},
"emptyExpiration": {"--username", common.GenerateRandomName("userName2", 2)},
"emptyExpiration": {"--username", helper.GenerateRandomName("userName2", 2)},
"empty": {},
}

Expand Down Expand Up @@ -172,29 +172,29 @@ var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider,
providerNameList := []string{}
var providerName string

caPath, err := common.CreateTempFileWithContent(ca)
caPath, err := helper.CreateTempFileWithContent(ca)
defer os.Remove(caPath)
Expect(err).ToNot(HaveOccurred())

reqBody := map[string][]string{
"simple": {
"--name", common.GenerateRandomName("provider1", 2),
"--name", helper.GenerateRandomName("provider1", 2),
"--issuer-url", issuerURL,
"--issuer-audiences", issuerAudience,
"--claim-mapping-username-claim", userNameClaim,
"--claim-mapping-groups-claim", groupClaim,
"--claim-validation-rule", claimValidationRuleClaim,
},
"with_ca": {
"--name", common.GenerateRandomName("provider2", 2),
"--name", helper.GenerateRandomName("provider2", 2),
"--issuer-url", issuerURL,
"--issuer-audiences", issuerAudience,
"--claim-mapping-username-claim", userNameClaim,
"--claim-mapping-groups-claim", groupClaim,
"--issuer-ca-file", caPath,
},
"with_client_parameters": {
"--name", common.GenerateRandomName("provider3", 2),
"--name", helper.GenerateRandomName("provider3", 2),
"--issuer-url", issuerURL,
"--issuer-audiences", issuerAudience,
"--claim-mapping-username-claim", userNameClaim,
Expand Down Expand Up @@ -282,7 +282,7 @@ var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider,

if !hosted {
By("Create a break-glass-credential to the cluster")
userName := common.GenerateRandomName("bgc-user-classic", 2)
userName := helper.GenerateRandomName("bgc-user-classic", 2)

resp, err := rosaClient.BreakGlassCredential.CreateBreakGlassCredential(
clusterID,
Expand Down Expand Up @@ -317,7 +317,7 @@ var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider,
Expect(err).ToNot(HaveOccurred())
if !externalAuthProvider {
By("Create a break-glass-credential to the cluster")
userName := common.GenerateRandomName("bgc-user-non-external", 2)
userName := helper.GenerateRandomName("bgc-user-non-external", 2)

resp, err := rosaClient.BreakGlassCredential.CreateBreakGlassCredential(
clusterID,
Expand Down Expand Up @@ -351,7 +351,7 @@ var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider,
} else if externalAuthProvider {

By("Create break-glass-credential with invalid --username")
userName := common.GenerateRandomName("bgc-user_", 2)
userName := helper.GenerateRandomName("bgc-user_", 2)

resp, err := rosaClient.BreakGlassCredential.CreateBreakGlassCredential(
clusterID,
Expand All @@ -367,7 +367,7 @@ var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider,
userName))

By("Create break-glass-credential with invalid --expiration")
userName = common.GenerateRandomName("bgc-user-invalid-exp", 2)
userName = helper.GenerateRandomName("bgc-user-invalid-exp", 2)
expirationTime := "2may"

resp, err = rosaClient.BreakGlassCredential.CreateBreakGlassCredential(
Expand All @@ -382,7 +382,7 @@ var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider,
expirationTime))

By("Create break-glass-credential with invalid expiration")
userName = common.GenerateRandomName("bgc-user-exp-1s", 2)
userName = helper.GenerateRandomName("bgc-user-exp-1s", 2)

resp, err = rosaClient.BreakGlassCredential.CreateBreakGlassCredential(
clusterID,
Expand Down Expand Up @@ -433,7 +433,7 @@ var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider,
"ERR: Deleting the 'cluster-admin' user is not supported for clusters with external authentication configured."))

By("Create idp on --external-auth-providers-enabled cluster")
idpName := common.GenerateRandomName("cluster-idp", 2)
idpName := helper.GenerateRandomName("cluster-idp", 2)
output, err = rosaClient.IDP.CreateIDP(clusterID, idpName, "--type", "htpasswd")
Expect(err).To(HaveOccurred())
textData = rosaClient.Parser.TextData.Input(output).Parse().Tip()
Expand Down
18 changes: 9 additions & 9 deletions tests/e2e/hcp_machine_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"github.com/openshift-online/ocm-common/pkg/test/vpc_client"

"github.com/openshift/rosa/tests/ci/labels"
"github.com/openshift/rosa/tests/utils/common"
"github.com/openshift/rosa/tests/utils/common/constants"
"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"
ph "github.com/openshift/rosa/tests/utils/profilehandler"
)

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

By("Prepare security groups")
// Configure with a random str, which can solve the rerun failure
sgPrefix := common.GenerateRandomName("72195", 2)
sgPrefix := helper.GenerateRandomName("72195", 2)
sgIDs, err := vpcClient.CreateAdditionalSecurityGroups(3, sgPrefix, "testing for case 72195")
Expect(err).ToNot(HaveOccurred())

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

By("Check the help message of machinepool creation")
mpID := common.GenerateRandomName("mp-73638", 2)
mpID := helper.GenerateRandomName("mp-73638", 2)
out, err := machinePoolService.CreateMachinePool(clusterID, mpID, "-h")
Expect(err).ToNot(HaveOccurred(), out.String())
Expect(out.String()).Should(ContainSubstring("--tags strings"))
Expand Down Expand Up @@ -219,7 +219,7 @@ var _ = Describe("HCP Machine Pool", labels.Feature.Machinepool, func() {

By("Create machinepool with " + amdOrArm + " instance " + instanceType)
mpPrefix := fmt.Sprintf("%v-60278", amdOrArm)
mpName := common.GenerateRandomName(mpPrefix, 2)
mpName := helper.GenerateRandomName(mpPrefix, 2)
desiredReplicas := 1
_, err := rosaClient.MachinePool.CreateMachinePool(clusterID, mpName,
"--instance-type", instanceType,
Expand Down Expand Up @@ -272,7 +272,7 @@ var _ = Describe("HCP Machine Pool", labels.Feature.Machinepool, func() {
DescribeTable("Scale up/down a machine pool with invalid replica", labels.Critical, labels.Runtime.Day2,
func(instanceType string, updatedReplicas string, expectedErrMsg string) {
By("Create machinepool with instance " + instanceType)
mpName := common.GenerateRandomName("mp-60278", 2)
mpName := helper.GenerateRandomName("mp-60278", 2)
desiredReplicas := 1
_, err := rosaClient.MachinePool.CreateMachinePool(clusterID, mpName,
"--instance-type", instanceType,
Expand Down Expand Up @@ -300,7 +300,7 @@ var _ = Describe("HCP Machine Pool", labels.Feature.Machinepool, func() {
By("Create machinepool with " + " instance " + instanceType + " and enable autoscale")

mpPrefix := "autoscale"
mpName := common.GenerateRandomName(mpPrefix, 2)
mpName := helper.GenerateRandomName(mpPrefix, 2)
minReplica := 1
maxReplica := 3
_, err := rosaClient.MachinePool.CreateMachinePool(clusterID, mpName,
Expand Down Expand Up @@ -350,7 +350,7 @@ var _ = Describe("HCP Machine Pool", labels.Feature.Machinepool, func() {
By("Create machinepool with" + " instance " + instanceType + " and enable autoscale")

mpPrefix := "autoscale"
mpName := common.GenerateRandomName(mpPrefix, 2)
mpName := helper.GenerateRandomName(mpPrefix, 2)
minReplica := 1
maxReplica := 2
_, err := rosaClient.MachinePool.CreateMachinePool(clusterID, mpName,
Expand Down Expand Up @@ -491,7 +491,7 @@ var _ = Describe("HCP Machine Pool", labels.Feature.Machinepool, func() {
Expect(err.Error()).Should(ContainSubstring("The subnet ID 'subnet-xxx' does not exist"))

By("with subnet not in VPC")
vpcPrefix := common.TrimNameByLength("c56786", 20)
vpcPrefix := helper.TrimNameByLength("c56786", 20)
vpc, err := vpc_client.PrepareVPC(vpcPrefix, profile.Region, constants.DefaultVPCCIDRValue, false, "")
Expect(err).ToNot(HaveOccurred())
defer vpc.DeleteVPCChain(true)
Expand Down
Loading

0 comments on commit 844632c

Please sign in to comment.