Skip to content

Commit 323d4f2

Browse files
committed
Relaxing outside websocket ssl test to not fail if due to timeout network issues.
1 parent 6ff179c commit 323d4f2

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

Release/tests/functional/websockets/client/authentication_tests.cpp

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,42 @@ TEST_FIXTURE(uri_address, auth_with_credentials, "Ignore", "245")
8989
TEST(ssl_test)
9090
{
9191
websocket_client client;
92-
client.connect(U("wss://echo.websocket.org/")).wait();
9392
std::string body_str("hello");
9493

95-
auto receive_task = client.receive().then([body_str](websocket_incoming_message ret_msg)
94+
try
9695
{
97-
auto ret_str = ret_msg.extract_string().get();
96+
client.connect(U("wss://echo.websocket.org/")).wait();
9897

99-
VERIFY_ARE_EQUAL(ret_msg.length(), body_str.length());
100-
VERIFY_ARE_EQUAL(body_str.compare(ret_str), 0);
101-
VERIFY_ARE_EQUAL(ret_msg.messge_type(), websocket_message_type::text_message);
102-
});
98+
auto receive_task = client.receive().then([body_str](websocket_incoming_message ret_msg)
99+
{
100+
auto ret_str = ret_msg.extract_string().get();
103101

104-
websocket_outgoing_message msg;
105-
msg.set_utf8_message(body_str);
106-
client.send(msg).wait();
102+
VERIFY_ARE_EQUAL(ret_msg.length(), body_str.length());
103+
VERIFY_ARE_EQUAL(body_str.compare(ret_str), 0);
104+
VERIFY_ARE_EQUAL(ret_msg.messge_type(), websocket_message_type::text_message);
105+
});
107106

108-
receive_task.wait();
109-
client.close().wait();
107+
websocket_outgoing_message msg;
108+
msg.set_utf8_message(body_str);
109+
client.send(msg).wait();
110+
111+
receive_task.wait();
112+
client.close().wait();
113+
}
114+
catch (const websocket_exception &e)
115+
{
116+
const auto msg = std::string(e.what());
117+
if (msg.find("set_fail_handler") != std::string::npos)
118+
{
119+
if (msg.find("TLS handshake timed out") != std::string::npos || msg.find("Timer Expired") != std::string::npos)
120+
{
121+
// Since this test depends on an outside server sometimes it sporadically can fail due to timeouts
122+
// especially on our build machines.
123+
return;
124+
}
125+
}
126+
throw;
127+
}
110128
}
111129

112130
// These tests are specific to our websocketpp based implementation.

0 commit comments

Comments
 (0)