-
Notifications
You must be signed in to change notification settings - Fork 4.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
Added a test to verify vhds updates when client closes connection #11341
Merged
alyssawilk
merged 7 commits into
envoyproxy:master
from
dmitri-d:fix-vhds-tsan-failures
Jun 10, 2020
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
af8d82d
Added a test to verify vhds updates when client closes connection
729a4af
Fixed formatting
5fb61a0
Added comments re: use of weak_ptr
de6d44f
Responded to feedback
3e1f390
cleaned up the test
1047ea7
Fixed build failure
2b9e7fe
Merge remote-tracking branch 'upstream' into fix-vhds-tsan-failures
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -653,5 +653,38 @@ TEST_P(VhdsIntegrationTest, VhdsOnDemandUpdateFailToResolveOneAliasOutOfSeveral) | |
cleanupUpstreamAndDownstream(); | ||
} | ||
|
||
// Verify that an vhds update succeeds even when the client closes its connection | ||
TEST_P(VhdsIntegrationTest, VhdsOnDemandUpdateHttpConnectionCloses) { | ||
// RDS exchange with a non-empty virtual_hosts field | ||
useRdsWithVhosts(); | ||
|
||
testRouterHeaderOnlyRequestAndResponse(nullptr, 1); | ||
cleanupUpstreamAndDownstream(); | ||
EXPECT_TRUE(codec_client_->waitForDisconnect()); | ||
|
||
// Attempt to make a request to an unknown host | ||
codec_client_ = makeHttpConnection(makeClientConnection((lookupPort("http")))); | ||
Http::TestRequestHeaderMapImpl request_headers{{":method", "GET"}, | ||
{":path", "/"}, | ||
{":scheme", "http"}, | ||
{":authority", "vhost_1"}, | ||
{"x-lyft-user-id", "123"}}; | ||
auto encoder_decoder = codec_client_->startRequest(request_headers); | ||
Http::RequestEncoder& encoder = encoder_decoder.first; | ||
IntegrationStreamDecoderPtr response = std::move(encoder_decoder.second); | ||
EXPECT_TRUE(compareDeltaDiscoveryRequest(Config::TypeUrl::get().VirtualHost, | ||
{vhdsRequestResourceName("vhost_1")}, {}, vhds_stream_)); | ||
|
||
envoy::api::v2::DeltaDiscoveryResponse vhds_update = | ||
createDeltaDiscoveryResponseWithResourceNameUsedAsAlias(); | ||
vhds_stream_->sendGrpcMessage(vhds_update); | ||
|
||
codec_client_->sendReset(encoder); | ||
response->waitForReset(); | ||
EXPECT_TRUE(codec_client_->connected()); | ||
|
||
cleanupUpstreamAndDownstream(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's wait for the client_codec_->waitForEndStream() and assert the connection is connected, to make sure we're covering the case we're trying to cover (stream is reset,connection is not) |
||
} | ||
|
||
} // namespace | ||
} // namespace Envoy | ||
} // namespace Envoy |
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.
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.
Thanks for adding a test for this!
So you're resetting the callback, but what tells the caller of the callback to not call it?
you've created this lambda capturing this of the filter, and if the filter is destroyed, and the resolution completes, won't the callback still be called?
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.
The callback pointer is eventually stored in a weak_ptr, which is verified before the invocation: https://github.com/envoyproxy/envoy/blob/master/source/common/router/rds_impl.cc#L288. A longer description of what's going on in relation to the callback is here: #9784 (comment).