@@ -77,8 +77,8 @@ INSTANTIATE_TEST_CASE_P(IpVersions, ConnectionImplDeathTest,
7777 TestUtility::ipTestParamsToString);
7878
7979TEST_P (ConnectionImplDeathTest, BadFd) {
80- DangerousDeprecatedTestTime test_time ;
81- Event::DispatcherImpl dispatcher (test_time. timeSource () );
80+ MockTimeSource time_source ;
81+ Event::DispatcherImpl dispatcher (time_source );
8282 EXPECT_DEATH_LOG_TO_STDERR (
8383 ConnectionImpl (dispatcher, std::make_unique<ConnectionSocketImpl>(-1 , nullptr , nullptr ),
8484 Network::Test::createRawBufferSocket (), false ),
@@ -89,7 +89,7 @@ class ConnectionImplTest : public testing::TestWithParam<Address::IpVersion> {
8989public:
9090 void setUpBasicConnection () {
9191 if (dispatcher_.get () == nullptr ) {
92- dispatcher_.reset (new Event::DispatcherImpl (test_time_. timeSource () ));
92+ dispatcher_.reset (new Event::DispatcherImpl (time_source_ ));
9393 }
9494 listener_ = dispatcher_->createListener (socket_, listener_callbacks_, true , false );
9595
@@ -152,7 +152,7 @@ class ConnectionImplTest : public testing::TestWithParam<Address::IpVersion> {
152152
153153 MockBufferFactory* factory = new StrictMock<MockBufferFactory>;
154154 dispatcher_.reset (
155- new Event::DispatcherImpl (test_time_. timeSource () , Buffer::WatermarkFactoryPtr{factory}));
155+ new Event::DispatcherImpl (time_source_ , Buffer::WatermarkFactoryPtr{factory}));
156156 // The first call to create a client session will get a MockBuffer.
157157 // Other calls for server sessions will by default get a normal OwnedImpl.
158158 EXPECT_CALL (*factory, create_ (_, _))
@@ -169,7 +169,7 @@ class ConnectionImplTest : public testing::TestWithParam<Address::IpVersion> {
169169 }
170170
171171protected:
172- DangerousDeprecatedTestTime test_time_ ;
172+ MockTimeSource time_source_ ;
173173 Event::DispatcherPtr dispatcher_;
174174 Stats::IsolatedStoreImpl stats_store_;
175175 Network::TcpListenSocket socket_{Network::Test::getAnyAddress (GetParam ()), nullptr , true };
@@ -233,7 +233,7 @@ TEST_P(ConnectionImplTest, CloseDuringConnectCallback) {
233233}
234234
235235TEST_P (ConnectionImplTest, ImmediateConnectError) {
236- dispatcher_.reset (new Event::DispatcherImpl (test_time_. timeSource () ));
236+ dispatcher_.reset (new Event::DispatcherImpl (time_source_ ));
237237
238238 // Using a broadcast/multicast address as the connection destiantion address causes an
239239 // immediate error return from connect().
@@ -805,7 +805,7 @@ TEST_P(ConnectionImplTest, BindFailureTest) {
805805 source_address_ = Network::Address::InstanceConstSharedPtr{
806806 new Network::Address::Ipv6Instance (address_string, 0 )};
807807 }
808- dispatcher_.reset (new Event::DispatcherImpl (test_time_. timeSource () ));
808+ dispatcher_.reset (new Event::DispatcherImpl (time_source_ ));
809809 listener_ = dispatcher_->createListener (socket_, listener_callbacks_, true , false );
810810
811811 client_connection_ = dispatcher_->createClientConnection (
@@ -1199,7 +1199,7 @@ class ReadBufferLimitTest : public ConnectionImplTest {
11991199public:
12001200 void readBufferLimitTest (uint32_t read_buffer_limit, uint32_t expected_chunk_size) {
12011201 const uint32_t buffer_size = 256 * 1024 ;
1202- dispatcher_.reset (new Event::DispatcherImpl (test_time_. timeSource () ));
1202+ dispatcher_.reset (new Event::DispatcherImpl (time_source_ ));
12031203 listener_ = dispatcher_->createListener (socket_, listener_callbacks_, true , false );
12041204
12051205 client_connection_ = dispatcher_->createClientConnection (
@@ -1270,8 +1270,8 @@ TEST_P(ReadBufferLimitTest, SomeLimit) {
12701270
12711271class TcpClientConnectionImplTest : public testing ::TestWithParam<Address::IpVersion> {
12721272protected:
1273- TcpClientConnectionImplTest () : dispatcher_(test_time_.timeSource() ) {}
1274- DangerousDeprecatedTestTime test_time_ ;
1273+ TcpClientConnectionImplTest () : dispatcher_(time_source_ ) {}
1274+ MockTimeSource time_source_ ;
12751275 Event::DispatcherImpl dispatcher_;
12761276};
12771277INSTANTIATE_TEST_CASE_P (IpVersions, TcpClientConnectionImplTest,
@@ -1309,5 +1309,33 @@ TEST_P(TcpClientConnectionImplTest, BadConnectConnRefused) {
13091309 dispatcher_.run (Event::Dispatcher::RunType::Block);
13101310}
13111311
1312+ class PipeClientConnectionImplTest : public testing ::Test {
1313+ protected:
1314+ PipeClientConnectionImplTest () : dispatcher_(time_source_) {}
1315+ MockTimeSource time_source_;
1316+ Event::DispatcherImpl dispatcher_;
1317+ const std::string path_{TestEnvironment::unixDomainSocketPath (" foo" )};
1318+ };
1319+
1320+ // Validate we skip setting socket options on UDS.
1321+ TEST_F (PipeClientConnectionImplTest, SkipSocketOptions) {
1322+ auto option = std::make_shared<MockSocketOption>();
1323+ EXPECT_CALL (*option, setOption (_, _)).Times (0 );
1324+ auto options = std::make_shared<Socket::Options>();
1325+ options->emplace_back (option);
1326+ ClientConnectionPtr connection = dispatcher_.createClientConnection (
1327+ Utility::resolveUrl (" unix://" + path_), Network::Address::InstanceConstSharedPtr (),
1328+ Network::Test::createRawBufferSocket (), options);
1329+ connection->close (ConnectionCloseType::NoFlush);
1330+ }
1331+
1332+ // Validate we skip setting source address.
1333+ TEST_F (PipeClientConnectionImplTest, SkipSourceAddress) {
1334+ ClientConnectionPtr connection = dispatcher_.createClientConnection (
1335+ Utility::resolveUrl (" unix://" + path_), Utility::resolveUrl (" tcp://1.2.3.4:5" ),
1336+ Network::Test::createRawBufferSocket (), nullptr );
1337+ connection->close (ConnectionCloseType::NoFlush);
1338+ }
1339+
13121340} // namespace Network
13131341} // namespace Envoy
0 commit comments