-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Changed code to improve output for files under test/e2e/framework #105939
Conversation
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 Once the patch is verified, the new status will be reflected by the 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. |
|
/triage accepted |
/kind cleanup |
455d3c2
to
6c739fb
Compare
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:
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. |
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 |
1a08111
to
2d81f09
Compare
test/e2e/framework/util.go
Outdated
@@ -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)) |
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.
Inside the "framework" package itself, Failf
can be invoked without the framework.
prefix.
test/e2e/framework/util.go
Outdated
@@ -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) { |
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.
This is a case for Expect(len(expectedWatchEvents)).To(BeNumerically(">", len(actualWatchEvents), ...)
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.
Removed framework. prefix
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.
The entire if Failf
can be replaced with:
Expect(len(expectedWatchEvents)).To(BeNumerically("<=", len(actualWatchEvents), "Did not get enough watch events")
9537fa7
to
e52e671
Compare
@pohly and @oomichi One of the test is saying that |
Will this output will be fine |
@@ -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) |
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.
framework.Failf("Unable to syn caches for %v", p.controller) | |
framework.Failf("Unable to sync caches for %v", p.controller) |
test/e2e/framework/util.go
Outdated
@@ -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) { |
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.
The entire if Failf
can be replaced with:
Expect(len(expectedWatchEvents)).To(BeNumerically("<=", len(actualWatchEvents), "Did not get enough watch events")
test/e2e/framework/util.go
Outdated
@@ -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 - ")) |
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.
Failf("Error: %v", strings.Join(errs.List(), "\n - ")) | |
Failf("Unexpected error(s): %v", strings.Join(errs.List(), "\n - ")) |
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). |
4c8c0f3
to
c2809f4
Compare
c2809f4
to
2e18992
Compare
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.
/lgtm
/approve
[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 |
@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 |
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?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: