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

Fixes project wait flag #2221

Merged

Conversation

mik-dass
Copy link
Contributor

@mik-dass mik-dass commented Oct 1, 2019

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.

@mik-dass mik-dass requested a review from kadel October 1, 2019 14:44
@mik-dass mik-dass changed the title Fixes project wait flag [WIP] Fixes project wait flag Oct 1, 2019
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Oct 1, 2019
@mik-dass mik-dass changed the title [WIP] Fixes project wait flag Fixes project wait flag Oct 3, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Oct 3, 2019
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}}`))
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool!!!

Comment on lines 43 to 44
helper.CmdRunner("odo", "project", "list")
time.Sleep(1 * time.Second)
Copy link
Contributor

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.

@mik-dass
Copy link
Contributor Author

mik-dass commented Oct 3, 2019

✗  Waiting for component to start [4m]
[odo]  ✗  waited 4m0s but couldn't find running pod matching selector: 'deploymentconfig=mycomponent-myapp'

/retest

@mik-dass
Copy link
Contributor Author

mik-dass commented Oct 3, 2019

@amitkrout Done

@amitkrout
Copy link
Contributor

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Oct 3, 2019
Copy link
Member

@cdrage cdrage left a 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":{},`))
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 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.

Copy link
Contributor

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..

@cdrage #2221 (comment)

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.

Copy link
Contributor Author

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?

Copy link
Member

@cdrage cdrage Oct 3, 2019

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?

Copy link
Contributor

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.

@openshift-ci-robot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mik-dass
Copy link
Contributor Author

mik-dass commented Oct 4, 2019

@cdrage @amitkrout Done please have a look

@amitkrout
Copy link
Contributor

@cdrage @amitkrout Done please have a look

Looks good to me.

@mik-dass
Copy link
Contributor Author

mik-dass commented Oct 4, 2019

[oc] Error in configuration: 
[oc] * context was not found for specified context: yfkoarskib/api-ci-op-r1xy5kvm-1b2f4-origin-ci-int-aws-dev-rhcloud-com:6443/developer
[oc] * cluster has no server defined

/retest

Copy link
Member

@cdrage cdrage left a 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}}`))
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! 👍 way better.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Oct 4, 2019
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit f569be9 into redhat-developer:master Oct 4, 2019
@mik-dass mik-dass deleted the fix_proj_wait branch October 17, 2019 08:46
@rm3l rm3l added the estimated-size/S (5-10) Rough sizing for Epics. Less then one sprint of work for one person label Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. estimated-size/S (5-10) Rough sizing for Epics. Less then one sprint of work for one person lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project create doesn't wait properly
7 participants