common/UnitHTTP.cpp | 4 + common/UnitHTTP.hpp | 2 test/Makefile.am | 6 +- test/UnitMinSocketBufferSize.cpp | 84 +++++++++++++++++++++++++++++++++++++++ wsd/LOOLWebSocket.hpp | 31 ++++++++++++++ 5 files changed, 125 insertions(+), 2 deletions(-)
New commits: commit 268ffa2c5a6e4a40474e62d65be5a3e00e90cc20 Author: Pranav Kant <pran...@collabora.co.uk> Date: Fri Dec 16 13:16:31 2016 +0530 New unit test for missing tiles due to low socket buffer size Change-Id: I278c5d532cb9b6340dee71a4b66410b32a164704 (cherry picked from commit da7d1ee60064947b405fc52f121ae011000b083f) Reviewed-on: https://gerrit.libreoffice.org/32074 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/common/UnitHTTP.cpp b/common/UnitHTTP.cpp index 6775695..29f5e40 100644 --- a/common/UnitHTTP.cpp +++ b/common/UnitHTTP.cpp @@ -33,3 +33,7 @@ UnitWebSocket::UnitWebSocket(const std::string &docURL) } } +LOOLWebSocket* UnitWebSocket::getLOOLWebSocket() const +{ + return _socket; +} diff --git a/common/UnitHTTP.hpp b/common/UnitHTTP.hpp index e70af89..ec3882a 100644 --- a/common/UnitHTTP.hpp +++ b/common/UnitHTTP.hpp @@ -130,6 +130,8 @@ public: delete _socket; delete _session; } + + LOOLWebSocket* getLOOLWebSocket() const; }; #endif diff --git a/test/Makefile.am b/test/Makefile.am index e18d3db..5a7d33e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -16,7 +16,8 @@ noinst_LTLIBRARIES = \ unit-timeout.la unit-prefork.la \ unit-storage.la unit-fonts.la \ unit-admin.la unit-tilecache.la \ - unit-fuzz.la unit-requests.la + unit-fuzz.la unit-requests.la \ + unit-minsocketbuffersize.la MAGIC_TO_FORCE_SHLIB_CREATION = -rpath /dummy AM_LDFLAGS = -pthread -module $(MAGIC_TO_FORCE_SHLIB_CREATION) @@ -59,6 +60,7 @@ unit_timeout_la_SOURCES = UnitTimeout.cpp unit_prefork_la_SOURCES = UnitPrefork.cpp unit_storage_la_SOURCES = UnitStorage.cpp unit_tilecache_la_SOURCES = UnitTileCache.cpp +unit_minsocketbuffersize_la_SOURCES = UnitMinSocketBufferSize.cpp if HAVE_LO_PATH SYSTEM_STAMP = @SYSTEMPLATE_PATH@/system_stamp @@ -70,7 +72,7 @@ if HAVE_LO_PATH check-local: ./run_unit.sh --log-file test.log --trs-file test.trs # FIXME unit-fonts.la is unstable, disabled for now. -TESTS = unit-tilecache.la unit-storage.la unit-timeout.la unit-prefork.la unit-admin.la unit-requests.la +TESTS = unit-tilecache.la unit-storage.la unit-timeout.la unit-prefork.la unit-admin.la unit-requests.la unit-minsocketbuffersize.la else TESTS = ${top_builddir}/test/test endif diff --git a/test/UnitMinSocketBufferSize.cpp b/test/UnitMinSocketBufferSize.cpp new file mode 100644 index 0000000..00e1dba --- /dev/null +++ b/test/UnitMinSocketBufferSize.cpp @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "Log.hpp" +#include "Protocol.hpp" +#include "Unit.hpp" +#include "UnitHTTP.hpp" +#include "helpers.hpp" + +using namespace helpers; + +class UnitMinSocketBufferSize: public UnitWSD +{ + enum { + PHASE_LOAD, // load the document + PHASE_REQUEST, // Request tiles etc. + PHASE_CHECK_RESPONSE // Check if we got correct response + } _phase; + std::string _docURL, _docPath; + std::unique_ptr<UnitWebSocket> _ws; +public: + UnitMinSocketBufferSize() : + _phase(PHASE_LOAD) + { + } + + virtual void invokeTest() + { + switch (_phase) + { + case PHASE_LOAD: + { + getDocumentPathAndURL("Example.odt", _docPath, _docURL); + _ws = std::unique_ptr<UnitWebSocket>(new UnitWebSocket(_docURL)); + assert(_ws.get()); + + _phase = PHASE_REQUEST; + LOG_DBG("Document loaded successfully."); + break; + } + case PHASE_REQUEST: + { + const std::string loadMsg = "load url=" + _docURL; + const std::string tilecombineMsg = "tilecombine part=0 width=256 height=256 tileposx=0,3840,7680,11520,0,3840,7680,11520,0,3840,7680,11520,0,3840,7680,11520,0,3840,7680,11520 tileposy=0,0,0,0,3840,3840,3840,3840,7680,7680,7680,7680,11520,11520,11520,11520,15360,15360,15360,15360 tilewidth=3840 tileheight=3840"; + _ws->getLOOLWebSocket()->sendFrame(loadMsg.data(), loadMsg.size()); + _ws->getLOOLWebSocket()->sendFrame(tilecombineMsg.data(), tilecombineMsg.size()); + + LOG_DBG("Tilecombine request sent"); + _phase = PHASE_CHECK_RESPONSE; + break; + } + case PHASE_CHECK_RESPONSE: + LOG_DBG("Checking if get back all the tiles"); + int nTiles = 20; + bool success = true; + while (nTiles--) + { + const auto tile = getResponseMessage(*_ws->getLOOLWebSocket(), "tile: part=0 width=256 height=256", "Waiting for tiles ..."); + const auto firstLine = LOOLProtocol::getFirstLine(tile); + LOG_DBG("Tile received " << firstLine); + if (!LOOLProtocol::matchPrefix("tile:", firstLine)) + { + success = false; + } + } + + exitTest(success ? TestResult::TEST_OK : TestResult::TEST_FAILED); + break; + } + } +}; + +UnitBase *unit_create_wsd(void) +{ + return new UnitMinSocketBufferSize(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 7a95430eb054120944b7ad2e51e77f9634635366 Author: Pranav Kant <pran...@collabora.co.uk> Date: Fri Dec 16 12:52:23 2016 +0530 wsd: set minimum socket buffer size in debug mode Change-Id: Ieae9721d45ade34c5ce9773867ab1ab997a344dc (cherry picked from commit 0b1171f6b38912b8246f742bd1f0d02c173467ae) Reviewed-on: https://gerrit.libreoffice.org/32073 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/wsd/LOOLWebSocket.hpp b/wsd/LOOLWebSocket.hpp index 02dc14d..64aa9f5 100644 --- a/wsd/LOOLWebSocket.hpp +++ b/wsd/LOOLWebSocket.hpp @@ -51,6 +51,13 @@ private: } #endif + void setMinSocketBufferSize() + { + // Lets set it to zero as system will automatically adjust it to minimum + setSendBufferSize(0); + LOG_INF("Send buffer size for web socket set to minimum: " << getSendBufferSize()); + } + public: LOOLWebSocket(const Socket& socket) : Poco::Net::WebSocket(socket) @@ -61,6 +68,14 @@ public: Poco::Net::HTTPServerResponse& response) : Poco::Net::WebSocket(request, response) { +#if ENABLE_DEBUG + setMinSocketBufferSize(); +#else + if (UnitWSD::isUnitTesting()) + { + setMinSocketBufferSize(); + } +#endif } LOOLWebSocket(Poco::Net::HTTPClientSession& cs, @@ -68,6 +83,14 @@ public: Poco::Net::HTTPResponse& response) : Poco::Net::WebSocket(cs, request, response) { +#if ENABLE_DEBUG + setMinSocketBufferSize(); +#else + if (UnitWSD::isUnitTesting()) + { + setMinSocketBufferSize(); + } +#endif } LOOLWebSocket(Poco::Net::HTTPClientSession& cs, @@ -76,6 +99,14 @@ public: Poco::Net::HTTPCredentials& credentials) : Poco::Net::WebSocket(cs, request, response, credentials) { +#if ENABLE_DEBUG + setMinSocketBufferSize(); +#else + if (UnitWSD::isUnitTesting()) + { + setMinSocketBufferSize(); + } +#endif } /// Wrapper for Poco::Net::WebSocket::receiveFrame() that handles PING frames _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits