From 9ecb0a4a04e37c5bf8c3424fae07eb96e724f683 Mon Sep 17 00:00:00 2001 From: alyssawilk Date: Tue, 6 Feb 2024 14:11:01 -0500 Subject: [PATCH] alpn: adding a connection fail test (#31965) Signed-off-by: Alyssa Wilk --- test/integration/BUILD | 1 + test/integration/alpn_integration_test.cc | 29 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/test/integration/BUILD b/test/integration/BUILD index 4649014f41af..caa4b6b2a368 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -82,6 +82,7 @@ envoy_cc_test( name = "alpn_integration_test", size = "large", srcs = ["alpn_integration_test.cc"], + shard_count = 2, tags = [ "cpu:3", ], diff --git a/test/integration/alpn_integration_test.cc b/test/integration/alpn_integration_test.cc index dada4bfe73db..d15d590332df 100644 --- a/test/integration/alpn_integration_test.cc +++ b/test/integration/alpn_integration_test.cc @@ -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