Skip to content

Commit

Permalink
Attempts to add test coverage.
Browse files Browse the repository at this point in the history
Signed-off-by: Biren Roy <birenroy@google.com>
  • Loading branch information
birenroy committed May 22, 2024
1 parent 829fb9c commit 0ebc929
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/common/http/http2/codec_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,51 @@ TEST_P(Http2CodecImplTest, SimpleRequestResponse) {
}
}

TEST_P(Http2CodecImplTest, SimpleRequestResponseOldApi) {
scoped_runtime_.mergeValues({{"envoy.reloadable_features.http2_use_visitor_for_data", "false"}});
initialize();

InSequence s;
TestRequestHeaderMapImpl request_headers;
HttpTestUtility::addDefaultHeaders(request_headers);
request_headers.setMethod("POST");

// Encode request headers.
EXPECT_CALL(request_decoder_, decodeHeaders_(_, false));
EXPECT_TRUE(request_encoder_->encodeHeaders(request_headers, false).ok());

// Queue request body.
Buffer::OwnedImpl request_body(std::string(1024, 'a'));
request_encoder_->encodeData(request_body, true);

// Flush request body.
EXPECT_CALL(request_decoder_, decodeData(_, true)).Times(AtLeast(1));
driveToCompletion();

TestResponseHeaderMapImpl response_headers{{":status", "200"}};

// Encode response headers.
EXPECT_CALL(response_decoder_, decodeHeaders_(_, false));
response_encoder_->encodeHeaders(response_headers, false);

// Queue response body.
Buffer::OwnedImpl response_body(std::string(1024, 'b'));
response_encoder_->encodeData(response_body, true);

// Flush response body.
EXPECT_CALL(response_decoder_, decodeData(_, true)).Times(AtLeast(1));
driveToCompletion();

EXPECT_TRUE(client_wrapper_->status_.ok());
EXPECT_TRUE(server_wrapper_->status_.ok());

if (http2_implementation_ == Http2Impl::Nghttp2) {
// Regression test for issue #19761.
EXPECT_EQ(0, getClientDataSourcesSize());
EXPECT_EQ(0, getServerDataSourcesSize());
}
}

TEST_P(Http2CodecImplTest, ShutdownNotice) {
initialize();
EXPECT_EQ(absl::nullopt, request_encoder_->http1StreamEncoderOptions());
Expand Down

0 comments on commit 0ebc929

Please sign in to comment.