[Libreoffice-commits] online.git: test/helpers.hpp test/httpcrashtest.cpp
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Fri Aug 30 10:22:32 UTC 2019
test/helpers.hpp | 13 +++++++++----
test/httpcrashtest.cpp | 8 +++++++-
2 files changed, 16 insertions(+), 5 deletions(-)
New commits:
commit 51b8ed7309979548c1f72918edab29b939eae488
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Aug 30 12:22:04 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Aug 30 12:22:11 2019 +0200
Try to avoid a timing problem in HTTPCrashTest::testRecoverAfterKitCrash()
In case we fail to open the document, try again in 2 seconds (same value
as in HTTPServerTest::testConvertTo()). This seems to be needed fore
core.git dbgutil builds, but don't do that unconditionally, in case the
sleep is not needed for optimized core.git.
Change-Id: I4585d1f273bfa5fffc4b02bc6107f27a2c9e1280
diff --git a/test/helpers.hpp b/test/helpers.hpp
index 708806cd2..19bf0b516 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -416,7 +416,7 @@ connectLOKit(const Poco::URI& uri,
}
inline
-std::shared_ptr<LOOLWebSocket> loadDocAndGetSocket(const Poco::URI& uri, const std::string& documentURL, const std::string& testname, bool isView = true)
+std::shared_ptr<LOOLWebSocket> loadDocAndGetSocket(const Poco::URI& uri, const std::string& documentURL, const std::string& testname, bool isView = true, bool isAssert = true)
{
try
{
@@ -426,7 +426,12 @@ std::shared_ptr<LOOLWebSocket> loadDocAndGetSocket(const Poco::URI& uri, const s
std::shared_ptr<LOOLWebSocket> socket = connectLOKit(uri, request, response, testname);
sendTextFrame(socket, "load url=" + documentURL, testname);
- CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(*socket, testname, isView));
+ bool isLoaded = isDocumentLoaded(*socket, testname, isView);
+ if (!isLoaded && !isAssert)
+ {
+ return nullptr;
+ }
+ CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isLoaded);
TST_LOG("Loaded document [" << documentURL << "].");
return socket;
@@ -441,13 +446,13 @@ std::shared_ptr<LOOLWebSocket> loadDocAndGetSocket(const Poco::URI& uri, const s
}
inline
-std::shared_ptr<LOOLWebSocket> loadDocAndGetSocket(const std::string& docFilename, const Poco::URI& uri, const std::string& testname, bool isView = true)
+std::shared_ptr<LOOLWebSocket> loadDocAndGetSocket(const std::string& docFilename, const Poco::URI& uri, const std::string& testname, bool isView = true, bool isAssert = true)
{
try
{
std::string documentPath, documentURL;
getDocumentPathAndURL(docFilename, documentPath, documentURL, testname);
- return loadDocAndGetSocket(uri, documentURL, testname, isView);
+ return loadDocAndGetSocket(uri, documentURL, testname, isView, isAssert);
}
catch (const Poco::Exception& exc)
{
diff --git a/test/httpcrashtest.cpp b/test/httpcrashtest.cpp
index 8636c5cea..d0769e9ef 100644
--- a/test/httpcrashtest.cpp
+++ b/test/httpcrashtest.cpp
@@ -198,7 +198,13 @@ void HTTPCrashTest::testRecoverAfterKitCrash()
// We expect the client connection to close.
TST_LOG("Reconnect after kill.");
- std::shared_ptr<LOOLWebSocket> socket2 = loadDocAndGetSocket("empty.odt", _uri, testname);
+ std::shared_ptr<LOOLWebSocket> socket2 = loadDocAndGetSocket("empty.odt", _uri, testname, /*isView=*/true, /*isAssert=*/false);
+ if (!socket2)
+ {
+ // In case still starting up.
+ sleep(2);
+ socket2 = loadDocAndGetSocket("empty.odt", _uri, testname);
+ }
sendTextFrame(socket2, "status", testname);
assertResponseString(socket2, "status:", testname);
}
More information about the Libreoffice-commits
mailing list