-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
send bookmark right now after sending all items in watchCache store #127012
Conversation
|
Hi @Chaunceyctx. 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-sigs/prow repository. |
3329749
to
5c266bb
Compare
gentle /ping @wojtek-t @p0lyn0mial @liggitt |
5c266bb
to
e720455
Compare
e720455
to
fc4a502
Compare
/ok-to-test |
gentle /ping @wojtek-t @p0lyn0mial :) |
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.
Sorry for delay
if err != nil { | ||
t.Fatalf("Failed to create watch: %v", err) | ||
} | ||
verifyWatchEvents(t, w, 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.
Please don't create a new function - simply use testCheckResultsInStrictOrder
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.
ping
@@ -193,7 +193,13 @@ func testCheckResultsInStrictOrder(t *testing.T, w watch.Interface, expectedEven | |||
} | |||
} | |||
|
|||
func testCheckNoMoreResults(t *testing.T, w watch.Interface) { | |||
func testCheckResultsWithDesiredAndActual(t *testing.T, expectedEvents []watch.Event, actualEvents []watch.Event) { |
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.
no need to introduce such function - there already is testCheckResultsInStrictOrder
testCheckResultsInStrictOrder(t, w, scenario.expectedEventsAfterEstablishingWatch(createdPods)) | ||
testCheckNoMoreResults(t, w) | ||
|
||
// before this pr: |
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.
we generally don't describe state before the PR - it's useless for future readers.
State before the PR can be documented in PR or commit description.
|
||
// In a word, this phenomenon doesn't affect the function of watchlist feature. It's just that we need to pay attention to this phenomenon when writing ut cases | ||
|
||
// get corresponding pod watch events |
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.
I initially started thinking if making bookmark period a configurable option and switching it off wouldn't be a better option for this test, but in the end, I wouldn't go this way.
That said, I would approach this slightly differently. In particular:
- let's introduce
testCheckResultWithIgnoreFunc
function
it's supposed to be somewhat similar totestCheckResultFunc
, but additionally takesignore func(watch.Event) bool
parameter [and it has a loop for getting items from watch and just ignores one for which theignore
function returns true) - let's simply use this new helper function here, passing function that ignores events with type Bookmark as the
ignore
function
Don’t Worry about it. Thanks for your review. I will address all comments. :) |
8d08005
to
ffe1ff0
Compare
/retest some ci jobs are so weird. I have change |
ffe1ff0
to
e3098de
Compare
fine. I don't rebase master branch. lol |
e3098de
to
e4ced4a
Compare
} | ||
|
||
// make cacher.dispatchEvents goroutine exit and bookmark event will only be created by processInterval method | ||
cacher.stopCh <- struct{}{} |
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.
close stopCh instead.
Or you can probably even call cacher.Stop()
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.
I apologize for this mistake. In fact, we cannot close stopCh
because watchCache will become not ready, affecting watch request. For sendInitialEvents=false, AllowBookmarks=true
watch request, the bookmark sending frequency is 1 minute, and I control the watchevent receive timeout to 5 seconds, which is equivalent to ensuring that bookmarks are only generated by the processInterval method. So I just delete this code. : )
/gentle ping @wojtek-t
if err != nil { | ||
t.Fatalf("Failed to create watch: %v", err) | ||
} | ||
verifyWatchEvents(t, w, 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.
ping
bcebd56
to
25113e8
Compare
/retest |
25113e8
to
973f20c
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.
Just few more nits - other than that LGTM.
} | ||
|
||
for i := range scenarios { | ||
expectedWatchEvents := expectedPodEvents |
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.
for _, tc := range scenarios {
t.Run(tc.name, func(t *testing.T) {
...
}
}
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.
get it!
} | ||
storagetesting.TestCheckResultsInStrictOrder(t, w, expectedWatchEvents) | ||
storagetesting.TestCheckNoMoreResults(t, w) | ||
cancel() |
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.
with the comment I mentioned above, make it a defer cancel() next to where context is created
} else { | ||
t.Fatalf("cannot receive correct event, expect no event, but get a event: %+v", event) | ||
} | ||
case <-time.After(2 * time.Second): |
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.
We still didn't fully address the problem of long-running tests and exceeding the timeout for single package tests.
So let's for now use something shorter - please do the same thing as in testCheckNoMoreResults
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.
I noticed that the timeout used in the testCheckNoMoreResults
function is 100ms
, but we cannot guarantee that the normal bookmark event (not the initial bookmark event) will be received within 100ms
. It is possible that it will be received at 101ms
, 102ms
, or 103ms
..., which could cause the subsequent testCheckNoMoreResults
function to fail. Therefore, I still use 100ms
in the testCheckResultWithIgnoreFunc
function to avoid package test taking too long, and I add an ignore function argument to testCheckNoMoreResults
and rename it to testCheckNoMoreResultsWithIgnoreFunc
to ignore the normal bookmark event. :)
@@ -1512,8 +1512,10 @@ func RunWatchSemantics(ctx context.Context, t *testing.T, store storage.Interfac | |||
require.NoError(t, err, "failed to add a pod: %v") | |||
createdPods = append(createdPods, out) | |||
} | |||
testCheckResultsInStrictOrder(t, w, scenario.expectedEventsAfterEstablishingWatch(createdPods)) | |||
testCheckNoMoreResults(t, w) | |||
testCheckResultWithIgnoreFunc(t, w, scenario.expectedEventsAfterEstablishingWatch(createdPods), func(watchEvent watch.Event) bool { |
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.
nit: define
var ignoreEventsFn := func(event watch.Event) bool { return event.Type == watch.Bookmark }
and use it here
973f20c
to
278f2a4
Compare
/retest |
59b0e4f
to
f476c78
Compare
f476c78
to
7239202
Compare
/lgtm |
LGTM label has been added. Git tree hash: 850b4e6861b8d406b79824ab024c7a1698fa3667
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Chaunceyctx, wojtek-t 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 |
What type of PR is this?
What this PR does / why we need it:
/kind bug
Which issue(s) this PR fixes:
Fixes # #126958
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: