Commit Graph

192 Commits (master)

Author SHA1 Message Date
Michael Meeks ebb4eda3df Move common/MessageQueue.cpp -> kit/KitQueue.cpp.
This is not common code, it's used only in the Kit.

Rename TileQueue -> KitQueue as well as unhelpful member variable naming.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: If158597f99f302cbc27e8eab139972f57a2fc3bb
2024-05-09 09:50:08 +01:00
Caolán McNamara a6b3961c50 add a test for joining doc and disconnecting
a normal case, where user#2 joins the document successfully and then
their connection closes; where the remaining client gets the
notification that there is only one client in the session.

an abnormal case, failing test currently disabled, where user#2 joins
the document, "load url" is launched, but the connection is immediately
dropped; the other client gets a notification that a user has joined to
make it a 2 user session, but no notification that the user has dropped.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8271fb3d4def917acdff0fae6a3a52b5d02ef7af
2024-05-03 20:14:11 +02:00
Michael Meeks 642da39dc5 test: create UnitSyntheticLok - to stub and override LOK behavior.
Simple example to re-instate previous unit test.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I26da1178bc897797a656eb5ae9f838d17cbaf75f
2024-04-29 10:56:54 +02:00
Michael Meeks 03a8be557e bgsave: initial unit testing skeleton.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ia231d0f0f9d6ea0cd20b7ad7e28eee082530cf71
2024-04-16 16:43:52 +01:00
Miklos Vajna b14f3fffff cool#8465 clipboard: improve handling of plain text copy, complex case
In case the selection is complex (not simple), we used to just request
HTML, and then the browser converted that to plain text, which has the
downsides already mentioned in commit
7f9de46688 (cool#8465 clipboard: improve
handling of plain text copy, simple case, 2024-03-08).

Steps to support this:

1) Clipboard.js now asks for the text/html,text/plain;charset=utf-8 MIME
   types.

2) wsd: ClientRequestDispatcher::handleClipboardRequest() now maps this
   to DocumentBroker::CLIP_REQUEST_GET_HTML_PLAIN_ONLY

3) ClientSession::handleClipboardRequest() maps this to the HTML+plain
   text MIME type list.

4) kit: ChildSession::getClipboard() is now improved to take a list of
   MIME types, not just 1 or everything.

5) kit: ChildSession::getClipboard() now emits JSON in case not all, but
   multiple MIME types are requested.

6) wsd: ClientSession::postProcessCopyPayload() now knows how to
   postprocess clipboardcontent messages, which may or may not be JSON
   (it's JSON if more formats are requested explicitly, leaving the 1
   format or all format cases unchanged)

7) Control.DownloadProgress.js now handles the case when we get JSON and
   sets the core-provided plain text next to the HTML.

   Leave the handling of non-JSON case in, because this means we can
   copy from an old COOL server to a new one.

Note that this approach has the benefit that once the clipboard marker
is inserted, the length of the text/html format would change, which
means we can't parse the clipboard data till the marker is removed.
Emitting JSON for html+text means adding the marker keeps the ability to
parse the HTML and the plain text part of the clipboard in JS.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I67a1f669e8a638d34cc25a2f288a7b30884b9892
2024-03-20 10:21:59 +01:00
Jaume Pujantell 3ba713aabf add isMobileApp util function to reduce ifdefs
Removed all MOBILEAPP preprocessor conditionals from Util.hpp/.cpp
Added isMobileApp function to help remove further conditionals.

Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: I038a4db47ec2a2c7bb10f5696df5571b13bd9a61
2024-03-20 09:13:00 +01:00
Neil Guertin f82915ebcb Move kit pid helper functions to one file
Signed-off-by: Neil Guertin <neil.guertin@collabora.com>
Change-Id: If77b8ac3c7493f4d44b510ec54b68292856f89d5
2024-03-09 16:36:39 +00:00
Michael Meeks c117d87bb4 nearly pure re-factor: split out code into its own modules.
StateRecorder.hpp split from ChildSession.cpp
KitWebSocketHandler.[ch]pp split from Kit.cpp.
ThreadPool.hpp split from RenderTiles.hpp

Expose headers for KitSocketPoll and Document
at the same time.

Not clear we need the DocumentManagerInterface anymore.

Conditionally compile out Document::createSession for unittest
dependency breaking, and avoid Rlimit::handleSetrlimitCommand
likewise.

Make makePropertyValue a private method of Kit.cpp.

clang-format new files.

Change-Id: I47a1d6afe20165f156b477a931b94c916cff4b9d
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-03-06 20:56:55 -05:00
Henry Castro f6a0c366db fix fail unit test "builddir != srcdir"
Change-Id: I7a5b96da9e892c1948cbbc52c57344a2b67daab6
Signed-off-by: Henry Castro <hcastro@collabora.com>
2024-02-14 09:12:12 +00:00
Caolán McNamara 42e98bb2e4 experimentally bootstrap something using avx2 to generate bitmap
just enough to get the same results as before

https://github.com/CollaboraOnline/online/issues/7165

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I109c9b8f1e7935782c72e0179aa0ed48712eadb6
2023-09-25 16:55:04 +01:00
Michael Meeks cce3767ba8 First cut SIMD wrappers / separation to accelerate RLE code.
Split it out as a C file, to avoid accidental C++ header inclusion,
and C is a cross-platform assembler anyway so a good match.

Change-Id: I6c042781713aecaf143b9663af8377659a7deaf1
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-09-25 16:55:04 +01:00
Ashod Nakashian 968ab3e529 wsd: test: move File-Serve whitebox tests to own file
Change-Id: I4e659f28636cc78beca3c05ed7f23ef714d32063
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 08:58:39 +02:00
Ashod Nakashian 87bce5dc5d wsd: test: merge UnitWopiUnlock into UnitWOPILock.cpp
Change-Id: If051032e2ed9d7a0ab345bdad710ba1eafe92d96
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Andras Timar 4ac8c8ee28 configure option to disable building unit tests
rational: building for release takes a lot of time and we
neither package, nor run (most of) these unit tests when
we make packages.
CI runs all of these tests before merging PRs, so risk is low,
if we do not run the few build-time unit tests when we package.

make -j12
--enable-tests (default): 3m 18s
--disable-test: 1m 9s
3x faster...

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I4edd98af55748432e30c65c4c910e72c0221272a
2023-06-16 09:12:21 +02:00
Caolán McNamara 71d630c607 DeltaTests::testDeltaCopyOutOfBounds fails in a build from make dist tarball
because data/delta-graphic.png and data/delta-graphic2.png are missing

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ie850d9ae76946e891d2928de80c5ded4e970f4cf
2023-06-07 14:48:39 +01:00
Ashod Nakashian 941ff1e2fb wsd: test: reduce test run time
Change-Id: I0e6b013892d3ad813a5db6a8a1328849dcd0c6ab
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-31 07:40:11 -04:00
Ashod Nakashian 545aa4acb8 wsd: test: merge UnitWopiHttpRedirectLoop with Redirect
Change-Id: I25a2ae4e5d0864b36e520ebb75c31d45b0c12530
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-31 07:40:11 -04:00
Ashod Nakashian c6dd263ab1 make: silence clang complaining of -pthread
The clang linker doesn't need -pthread and
warns of unknown command-line option.

This detects clang and forgoes the -pthread
flag to the linker.

Change-Id: I658cd887c567a5beeeae0e6e1b6d596231894c1b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-15 08:47:26 +01:00
Ashod Nakashian d40aaec1e4 wsd: test: add quarantine test
Change-Id: Ic08f7ed0f177fc5e3a08b47e16ba8131c6dff788
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-15 08:47:26 +01:00
Ashod Nakashian 5d2f27d4cb wsd: test: reorder tests to minimize parallel runtime
Change-Id: Ib308757cd100df83b934995c2eee2d38d3120ecb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-02 19:54:31 -04:00
Ashod Nakashian 86c1dca7b6 make: cosmetics
Change-Id: Id1ebe96edef9f41be05b84e4c27388adde864aa3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-02 19:54:31 -04:00
Andras Timar 3e6705a3b6 fix include_path with non-system libs in test/Makefile
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ic6dfa7086e1b7fc55b007cee679577a584adeee9
2023-02-26 19:19:22 +01:00
Ashod Nakashian 0adef5dd19 wsd: test: move UnitWOPIAsyncUpload_Close
Another failure-to-upload test that best
belongs to the UnitWOPIFailUpload suite.

Change-Id: I48f34413337f34a959a38402409e7321203dff35
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-27 08:03:18 -04:00
Ashod Nakashian 9ccb57b4c3 wsd: test: move UnitWOPIAsyncUpload_Modify
This is a failure-to-upload test that best
belongs to the UnitWOPIFailUpload suite.

Change-Id: I28e4e55f8298fe964537f8b67b0e717ecf2e3935
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-23 11:07:55 -04:00
Ashod Nakashian db50626aff wsd: test: refactor BaseUnit self-test
The BaseUnit test didn't belong to UnitTimeout
and, more important, it needed access to
private members to both validate their state
and to reset them (since the test is artificially
initializing both WSD and Kit tests and cannot
uninitialize them, lest we unload ourselves).

As such, the self-test is now internal to
BaseUnit, with the added bonus that it
is called on all tests and not just UnitTimeout.

Also, more assertions have been added.

Change-Id: Ieaf60594f39e978a7250407262bd8bbc9b642c43
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-23 11:07:55 -04:00
Ashod Nakashian 155dfcee88 wsd: test: reduce the UnitWOPISlow test doc size
With the latest gcc and Core, debug builds load
and save is substantially slower. The size of
the test document for UnitWOPISlow was 100s
of pages, which took minutes to load and save.

This reduces the size and re-sorts the tests
to minimize the total run time.

Change-Id: Id1ca10d882c5ffcd1ea894279b21fedb06f287f7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-07 17:33:11 +03:00
Andras Timar d17fb50487 enable link to non-system libpng and openssl
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I109242bde268e63e9918af0f44fcb456e2b8f6c5
2022-11-28 12:41:59 +01:00
Ashod Nakashian 2ad1b5f83e wsd: unlock the document only after uploading
Since uploading has become asynchronous, it
might not have finished by the time we
unlock the document. This race can result
in the upload to fail, if the document
is no longer locked.

Now, we ensure that the lock is released
only after uploading, when we remove the
session. With test.

Change-Id: Ic9ba3290dfbfde0eb4af7a70bb5b56ff28711f5c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-12 19:42:30 -05:00
Ashod Nakashian c4fb6c1964 wsd: test: re-order tests to minimize execution time
Change-Id: I3e7b60962ba7d579328c48f500a062dda32e27be
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-12 18:45:35 -05:00
Ashod Nakashian 48c08a40d8 wsd: test: enable tile-tests
Based on the assumption that the new
number of tiles is correct, the assertion
is updated and the tile tests re-enabled.

Change-Id: I9dabe1ea4ec1b091917c4a94c549f967b9539c13
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-12 18:45:35 -05:00
Michael Meeks 2def6dc3d5 Switch to zstd image compression.
zstd provides for much faster compression server-side, as well
as better decompression.

zstd allows us to de-compress a keyframe and several deltas in a
single call in JS, so it is necessar to add a terminator to the
delta stream so that we can detect when to flush the buffer we
are working on - so the next delta applies to the correct data.

Change-Id: I0e292e3a697b4902d6488b7c04deaba2d1485e94
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-11-02 12:09:53 +01:00
Aron Budea 6910653a8c Temporarily disable unit-tiletest
Due to this error:
[ coolwsd ] TST  testTileProcessed  [testTileProcessed] (+12566ms):
ERROR: Assertion failure: Expected exactly the requested number of
tiles Expected arrivedTile == [25] but got [28]
| TileCacheTests.cpp:1580

Probably since 2cc955f9109c0fc8443c9f93c1bf6bd317043cb5 (core)

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: Ie854a57e4241f2c8fbf8e3d769aba8a19981feb1
2022-09-05 22:00:18 +02:00
Ashod Nakashian 648ab10c66 wsd: test: move UnitWOPIStuckSave
For some as-yet unknown reason, UnitWOPIStuckSave
is timing out with -j8 for me. It seems that
the issue has to do with the socket not having
the data in a timely fashion. The only thing
that reproduces the issue is the order, and
that isn't always the case. So, it seems
that at some point, on my particular system,
having this test any earlier than where I put
is causing the failure. The fix was to move it.

While I don't yet know the reason, this isn't
happening all the time. It would seem that
after restarting it goes away. So it might
be some system state that is interfering.
Still, I can't explain why this test should
suffer reliably and none of the others.

Worth investigating further, but for now
changing the order.

Change-Id: Ibbb912941f8872c4825468e940e82814b2d14168
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-25 15:12:10 +01:00
Ashod Nakashian 551454c9f5 wsd: test: reorder test execution order
Now that most tests are rid of poco sockets
and fixed a number of other issues, the
tests run much faster. The relative timings
have changed, so re-ordering can yield
better total time with -j.

The new order gives ~20% shorter execution
time with -j8 (on 8c/16t i9 @ 2.0 Ghz fixed).
Actual time went from ~2:11 down to 1:46.
A saving of more than 25 seconds.

Change-Id: I0f23b86e4218fff187cdbcc756eb77522732a64b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian ba09a78721 wsd: test: modernize UnitTileCache
And disable it, since it's empty and has
no functional tests in it at all (it just
loads a document and exits the test, without
even waiting for the loading to finish).

We modernize, even though we also disable it,
because otherwise it wouldn't build.

Change-Id: I3735f28fa27af1d00e764f4e0070a25ff36b32d5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian 697607d122 wsd: timeout on saving stuck with test
Change-Id: I66769e4e5131f60b41327ada9a6f0a45b2ee11ac
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-27 14:07:08 +01:00
Ashod Nakashian 79f122c552 wsd: test: capture the log from unithttplib and display on failure
Change-Id: Iea7ae1c6ff129ea13aac89929f47d61a9e82eb80
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-24 07:08:55 +01:00
Ashod Nakashian 758ae15e5a wsd: test: add multi-language views test
Change-Id: Idbe1ab22caa4218ead6a8598f6b2990383291dbd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Ashod Nakashian 2bf6f419a3 make: fail the build when the whitebox unittests fail
Change-Id: I2e4b483740eac67efffa96449347cc1453798b87
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-20 08:34:59 -04:00
Ashod Nakashian 26348a9785 wsd: test: move StringVector tests to StringVectorTests
WhiteBoxTests.cpp is by far the slowest TU
to compile (taking minutes) and gcc started showing
'note: variable tracking size limit exceeded'
and recompiles, which doubles the time.

This moves the StringVector tests into a new
home, which reduces the size of WhiteBoxTests.

Change-Id: Ia4e8daa921fb941815ad7e68f4dbb964fb2cd93e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Ashod Nakashian 0403a0c0fe wsd: test: split out RequestDetails tests
WhiteBoxTests.cpp is by far the slowest TU
to compile (taking minutes) and even gcc gives
'note: variable tracking size limit exceeded'
and recompiles, which doubles the time.

This extracts the RequestDetails tests into
its own file to better parallelize the build.

Change-Id: Ic8d54d06223a122bc1ccf73cfa216e2b3a8f32a5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Miklos Vajna f5836a5d1d sanitizers: fix unit-base, again
==4544==ERROR: AddressSanitizer: odr-violation (0x000002c40140):
  [1] size=104 'HostUtil::WopiHosts' ../wsd/HostUtil.cpp:12:34
  [2] size=104 'HostUtil::WopiHosts' wsd/HostUtil.cpp:12:34
These globals were registered at these points:
  [1]:
    #0 0x71f618 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-llvmorg-9.0.1.src/compiler-rt/lib/asan/asan_globals.cc:362
    #1 0x7f00cb0f3d7b in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/test/../test/.libs/unit-base.so+0x10e0d7b)

  [2]:
    #0 0x71f618 in __asan_register_globals.part.13 /home/vmiklos/git/libreoffice/lode/packages/llvm-llvmorg-9.0.1.src/compiler-rt/lib/asan/asan_globals.cc:362
    #1 0x120e2ae in asan.module_ctor (/home/vmiklos/git/libreoffice/online-san/coolwsd+0x120e2ae)

==4544==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'HostUtil::WopiHosts' at ../wsd/HostUtil.cpp:12:34
==4544==ABORTING

All of HostUtil was duplicated between the test shared objects and
coolwsd, so remove it from the test objects and rather exclude
RequestDetails::getDocKey() from the test objects instead, which was
linked in but was not used in practice.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ia2147c89cf4230df97a8f45ac7d509aa11cdca97
2022-04-01 13:31:45 +02:00
Ashod Nakashian 099246d67a wsd: unload when no Kit and nothing to upload
When the Kit dies and there is no data saved to
disk to upload, there is nothing to do but unload
DocBroker and log the fact.

With unit-test that simulates the situation by
killing the Kit of a modified document.

Change-Id: I7dcc0583c053d7166935d15d045fcf6624e43b4e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-30 23:18:57 -04:00
Rash419 31d8822758 wsd: cleanup: moved all parsing related static methods and containers to HostUtil.cpp
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I8555522c6216f893b90ba4c27747314830f7abd2
2022-03-29 12:18:31 +02:00
Ashod Nakashian 9732689668 wsd: stop loading when low on disk space
For some reason the disk-space check wasn't
done for WOPI storage. Here we add the check
and bubble the exception up to stop loading.

UnitStorage has been updated and re-enabled.

Change-Id: I15a093554b662d6c0828da7683ca0190a8225fc9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-16 08:31:54 -04:00
Rash419 d02dd19f33 wsd: use hostname, port and scheme in doc key
This allows us to use multiple hosts using same coolwsd instance.

added aliases configuration to coolwsd.xml to avoid
possibility of opening the same file as two if the
WOPI host is accessed using different aliases

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I32913015c15fd396cecc702b76e0dcaa8bcafad3
2022-03-16 11:32:59 +03:00
Ashod Nakashian cfca251654 wsd: test: faster unit-test execution
All tests are now ordered to minimize
the time paralell runs take. And the
two longest-running tests are augmented
to take less time. They still take about
20x longer than the fast test, but they
do serve a purpose and we have 50+ other
tests to go through in parallel.

Total time is not much longer than the
longest test with -j8, at around 150
seconds, give or take, on an 8 core,
16 thread CPU.

Duplication in Makefile.am is reduced
with some minor clean ups.

Change-Id: I14530531485bf85d8b59e476aa933e5b2cc26c93
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Michael Meeks 96b15bd704 Count and report on various internal exceptions.
An initial set of seven of these, easy to add more as/when needed.

Change-Id: I6c65e052d00f9eaa10adee3c9464043e4c594848
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-02-18 13:51:41 +00:00
Ashod Nakashian 3d04a857bd wsd: test: improved and simplify test logging
Build-time unit-test output is now only
displayed when the test fails. This is to
reduce noise while building when not helpful.

Change-Id: I273d97dae192a24e9a1ae9f662b0fcd7ff555b75
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian af77b68d97 wsd: limit store failure when unloading
When saving and/or uploading fails, we have
to give up after a certain number of retries.

A new config entry, per_document.limit_store_failures,
controls the number of consecutive failures
before giving up. This prevents locking-up
documents while uploading.

Includes a new unit-test.

Change-Id: I1296df1691fcaa982df9e861d34cb946a2eda860
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-09 19:35:19 -05:00