-
Notifications
You must be signed in to change notification settings - Fork 244
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
Refactoring e2e tests #625
Refactoring e2e tests #625
Conversation
89a661f
to
cc40975
Compare
@ashetty1 Please add a link to the issue for every PR that you open. Also, some description would be nice ;-) |
818f66c
to
e5e53f9
Compare
e5e53f9
to
9a1bbb7
Compare
tests/e2e/README.md
Outdated
@@ -17,39 +17,43 @@ Run `make test-e2e` to execute the tests. | |||
| `project create` | Y | | |||
| `project get` | Y | | |||
| `project delete` | Y | | |||
| `project list` | N | | |||
| `project list` | Y | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that this should be N
as it is commented out.
4df9bc0
to
498a7ef
Compare
498a7ef
to
c4cab72
Compare
@surajnarwade @cdrage @anmolbabu @mik-dass @syamgk please review! |
tests/e2e/cmp_test.go
Outdated
) | ||
|
||
// SourceTest checks the component-source-type and the source url in the annotation of the bc and dc | ||
// appTestName is the app of the app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name of the app?
// source is the source of the component i.e gitUrl or path to the directory or binary file | ||
func SourceTest(appTestName string, sourceType string, source string) { | ||
// checking for source-type in dc | ||
getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='{{index .metadata.annotations \"app.kubernetes.io/component-source-type\"}}'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we extract out wildfly or the component type also to parameter in all the lines in this func?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anmolbabu this is an old function. I just did some rearrangement of tests with this PR. Let me see if I can change that. I agree with you, it would be nice to do that.
tests/e2e/e2e_test.go
Outdated
|
||
// Failing: Issue #630 | ||
// It("should list the project", func() { | ||
// listProj := runCmd("odo project list") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test need not be commented
replace listProj := runCmd("odo project list")
with listProj := runCmd("sleep 2s && odo project list")
refer comment on #630 (comment)
@@ -0,0 +1,370 @@ | |||
// +build !race |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also move the following:
Lines 65 to 82 in c4cab72
Context("creating component without an application", func() { | |
It("should create the component in default application", func() { | |
runCmd("odo create php testcmp") | |
getCmp := runCmd("odo component get --short") | |
Expect(getCmp).To(Equal("testcmp")) | |
getApp := runCmd("odo app get --short") | |
Expect(getApp).To(Equal("app")) | |
}) | |
It("should be able to delete the component", func() { | |
runCmd("odo delete testcmp -f") | |
getCmp := runCmd("odo list") | |
Expect(getCmp).NotTo(ContainSubstring("testcmp")) | |
}) | |
}) |
Lines 120 to 189 in c4cab72
Describe("creating a component", func() { | |
Context("when application exists", func() { | |
It("should create a component", func() { | |
runCmd("git clone https://github.com/openshift/nodejs-ex " + | |
tmpDir + "/nodejs-ex") | |
// TODO: add tests for --git | |
runCmd("odo create nodejs --local " + tmpDir + "/nodejs-ex") | |
runCmd("odo push") | |
}) | |
It("should be the get the component created as active component", func() { | |
cmp := runCmd("odo component get --short") | |
Expect(cmp).To(Equal("nodejs")) | |
}) | |
It("should create the component within the application", func() { | |
getApp := runCmd("odo app get --short") | |
Expect(getApp).To(Equal(appTestName)) | |
}) | |
It("should list the components within the application", func() { | |
cmpList := runCmd("odo list") | |
Expect(cmpList).To(ContainSubstring("nodejs")) | |
}) | |
It("should be able to create multiple components within the same application", func() { | |
runCmd("odo create php") | |
}) | |
It("should list the newly created second component", func() { | |
cmpList := runCmd("odo list") | |
Expect(cmpList).To(ContainSubstring("php")) | |
}) | |
It("should get the application "+appTestName, func() { | |
appGet := runCmd("odo app get --short") | |
Expect(appGet).To(Equal(appTestName)) | |
}) | |
It("should be able to set a component as active", func() { | |
cmpSet := runCmd("odo component set nodejs") | |
Expect(cmpSet).To(ContainSubstring("nodejs")) | |
}) | |
It("should be able to retrieve logs", func() { | |
runCmd("odo log") | |
runCmd("odo log nodejs") | |
}) | |
It("should be able to create git component with required ports", func() { | |
runCmd("odo create nodejs nodejs-git --git https://github.com/openshift/nodejs-ex --port 8080/tcp,9100/udp") | |
// checking port names | |
portsNames := runCmd("oc get services nodejs-git-" + appTestName + " -o go-template='{{range .spec.ports}}{{.name}}{{end}}'") | |
Expect(portsNames).To(ContainSubstring("8080-tcp")) | |
Expect(portsNames).To(ContainSubstring("9100-udp")) | |
// checking port numbers | |
ports := runCmd("oc get services nodejs-git-" + appTestName + " -o go-template='{{range .spec.ports}}{{.port}}{{end}}'") | |
Expect(ports).To(ContainSubstring("8080")) | |
Expect(ports).To(ContainSubstring("9100")) | |
// checking protocols | |
protocols := runCmd("oc get services nodejs-git-" + appTestName + " -o go-template='{{range .spec.ports}}{{.protocol}}{{end}}'") | |
Expect(protocols).To(ContainSubstring("TCP")) | |
Expect(protocols).To(ContainSubstring("UDP")) | |
}) | |
}) | |
}) |
also here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anmolbabu nope. We need a few basic component tests in e2e_test.go too.
521a00b
to
3c5405b
Compare
@surajnarwade @anmolbabu @mik-dass guys one final review and merge? |
This LGTM! |
demo_test.go and e2e_test.go have a lot of duplicate tests. With this PR, I am moving all the component related tests to cmp_test.go, and am removing demo_test.go. We will continue to add more component tests to cmp_test.go
3c5405b
to
7a75571
Compare
@surajnarwade @syamgk @mik-dass Can you guys review this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 😄
demo_test.go and e2e_test.go have a lot of duplicate tests. With this PR, I am moving all the component related tests will be moved to cmp_test.go, and have deleted demo_test.go.
Part of the refactoring effort at #576