-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
testutils: add ExpectExactNTimes function to LogObserver #18637
base: main
Are you sure you want to change the base?
testutils: add ExpectExactNTimes function to LogObserver #18637
Conversation
Signed-off-by: Clement <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: clement2026 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @clement2026. Thanks for your PR. I'm waiting for a etcd-io 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-sigs/prow repository. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted filessee 23 files with indirect coverage changes @@ Coverage Diff @@
## main #18637 +/- ##
==========================================
+ Coverage 68.77% 68.81% +0.03%
==========================================
Files 420 420
Lines 35535 35535
==========================================
+ Hits 24439 24452 +13
+ Misses 9666 9651 -15
- Partials 1430 1432 +2 Continue to review full report in Codecov by Sentry.
|
// ExpectExactNTimes returns all lines that satisfy the filter if there are | ||
// exactly `count` of them when the duration ends. Otherwise, it returns an error. | ||
// Make sure ctx has a timeout longer than duration for ExpectExactNTimes to work properly. | ||
func (logOb *LogObserver) ExpectExactNTimes(ctx context.Context, s string, count int, duration time.Duration) ([]string, error) { |
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.
Don't use duration, timeout should be passed via context.
Do we really need to check if |
// Expect returns the first N lines containing the given string. | ||
func (logOb *LogObserver) Expect(ctx context.Context, s string, count int) ([]string, error) { | ||
// ExpectAtLeastNTimes returns the first N lines containing the given string. | ||
func (logOb *LogObserver) ExpectAtLeastNTimes(ctx context.Context, s string, count int) ([]string, error) { | ||
return logOb.ExpectFunc(ctx, func(log string) bool { return strings.Contains(log, s) }, count) |
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.
Please update the Expect function instead.
Current implementation of expect should be renamed to ExpectNMatches
Context #18635 (comment)
#18635 needs this.