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

Fix odo log flake #3733

Merged

Conversation

adisky
Copy link
Contributor

@adisky adisky commented Aug 11, 2020

What type of PR is this?

/kind flake

What does does this PR do / why we need it:
Fixes the flag for odo log -f test. This PR updates the test to check the log until expected log is printed and timeout if it doesn't gets logged in specified timeout duration.

Which issue(s) this PR fixes:

Fixes #3610

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:

@openshift-ci-robot openshift-ci-robot added the flake Categorizes issue or PR as related to a flaky test. label Aug 11, 2020
// It is different from WaitforCmdOut which gives stdout in one go using session.Out.Contents()
// for commands like odo log -f which streams continuous data and does not terminate by their own
// we need to read the stream data from buffer.
func RunCmdWithMatchOutputFromBuffer(timeoutAfter time.Duration, matchString, program string, args ...string) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

+100

output = helper.CmdShouldRunWithTimeout(1*time.Second, "odo", "log", "-f")
Expect(output).To(ContainSubstring("program=devrun"))
// Test odo log -f
match, err := helper.RunCmdWithMatchOutputFromBuffer(30*time.Second, "program=devrun", "odo", "log", "-f")
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

// It is different from WaitforCmdOut which gives stdout in one go using session.Out.Contents()
// for commands like odo log -f which streams continuous data and does not terminate by their own
// we need to read the stream data from buffer.
func RunCmdWithMatchOutputFromBuffer(timeoutAfter time.Duration, matchString, program string, args ...string) (bool, error) {
Copy link
Contributor

@prietyc123 prietyc123 Aug 11, 2020

Choose a reason for hiding this comment

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

I was thinking instead of overloading helper file, Can't we use gingko in-build pattern for timeout - https://onsi.github.io/ginkgo/#asynchronous-tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@prietyc123 I follow the pattern from odo watch tests, timeout we are using this way only. I agree with your concern, once you update some other tests with gingko in-build pattern as an example, i would follow the same.

@codecov
Copy link

codecov bot commented Aug 11, 2020

Codecov Report

Merging #3733 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3733   +/-   ##
=======================================
  Coverage   44.93%   44.93%           
=======================================
  Files         133      133           
  Lines       12749    12749           
=======================================
  Hits         5729     5729           
  Misses       6460     6460           
  Partials      560      560           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf474b1...a0daeb1. Read the comment docs.


command := exec.Command(program, args...)
command.Stdout = &buf

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also check the StdErr stream. In case of the timeout, we can print the contents from the error buffer. It will help in debugging in case the command fails to stream.

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to use a different buffer for the error stream like in case of the watch test.

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

@mik-dass
Copy link
Contributor


• Failure [342.243 seconds]
odo devfile watch command tests
/go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_watch_test.go:15
  when executing odo watch after odo push with debug flag
  /go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_watch_test.go:124
    should be able to start a debug session after push with debug flag using odo watch and revert back after normal push [It]
    /go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_watch_test.go:125
    Timeout after 5.00 minutes

/retest

@amitkrout
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Aug 13, 2020
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.

small nitpick but code looks good to to me.

/approve

select {
case <-timeoutCh:
fmt.Fprintln(GinkgoWriter, errBuf.String())
return false, errors.New("Timeout waiting for the conditon")
Copy link
Member

Choose a reason for hiding this comment

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

no capitalization on errors

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cdrage

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

@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 Aug 17, 2020
@adisky
Copy link
Contributor Author

adisky commented Aug 18, 2020

/retest

odo devfile watch command tests
/go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_watch_test.go:20
  when executing odo watch after odo push with debug flag
  /go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_watch_test.go:185
    should be able to start a debug session after push with debug flag using odo watch and revert back after normal push
    /go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_watch_test.go:186
------------------------------
•••••••••••••••••••••••••••••••••••••••••••••••••
	 -------------------------------------------------------------------
	|                                                                   |
	|  Ginkgo timed out waiting for all parallel nodes to report back!  |
	|                                                                   |
	 -------------------------------------------------------------------
 devfile timed out. path: ./tests/integration/devfile

@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 eec93d3 into redhat-developer:master Aug 18, 2020
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. flake Categorizes issue or PR as related to a flaky test. 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.

odo log -f terminates earlier
8 participants