Skip to content

Commit

Permalink
Refs #20141: Fix windows tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jesus Perez <jesusperez@eprosima.com>
  • Loading branch information
jepemi committed Feb 21, 2024
1 parent f2095a4 commit 272e99a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
18 changes: 8 additions & 10 deletions test/unittest/transport/TCPv4Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2059,12 +2059,12 @@ TEST_F(TCPv4Tests, reconnect_after_open_port_failure)
// Create a TCP Server transport
TCPv4TransportDescriptor serverDescriptor;
serverDescriptor.add_listener_port(port);
TCPv4Transport* serverTransportUnderTest = new TCPv4Transport(serverDescriptor);
std::unique_ptr<TCPv4Transport> serverTransportUnderTest(new TCPv4Transport(serverDescriptor));
serverTransportUnderTest->init();

// Create a TCP Client transport
TCPv4TransportDescriptor clientDescriptor;
MockTCPv4Transport* clientTransportUnderTest = new MockTCPv4Transport(clientDescriptor);
std::unique_ptr<MockTCPv4Transport> clientTransportUnderTest(new MockTCPv4Transport(clientDescriptor));
clientTransportUnderTest->init();

// Add initial peer to the client
Expand All @@ -2087,14 +2087,14 @@ TEST_F(TCPv4Tests, reconnect_after_open_port_failure)

// Disconnect server
EXPECT_TRUE(serverTransportUnderTest->CloseInputChannel(initialPeerLocator));
delete serverTransportUnderTest;
serverTransportUnderTest.reset();
std::this_thread::sleep_for(std::chrono::milliseconds(300));
// Client should have passed logical port to pending list
ASSERT_FALSE(channel->is_logical_port_opened(7410));
ASSERT_TRUE(channel->is_logical_port_added(7410));

// Now try normal reconnection
serverTransportUnderTest = new TCPv4Transport(serverDescriptor);
serverTransportUnderTest.reset(new TCPv4Transport(serverDescriptor));
serverTransportUnderTest->init();
ASSERT_TRUE(serverTransportUnderTest->OpenInputChannel(initialPeerLocator, nullptr, 0x00FF));
clientTransportUnderTest->send(nullptr, 0, channel->locator(), initialPeerLocator); // connect()
Expand All @@ -2105,26 +2105,26 @@ TEST_F(TCPv4Tests, reconnect_after_open_port_failure)

// Disconnect server
EXPECT_TRUE(serverTransportUnderTest->CloseInputChannel(initialPeerLocator));
delete serverTransportUnderTest;
serverTransportUnderTest.reset();
std::this_thread::sleep_for(std::chrono::milliseconds(300));
// Client should have passed logical port to pending list
ASSERT_FALSE(channel->is_logical_port_opened(7410));
ASSERT_TRUE(channel->is_logical_port_added(7410));

// Now try reconnect the server and close server's input channel before client's open logical
// port request, and then delete server and reconnect
serverTransportUnderTest = new TCPv4Transport(serverDescriptor);
serverTransportUnderTest.reset(new TCPv4Transport(serverDescriptor));
serverTransportUnderTest->init();
ASSERT_TRUE(serverTransportUnderTest->OpenInputChannel(initialPeerLocator, nullptr, 0x00FF));
EXPECT_TRUE(serverTransportUnderTest->CloseInputChannel(initialPeerLocator));
clientTransportUnderTest->send(nullptr, 0, channel->locator(), initialPeerLocator); // connect()
std::this_thread::sleep_for(std::chrono::milliseconds(300));
delete serverTransportUnderTest;
serverTransportUnderTest.reset();
ASSERT_FALSE(channel->is_logical_port_opened(7410));
ASSERT_TRUE(channel->is_logical_port_added(7410));

// Now try normal reconnection
serverTransportUnderTest = new TCPv4Transport(serverDescriptor);
serverTransportUnderTest.reset(new TCPv4Transport(serverDescriptor));
serverTransportUnderTest->init();
ASSERT_TRUE(serverTransportUnderTest->OpenInputChannel(initialPeerLocator, nullptr, 0x00FF));
clientTransportUnderTest->send(nullptr, 0, channel->locator(), initialPeerLocator); // connect()
Expand All @@ -2136,8 +2136,6 @@ TEST_F(TCPv4Tests, reconnect_after_open_port_failure)
// Clear test
EXPECT_TRUE(serverTransportUnderTest->CloseInputChannel(initialPeerLocator));
client_resource_list.clear();
delete serverTransportUnderTest;
delete clientTransportUnderTest;
}

void TCPv4Tests::HELPER_SetDescriptorDefaults()
Expand Down
18 changes: 8 additions & 10 deletions test/unittest/transport/TCPv6Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,12 @@ TEST_F(TCPv6Tests, reconnect_after_open_port_failure)
// Create a TCP Server transport
TCPv6TransportDescriptor serverDescriptor;
serverDescriptor.add_listener_port(port);
TCPv6Transport* serverTransportUnderTest = new TCPv6Transport(serverDescriptor);
std::unique_ptr<TCPv6Transport> serverTransportUnderTest(new TCPv6Transport(serverDescriptor));
serverTransportUnderTest->init();

// Create a TCP Client transport
TCPv6TransportDescriptor clientDescriptor;
MockTCPv6Transport* clientTransportUnderTest = new MockTCPv6Transport(clientDescriptor);
std::unique_ptr<MockTCPv6Transport> clientTransportUnderTest(new MockTCPv6Transport(clientDescriptor));
clientTransportUnderTest->init();

// Add initial peer to the client
Expand All @@ -437,14 +437,14 @@ TEST_F(TCPv6Tests, reconnect_after_open_port_failure)

// Disconnect server
EXPECT_TRUE(serverTransportUnderTest->CloseInputChannel(initialPeerLocator));
delete serverTransportUnderTest;
serverTransportUnderTest.reset();
std::this_thread::sleep_for(std::chrono::milliseconds(300));
// Client should have passed logical port to pending list
ASSERT_FALSE(channel->is_logical_port_opened(7410));
ASSERT_TRUE(channel->is_logical_port_added(7410));

// Now try normal reconnection
serverTransportUnderTest = new TCPv6Transport(serverDescriptor);
serverTransportUnderTest.reset(new TCPv6Transport(serverDescriptor));
serverTransportUnderTest->init();
ASSERT_TRUE(serverTransportUnderTest->OpenInputChannel(initialPeerLocator, nullptr, 0x00FF));
clientTransportUnderTest->send(nullptr, 0, channel->locator(), initialPeerLocator); // connect()
Expand All @@ -455,26 +455,26 @@ TEST_F(TCPv6Tests, reconnect_after_open_port_failure)

// Disconnect server
EXPECT_TRUE(serverTransportUnderTest->CloseInputChannel(initialPeerLocator));
delete serverTransportUnderTest;
serverTransportUnderTest.reset();
std::this_thread::sleep_for(std::chrono::milliseconds(300));
// Client should have passed logical port to pending list
ASSERT_FALSE(channel->is_logical_port_opened(7410));
ASSERT_TRUE(channel->is_logical_port_added(7410));

// Now try reconnect the server and close server's input channel before client's open logical
// port request, and then delete server and reconnect
serverTransportUnderTest = new TCPv6Transport(serverDescriptor);
serverTransportUnderTest.reset(new TCPv6Transport(serverDescriptor));
serverTransportUnderTest->init();
ASSERT_TRUE(serverTransportUnderTest->OpenInputChannel(initialPeerLocator, nullptr, 0x00FF));
EXPECT_TRUE(serverTransportUnderTest->CloseInputChannel(initialPeerLocator));
clientTransportUnderTest->send(nullptr, 0, channel->locator(), initialPeerLocator); // connect()
std::this_thread::sleep_for(std::chrono::milliseconds(300));
delete serverTransportUnderTest;
serverTransportUnderTest.reset();
ASSERT_FALSE(channel->is_logical_port_opened(7410));
ASSERT_TRUE(channel->is_logical_port_added(7410));

// Now try normal reconnection
serverTransportUnderTest = new TCPv6Transport(serverDescriptor);
serverTransportUnderTest.reset(new TCPv6Transport(serverDescriptor));
serverTransportUnderTest->init();
ASSERT_TRUE(serverTransportUnderTest->OpenInputChannel(initialPeerLocator, nullptr, 0x00FF));
clientTransportUnderTest->send(nullptr, 0, channel->locator(), initialPeerLocator); // connect()
Expand All @@ -486,8 +486,6 @@ TEST_F(TCPv6Tests, reconnect_after_open_port_failure)
// Clear test
EXPECT_TRUE(serverTransportUnderTest->CloseInputChannel(initialPeerLocator));
client_resource_list.clear();
delete serverTransportUnderTest;
delete clientTransportUnderTest;
}


Expand Down

0 comments on commit 272e99a

Please sign in to comment.