wsd: fixup max connections unittest
Change-Id: I107dadb973554b21f20211c8316cec7139953f47 Reviewed-on: https://gerrit.libreoffice.org/32713 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
parent
3a79e13214
commit
606f85db87
2 changed files with 20 additions and 9 deletions
|
@ -187,6 +187,12 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
|
|||
return statusCode;
|
||||
}
|
||||
|
||||
inline
|
||||
int getErrorCode(const std::shared_ptr<LOOLWebSocket>& ws, std::string& message)
|
||||
{
|
||||
return getErrorCode(*ws, message);
|
||||
}
|
||||
|
||||
inline
|
||||
std::vector<char> getResponseMessage(LOOLWebSocket& ws, const std::string& prefix, std::string name = "", const size_t timeoutMs = 10000)
|
||||
{
|
||||
|
|
|
@ -142,8 +142,16 @@ void HTTPWSError::testMaxDocuments()
|
|||
|
||||
void HTTPWSError::testMaxConnections()
|
||||
{
|
||||
#if MAX_CONNECTIONS > 0
|
||||
static_assert(MAX_CONNECTIONS >= 3, "MAX_CONNECTIONS must be at least 3");
|
||||
const auto testname = "maxConnections ";
|
||||
|
||||
if (MAX_CONNECTIONS > 100)
|
||||
{
|
||||
std::cerr << "Skipping " << testname << "test since MAX_CONNECTION (" << MAX_CONNECTIONS
|
||||
<< ") is too high to test. Set to a more sensible number, ideally a dozen or so." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
std::cerr << "Opening max number of connections: " << MAX_CONNECTIONS << std::endl;
|
||||
|
@ -158,7 +166,7 @@ void HTTPWSError::testMaxConnections()
|
|||
std::cerr << "Opened connect #1 of " << MAX_CONNECTIONS << std::endl;
|
||||
|
||||
std::vector<std::shared_ptr<LOOLWebSocket>> views;
|
||||
for(int it = 1; it < MAX_CONNECTIONS; it++)
|
||||
for (int it = 1; it < MAX_CONNECTIONS; ++it)
|
||||
{
|
||||
std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(_uri));
|
||||
auto ws = std::make_shared<LOOLWebSocket>(*session, request, _response);
|
||||
|
@ -170,24 +178,21 @@ void HTTPWSError::testMaxConnections()
|
|||
|
||||
// try to connect MAX_CONNECTIONS + 1
|
||||
std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(_uri));
|
||||
LOOLWebSocket socketN(*session, request, _response);
|
||||
auto socketN = std::make_shared<LOOLWebSocket>(*session, request, _response);
|
||||
|
||||
// send loolclient, load and partpagerectangles
|
||||
sendTextFrame(socketN, "loolclient ", testname);
|
||||
sendTextFrame(socketN, "load ", testname);
|
||||
sendTextFrame(socketN, "partpagerectangles ", testname);
|
||||
// Send load request, which will fail.
|
||||
sendTextFrame(socketN, "load url=" + docURL, testname);
|
||||
|
||||
std::string message;
|
||||
const auto statusCode = getErrorCode(socketN, message);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode);
|
||||
|
||||
socketN.shutdown();
|
||||
socketN->shutdown();
|
||||
}
|
||||
catch (const Poco::Exception& exc)
|
||||
{
|
||||
CPPUNIT_FAIL(exc.displayText());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(HTTPWSError);
|
||||
|
|
Loading…
Reference in a new issue