[Libreoffice-commits] online.git: test/httpwstest.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sun Jan 1 03:58:48 UTC 2017
test/httpwstest.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
New commits:
commit 2f81b37c076d16810ca4588db6f86a84e43d6527
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Wed Dec 21 21:22:03 2016 -0500
wsd: load torture test
Load multiple views on multiple documents
concurrently and verify that the number
of views for each case is consistent and
as expected.
Change-Id: Ie550dd42880da7bdd0aef6d642e9b000be5c3f84
Reviewed-on: https://gerrit.libreoffice.org/32556
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 56493b3..9730f9f 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -64,6 +64,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testCloseAfterClose);
CPPUNIT_TEST(testConnectNoLoad); // This fails most of the times but occasionally succeeds
CPPUNIT_TEST(testLoad);
+ CPPUNIT_TEST(testLoadTorture);
CPPUNIT_TEST(testBadLoad);
CPPUNIT_TEST(testReload);
CPPUNIT_TEST(testGetTextSelection);
@@ -107,6 +108,7 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
void testCloseAfterClose();
void testConnectNoLoad();
void testLoad();
+ void testLoadTorture();
void testBadLoad();
void testReload();
void testGetTextSelection();
@@ -145,6 +147,11 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
void loadDoc(const std::string& documentURL, const std::string& testname);
+ void loadTorture(const std::string& docName,
+ const size_t thread_count,
+ const size_t loads_per_thread,
+ const size_t max_jitter_ms);
+
void getPartHashCodes(const std::string response,
std::vector<std::string>& parts);
@@ -378,6 +385,87 @@ void HTTPWSTest::testLoad()
loadDoc(documentURL, "load ");
}
+void HTTPWSTest::loadTorture(const std::string& docName,
+ const size_t thread_count,
+ const size_t loads_per_thread,
+ const size_t max_jitter_ms)
+{
+ const auto testname = "loadTorture ";
+
+ // Load same document from many threads together.
+ std::string documentPath, documentURL;
+ getDocumentPathAndURL(docName, documentPath, documentURL);
+
+ const auto number_of_loads = thread_count * loads_per_thread;
+ const int exp_sum_view_ids = number_of_loads * (number_of_loads - 1) / 2; // 0-based view-ids.
+
+ std::atomic<int> sum_view_ids;
+ sum_view_ids = 0;
+
+ std::vector<std::thread> threads;
+ for (size_t i = 0; i < thread_count; ++i)
+ {
+ threads.emplace_back([&]
+ {
+ try
+ {
+ for (size_t j = 0; j < loads_per_thread; ++j)
+ {
+ // Load a document and wait for the status.
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
+ auto socket = connectLOKit(_uri, request, _response, testname);
+ sendTextFrame(socket, "load url=" + documentURL, testname);
+
+ const auto status = assertResponseString(socket, "status:", testname);
+ int viewid = -1;
+ LOOLProtocol::getTokenIntegerFromMessage(status, "viewid", viewid);
+ sum_view_ids += viewid;
+
+ if (max_jitter_ms > 0)
+ {
+ const auto ms = std::chrono::milliseconds(Util::rng::getNext() % max_jitter_ms);
+ std::this_thread::sleep_for(ms);
+ }
+ }
+ }
+ catch (const Poco::Exception& exc)
+ {
+ CPPUNIT_FAIL(exc.displayText());
+ }
+ });
+ }
+
+ for (auto& thread : threads)
+ {
+ thread.join();
+ }
+
+ CPPUNIT_ASSERT_EQUAL(exp_sum_view_ids, sum_view_ids.load());
+}
+
+void HTTPWSTest::testLoadTorture()
+{
+ const auto thread_count = 3;
+ const auto loads_per_thread = 3;
+ const auto max_jitter_ms = 75;
+
+ std::vector<std::string> docNames = { "setclientpart.ods", "hello.odt", "empty.ods" };
+
+ std::vector<std::thread> threads;
+ for (const auto& docName : docNames)
+ {
+ threads.emplace_back([&]
+ {
+ loadTorture(docName, thread_count, loads_per_thread, max_jitter_ms);
+ });
+ }
+
+ for (auto& thread : threads)
+ {
+ thread.join();
+ }
+}
+
void HTTPWSTest::testBadLoad()
{
try
More information about the Libreoffice-commits
mailing list