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
Fixes project wait flag #2221
Fixes project wait flag #2221
Conversation
8ed2529
to
acb1f4b
Compare
acb1f4b
to
20144f8
Compare
listOutput := helper.CmdShouldPass("odo", "project", "list") | ||
Expect(listOutput).To(ContainSubstring(project)) | ||
|
||
// project deletion doesn't happen immediately, so we test subset of the string | ||
listOutputJson := helper.CmdShouldPass("odo", "project", "list", "-o", "json") | ||
Expect(listOutputJson).To(ContainSubstring(`{"kind":"Project","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"` + project + `","namespace":"` + project + `","creationTimestamp":null},"spec":{},"status":{"active":false}}`)) | ||
Expect(listOutputJson).To(ContainSubstring(`{"kind":"Project","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"` + project + `","namespace":"` + project + `","creationTimestamp":null},"spec":{},"status":{"active":true}}`)) |
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.
In parallel run validating the projects status "status":{"active":true}}
or "status":{"active":true}}
could lead to a flaky behavior. Instead of matching the full json can you match some major key value pair.
For now see how this is being done in one of our test cases - https://github.com/openshift/odo/blob/master/tests/integration/component.go#L197
@@ -41,13 +41,12 @@ var _ = Describe("odo project command tests", func() { | |||
Context("when running project command app parameter in directory that doesn't contain .odo config directory", func() { | |||
It("should successfully execute list along with machine readable output", func() { | |||
helper.CmdRunner("odo", "project", "list") | |||
time.Sleep(1 * time.Second) |
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.
Cool!!!
helper.CmdRunner("odo", "project", "list") | ||
time.Sleep(1 * time.Second) |
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.
Also remove helper.CmdRunner("odo", "project", "list")
. In the next line it is being duplicated.
20144f8
to
0969c09
Compare
/retest |
@amitkrout Done |
0969c09
to
ec18008
Compare
/approve |
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.
Failing test / you need to modify your current test to make sure that it will pass..
listOutput := helper.CmdShouldPass("odo", "project", "list") | ||
Expect(listOutput).To(ContainSubstring(project)) | ||
|
||
// project deletion doesn't happen immediately, so we test subset of the string | ||
listOutputJson := helper.CmdShouldPass("odo", "project", "list", "-o", "json") | ||
Expect(listOutputJson).To(ContainSubstring(`{"kind":"Project","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"` + project + `","namespace":"` + project + `","creationTimestamp":null},"spec":{},"status":{"active":false}}`)) | ||
Expect(listOutputJson).To(ContainSubstring(`{"kind":"Project","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"` + project + `","namespace":"` + project + `","creationTimestamp":null},"spec":{},`)) |
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.
Shouldn't this be status: active? Why was it removed? This is obvious that the test is failing.. In this test scenario, you can modify the beforeEach
to add -w
to wait for the project to come up.
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.
Shouldn't this be status: active? Why was it removed? This is obvious that the test is failing..
Think a case where you have more scenarios are running for example make test-integration
then in two node you cannot be sure that the current scenario project is active throughout the scenario. May be in the same time some different project scenario is created and become active.
In this test scenario, you can modify the beforeEach to add -w to wait for the project to come up
In the test script we have already made this behavior as default to avoid flakes. see - https://github.com/openshift/odo/blob/master/tests/helper/odo_utils.go#L79. The failure was happening due to the step CmdRunner(...)
which does not wait for command output.
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.
As @amitkrout pointed due to parallel tests we can't be sure of the activeness of the test throughout the scenario so I removed the status. @cdrage @kadel WDYT?
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.
Ah, but that defeats the whole purpose of the test though, to make sure that it's the active project. Any way to test that individually without parallelism?
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.
yup, there is an option of sequential run. In a long run it would be hard to even manage get
and set
command in parallel run. @mik-dass Please do the change to run it on single node test.
For reference check - https://github.com/openshift/odo/tree/master/tests/integration/loginlogout.
ec18008
to
b942e32
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amitkrout The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
b942e32
to
d473b60
Compare
@cdrage @amitkrout Done please have a look |
Looks good to me. |
/retest |
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.
Thanks for the tests. These work way better.
/lgtm
listOutput := helper.CmdShouldPass("odo", "project", "list") | ||
Expect(listOutput).To(ContainSubstring(project)) | ||
|
||
// project deletion doesn't happen immediately, so we test subset of the string | ||
listOutputJson := helper.CmdShouldPass("odo", "project", "list", "-o", "json") | ||
Expect(listOutputJson).To(ContainSubstring(`{"kind":"Project","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"` + project + `","namespace":"` + project + `","creationTimestamp":null},"spec":{},"status":{"active":false}}`)) | ||
Expect(listOutputJson).To(ContainSubstring(`{"kind":"Project","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"` + project + `","namespace":"` + project + `","creationTimestamp":null},"spec":{},"status":{"active":true}}`)) |
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.
Thanks! 👍 way better.
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
fixes #2117
How to test:
Check if the
odo project create <project-name> -w
works and it waits properly for the project to be ready.