Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run all integration test in parallel #1912

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 44 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ COMMON_FLAGS := -X $(PROJECT)/pkg/odo/cli/version.GITCOMMIT=$(GITCOMMIT)
BUILD_FLAGS := -ldflags="-w $(COMMON_FLAGS)"
DEBUG_BUILD_FLAGS := -ldflags="$(COMMON_FLAGS)"
FILES := odo dist
TIMEOUT ?= 1800s
TIMEOUT ?= 7200s

# Env variable TEST_EXEC_NODES is used to pass spec execution type
# (parallel or sequential) for ginkgo tests. To run the specs sequentially use
Expand Down Expand Up @@ -113,89 +113,114 @@ test:
# Run generic integration tests
.PHONY: test-generic
test-generic:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo generic" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo generic" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run json outout tests
.PHONY: test-json-format-output
test-json-format-output:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odojsonoutput" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odojsonoutput" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run component e2e tests
.PHONY: test-cmp-e2e
test-cmp-e2e:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmpE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmpE2e" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run component subcommands e2e tests
.PHONY: test-cmp-sub-e2e
test-cmp-sub-e2e:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmpSubE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmpSubE2e" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run java e2e tests
.PHONY: test-java-e2e
test-java-e2e:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoJavaE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoJavaE2e" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run source e2e tests
.PHONY: test-source-e2e
test-source-e2e:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoSourceE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoSourceE2e" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run service catalog e2e tests
.PHONY: test-service-e2e
test-service-e2e:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoServiceE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoServiceE2e" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/servicecatalog/ -timeout $(TIMEOUT)

# Run link e2e tests
.PHONY: test-link-e2e
test-link-e2e:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoLinkE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoLinkE2e" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/servicecatalog/ -timeout $(TIMEOUT)

# Run watch e2e tests
.PHONY: test-watch-e2e
test-watch-e2e:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoWatchE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoWatchE2e" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run storage command integration tests
.PHONY: test-cmd-storage
test-cmd-storage:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo storage command" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo storage command" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run odo app cmd tests
.PHONY: test-cmd-app
test-cmd-app:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmdApp" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmdApp" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run login e2e tests
# This test shouldn't run spec in paralel because it will break the test behaviour
# due to race condition in parallel run.
.PHONY: test-odo-login-e2e
test-odo-login-e2e:
ginkgo -v -nodes=1 -focus="odoLoginE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=1 -focus="odoLoginE2e" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/loginlogout/ -timeout $(TIMEOUT)

# Run config tests
.PHONY: test-odo-config
test-odo-config:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo config test" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo config test" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run all integration tests
# Run command's integration tests irrespective of service catalog status in the cluster.
# Service, link and login/logout command tests are not the part of this test run
.PHONY: test-integration
test-integration:
go test -v github.com/openshift/odo/tests/integration -ginkgo.slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -ginkgo.v -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run command's integration tests which are depend on service catalog enabled cluster.
# Only service and link command tests are the part of this test run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for explicitly adding this. Thanks!

.PHONY: test-integration-service-catalog
test-integration-service-catalog:
ginkgo -v -nodes=$(TEST_EXEC_NODES) \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/servicecatalog -timeout $(TIMEOUT)

# Run url integreation tests
.PHONY: test-odo-url-int
test-odo-url-int:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoURLIntegration" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoURLIntegration" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run push command e2e
.PHONY: test-cmd-push
test-cmd-push:
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo push command tests" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo push command tests" \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)

# Run e2e test scenarios
.PHONY: test-e2e-scenarios
test-e2e-scenarios:
ginkgo -v -nodes=$(TEST_EXEC_NODES) slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/e2escenarios/ -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -randomizeAllSpecs \
slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) tests/e2escenarios/ -timeout $(TIMEOUT)

# this test shouldn't be in paralel - it will effect the results
.PHONY: test-benchmark
Expand Down
27 changes: 25 additions & 2 deletions docs/development.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ $ make test-source-e2e

* To run the tests sequentially or on single ginkgo test node use enviornment variable `TEST_EXEC_NODES`:
+

NOTE: However the env variable `TEST_EXEC_NODES` can be used to increase or decrease any number of test node for parallel run depending on the resource allocated to the OpenShift cluster. Make sure that the `TEST_EXEC_NODES` value cannot be `0` or any `negative` value.
+

Run component command integration tests
+
----
Expand Down Expand Up @@ -354,14 +358,33 @@ $ make test-odo-login-e2e

NOTE: `make test-odo-login-e2e` doesn't honour environment variable `TEST_EXEC_NODES`. So by default it runs login and logout command integration test suite on a single ginkgo test node sequentially to avoid race conditions in a parallel run.

* For the entire integration test suite:
Entire integration tests suite can be run in parallel and sequentially separately:

* To run entire integration tests spec in parallel (default: 2 ginkgo test node), on a test cluster:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also mention how someone can set the value to something other than 2 if it's relevant for their environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, i can put a note or a place where it fits better in the doc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

+
----
$ make test-integration-service-catalog
----
+

----
$ make test-integration
----
+

NOTE: `make test-integration` doesn't honour enviornment variable `TEST_EXEC_NODES`. So by default it runs the entire integration test suite on a single ginkgo test node sequentially.
* To run entire integration tests spec sequentially or on single ginkgo test node use enviornment variable `TEST_EXEC_NODES`:
+
----
$ TEST_EXEC_NODES=1 make test-integration-service-catalog
----
+

----
$ TEST_EXEC_NODES=1 make test-integration
----
+

NOTE: `make test-integration-service-catalog` includes only service and link tests and can be successfully validated only if the cluster has service catalog enabled. Whereas `make test-integration` includes tests except service, link, login tests and runs rest of the tests irrespective of service catalog status in the cluster.

Similarly e2e (end to end) tests can be run in parallel and sequentially separately.

Expand Down
12 changes: 6 additions & 6 deletions pkg/preference/preference.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ func NewPreference() Preference {
// NewPreferenceInfo gets the PreferenceInfo from preference file and creates the preference file in case it's
// not present
func NewPreferenceInfo() (*PreferenceInfo, error) {
configFile, err := getPreferenceFile()
glog.V(4).Infof("The configFile is %+v", configFile)
preferenceFile, err := getPreferenceFile()
glog.V(4).Infof("The preference file is %+v", preferenceFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! No more configFile vs. preferenceFile confusion. 😄

if err != nil {
return nil, errors.Wrap(err, "unable to get odo config file")
return nil, errors.Wrap(err, "unable to get odo preference file")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also change https://github.com/openshift/odo/pull/1912/files#diff-5f21db40ee2e66f00f206912f4dddc2fR116 to write preferenceFile instead of configFile? Using configFile and preferenceFile interchangeably could cause ambiguity, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, I am going to update it in the next commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

c := PreferenceInfo{
Preference: NewPreference(),
Filename: configFile,
Filename: preferenceFile,
}
// if the config file doesn't exist then we dont worry about it and return
if _, err = os.Stat(configFile); os.IsNotExist(err) {
// if the preference file doesn't exist then we dont worry about it and return
if _, err = os.Stat(preferenceFile); os.IsNotExist(err) {
return &c, nil
}

Expand Down
2 changes: 1 addition & 1 deletion tests/e2escenarios/core_beta_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ var _ = Describe("Core beta flow", func() {
oc = helper.NewOcRunner("oc")
odo = "odo"

project = helper.CreateRandProject()
context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml"))
project = helper.CreateRandProject()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what impact does this have whether we create a project earlier or later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just to make sure that the set global preference path is used in the project creation step though there is no validation done for it. But if you keep the project create step as it was then project creation step picks the default preference path (~/.odo/preference.yaml) and then the very next odo command start picking the preference path from newly set path.

So i cleaned up this in all test file and later i will create some fresh spec where the validation will be done including all possible cases without duplicating the scenario.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for another discussion, but I think that CreateRandProject should be using oc not odo.

})

AfterEach(func() {
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/cmd_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ var _ = Describe("odoCmdApp", func() {
var _ = BeforeEach(func() {
SetDefaultEventuallyTimeout(10 * time.Minute)
SetDefaultConsistentlyDuration(30 * time.Second)
project = helper.CreateRandProject()
context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml"))
project = helper.CreateRandProject()
originalDir = helper.Getwd()
})

Expand Down Expand Up @@ -61,6 +61,11 @@ var _ = Describe("odoCmdApp", func() {
})

Context("when running app command without app parameter in directory that contains .odo config directory", func() {

JustAfterEach(func() {
helper.Chdir(originalDir)
})

It("should successfuly execute list, describe and delete along with machine readable output", func() {
helper.CopyExample(filepath.Join("source", "nodejs"), context)
helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)
Expand All @@ -80,7 +85,6 @@ var _ = Describe("odoCmdApp", func() {
Expect(desiredDesAppJSON).Should(MatchJSON(actualDesAppJSON))

helper.CmdShouldPass("odo", "app", "delete", "-f")
helper.Chdir(originalDir)
})
})

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/cmd_pref_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ var _ = Describe("odo config test", func() {

Context("when creating odo local config in the same config dir", func() {
JustBeforeEach(func() {
project = helper.CreateRandProject()
context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "preference.yaml"))
project = helper.CreateRandProject()
originalDir = helper.Getwd()
helper.Chdir(context)
})
Expand Down Expand Up @@ -161,9 +161,9 @@ var _ = Describe("odo config test", func() {

Context("when creating odo local config with context flag", func() {
JustBeforeEach(func() {
project = helper.CreateRandProject()
context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "preference.yaml"))
project = helper.CreateRandProject()
})
JustAfterEach(func() {
helper.DeleteProject(project)
Expand Down Expand Up @@ -239,9 +239,9 @@ var _ = Describe("odo config test", func() {

Context("when creating odo local config with env variables", func() {
JustBeforeEach(func() {
project = helper.CreateRandProject()
context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "preference.yaml"))
project = helper.CreateRandProject()
})
JustAfterEach(func() {
helper.DeleteProject(project)
Expand All @@ -266,9 +266,9 @@ var _ = Describe("odo config test", func() {

Context("when viewing local config without logging into the OpenShift cluster", func() {
JustBeforeEach(func() {
project = helper.CreateRandProject()
context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "preference.yaml"))
project = helper.CreateRandProject()
})
JustAfterEach(func() {
helper.DeleteProject(project)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cmd_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ var _ = Describe("odo storage command", func() {
var _ = BeforeEach(func() {
SetDefaultEventuallyTimeout(10 * time.Minute)
SetDefaultConsistentlyDuration(30 * time.Second)
project = helper.CreateRandProject()
context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml"))
project = helper.CreateRandProject()
oc = helper.NewOcRunner("oc")
})

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cmd_watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ var _ = Describe("odoWatchE2e", func() {
BeforeEach(func() {
SetDefaultEventuallyTimeout(10 * time.Minute)
SetDefaultConsistentlyDuration(30 * time.Second)
project = helper.CreateRandProject()
context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml"))
project = helper.CreateRandProject()
})

// Clean up after the test
Expand Down
Loading