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 component test in parallel #1797

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
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,18 @@ test-generic:
test-json-format-output:
go test -v github.com/openshift/odo/tests/integration --ginkgo.focus="odojsonoutput" -ginkgo.slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -ginkgo.v -timeout $(TIMEOUT)

# -randomizeAllSpecs - If set, ginkgo will randomize all specs together.
# By default, ginkgo only randomizes the top level Describe, Context and When groups.

# Run component e2e tests
.PHONY: test-cmp-e2e
test-cmp-e2e:
go test -v github.com/openshift/odo/tests/integration --ginkgo.focus="odoCmpE2e" -ginkgo.slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -ginkgo.v -timeout $(TIMEOUT)
ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmpE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT)
Copy link
Member

Choose a reason for hiding this comment

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

why are we now randomizing? you need to document this in your PR description / 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.


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

# Run java e2e tests
.PHONY: test-java-e2e
Expand Down Expand Up @@ -166,9 +169,9 @@ test-odo-login-e2e:
test-odo-config:
go test -v github.com/openshift/odo/tests/integration --ginkgo.focus="odo config test" -ginkgo.slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -ginkgo.v -timeout $(TIMEOUT)

# Run all e2e tests
.PHONY: test-e2e
test-e2e:
# Run all integration tests
.PHONY: test-integration
test-integration:
go test -v github.com/openshift/odo/tests/integration -ginkgo.slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -ginkgo.v -timeout $(TIMEOUT)

# Run e2e test scenarios
Expand Down
33 changes: 17 additions & 16 deletions docs/development.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -158,35 +158,36 @@ $ MINISHIFT_ENABLE_EXPERIMENTAL=y minishift start --extra-clusterup-flags "--ena

* `odo` and `oc` binaries in `$PATH`.

.Procedure:

To deploy an integration test:
.How to write:

Refer to the odo clean test link:https://github.com/openshift/odo/blob/master/tests/template/template_cleantest_test.go[`template`].

* For the entire integration suite use:
----
$ make test-e2e
Copy link
Member

Choose a reason for hiding this comment

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

@amitkrout again, you're removing documentation and not adding it again... no documentation on make test-integration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh...my bad. Will update it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

----
.Procedure:

* For the generic tests use:
----
$ make test-generic
----
Integration tests can be run in the following two ways:

* For the component tests use:
* To run the component test in parallel (default: 4 ginkgo test node), on a test cluster :
+
----
$ make test-cmp-e2e
----
+

* For the service catalog tests use:
* To run component test sequentially or on single ginkgo test node use enviornment variable `TEST_EXEC_NODES`:
+
----
$ make test-service-e2e
$ make test-cmp-e2e TEST_EXEC_NODES=1
----
+

* For the e2e scenario test use:
* For the entire integration test suite use:
+
----
$ make test-e2e-scenarios
$ 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.

You can run a subset of tests with ginkgo by using focused specs mechanism https://onsi.github.io/ginkgo/#focused-specs

Expand Down
File renamed without changes.
110 changes: 45 additions & 65 deletions tests/integration/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,41 @@ func componentTests(args ...string) {
var project string
var context string
var originalDir string
oc = helper.NewOcRunner("oc")

BeforeEach(func() {
SetDefaultEventuallyTimeout(10 * time.Minute)
oc = helper.NewOcRunner("oc")
context = helper.CreateNewContext()
os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml"))
})

Context("odo component creation without application", func() {
// Clean up after the test
// This is run after every Spec (It)
var _ = AfterEach(func() {
helper.DeleteDir(context)
os.Unsetenv("GLOBALODOCONFIG")
})

Context("Creating component", func() {
JustBeforeEach(func() {
project = helper.CreateRandProject()
originalDir = helper.Getwd()
helper.Chdir(context)
})
JustAfterEach(func() {
helper.DeleteProject(project)
os.RemoveAll(".odo")
helper.Chdir(originalDir)
})
It("creating a component without an application should create one", func() {

It("should create component even in new project", func() {
helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--git", "https://github.com/openshift/nodejs-ex", "--project", project, "--context", context, "--app", "testing")...)
helper.CmdShouldPass("odo", "push", "--context", context, "-v4")
oc.SwitchProject(project)
projectList := helper.CmdShouldPass("odo", "project", "list")
Expect(projectList).To(ContainSubstring(project))
})

It("Without an application should create one", func() {
componentName := helper.RandString(6)
helper.CmdShouldPass("odo", append(args, "create", "nodejs", "--project", project, componentName, "--ref", "master", "--git", "https://github.com/openshift/nodejs-ex")...)
helper.CmdShouldPass("odo", "push")
Expand All @@ -51,74 +70,44 @@ func componentTests(args ...string) {
helper.CmdShouldFail("odo", "component", "delete", componentName, "-f")

})
})

Context("odo component creation", func() {

JustBeforeEach(func() {
project = helper.CreateRandProject()
})
JustAfterEach(func() {
helper.DeleteProject(project)
os.RemoveAll(".odo")
})

It("should show an error when ref flag is provided with sources except git", func() {
outputErr := helper.CmdShouldFail("odo", append(args, "create", "nodejs", "--project", project, "cmp-git", "--ref", "test")...)
Expect(outputErr).To(ContainSubstring("The --ref flag is only valid for --git flag"))
})

It("create component twice fails from same directory", func() {
helper.CmdShouldPass("odo", append(args, "create", "nodejs", "--project", project)...)
output := helper.CmdShouldFail("odo", append(args, "create", "nodejs", "--project", project)...)
Expect(output).To(ContainSubstring("this directory already contains a component"))
})

It("should create the component from the branch ref when provided", func() {
helper.CmdShouldPass("odo", append(args, "create", "ruby", "ref-test", "--project", project, "--git", "https://github.com/girishramnani/ruby-ex.git", "--ref", "develop")...)
helper.CmdShouldPass("odo", "push")
})
})

Context("odo component creation", func() {
JustBeforeEach(func() {
project = helper.CreateRandProject()
context = helper.CreateNewContext()
})

JustAfterEach(func() {
helper.DeleteProject(project)
os.RemoveAll(context)
})

It("should list the component", func() {
helper.CmdShouldPass("odo", append(args, "create", "nodejs", "cmp-git", "--project", project, "--git", "https://github.com/openshift/nodejs-ex", "--min-memory", "100Mi", "--max-memory", "300Mi", "--min-cpu", "0.1", "--max-cpu", "2", "--context", context, "--app", "testing")...)
helper.CmdShouldPass("odo", "push", "--context", context)
originalDir := helper.Getwd()
helper.Chdir(context)
cmpList := helper.CmdShouldPass("odo", append(args, "list")...)
Expect(cmpList).To(ContainSubstring("cmp-git"))
helper.CmdShouldPass("odo", append(args, "delete", "cmp-git", "-f")...)
helper.Chdir(originalDir)
})
})

Context("Test odo push with --source and --config flags", func() {
var originalDir string
BeforeEach(func() {
context = helper.CreateNewContext()
JustBeforeEach(func() {
project = helper.CreateRandProject()
originalDir = helper.Getwd()
helper.Chdir(context)
})

AfterEach(func() {
JustAfterEach(func() {
helper.DeleteProject(project)
helper.DeleteDir(context)
helper.Chdir(originalDir)
})

Context("when using project flag(--project) and current directory", func() {
JustBeforeEach(func() {
project = helper.CreateRandProject()
originalDir = helper.Getwd()
helper.Chdir(context)
})

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

Context("Using project flag(--project) and current directory", func() {
It("create local nodejs component and push source and code separately", func() {
appName := "nodejs-push-test"
cmpName := "nodejs"
Expand Down Expand Up @@ -177,16 +166,8 @@ func componentTests(args ...string) {
})
})

Context("when --context is used", func() {
Context("Flag --context is used", func() {
// don't need to switch to any dir here, as this test should use --context flag
JustBeforeEach(func() {
project = helper.CreateRandProject()
})

JustAfterEach(func() {
os.RemoveAll(".odo")
})

It("create local nodejs component and push source and code separately", func() {
appName := "nodejs-push-context-test"
cmpName := "nodejs"
Expand Down Expand Up @@ -271,12 +252,14 @@ func componentTests(args ...string) {

JustBeforeEach(func() {
context = helper.CreateNewContext()
project = helper.CreateRandProject()
originalDir = helper.Getwd()
helper.Chdir(context)
})

JustAfterEach(func() {
helper.Chdir(originalDir)
helper.DeleteProject(project)
os.RemoveAll(context)
})

Expand Down Expand Up @@ -380,7 +363,6 @@ func componentTests(args ...string) {
cmpName := "nodejs"

JustBeforeEach(func() {
SetDefaultEventuallyTimeout(10 * time.Minute)
project = helper.CreateRandProject()
context = helper.CreateNewContext()
originalDir = helper.Getwd()
Expand Down Expand Up @@ -412,23 +394,21 @@ func componentTests(args ...string) {
helper.CmdShouldPass("odo", "push", "--context", context)

// list command should fail as no app flag is given
helper.CmdShouldFail("odo", "list")
helper.CmdShouldFail("odo", "list", "--project", project)
// commands should fail as the component name is missing
helper.CmdShouldFail("odo", "describe", "--app", appName)
helper.CmdShouldFail("odo", "delete", "-f", "--app", appName)
helper.CmdShouldFail("odo", "describe", "--app", appName, "--project", project)
helper.CmdShouldFail("odo", "delete", "-f", "--app", appName, "--project", project)
})

It("should pass outside a odo directory with component name as parameter", func() {
helper.CopyExample(filepath.Join("source", "nodejs"), context)
helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context)
helper.CmdShouldPass("odo", "push", "--context", context)

cmpListOutput := helper.CmdShouldPass("odo", "list", "--app", appName)
cmpListOutput := helper.CmdShouldPass("odo", "list", "--app", appName, "--project", project)
Expect(cmpListOutput).To(ContainSubstring(cmpName))
helper.CmdShouldPass("odo", "describe", cmpName, "--app", appName)
helper.CmdShouldPass("odo", "delete", cmpName, "--app", appName, "-f")
helper.CmdShouldPass("odo", "describe", cmpName, "--app", appName, "--project", project)
helper.CmdShouldPass("odo", "delete", cmpName, "--app", appName, "--project", project, "-f")
})

})

}