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

testutils: add ExpectExactNTimes function to LogObserver #18637

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clement2026
Copy link
Contributor

@clement2026 clement2026 commented Sep 25, 2024

Context #18635 (comment)

#18635 needs this.

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: clement2026
Once this PR has been reviewed and has the lgtm label, please assign serathius for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link

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 /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-sigs/prow repository.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.81%. Comparing base (5704c61) to head (136409c).

Current head 136409c differs from pull request most recent head 5b38a8f

Please upload reports for the commit 5b38a8f to get more accurate results.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

see 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.

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

// 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) {
Copy link
Member

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.

@serathius
Copy link
Member

Do we really need to check if compacted Raft log occured at most N times? This is hard to check, why checking if "compact-index": X is not enough ?

// 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)
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants