Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: adding network coverage #19684

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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