Fix ping (#80)

* let poll do his job when closing

* try fix test

* try fix test

* Update IXWebSocketTransport.cpp

* add log to find issue on CI

* add log to find issue on CI

* add log to find issue on CI

* add log to find issue on CI

* add log to find issue on CI

* change state immediately, and send close frame after

* add immediate close test

* disable test for windows

* reenable ping / ping timeout tests

* add time to let windows close client

* reenable ping timeout test

* add 100ms more

* disable test for windows
This commit is contained in:
Kumamon38 2019-05-21 18:35:41 +02:00 committed by Benjamin Sergeant
parent 3990d3bcbf
commit 6264a8b41d
3 changed files with 23 additions and 25 deletions

View File

@ -45,12 +45,12 @@ if (UNIX)
IXDNSLookupTest.cpp
cmd_websocket_chat.cpp
IXWebSocketCloseTest.cpp
IXWebSocketPingTest.cpp
IXWebSocketPingTimeoutTest.cpp
)
endif()
# Disable tests for now that are failing or not reliable
# IXWebSocketPingTest.cpp
# IXWebSocketPingTimeoutTest.cpp
# IXWebSocketMessageQTest.cpp (trigger a segfault on Linux)
add_executable(ixwebsocket_unittest ${SOURCES})

View File

@ -225,8 +225,8 @@ TEST_CASE("Websocket_ping_no_data_sent_setPingInterval", "[setPingInterval]")
// -> expected ping messages == 2 as 2100 seconds, 1 ping sent every second
REQUIRE(serverReceivedPingMessages == 2);
// Give us 500ms for the server to notice that clients went away
ix::msleep(500);
// Give us 1000ms for the server to notice that clients went away
ix::msleep(1000);
REQUIRE(server.getClients().size() == 0);
ix::reportWebSocketTraffic();
@ -272,8 +272,8 @@ TEST_CASE("Websocket_ping_data_sent_setPingInterval", "[setPingInterval]")
// -> expected ping messages == 3 as 900+900+1300 = 3100 seconds, 1 ping sent every second
REQUIRE(serverReceivedPingMessages == 3);
// Give us 500ms for the server to notice that clients went away
ix::msleep(500);
// Give us 1000ms for the server to notice that clients went away
ix::msleep(1000);
REQUIRE(server.getClients().size() == 0);
ix::reportWebSocketTraffic();
@ -325,8 +325,8 @@ TEST_CASE("Websocket_ping_data_sent_setPingInterval_half_full", "[setPingInterva
webSocketClient.stop();
// Give us 500ms for the server to notice that clients went away
ix::msleep(500);
// Give us 1000ms for the server to notice that clients went away
ix::msleep(1000);
REQUIRE(server.getClients().size() == 0);
ix::reportWebSocketTraffic();
@ -377,8 +377,8 @@ TEST_CASE("Websocket_ping_data_sent_setPingInterval_full", "[setPingInterval]")
webSocketClient.stop();
// Give us 500ms for the server to notice that clients went away
ix::msleep(500);
// Give us 1000ms for the server to notice that clients went away
ix::msleep(1000);
REQUIRE(server.getClients().size() == 0);
ix::reportWebSocketTraffic();
@ -422,8 +422,8 @@ TEST_CASE("Websocket_ping_no_data_sent_setHeartBeatPeriod", "[setHeartBeatPeriod
// -> expected ping messages == 1 as 1900 seconds, 1 ping sent every second
REQUIRE(serverReceivedPingMessages == 1);
// Give us 500ms for the server to notice that clients went away
ix::msleep(500);
// Give us 1000ms for the server to notice that clients went away
ix::msleep(1000);
REQUIRE(server.getClients().size() == 0);
ix::reportWebSocketTraffic();
@ -472,8 +472,8 @@ TEST_CASE("Websocket_ping_data_sent_setHeartBeatPeriod", "[setHeartBeatPeriod]")
// -> expected ping messages == 2 as 900+900+1100 = 2900 seconds, 1 ping sent every second
REQUIRE(serverReceivedPingMessages == 2);
// Give us 500ms for the server to notice that clients went away
ix::msleep(500);
// Give us 1000ms for the server to notice that clients went away
ix::msleep(1000);
REQUIRE(server.getClients().size() == 0);
ix::reportWebSocketTraffic();

View File

@ -259,8 +259,8 @@ TEST_CASE("Websocket_ping_timeout_not_checked", "[setPingTimeout]")
webSocketClient.stop();
// Give us 500ms for the server to notice that clients went away
ix::msleep(500);
// Give us 1000ms for the server to notice that clients went away
ix::msleep(1000);
REQUIRE(server.getClients().size() == 0);
// Ensure client close was not by ping timeout
@ -298,7 +298,7 @@ TEST_CASE("Websocket_ping_no_timeout", "[setPingTimeout]")
REQUIRE(server.getClients().size() == 1);
ix::msleep(1100);
ix::msleep(1200);
// Here we test ping timeout, no timeout
REQUIRE(serverReceivedPingMessages == 1);
@ -312,8 +312,8 @@ TEST_CASE("Websocket_ping_no_timeout", "[setPingTimeout]")
webSocketClient.stop();
// Give us 500ms for the server to notice that clients went away
ix::msleep(500);
// Give us 1000ms for the server to notice that clients went away
ix::msleep(1000);
REQUIRE(server.getClients().size() == 0);
// Ensure client close was not by ping timeout
@ -365,7 +365,7 @@ TEST_CASE("Websocket_no_ping_but_timeout", "[setPingTimeout]")
REQUIRE(serverReceivedPingMessages == 0);
REQUIRE(webSocketClient.getReceivedPongMessages() == 0);
// Ensure client close was by ping timeout
ix::msleep(300);
ix::msleep(1000);
REQUIRE(webSocketClient.isClosed() == true);
REQUIRE(webSocketClient.closedDueToPingTimeout() == true);
@ -417,7 +417,7 @@ TEST_CASE("Websocket_ping_timeout", "[setPingTimeout]")
REQUIRE(serverReceivedPingMessages == 1);
REQUIRE(webSocketClient.getReceivedPongMessages() == 0);
// Ensure client close was by ping timeout
ix::msleep(300);
ix::msleep(1000);
REQUIRE(webSocketClient.isClosed() == true);
REQUIRE(webSocketClient.closedDueToPingTimeout() == true);
@ -429,7 +429,6 @@ TEST_CASE("Websocket_ping_timeout", "[setPingTimeout]")
}
}
#if 0 // this test fails on travis / commenting it out for now to get back to a green travis state
TEST_CASE("Websocket_ping_long_timeout", "[setPingTimeout]")
{
SECTION("Make sure that ping messages don't have responses (no PONG).")
@ -458,7 +457,7 @@ TEST_CASE("Websocket_ping_long_timeout", "[setPingTimeout]")
REQUIRE(server.getClients().size() == 1);
ix::msleep(5900);
ix::msleep(5800);
// Here we test ping timeout, no timeout yet (2 ping sent at 2s and 4s)
REQUIRE(serverReceivedPingMessages == 2);
@ -468,7 +467,7 @@ TEST_CASE("Websocket_ping_long_timeout", "[setPingTimeout]")
REQUIRE(webSocketClient.isClosed() == false);
REQUIRE(webSocketClient.closedDueToPingTimeout() == false);
ix::msleep(200);
ix::msleep(600);
// Here we test ping timeout, timeout (at 6 seconds)
REQUIRE(serverReceivedPingMessages == 2);
@ -484,4 +483,3 @@ TEST_CASE("Websocket_ping_long_timeout", "[setPingTimeout]")
ix::reportWebSocketTraffic();
}
}
#endif