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

Changed code to improve output for files under test/e2e/framework #105939

Merged

Conversation

NikhilSharmaWe
Copy link
Member

What type of PR is this?

Enhancement

What this PR does / why we need it:

For better (more informative) output for developers when test fails. Changed files are under test/e2e/framework for this PR.

Which issue(s) this PR fixes:

Part of #105678

Special notes for your reviewer:

Does this PR introduce a user-facing change?

None

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 27, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @NikhilSharmaWe. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Oct 27, 2021
@k8s-ci-robot k8s-ci-robot added area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 27, 2021
@NikhilSharmaWe
Copy link
Member Author

$ git grep -n 'Expect.*Equal([^,]*, *\(true\|false\)' -- test/e2e/framework test/e2e/framework/log_test.go:60: framework.ExpectEqual(false, true, "false is never true") test/e2e/framework/log_test.go:71: framework.ExpectEqual(true, false, "true is never false either") test/e2e/framework/util.go:1380: ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount (%d) must be greater than or equal to expected watch events amount (%d)", len(actualWatchEvents), len(expectedWatchEvents)) test/e2e/framework/util.go:1409: ExpectEqual(errs.Len() > 0, false, strings.Join(errs.List(), "\n - "))
According to me the rest of the cases are giving output which does not need the be changed. If they need change please inform.

@oomichi
Copy link
Member

oomichi commented Oct 27, 2021

/triage accepted
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 27, 2021
@oomichi
Copy link
Member

oomichi commented Oct 27, 2021

/kind cleanup

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Oct 27, 2021
@NikhilSharmaWe
Copy link
Member Author

NikhilSharmaWe commented Oct 28, 2021

@oomichi and @pohly how to proceed, what can be the reason of the test failing.

@pohly
Copy link
Contributor

pohly commented Oct 28, 2021

According to me the rest of the cases are giving output which does not need the be changed. If they need change please inform.

While some of those assertions have a reasonable message text, the assertion output itself is still going to be fairly useless. Therefore it makes sense to convert these:

test/e2e/framework/util.go:1380: ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount (%d) must be greater than or equal to expected watch events amount (%d)", len(actualWatchEvents), len(expectedWatchEvents))
test/e2e/framework/util.go:1409: ExpectEqual(errs.Len() > 0, false, strings.Join(errs.List(), "\n - ")) 

log_test.go can be ignored, that isn't a real test.

how to proceed, what can be the reason of the test failing.

You can find that out by following the "Details" link for a failed job. "verify: gofmt" failed because code formatting isn't quite right. "verify: govet" failed because of an invalid Failf format specifier.

The integration test failure looks like an unrelated test flake.

@NikhilSharmaWe
Copy link
Member Author

NikhilSharmaWe commented Oct 28, 2021

What should be the correction here, what should be written in Failf func in this case.

https://github.com/kubernetes/kubernetes/blob/master/test/e2e/framework/util.go#L1409

@@ -1377,7 +1378,9 @@ retriesLoop:
// NOTE the test may need access to the events to see what's going on, such as a change in status
actualWatchEvents := scenario(resourceWatch)
errs := sets.NewString()
ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount (%d) must be greater than or equal to expected watch events amount (%d)", len(actualWatchEvents), len(expectedWatchEvents))
if len(expectedWatchEvents) > len(actualWatchEvents) {
framework.Failf("Error: actual watch events amount", len(actualWatchEvents), "must be greater than or equal to expected watch events", len(expectedWatchEvents))
Copy link
Contributor

Choose a reason for hiding this comment

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

Inside the "framework" package itself, Failf can be invoked without the framework. prefix.

@@ -1377,7 +1378,9 @@ retriesLoop:
// NOTE the test may need access to the events to see what's going on, such as a change in status
actualWatchEvents := scenario(resourceWatch)
errs := sets.NewString()
ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount (%d) must be greater than or equal to expected watch events amount (%d)", len(actualWatchEvents), len(expectedWatchEvents))
if len(expectedWatchEvents) > len(actualWatchEvents) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a case for Expect(len(expectedWatchEvents)).To(BeNumerically(">", len(actualWatchEvents), ...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed framework. prefix

Copy link
Contributor

Choose a reason for hiding this comment

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

The entire if Failf can be replaced with:

Expect(len(expectedWatchEvents)).To(BeNumerically("<=", len(actualWatchEvents), "Did not get enough watch events")

@NikhilSharmaWe NikhilSharmaWe force-pushed the betterOutputFramework branch 3 times, most recently from 9537fa7 to e52e671 Compare October 30, 2021 22:48
@NikhilSharmaWe
Copy link
Member Author

@pohly and @oomichi One of the test is saying that
k8s.io/kubernetes/test/e2e/framework test/e2e/framework/util.go:1381:9: Failf call has arguments but no formatting directives k8s.io/kubernetes/test/e2e/framework/providers/kubemark test/e2e/framework/providers/kubemark/kubemark.go:79:19: Failf call has arguments but no formatting directives
so, should I add %v format directive in the Failf function.

@NikhilSharmaWe
Copy link
Member Author

NikhilSharmaWe commented Oct 31, 2021

Will this output will be fine
if !errs.Len() > 0 { Failf("Error : %v", strings.Join(errs.List(), "\n - ")) }
at place of
https://github.com/kubernetes/kubernetes/blob/master/test/e2e/framework/util.go#L1409

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 31, 2021
@NikhilSharmaWe
Copy link
Member Author

@pohly and @oomichi if you can confirm that the output for all cases are fine, then I can convert the changes to a single commit.

@@ -75,7 +75,9 @@ func (p *Provider) FrameworkBeforeEach(f *framework.Framework) {
p.controller, err = kubemark.NewKubemarkController(externalClient, externalInformerFactory, f.ClientSet, kubemarkNodeInformer)
framework.ExpectNoError(err)
externalInformerFactory.Start(p.closeChannel)
framework.ExpectEqual(p.controller.WaitForCacheSync(p.closeChannel), true)
if !p.controller.WaitForCacheSync(p.closeChannel) {
framework.Failf("Unable to syn caches for %v", p.controller)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
framework.Failf("Unable to syn caches for %v", p.controller)
framework.Failf("Unable to sync caches for %v", p.controller)

@@ -1377,7 +1378,9 @@ retriesLoop:
// NOTE the test may need access to the events to see what's going on, such as a change in status
actualWatchEvents := scenario(resourceWatch)
errs := sets.NewString()
ExpectEqual(len(expectedWatchEvents) <= len(actualWatchEvents), true, "Error: actual watch events amount (%d) must be greater than or equal to expected watch events amount (%d)", len(actualWatchEvents), len(expectedWatchEvents))
if len(expectedWatchEvents) > len(actualWatchEvents) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The entire if Failf can be replaced with:

Expect(len(expectedWatchEvents)).To(BeNumerically("<=", len(actualWatchEvents), "Did not get enough watch events")

@@ -1406,7 +1408,9 @@ retriesLoop:
fmt.Println("invariants violated:\n", strings.Join(errs.List(), "\n - "))
continue retriesLoop
}
ExpectEqual(errs.Len() > 0, false, strings.Join(errs.List(), "\n - "))
if errs.Len() > 0 {
Failf("Error: %v", strings.Join(errs.List(), "\n - "))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Failf("Error: %v", strings.Join(errs.List(), "\n - "))
Failf("Unexpected error(s): %v", strings.Join(errs.List(), "\n - "))

@pohly
Copy link
Contributor

pohly commented Nov 3, 2021

then I can convert the changes to a single commit

Feel free to do that right away before pushing an update. At least I prefer it that way (avoids one roundtrip when the result is okay).

@NikhilSharmaWe NikhilSharmaWe force-pushed the betterOutputFramework branch 3 times, most recently from 4c8c0f3 to c2809f4 Compare November 3, 2021 11:44
Copy link
Contributor

@pohly pohly left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 3, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: NikhilSharmaWe, pohly

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 3, 2021
@k8s-ci-robot k8s-ci-robot merged commit 16c8640 into kubernetes:master Nov 3, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Nov 3, 2021
@NikhilSharmaWe
Copy link
Member Author

@oomichi could you please sponsor my application for becoming a member of Kubernetes organization.

@oomichi
Copy link
Member

oomichi commented Nov 9, 2021

@oomichi could you please sponsor my application for becoming a member of Kubernetes organization.

According to https://k8s.devstats.cncf.io/d/13/developer-activity-counts-by-repository-group?orgId=1[…]var-country_name=All&var-repo_name=kubernetes%2Fkubernetes
you already have good contributions on this develop cycle.
I am happy to support you, please let me know if you open an issue for the organization membership.

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. area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants