Skip to content

Commit

Permalink
tests: adding network coverage (#19684)
Browse files Browse the repository at this point in the history
Signed-off-by: Alyssa Wilk <[email protected]>
  • Loading branch information
alyssawilk authored Jan 25, 2022
1 parent d0b54fe commit 450631b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 0 additions & 3 deletions source/common/network/addr_family_aware_socket_option_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ class AddrFamilyAwareSocketOptionImpl : public Socket::Option,
SocketOptionName ipv6_optname, absl::string_view ipv6_value)
: ipv4_option_(std::make_unique<SocketOptionImpl>(in_state, ipv4_optname, ipv4_value)),
ipv6_option_(std::make_unique<SocketOptionImpl>(in_state, ipv6_optname, ipv6_value)) {}
AddrFamilyAwareSocketOptionImpl(Socket::OptionConstPtr&& ipv4_option,
Socket::OptionConstPtr&& ipv6_option)
: ipv4_option_(std::move(ipv4_option)), ipv6_option_(std::move(ipv6_option)) {}

// Socket::Option
bool setOption(Socket& socket,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ TEST_F(AddrFamilyAwareSocketOptionImplTest, DifferentV4AndV6OptionData) {
AddrFamilyAwareSocketOptionImpl socket_option{
envoy::config::core::v3::SocketOption::STATE_PREBIND, ENVOY_MAKE_SOCKET_OPTION_NAME(5, 10),
"hello", ENVOY_MAKE_SOCKET_OPTION_NAME(5, 10), "world"};
EXPECT_TRUE(socket_option.isSupported());
EXPECT_CALL(socket_, ipVersion()).WillRepeatedly(testing::Return(Address::IpVersion::v4));
EXPECT_EQ(
"hello",
Expand Down
5 changes: 4 additions & 1 deletion test/common/network/connection_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,7 @@ TEST_F(MockTransportConnectionImplTest, WriteReadyOnConnected) {
}

// Test the interface used by external consumers.
TEST_F(MockTransportConnectionImplTest, FlushWriteBuffer) {
TEST_F(MockTransportConnectionImplTest, FlushWriteBufferAndRtt) {
InSequence s;

// Queue up some data in write buffer.
Expand All @@ -2655,6 +2655,9 @@ TEST_F(MockTransportConnectionImplTest, FlushWriteBuffer) {
.WillOnce(Return(IoResult{PostIoAction::KeepOpen, 0, false}));
connection_->write(buffer, false);

// Make sure calling the rtt function doesn't cause problems.
connection_->lastRoundTripTime();

// A read event triggers underlying socket to ask for more data.
EXPECT_CALL(*transport_socket_, doRead(_)).WillOnce(InvokeWithoutArgs([this] {
transport_socket_callbacks_->flushWriteBuffer();
Expand Down
9 changes: 9 additions & 0 deletions test/common/network/happy_eyeballs_connection_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ TEST_F(HappyEyeballsConnectionImplTest, ConnectTimeoutThenFirstSuccess) {
EXPECT_FALSE(impl_->connecting());
}

TEST_F(HappyEyeballsConnectionImplTest, DisallowedFunctions) {
startConnect();

EXPECT_ENVOY_BUG(connection_callbacks_[0]->onAboveWriteBufferHighWatermark(),
"Unexpected data written to happy eyeballs connection");
EXPECT_ENVOY_BUG(connection_callbacks_[0]->onBelowWriteBufferLowWatermark(),
"Unexpected data drained from happy eyeballs connection");
}

TEST_F(HappyEyeballsConnectionImplTest, ConnectTimeoutThenSecondSuccess) {
startConnect();

Expand Down

0 comments on commit 450631b

Please sign in to comment.