Skip to content

Commit

Permalink
alpn: adding a connection fail test (envoyproxy#31965)
Browse files Browse the repository at this point in the history

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
  • Loading branch information
alyssawilk authored Feb 6, 2024
1 parent e5087ac commit 9ecb0a4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ envoy_cc_test(
name = "alpn_integration_test",
size = "large",
srcs = ["alpn_integration_test.cc"],
shard_count = 2,
tags = [
"cpu:3",
],
Expand Down
29 changes: 29 additions & 0 deletions test/integration/alpn_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,34 @@ TEST_P(AlpnIntegrationTest, Mixed) {
EXPECT_EQ("200", response2->headers().Status()->value().getStringView());
}

TEST_P(AlpnIntegrationTest, DisconnectDuringHandshake) {
DISABLE_UNDER_WINDOWS;
setUpstreamProtocol(Http::CodecType::HTTP2);
protocols_ = {Http::CodecType::HTTP2};
setUpstreamCount(1);
initialize();

absl::Notification unblock_accept;
absl::Notification accept_blocked;
fake_upstreams_[0]->runOnDispatcherThread([&] {
accept_blocked.Notify();
unblock_accept.WaitForNotification();
});
accept_blocked.WaitForNotification();

// Connect and wait for the upstream connection to be established.
codec_client_ = makeHttpConnection(makeClientConnection((lookupPort("http"))));
auto response = codec_client_->makeHeaderOnlyRequest(default_request_headers_);
test_server_->waitForCounterGe("cluster.cluster_0.upstream_cx_total", 1);

// Close the downstream connection and wait for the upstream stream to go away.
codec_client_->close();
test_server_->waitForCounterEq("cluster.cluster_0.upstream_rq_cancelled", 1);

// Allow the connection to complete.
unblock_accept.Notify();
test_server_->waitForCounterGe("cluster.cluster_0.upstream_cx_http2_total", 1);
}

} // namespace
} // namespace Envoy

0 comments on commit 9ecb0a4

Please sign in to comment.