-
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
Add api-machinery 'watch-consistency' e2e test #69829
Conversation
6a31f91
to
cc826d5
Compare
cc826d5
to
44995af
Compare
test/e2e/apimachinery/watch.go
Outdated
@@ -314,6 +316,49 @@ var _ = SIGDescribe("Watchers", func() { | |||
expectEvent(testWatch, watch.Modified, testConfigMapThirdUpdate) | |||
expectEvent(testWatch, watch.Deleted, nil) | |||
}) | |||
|
|||
/* | |||
Testname: watch-consistency |
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.
Something
weird
happened
to
this comment
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.
gah! fixed
44995af
to
5ee5ff1
Compare
5ee5ff1
to
ad16c94
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.
Nits. Do we want to resume a watch if it fails for some reason, or should that fail the test? I'm unsure. Watches shouldn't really randomly fail.
Expect(err).NotTo(HaveOccurred()) | ||
wcs = append(wcs, wc) | ||
resourceVersion = waitForNextConfigMapEvent(wcs[0]).ResourceVersion | ||
for _, wc := range wcs[1:] { |
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 bet doing these all in parallel would significantly reduce the wall time.
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.
A bit to my surprise, this didn't speed things up. I'm guessing that the buffered channels <-watch.ResultChan()
in waitForNextConfigMapEvent()
are sufficiently concurrent already, since the watches are initiated in the outer for loop.
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.
Interesting.
test/e2e/apimachinery/watch.go
Outdated
|
||
existing := []int{} | ||
for i := 0; ; i++ { | ||
waitc := time.After(minWaitBetweenEvents) // rate limit |
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.
tc := time.NewTicker(minWaitBetweenEvents)
defer tc.Stop()
for range tc.C
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.
Ah I see you have a multi channel select statement at the bottom, so the for statement I suggested won't work. I think it still makes sense to use the ticker?
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.
Code using the ticker reads better. Thanks!
test/e2e/apimachinery/watch.go
Outdated
Expect(err).NotTo(HaveOccurred()) | ||
existing = append(existing, i) | ||
case updateEvent: | ||
idx := rand.Int() % len(existing) |
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.
Intn(existing)
Mod leaves a biased result if existing
isn't a divisor of 2^32. This 100% doesn't matter for this use but no need to leave the example here to confuse people :)
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.
yikes, yes, happy to leave a good example here.
test/e2e/apimachinery/watch.go
Outdated
const ( | ||
createEvent = 0 | ||
updateEvent = iota | ||
deleteEvent = iota |
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 think you can just:
createEvent = iota
updateEvent
deleteEvent
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.
Much better, fixed.
test/e2e/apimachinery/watch.go
Outdated
Expect(err).NotTo(HaveOccurred()) | ||
case deleteEvent: | ||
idx := rand.Int() % len(existing) | ||
name := fmt.Sprintf("cm-%d", existing[idx]) |
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: might be worth it to declare name := func(n int) string { return fmt.Sprintf("cm-%d", existing[n]) }
somewhere?
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.
sg
I think we need to get the test in and demonstrate that it works before adding it to conformance. |
ad16c94
to
88ac549
Compare
Thanks @lavalamp. Feedback applied. I've removed this from conformance (in code and in PR title/desc/labels). Once its had some bake time I'll propose it for conformance via a separate PR. |
d39bd21
to
8616fbb
Compare
/test pull-kubernetes-e2e-kops-aws |
/retest |
1 similar comment
/retest |
This is ready for review. Tests are all passing. |
test/e2e/apimachinery/watch.go
Outdated
go func() { | ||
defer GinkgoRecover() | ||
produceConfigMapEvents(f, stopc, 5*time.Millisecond) | ||
close(donec) |
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: probably best to defer this.
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.
Fixed. Thanks!
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jpbetz, lavalamp 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 |
8616fbb
to
f87d2c6
Compare
/retest |
1 similar comment
/retest |
/lgtm |
/retest |
/retest Review the full test history for this PR. Silence the bot with an |
Added a watch consistency e2e test as originally proposed in #67717.
Plan is to make this a conformance test after it's had sufficient bake time.
This test continues to use ConfigMap for watch tests. We will expand the watch tests to also test others resource separately as part of #67718.
to ensure concurrent writes throughout the test, event production runs in the background throughout the test. It's rated limited to no more than 200 events/sec, but runs indefinitely until the watchers complete their testing.
100 iterations was selected since that runs in ~15 seconds and the recommended limit for e2e tests is 20 seconds.
/kind cleanup
/sig api-machinery
/cc @lavalamp