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

Exit a test early if a session has exited while waiting for an output to contain a substring #6711

Merged

Conversation

valaparthvi
Copy link
Contributor

@valaparthvi valaparthvi commented Apr 3, 2023

What type of PR is this:
/kind tests

What does this PR do / why we need it:
This PR extends the helper functions WaitForOutputToContain and the likes to exit early if a session has exited due to an error.

The motivation behind adding this change is while developing a new feature, in my case #6704, I had run into a case where --port-forward was given an invalid value, and odo dev exited, but the test session running StartDevMode and in turn running WaitForOutputToContain still kept running and waiting for the output to contain a given substring. It would save a lot of time while developing a new test if the test exited early.

Which issue(s) this PR fixes:

Fixes #

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:
Add the following test to a test file(perhaps cmd_dev_test.go):

	FIt("should exit early", func() {
		helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
		helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile.yaml")).ShouldPass()
		sess, _, _, _, err := helper.StartDevMode(helper.DevSessionOpts{CmdlineArgs: []string{"--ignore-localhost", "--forward-localhost"}, RunOnPodman: true})
		defer sess.Stop()
		Expect(err).To(HaveOccurred())
	})

@openshift-ci
Copy link

openshift-ci bot commented Apr 3, 2023

@valaparthvi: The label(s) kind/tests cannot be applied, because the repository doesn't have them.

In response to this:

What type of PR is this:
/kind tests

What does this PR do / why we need it:
This PR extends the helper functions WaitForOutputToContain and the likes to exit early if a session has exited due to an error.
Which issue(s) this PR fixes:

Fixes #

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:

  1. Modify an odo dev test using StartDevMode to fail, perhaps by using 2 flags that must not be used together, for e.g. --ignore-localhost and --forward-localhost.
  2. Ensure the test fails early.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot requested review from feloy and ritudes April 3, 2023 17:50
@netlify
Copy link

netlify bot commented Apr 3, 2023

Deploy Preview for odo-docusaurus-preview canceled.

Name Link
🔨 Latest commit 60d44ea
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/642be14eb2a9c200085bc1e0

@odo-robot
Copy link

odo-robot bot commented Apr 3, 2023

OpenShift Unauthenticated Tests on commit 42de3b8 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Apr 3, 2023

NoCluster Tests on commit 42de3b8 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Apr 3, 2023

Unit Tests on commit 42de3b8 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Apr 3, 2023

Validate Tests on commit 42de3b8 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Apr 3, 2023

Windows Tests (OCP) on commit 42de3b8 finished with errors.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Apr 3, 2023

OpenShift Tests on commit 42de3b8 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Apr 3, 2023

Kubernetes Tests on commit 42de3b8 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Apr 3, 2023

Kubernetes Docs Tests on commit 033a402 finished successfully.
View logs: TXT HTML

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Apr 4, 2023
Signed-off-by: Parthvi Vala <pvala@redhat.com>
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Apr 4, 2023
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.3% 0.3% Duplication

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Apr 4, 2023
@valaparthvi
Copy link
Contributor Author

/override windows-integration-test/Windows-test

  [odo] Error occurred on Push - unable to generate component from watch parameters: failed to populateAndParseDevfile: failed to read devfile from path 'C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3257872455\devfile.yaml': open C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3257872455\devfile.yaml: The system cannot find the file specified.
  [odo] 
  Deleting dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3257872455
  Unable to delete C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3257872455 on attempt #11, trying again...
  [FAILED] in [AfterEach] - C:/Users/Administrator.ANSIBLE-TEST-VS/3605/tests/helper/helper_filesystem.go:48 @ 04/04/23 04:16:35.035
  << Timeline

  [FAILED] Expected
      <*url.Error | 0xc000702c60>: {
          Op: "Post",
          URL: "http://127.0.0.1:64484/api/newuser",
          Err: <*errors.errorString | 0xc000102100>{s: "EOF"},
      }
  to be nil
  In [It] at: C:/Users/Administrator.ANSIBLE-TEST-VS/3605/tests/e2escenarios/e2e_test.go:306 @ 04/04/23 04:14:28.661

  There were additional failures detected.  To view them in detail run ginkgo -vv
------------------------------

Summarizing 1 Failure:
  [FAIL] E2E Test starting with non-empty Directory add Binding [It] should verify developer workflow of using binding as env in innerloop
  C:/Users/Administrator.ANSIBLE-TEST-VS/3605/tests/e2escenarios/e2e_test.go:306

@openshift-ci
Copy link

openshift-ci bot commented Apr 4, 2023

@valaparthvi: Overrode contexts on behalf of valaparthvi: windows-integration-test/Windows-test

In response to this:

/override windows-integration-test/Windows-test

 [odo] Error occurred on Push - unable to generate component from watch parameters: failed to populateAndParseDevfile: failed to read devfile from path 'C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3257872455\devfile.yaml': open C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3257872455\devfile.yaml: The system cannot find the file specified.
 [odo] 
 Deleting dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3257872455
 Unable to delete C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3257872455 on attempt #11, trying again...
 [FAILED] in [AfterEach] - C:/Users/Administrator.ANSIBLE-TEST-VS/3605/tests/helper/helper_filesystem.go:48 @ 04/04/23 04:16:35.035
 << Timeline

 [FAILED] Expected
     <*url.Error | 0xc000702c60>: {
         Op: "Post",
         URL: "http://127.0.0.1:64484/api/newuser",
         Err: <*errors.errorString | 0xc000102100>{s: "EOF"},
     }
 to be nil
 In [It] at: C:/Users/Administrator.ANSIBLE-TEST-VS/3605/tests/e2escenarios/e2e_test.go:306 @ 04/04/23 04:14:28.661

 There were additional failures detected.  To view them in detail run ginkgo -vv
------------------------------

Summarizing 1 Failure:
 [FAIL] E2E Test starting with non-empty Directory add Binding [It] should verify developer workflow of using binding as env in innerloop
 C:/Users/Administrator.ANSIBLE-TEST-VS/3605/tests/e2escenarios/e2e_test.go:306

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-merge-robot openshift-merge-robot merged commit 8876e1a into redhat-developer:main Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants