[Libreoffice-commits] online.git: 2 commits - loolwsd/test

Tor Lillqvist tml at collabora.com
Mon Oct 17 19:12:06 UTC 2016


 loolwsd/test/countloolkits.hpp |   14 +++++++++++---
 loolwsd/test/httpcrashtest.cpp |    1 -
 2 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 970259d170ddcb938bccdecad7f32792639ba62a
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Oct 17 21:56:14 2016 +0300

    killLoKitProcesses() already calls countLoolKitProcesses(0)
    
    No need to immetiately call it again in testBarren().

diff --git a/loolwsd/test/httpcrashtest.cpp b/loolwsd/test/httpcrashtest.cpp
index fad34a2..53e6f0c 100644
--- a/loolwsd/test/httpcrashtest.cpp
+++ b/loolwsd/test/httpcrashtest.cpp
@@ -122,7 +122,6 @@ void HTTPCrashTest::testBarren()
     try
     {
         killLoKitProcesses();
-        countLoolKitProcesses(0);
 
         std::cerr << "Loading after kill." << std::endl;
 
commit a3236497a85c8fcdc48c55a2c7830cefdb05e619
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Oct 17 21:44:28 2016 +0300

    Fix HTTPWSTest::testConnectNoLoad
    
    The waiting for the expected number of loolkit processes after that
    test never succeeded. That apparently was caused by the fact that the
    loolwsd process is waiting for up to COMMAND_TIMEOUT_MS (five seconds
    currently) for an auto-save of the document to succeed, and that never
    happens in this case.
    
    countLoolKitProcesses() on the other hand was waiting only a bit over
    three seconds (calculated in a complicated way from POLL_TIMEOUT_MS
    and a few magic numbers) for the number of loolkit processes to reach
    the expected number. Or something like that.
    
    COMMAND_TIMEOUT_MS=5000 and POLL_TIMEOUT_MS=COMMAND_TIMEOUT_MS/10 =>
    500. We used to have in countLoolKitProcesses():
    sleepMs=POLL_TIMEOUT_MS/3 => 166 and repeat=(3000/sleepMs)+1 =>
    19. 19*166 => 3154.
    
    Fix by calculating the max time to wait for the expected number of
    loolkit processes in countLoolKitProcesses() in a different way, so
    that it is always longer than COMMAND_TIMEOUT_MS.

diff --git a/loolwsd/test/countloolkits.hpp b/loolwsd/test/countloolkits.hpp
index b96e173..275efea 100644
--- a/loolwsd/test/countloolkits.hpp
+++ b/loolwsd/test/countloolkits.hpp
@@ -69,9 +69,17 @@ int countLoolKitProcesses(const int expected)
 {
     std::cerr << "Waiting to have " << expected << " loolkit processes. Loolkits: ";
 
-    // Retry for about 3 seconds.
-    const auto sleepMs = static_cast<int>(POLL_TIMEOUT_MS / 3);
-    const size_t repeat = (3000 / sleepMs) + 1;
+    // We have to wait at least for the time the call docBroker->autoSave(forceSave,
+    // COMMAND_TIMEOUT_MS)) in ClientRequestHandler:::handleGetRequest() can take to wait for
+    // information about a successful auto-save. In the HTTPWSTest::testConnectNoLoad() there is
+    // nothing to auto-save, so it waits in vain.
+
+    // This does not need to depend on any constant from Common.hpp. The shorter the better (the
+    // quicker the test runs).
+    const auto sleepMs = 200;
+
+    // This has to cause waiting for at least COMMAND_TIMEOUT_MS. Add one second for safety.
+    const size_t repeat = ((COMMAND_TIMEOUT_MS + 1000) / sleepMs);
     auto count = getLoolKitProcessCount();
     for (size_t i = 0; i < repeat; ++i)
     {


More information about the Libreoffice-commits mailing list