Skip to content

Commit

Permalink
OCM-6708 | ci: Enable lint check on e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
radtriste committed Jun 25, 2024
1 parent 921d50f commit d78f09a
Show file tree
Hide file tree
Showing 48 changed files with 1,803 additions and 823 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ install:

.PHONY: fmt
fmt: fmt-imports
gofmt -s -l -w cmd pkg
gofmt -s -l -w cmd pkg tests

.PHONY: fmt-imports
fmt-imports: $(GCI)
find . -name '*.go' -not -path './vendor/*' | xargs $(GCI) write -s standard -s default -s "prefix(k8s)" -s "prefix(sigs.k8s)" -s "prefix(github.com)" -s "prefix(gitlab)" -s "prefix(github.com/openshift/rosa)" --custom-order --skip-generated

.PHONY: lint
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --timeout 5m0s --skip-dirs tests ./...
$(GOLANGCI_LINT) run --timeout 5m0s ./...

.PHONY: commits/check
commits/check:
Expand Down
52 changes: 30 additions & 22 deletions tests/ci/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ 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
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
CreateCommandFile string
// Temporary file to compatible to current CI jobs. Will remove once all CI jobs migration finished
ClusterIDFile string
APIURLFile string
ClusterNameFile string
ClusterTypeFile string
ConsoleUrlFile string
InfraIDFile string
// End of temporary
ClusterDetailFile string
ClusterInstallLogArtifactFile string
ClusterAdminFile string
Expand All @@ -56,8 +58,10 @@ func init() {

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.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 {
Expand All @@ -66,11 +70,15 @@ func init() {
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

// Temporary files to compatible to current CI jobs. Will remove once all CI jobs migration finished
Test.ClusterIDFile = path.Join(Test.OutputDir, "cluster-id")
Test.ClusterNameFile = path.Join(Test.OutputDir, "cluster-name")
Test.ClusterTypeFile = path.Join(Test.OutputDir, "cluster-type")
Test.ConsoleUrlFile = path.Join(Test.OutputDir, "console.url")
Test.InfraIDFile = path.Join(Test.OutputDir, "infra_id")
// End of temporary

Test.CreateCommandFile = path.Join(Test.OutputDir, "create_cluster.sh")
Test.ClusterDetailFile = path.Join(Test.OutputDir, "cluster-detail.json")
Test.ClusterInstallLogArtifactFile = path.Join(Test.ArtifactDir, ".install.log")
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/dummy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var _ = Describe("ROSA CLI 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")
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() {
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/e2e_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
. "github.com/onsi/ginkgo/v2"

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

var _ = Describe("Report", func() {
It("report-portal", labels.E2EReport, func() {
rosacli.GenerateReportXMLFile()
rosacli.GenerateReportLog()
reportportal.GenerateReportXMLFile()
reportportal.GenerateReportLog()
})
})
8 changes: 6 additions & 2 deletions tests/e2e/hcp_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,15 @@ var _ = Describe("HCP cluster testing",
output, err = rosaClient.User.CreateAdmin(clusterID)
Expect(err).ToNot(BeNil())
textData := rosaClient.Parser.TextData.Input(output).Parse().Tip()
Expect(textData).Should(ContainSubstring("ERR: Creating the 'cluster-admin' user is not supported for clusters with external authentication configured"))
Expect(textData).
Should(ContainSubstring(
"ERR: Creating the 'cluster-admin' user is not supported for clusters with external authentication configured"))

_, output, err = rosaClient.IDP.ListIDP(clusterID)
Expect(err).ToNot(BeNil())
textData = rosaClient.Parser.TextData.Input(output).Parse().Tip()
Expect(textData).Should(ContainSubstring("ERR: Listing identity providers is not supported for clusters with external authentication configured"))
Expect(textData).
Should(ContainSubstring(
"ERR: Listing identity providers is not supported for clusters with external authentication configured"))
})
})
Loading

0 comments on commit d78f09a

Please sign in to comment.