loolwsd: test logging cleanup
Change-Id: Ie2fa40eab6fec4cfe9819d75f1c35efd835b11b7 Reviewed-on: https://gerrit.libreoffice.org/24480 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
parent
7f17561f7a
commit
c6380f5820
1 changed files with 22 additions and 12 deletions
|
@ -56,15 +56,20 @@ void getDocumentPathAndURL(const char* document, std::string& documentPath, std:
|
||||||
std::cerr << "Test file: " << documentPath << std::endl;
|
std::cerr << "Test file: " << documentPath << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
inline
|
||||||
void sendTextFrame(Poco::Net::WebSocket& socket, const std::string& string)
|
void sendTextFrame(Poco::Net::WebSocket& socket, const std::string& string)
|
||||||
{
|
{
|
||||||
socket.sendFrame(string.data(), string.size());
|
socket.sendFrame(string.data(), string.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
inline
|
||||||
bool isDocumentLoaded(Poco::Net::WebSocket& ws)
|
bool isDocumentLoaded(Poco::Net::WebSocket& ws, std::string name = "")
|
||||||
{
|
{
|
||||||
|
if (!name.empty())
|
||||||
|
{
|
||||||
|
name += ' ';
|
||||||
|
}
|
||||||
|
|
||||||
bool isLoaded = false;
|
bool isLoaded = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -74,7 +79,6 @@ bool isDocumentLoaded(Poco::Net::WebSocket& ws)
|
||||||
const Poco::Timespan waitTime(1000000);
|
const Poco::Timespan waitTime(1000000);
|
||||||
|
|
||||||
ws.setReceiveTimeout(0);
|
ws.setReceiveTimeout(0);
|
||||||
std::cout << "==> isDocumentLoaded\n";
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
char buffer[READ_BUFFER_SIZE];
|
char buffer[READ_BUFFER_SIZE];
|
||||||
|
@ -82,10 +86,9 @@ bool isDocumentLoaded(Poco::Net::WebSocket& ws)
|
||||||
if (ws.poll(waitTime, Poco::Net::Socket::SELECT_READ))
|
if (ws.poll(waitTime, Poco::Net::Socket::SELECT_READ))
|
||||||
{
|
{
|
||||||
bytes = ws.receiveFrame(buffer, sizeof(buffer), flags);
|
bytes = ws.receiveFrame(buffer, sizeof(buffer), flags);
|
||||||
std::cout << "Got " << bytes << " bytes, flags: " << std::hex << flags << std::dec << '\n';
|
|
||||||
if (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
|
if (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
|
||||||
{
|
{
|
||||||
std::cout << "Received message: " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << '\n';
|
std::cout << name << "Got " << bytes << " bytes: " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << std::endl;
|
||||||
const std::string line = LOOLProtocol::getFirstLine(buffer, bytes);
|
const std::string line = LOOLProtocol::getFirstLine(buffer, bytes);
|
||||||
const std::string prefixIndicator = "statusindicatorfinish:";
|
const std::string prefixIndicator = "statusindicatorfinish:";
|
||||||
const std::string prefixStatus = "status:";
|
const std::string prefixStatus = "status:";
|
||||||
|
@ -95,6 +98,11 @@ bool isDocumentLoaded(Poco::Net::WebSocket& ws)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << name << "Got " << bytes << " bytes, flags: " << std::hex << flags << std::dec << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
retries = 10;
|
retries = 10;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -118,7 +126,7 @@ bool isDocumentLoaded(Poco::Net::WebSocket& ws)
|
||||||
// jobs to establish the bridge connection between the Client and Kit process,
|
// jobs to establish the bridge connection between the Client and Kit process,
|
||||||
// The result, it is mostly time outs to get messages in the unit test and it could fail.
|
// The result, it is mostly time outs to get messages in the unit test and it could fail.
|
||||||
// connectLOKit ensures the websocket is connected to a kit process.
|
// connectLOKit ensures the websocket is connected to a kit process.
|
||||||
static
|
inline
|
||||||
std::shared_ptr<Poco::Net::WebSocket>
|
std::shared_ptr<Poco::Net::WebSocket>
|
||||||
connectLOKit(Poco::URI uri,
|
connectLOKit(Poco::URI uri,
|
||||||
Poco::Net::HTTPRequest& request,
|
Poco::Net::HTTPRequest& request,
|
||||||
|
@ -172,7 +180,7 @@ connectLOKit(Poco::URI uri,
|
||||||
return ws;
|
return ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
inline
|
||||||
void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std::string& response, const bool isLine)
|
void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std::string& response, const bool isLine)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -184,7 +192,6 @@ void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std
|
||||||
|
|
||||||
response.clear();
|
response.clear();
|
||||||
ws.setReceiveTimeout(0);
|
ws.setReceiveTimeout(0);
|
||||||
std::cout << "==> getResponseMessage(" << prefix << ")\n";
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
char buffer[READ_BUFFER_SIZE];
|
char buffer[READ_BUFFER_SIZE];
|
||||||
|
@ -192,10 +199,9 @@ void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std
|
||||||
if (ws.poll(waitTime, Poco::Net::Socket::SELECT_READ))
|
if (ws.poll(waitTime, Poco::Net::Socket::SELECT_READ))
|
||||||
{
|
{
|
||||||
bytes = ws.receiveFrame(buffer, sizeof(buffer), flags);
|
bytes = ws.receiveFrame(buffer, sizeof(buffer), flags);
|
||||||
std::cout << "Got " << bytes << " bytes, flags: " << std::hex << flags << std::dec << '\n';
|
|
||||||
if (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
|
if (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
|
||||||
{
|
{
|
||||||
std::cout << "Received message: " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << '\n';
|
std::cout << "Got " << bytes << " bytes: " << LOOLProtocol::getAbbreviatedMessage(buffer, bytes) << std::endl;
|
||||||
const std::string message = isLine ?
|
const std::string message = isLine ?
|
||||||
LOOLProtocol::getFirstLine(buffer, bytes) :
|
LOOLProtocol::getFirstLine(buffer, bytes) :
|
||||||
std::string(buffer, bytes);
|
std::string(buffer, bytes);
|
||||||
|
@ -206,6 +212,10 @@ void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Got " << bytes << " bytes, flags: " << std::hex << flags << std::dec << '\n';
|
||||||
|
}
|
||||||
retries = 10;
|
retries = 10;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -222,7 +232,7 @@ void getResponseMessage(Poco::Net::WebSocket& ws, const std::string& prefix, std
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
inline
|
||||||
std::shared_ptr<Poco::Net::WebSocket> loadDocAndGetSocket(const Poco::URI& uri, const std::string& documentURL)
|
std::shared_ptr<Poco::Net::WebSocket> loadDocAndGetSocket(const Poco::URI& uri, const std::string& documentURL)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in a new issue