* tests: execute in parallel * remove race in terminal * fix some tests * stop chat controller on exit * fix more tests * fix tests * query plans * update simplexmq * update direct-sqlcipher * fix tests * query plans * ios: update core * fix tests * update simplexmq and direct-sqlcipher, fixes * simplexmq * update simplexmq * parallel channel tests * update tests * fix tests * fix tests * query plans * fix test * more tests in CI * use ram drive in CI * fix tests, fix directory deleting voice file before it is uploaded * fix query * fix query to use index * link contact and channel owner profile when connecting via a signed link * update simplexmq, fix ghc 8.10.7 * fix tests * avoid double stop * query plans * fix more test races * more test fixes * fix queries * fixes * more fixes --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
4.4 KiB
Parallel test execution
Every test gets its own ports and its own directory, so hspec runs the tree
concurrently in one process with parallel and --jobs.
Decisions
TestParamsgainsportBase :: Int. A pool of bases[7000, 7010 .. 8990]is created inmain;testBrackettakes a base for the test and returns it after. Ports of a test: SMPbase + 1, XFTPbase + 2, second SMPbase + 3, remote hostbase + 4.TestCCcarriestestParams.class HasTestParamswith instances forTestParamsandTestCClets helpers take either, so closure tests reach the environment through a client:tmpFile bob "test.jpg",smpPort alice,withXFTPServer alice.- Client configs keep the literal ports 7001, 7002 and 7003 as the logical
layout.
startTestChat_maps them to the test's ports insmpServers,xftpServersandshortLinkPresetServers. Expected output uses the real ports throughsmpServerStr,xftpServerStr,smpPort,xftpPort,smpPort2. - Servers take the test:
smpServerCfg ps,withSmpServer ps,withSmpServerAndNames ps,xftpServerConfig ps,withXFTPServer ps. The XFTP server stays under test control, since tests exercise its restarts. Its files and store log are under the test directory. tests/tmpis created once around the whole run (withTmpFilesinmain) and each test works inwithTempDirectory "tests/tmp". Paths in tests aretmpDirandtmpFileof the client or params.xftpCLIruns the test binary as a subprocess with the first argumentxftp-cli, becausewithArgsandcapture_are process-global.- Test suite
ghc-optionsgain-rtsopts "-with-rtsopts=-N". parallelwraps the tree. Sequential remain: schema dump, API docs, "Save query plans" (last item, reads the maps after every test).- Postgres: the database is created once (
beforeAll_/afterAll_); the client schema prefix includes the test directory name. - Bots started through
directoryService,badgeServiceandsimplexChatCoretakecoreOptionsand the config fromtestPortsCfg. TestTerminalwraps the virtual terminal and writes the cursor row totermQonPutLn.- The "no output left" check runs in the bracket body;
stopTestChatstops the client in a separate thread with a 60 s limit and keeps the store open after the limit. - Per-test limit 180 s; the "channels" group is
sequential;@@@waits 500 ms. TTL and timed-message tests use multi-second TTLs; ratchet desynchronization helpers turn receipts off.
Status
Implemented; the suite builds. Runs so far: file tests, 39 examples in 111 s
with -j 8 on 4 cores at -O0, one timing failure per run, a different test
each time. "error receiving file" (testXFTPRcvError) fails intermittently
even alone with chat db error: SERcvFileInvalidDescrPart: appendRcvFD
receives a description part for a description that is already complete, so
the part arrives twice. The first block stops bob right after alice's upload
completes, without waiting for bob to process the description, which is the
likely source of the duplicate after his restart. The race predates this
change; -N and load make it more likely.
Direct, schema dump, protocol and names groups: 178 examples in 331 s with
-j 6, 11 failures. Two are environmental on this machine: the schema dump
cannot overwrite root-owned chat_schema.sql, and encrypt/decrypt database
needs direct-sqlcipher +openssl, which CI sets and the local build lacks.
The rest pass alone and fail under load: expiration and timed-message tests
with second-scale TTLs, the client-timeout retry test, and cases where a
line already consumed reappears at the end of the test, which points at the
window diff in readTerminalOutput under batched terminal updates.
Profile tests at the default job count (4 cores): 105 examples in 439 s, 2 failures, both timed-message tests with second-scale TTLs.
Mechanics
tests/ChatTests/DBUtils/*.hs:portBasefield.tests/ChatClient.hs:HasTestParams, port and path helpers, server configs and brackets as functions of the test, port mapping instartTestChat_,withTmpFileswithout removal per test.tests/Test.hs: port pool,xftp-clisubcommand,parallel,withTmpFilesaroundhspec.tests/SchemaDump.hs:withTmpFileswrappers removed.tests/ChatTests/Utils.hs:xftpCLIsubprocess.- Test modules: literal
tests/tmppaths, server ports and XFTP brackets rewritten through the helpers.