xdsclient: deflake Test/LDSWatch_PartialValid #5552
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #5546
I've seen a couple of flakes in this test:
go-control-plane
server continuously resends the same resources if the client NACKs it. This means that our tests which verify some sort of NACKing behavior will continuously receive the same resources again and again. This means that the watch callback will be called an arbitrary number of times. This causestestutils.Channel.Send()
to block because there is no buffer on the channel. Allocating a buffer for this channel is not an option since we do not know how big a buffer we would need. Instead usingSendContext()
would ensure that the call will return when the test's context is cancelled.envconfig.XDSFederation
is to true at the top of every test and a function is deferred to set it back to its original value. The xdsclient also reads this var at multiple places, and if it so happens that the xdsclient receives a resource at the time the test is cleaning up, we end up with a data race. I don't know what would be the best way to fix this (or if there is any easy way out at all). In this PR, I'm switching to usingt.Cleanup()
instead ofdefer
to see if it helps in anyway.RELEASE NOTES: none