forked from openshift/rosa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCM-6314 | ci: Refactor day1 creation function for test
Fix comments Fix comment Remove the redunant func OCM-6314 | ci: Refactor day1 creation function for test Fix name prefix cannot be set issue
- Loading branch information
1 parent
b3f87d7
commit e7a5023
Showing
21 changed files
with
1,373 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ docs/ | |
/rosa-linux-arm64 | ||
/rosa-linux-arm64.sha256 | ||
/*policy.json | ||
/tests/output | ||
.envrc | ||
.env | ||
cover.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/openshift/rosa/tests/utils/common" | ||
. "github.com/openshift/rosa/tests/utils/log" | ||
) | ||
|
||
var Test *TestConfig | ||
|
||
// TestConfig contains platforms info for the rosacli testing | ||
type TestConfig struct { | ||
// Env is the OpenShift Cluster Management environment used to provision clusters. | ||
ENV string `env:"OCM_LOGIN_ENV" default:""` | ||
TestProfile string `env:"TEST_PROFILE" default:""` | ||
OutputDir string `env:"OUTPUT_DIR" default:""` | ||
YAMLProfilesDir string `env:"TEST_PROFILE_DIR" default:""` | ||
RootDir string `env:"WORKSPACE" default:""` | ||
ClusterConfigFile string | ||
ArtifactDir string `env:"ARTIFACT_DIR" default:""` | ||
UserDataFile string | ||
ClusterIDFile string // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
CreateCommandFile string | ||
APIURLFile string // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
ClusterNameFile string // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
ClusterTypeFile string // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
ConsoleUrlFile string // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
InfraIDFile string // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
ClusterDetailFile string | ||
ClusterInstallLogArtifactFile string | ||
ClusterAdminFile string | ||
GlobalENV *GlobalENVVariables | ||
} | ||
type GlobalENVVariables struct { | ||
ChannelGroup string `env:"CHANNEL_GROUP" default:""` | ||
Version string `env:"VERSION" default:""` | ||
Region string `env:"REGION" default:""` | ||
ProvisionShard string `env:"PROVISION_SHARD" default:""` | ||
NamePrefix string `env:"NAME_PREFIX"` | ||
ClusterWaitingTime int `env:"CLUSTER_TIMEOUT" default:"60"` | ||
} | ||
|
||
func init() { | ||
Test = new(TestConfig) | ||
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", path.Join(Test.RootDir, "tests", "ci", "data", "profiles")) | ||
Test.OutputDir = common.ReadENVWithDefaultValue("SHARED_DIR", path.Join(Test.RootDir, "tests", "output", Test.TestProfile)) | ||
Test.ArtifactDir = common.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()) | ||
} | ||
Test.ClusterConfigFile = path.Join(Test.OutputDir, "cluster-config") | ||
Test.UserDataFile = path.Join(Test.OutputDir, "resources.json") | ||
Test.APIURLFile = path.Join(Test.OutputDir, "api.url") | ||
Test.ClusterIDFile = path.Join(Test.OutputDir, "cluster-id") // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
Test.ClusterNameFile = path.Join(Test.OutputDir, "cluster-name") // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
Test.ClusterTypeFile = path.Join(Test.OutputDir, "cluster-type") // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
Test.ConsoleUrlFile = path.Join(Test.OutputDir, "console.url") // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
Test.InfraIDFile = path.Join(Test.OutputDir, "infra_id") // Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished | ||
Test.ClusterDetailFile = path.Join(Test.OutputDir, "cluster-detail.json") | ||
Test.ClusterInstallLogArtifactFile = path.Join(Test.ArtifactDir, ".install.log") | ||
Test.ClusterAdminFile = path.Join(Test.ArtifactDir, ".admin") | ||
|
||
waitingTime, err := strconv.Atoi(common.ReadENVWithDefaultValue("CLUSTER_TIMEOUT", "60")) | ||
if err != nil { | ||
panic(fmt.Errorf("env variable CLUSTER_TIMEOUT must be set to an integer")) | ||
} | ||
Test.GlobalENV = &GlobalENVVariables{ | ||
ChannelGroup: os.Getenv("CHANNEL_GROUP"), | ||
Version: os.Getenv("VERSION"), | ||
Region: os.Getenv("REGION"), | ||
ProvisionShard: os.Getenv("PROVISION_SHARD"), | ||
NamePrefix: os.Getenv("NAME_PREFIX"), | ||
ClusterWaitingTime: waitingTime, | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ profiles: | |
additional_sg_number: 3 | ||
account-role: | ||
path: "" | ||
permission_boundary: "" | ||
permission_boundary: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,42 @@ | ||
package e2e | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
. "github.com/openshift/rosa/tests/utils/log" | ||
TC "github.com/openshift/rosa/tests/ci/config" | ||
"github.com/openshift/rosa/tests/utils/exec/rosacli" | ||
"github.com/openshift/rosa/tests/utils/log" | ||
PH "github.com/openshift/rosa/tests/utils/profilehandler" | ||
) | ||
|
||
var _ = Describe("ROSA CLI Test", func() { | ||
Describe("Dummy test", func() { | ||
It("Dummy", func() { | ||
str := "dummy string" | ||
Expect(str).ToNot(BeEmpty()) | ||
Logger.Infof("This is a dummy test to check everything is fine by executing jobs. Please remove me once other tests are added") | ||
log.Logger.Infof("This is a dummy test to check everything is fine by executing jobs. Please remove me once other tests are added") | ||
}) | ||
}) | ||
Describe("Profile test", func() { | ||
It("ProfileParserTest", func() { | ||
profile := PH.LoadProfileYamlFileByENV() | ||
log.Logger.Infof("Got configured profile prefix: %v", *profile) | ||
log.Logger.Infof("Got configured profile: %v", profile.NamePrefix) | ||
log.Logger.Infof("Got configured cluster profile: %v", *profile.ClusterConfig) | ||
log.Logger.Infof("Got configured account role profile: %v", *profile.AccountRoleConfig) | ||
}) | ||
It("TestENVSetup", func() { | ||
log.Logger.Infof("Got dir of out: %v", TC.Test.OutputDir) | ||
}) | ||
It("TestPrepareClusterByProfile", func() { | ||
client := rosacli.NewClient() | ||
profile := PH.LoadProfileYamlFileByENV() | ||
cluster, err := PH.CreateClusterByProfile(profile, client, true) | ||
Expect(err).ToNot(HaveOccurred()) | ||
fmt.Println(cluster.ID) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package e2e | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/openshift/rosa/tests/ci/labels" | ||
"github.com/openshift/rosa/tests/utils/exec/rosacli" | ||
"github.com/openshift/rosa/tests/utils/log" | ||
PH "github.com/openshift/rosa/tests/utils/profilehandler" | ||
) | ||
|
||
var _ = Describe("ROSA CLI Test", func() { | ||
It("PrepareClusterByProfile", | ||
labels.Critical, | ||
labels.Day1Prepare, | ||
func() { | ||
client := rosacli.NewClient() | ||
profile := PH.LoadProfileYamlFileByENV() | ||
cluster, err := PH.CreateClusterByProfile(profile, client, true) | ||
Expect(err).ToNot(HaveOccurred()) | ||
log.Logger.Infof("Cluster prepared successfully with id %s", cluster.ID) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,40 @@ | ||
package constants | ||
|
||
import ( | ||
"regexp" | ||
) | ||
|
||
const ( | ||
ClusterDescriptionComputeDesired = "Compute (desired)" | ||
ClusterDescriptionComputeAutoscaled = "Compute (autoscaled)" | ||
) | ||
|
||
// role and OIDC config | ||
const ( | ||
MaxRolePrefixLength = 32 | ||
MaxOIDCConfigPrefixLength = 15 | ||
) | ||
|
||
// profile | ||
const ( | ||
DefaultNamePrefix = "rosacli-ci" | ||
) | ||
|
||
// cluster status | ||
const ( | ||
Ready = "ready" | ||
Installing = "installing" | ||
Waiting = "waiting" | ||
Pending = "pending" | ||
Error = "error" | ||
Uninstalling = "uninstalling" | ||
Validating = "validating" | ||
) | ||
|
||
// version pattern supported for the CI | ||
var ( | ||
VersionLatestPattern = regexp.MustCompile("latest") | ||
VersionMajorMinorPattern = regexp.MustCompile(`^[0-9]+\.[0-9]+$`) | ||
VersionRawPattern = regexp.MustCompile(`[0-9]+\.[0-9]+\.[0-9]+-?[0-9a-z\.-]*`) | ||
VersionFlexyPattern = regexp.MustCompile(`[xy]{1}-[1-3]{1}`) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package common | ||
|
||
import "os" | ||
|
||
func ReadENVWithDefaultValue(envName string, fallback string) string { | ||
if os.Getenv(envName) != "" { | ||
return os.Getenv(envName) | ||
} | ||
return fallback | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.