Commit graph

879 commits

Author SHA1 Message Date
Ashod Nakashian
9fee4ef9fa wsd: test: make WopiTestServer and UnitWOPISlow consistent
Change-Id: Ifcf36de81a2a500c6c0ef128901c53b540345dc9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Michael Meeks
9ebffaa172 fuzz: cleanup constructors.
Change-Id: Ib70ad1ea7a8badd479cf3a254d5561b54088efaa
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-31 15:10:51 +02:00
Michael Meeks
30e6f08147 perf: merge deltas and keyframes into the same storage.
Simplifies and accelerates the code.

Change-Id: I56b661e566efd75e3ed46918a481c26ddd5ca4c4
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-27 22:01:24 +01:00
Michael Meeks
2f2b8fb2b1 TileData: write unit tests.
Change-Id: I6ce29952800cf43d95c5572201269839b5426eac
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-27 22:01:24 +01:00
Michael Meeks
6483e1500a Enable deltas by default.
Cleanup some debugging, distinguish wsd/viewport delta fetches from
client-side tilecombines.

Update tests for deltas where they are expected.

Change-Id: I3dca09e4ceb094abf03db2aed2618f19351f3e28
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-25 20:31:06 +01:00
Michael Meeks
c130231379 deltas: track, transmit and cache deltas (disabled for now)
Squashed from feature/deltas-expanded.

TileCache changes:
    + add montonic sequence (wid) numbers to TileData
    + account for sizes of TileData with multiple blobs
    + simplify saving and notifying of tiles

Sends updates (via appendChanges) based on the sequence the
right mix of keyframes and/or deltas required as a single
message, and parse and apply those on the JS side.

We continue to use PNG for slide previews and dialogs,
but remove PngCache - used by document tiles only.

Annotates delta: properly as a binary package for the websocket.

Distinguishes between deltas and keyframes we get from
the Kit based on an initial un-compressed prefix
character which we then discard.

kit can be forced to render a keyframe by oldWid=0

Track invalidity on tiles themselves - to keep the keyframe around.

    We need to be able to track that a tile is invalid, and so subscribe
    to the updated version as/when it is ready - but we also want to
    store the keyframe underneath any deltas.

force rendering of a keyframe for an empty slot in the TileCache.

force tile sequence to be zero for combinedtiles - so the client can
always request standalone tiles with explicit combinedtiles, or tile
requests.

move Blob to Common.hpp

use zero size for un-changed tiles.

remove obsolete render-id, and color deltas in debug mode.

cleanup unit tests for non-png tile results.

Change-Id: I987f84ac4e58004758a243c233b19a6f0d60f8c2
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-24 22:16:58 +01:00
Miklos Vajna
feb19b588b unit-test: fix crash-on-shutdown
A problem since c6561a99d8 (wsd: test:
correctly stop SocketPoll in UnitTimeout, 2022-04-21), the trouble was
that calling UnitWSD::returnValue() from UnitTimeout::returnValue()
deletes the 'this' pointer, so we need to copy the interesting data
members to the stack before calling the base.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I86583ae516e2b2f367fbf5cb2a9401cc21f1b1cf
2022-05-18 15:41:30 +02:00
Michael Meeks
0df3e41879 deltas: make delta creation & caching thread-safe.
Change-Id: If134ac6212850beadb262a4b8f4c084c78d8a44e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-10 09:35:47 +01:00
Michael Meeks
099ebaa089 deltas: add delta deflate compression.
Includes a horrible inlining of minified zlib de-compression (MIT)

Change-Id: Iaf5f9f5e1215458836e26d45e48e436ee52c48ef
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-10 09:35:47 +01:00
Michael Meeks
bfc4699ffb deltas: enable monotonic wid incrementing, build deltas based on pos.
We want to always generate a delta vs. the last state we have so we
move linearly forward into the future.

Change-Id: I730d1dfb125a19e2c48b8f84ad5563664d196ab0
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-10 09:35:47 +01:00
Michael Meeks
8eebe1e345 Tile-deltas, expose TileData to unit tests.
Change-Id: I5f33a56009927187b460775129f0818f47843368
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-10 09:35:47 +01:00
Michael Meeks
71ef6cb4a5 Switch Tile to have a list of deltas.
For each tile, the wire-id will grow incrementally for each key-frame
or delta appended; so we can tell which deltas to send.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ic5f201d23273c37eed232c5932b9da854e80d06a
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-10 09:35:47 +01:00
Michael Meeks
798eb25008 Cleanup performance traces.
Change-Id: Ie4a19485dc82ec3f6bc782dd3246543ac6968411
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-09 16:40:57 +01:00
Ashod Nakashian
a674a0d52e wsd: detect lost upload on exit and dumpState once only
Change-Id: If5a9601d9baa10dcdab38c57bfba82a45d8e5024
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-07 14:13:41 +01:00
Ashod Nakashian
c6561a99d8 wsd: test: correctly stop SocketPoll in UnitTimeout
Change-Id: I97317e8155e5c65d12e985cc837f07bfcf6a56d6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-06 14:45:34 +01:00
Ashod Nakashian
9a69adf766 wsd: test: always set the test name
Change-Id: Ibce5cf049ad1a1df7b11412ed7160d280ece60f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-06 14:45:34 +01:00
Ashod Nakashian
40839e8019 wsd: browser: Reset_Access_Token API to update access-tokens
Change-Id: I92cc424c30824232eaf156ddfe49104932b2ba81
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-06 11:13:35 +01:00
Ashod Nakashian
bed2c49ab0 wsd: test: prepare for more tests in UnitOAuth
Change-Id: I7c6949af0c87405ee18e445fd7e656cd82a9033c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-06 11:13:35 +01:00
Ashod Nakashian
3bd45ca339 wsd: test: modernize UnitOAuth
Change-Id: I84f7242997eb0fd8ab297c8fbdb684c2027ae3a0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-06 11:13:35 +01:00
Ashod Nakashian
0d027a9a56 wsd: test: disable verifySignature test with openssl 3
This is a temprorary patch until we can properly
migrate the verification code to openSSL 3.x.

Change-Id: I676ae3b5a1e0d27ef1d253dba2275f7de5fc08ff
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-26 14:08:48 +02:00
Ashod Nakashian
fac6c01725 wsd: replace strrchr with constexpr
This avoids the runtime overhead of strrchr used
in logged filenames on iOS, which is unnecessary
on string literals, and adds unit-tests.

We also strip leading './' and '../' in other builds.

Change-Id: I56ec722d1400fad9165eb046d1bd8d4438241ca3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-26 11:13:44 +03: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
96adaa15d1 wsd: kill coolwsd_fuzzer
coolwsd_fuzzer predates actual fuzzing
with libfuzzer and is currently unsused.

Change-Id: Id095b165943ba14dbf525ddc607ad329f5d952d4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-20 07:12:03 -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
480fb7b931 wsd: move tokenizer helpers into StringVector
In an attempt to reduce the size of Util.{c,h}pp
which has grown to contain all sorts of unrelated
helpers, we move StringVector helpers into
the StringVector.{c,h}pp files.

This makes the code better organized.

Change-Id: I152f341606807ae66253415b951bc9f89b09df57
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-12 07:39:07 -04:00
Ashod Nakashian
264bdec250 wsd: test: move Authorization tests to RequestDetailsTests
And cleanup includes to reduce build time.

Change-Id: If2e242e6688b788b91d62351ef555b31aad1ecde
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
b04bb490f1 test: increase buffer size in SocketProcessor()
The webframe buffer size used to be READ_BUFFER_SIZE (64k), but that's
no longer enough in unit-uno-command since
<a20e761cb1>
(jsdialog: fix toolboxes with children, 2022-03-17) if you have enough
fonts installed locally, because one toolbox in Writer is the font
dropdown, and that lists all the fonts you have.

getResponseMessage() already uses this increased buffer size, so this
also improves consistency.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ic2ad0e8e7443365395b16618d6c82465252ba455
2022-04-08 08:22:05 +02:00
Ashod Nakashian
f5c936ee63 wsd: add LOG_ASSERT to replace assert with extra logging
In NDEBUG builds, where there is no assert macro,
we log at debug level to still find issues without
adding noise to the logs.

However, in ENABLE_DEBUG builds not only do we assert
but we also log at error level.

Change-Id: I773dbf7bb2b459e505e73d91505b13d8ed2ed6d8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-06 18:33:45 -04:00
Ashod Nakashian
a9aa2258b7 wsd: modernize UnitWOPI
Also makes the test more stable by
avoiding racing the first save with
the subsequent modify, which is now
delayed until the save and upload
are done.

Change-Id: Icdebc3f9f5a4d4ef680cb04fd32a85433d645e07
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-06 18:33:45 -04:00
Ashod Nakashian
1d37371944 wsd: minor improvements to logging and macros
This primarily combines the string-literals
that form the filename and line number to
reduce four calls to operator<< to only one.

Also fix LOK_ASSERT_STATE to use its argument.

Change-Id: I5e8eeb4f862fe8679b1e1f7a57412dc84dc30e92
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-06 18:33:45 -04:00
Ashod Nakashian
b34de7fad1 wsd: move STATE_ENUM to common/StateEnum.hpp
With some minor modifications.

Change-Id: I5bc06bd96bbf201ccaee87170d052b4ad2a6c778
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-06 18:33:45 -04:00
Michael Meeks
db63703d0c Validate as utf-8 all Websocket text messages in debug mode.
Ensure that rendersearchresult: is terminated, and identified as binary.

Change-Id: I84e83c63351cd0aac0923bf7c833b14c1be2c051
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-04-04 20:46:11 +01:00
Tomaž Vajngerl
6c69202b18 fix build of HttpRequestTests when SSL is disabled
We can't test SSL when SSL is disabled.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I231a3c7d32f848870e90594e2d1151d3a0911f9a
2022-04-04 10:05:19 +02: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
11f31b0ba4 wsd: test SSL hostname
Change-Id: I0895d90d2c9be8a76afd209446ae39cd33fa5d2e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-01 10:33:55 +01: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
fc187b9e1f wsd: test: correctly show the failing code in the assertion message
Change-Id: I99b3688398fb3667ce4e0f5050aa5ca79e2fd0d1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-21 08:57:41 +00:00
Dennis Francis
3418f51ce4 test: make the test more specific
This is a follow up of feb672392 for the fix in 8af039251

Signed-off-by: Dennis Francis <dennis.francis@collabora.com>
Change-Id: I6a1c754193cce4f7d11d17b9bbe1986a2b46ad86
2022-03-17 18:31:41 +05:30
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
Ashod Nakashian
e5e67a71d7 wsd: wait longer when restarting forkit
Forkit takes significantly longer to start than
to fork. At the startup of WSD we do wait 4 times
as long for forkit than when forking kits.
Similarly, we should also wait that much when
forkit crashes and we recover.

This stabalizes the forkit crash tests, which
did fail rather frequently (in one example,
2 out of 10 runs had failed locally).

Change-Id: I990c8e595b64c34a8e202933be833c53d7ebfc01
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
Dennis Francis
feb6723924 test: fail on subsequent error message
This is to guard against 'faileddocloading' or other error message(s)
sent after the correct 'passwordrequired:to-view' message when a
protected document is loaded without providing password.

Signed-off-by: Dennis Francis <dennis.francis@collabora.com>
Change-Id: I13b1d4a805916fc7a209464f63cb2ecf883b11c4
2022-03-14 12:56:20 +00: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
Ashod Nakashian
d1a1c7fb1c wsd: test: reduce output from the test driver
Consolidate and reduce the messages printed
on stdout in the test driver, which also
makes interleaving the messages from
different tests less problematic.

Test output is more concise and cleaner now.

Change-Id: I4bb0de852a935614ebc3d9e663c5454cb10e404f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Ashod Nakashian
a4b798c9f5 wsd: test: extend tile test timeout
Change-Id: I3ce128ca96b394e20dc6ad7b3179e786302128ca
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Ashod Nakashian
31ff5bbcac wsd: test: assert forced uploading when expected
Change-Id: I17f83a010b71fca13d325e298760c4107fb1a39a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Ashod Nakashian
02f2860847 wsd: test: assert correct wopi GetFile and PutFile
Change-Id: I7e08d87eb382d67aed3ffaff32230e2c08d8c828
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Ashod Nakashian
e8319423b4 wsd: test: enable all conflict test scenarios
Change-Id: Ic1ae6804e90c99dfa0a8607a0d0d769a45353325
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00