Skip to content

Commit

Permalink
[test] Fixing integration test to cleanup cleanly (#18293)
Browse files Browse the repository at this point in the history
Commit Message: [test] Fixing integration test to cleanup cleanly
Additional Description:
Fixing the DownstreamSendingEmptyMetadata integration test to cleanup cleanly by closing the upstream connection before closing the client.

Risk Level: Low - tests only.
Testing: Fixed a current test.
Docs Changes: N/A.
Release Notes: N/A.
Platform Specific Features: N/A.
Part of the fix of #18290.

Signed-off-by: Adi Suissa-Peleg <adip@google.com>
  • Loading branch information
adisuissa authored Sep 28, 2021
1 parent b979155 commit 1504c2c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/integration/multiplexed_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1720,16 +1720,14 @@ TEST_P(Http2FrameIntegrationTest, DownstreamSendingEmptyMetadata) {
// This test uses an Http2Frame and not the encoder's encodeMetadata method,
// because encodeMetadata fails when an empty metadata map is sent.
beginSession();
FakeHttpConnectionPtr fake_upstream_connection;
FakeStreamPtr fake_upstream_request;

const uint32_t client_stream_idx = 1;
// Send request.
const Http2Frame request =
Http2Frame::makePostRequest(client_stream_idx, "host", "/path/to/long/url");
sendFrame(request);
ASSERT_TRUE(fake_upstreams_[0]->waitForHttpConnection(*dispatcher_, fake_upstream_connection));
ASSERT_TRUE(fake_upstream_connection->waitForNewStream(*dispatcher_, fake_upstream_request));
ASSERT_TRUE(fake_upstreams_[0]->waitForHttpConnection(*dispatcher_, fake_upstream_connection_));
ASSERT_TRUE(fake_upstream_connection_->waitForNewStream(*dispatcher_, upstream_request_));

// Send metadata frame with empty metadata map.
const Http::MetadataMap empty_metadata_map;
Expand All @@ -1743,9 +1741,9 @@ TEST_P(Http2FrameIntegrationTest, DownstreamSendingEmptyMetadata) {
sendFrame(empty_data_frame);

// Upstream sends a reply.
ASSERT_TRUE(fake_upstream_request->waitForEndStream(*dispatcher_));
ASSERT_TRUE(upstream_request_->waitForEndStream(*dispatcher_));
const Http::TestResponseHeaderMapImpl response_headers{{":status", "200"}};
fake_upstream_request->encodeHeaders(response_headers, true);
upstream_request_->encodeHeaders(response_headers, true);

// Make sure that a response from upstream is received by the client, and
// close the connection.
Expand All @@ -1754,7 +1752,10 @@ TEST_P(Http2FrameIntegrationTest, DownstreamSendingEmptyMetadata) {
EXPECT_EQ(Http2Frame::ResponseStatus::Ok, response.responseStatus());
EXPECT_EQ(1, test_server_->counter("http2.metadata_empty_frames")->value());

// Cleanup.
// Cleanup. Closing upstream connection first to avoid a race between the
// client FIN and the connection closure (see comment in
// HttpIntegrationTest::cleanupUpstreamAndDownstream).
cleanupUpstreamAndDownstream();
tcp_client_->close();
}

Expand Down

0 comments on commit 1504c2c

Please sign in to comment.