mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-22 07:58:02 +00:00
ci, tests: run all tests in CI (#8238)
* bots, tests: run broadcast bot test in CI * tests: test moderation that arrives before the message * ci, tests: run all tests in CI * tests: update re-enabled tests, restore query plans, PostgreSQL schema from CI * tests: remove CI skip helpers no longer used * tests: expect XFTP AUTH error of cancelled standalone file * tests: update query plans from CI * tests: update query plans from CI * tests: expect group history and member contacts in async group test * tests: accept subscription summary after first events on restart * tests: make AUTH and client timeout direct tests deterministic * tests: keep bob's badge clock before renewal until the move back * tests: keep the quota of 2 messages only on the member's receive queue * tests: keep query plans files with repeated entries of one query * tests: update query plans from CI * tests: stop the host before a member requests to join with a badge * tests: remove repeated entries of one query from query plans files * tests: accept the refusal of an unknown remote host after its session code * ci: state when the query plans test fails * tests: skip multicast discovery on macOS CI runners * tests: accept a remote host started with one local address * tests: restore the client timeout test except its zero timeout * tests: fail when a remote host prints another line than its other addresses * ci: name the tests that overwrite generated files * tests: move the badge clock after the restoring device arms its wake * tests: keep both members on the quota server in the member inactivity test * tests: accept subscription summaries in any order in the async group test * tests: update query plans from CI * tests: quota of 2 only on bob's queues in member inactivity test * tests: connect to a deleted link after its queue is deleted * core: save relay connection before requesting relay link data * core: share relay connection creation between join and retry * tests: connect to a re-added relay when its connection is saved late * tests: delay only the relay connection record, not the command * tests: record API fixtures on SQLite only * core: update query plans * ci: run PostgreSQL tests with the steps of build-linux
This commit is contained in:
1 parent
3682e5459e
commit
2a0ebcf0cd
19 files changed
+402
-152
No files matched your search
+108
-6
@@ -276,7 +276,7 @@ jobs:
|
||||
image_cache: ghcr.io/${{ github.repository_owner }}/simplex-chat-build-cache:${{ matrix.os }}-${{ matrix.arch }}-ghc${{ matrix.ghc }}
|
||||
source_hashes: dist-newstyle/sources.sha256
|
||||
concurrency: &linux-concurrency
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-linux-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ghc }}-${{ needs.maybe-release.outputs.libs_tag }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-linux-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ghc }}${{ matrix.postgres && '-postgres' || '' }}-${{ needs.maybe-release.outputs.libs_tag }}
|
||||
cancel-in-progress: ${{ github.event_name != 'push' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -378,7 +378,7 @@ jobs:
|
||||
toolchain=$(docker exec builder dpkg-query -W -f '${db:Status-Status} ${binary:Package} ${Version}\n' 'binutils*' 'cpp*' 'gcc*' '*-dev' | grep '^installed ' | sha256sum | cut -c1-16)
|
||||
target=ubuntu-${{ matrix.os }}-${{ matrix.arch }}-ghc${{ matrix.ghc }}-$toolchain
|
||||
echo "deps=deps-$target" >> "$GITHUB_OUTPUT"
|
||||
echo "dist=dist-$target" >> "$GITHUB_OUTPUT"
|
||||
echo "dist=${{ env.dist_name || 'dist' }}-$target" >> "$GITHUB_OUTPUT"
|
||||
echo "dist_lib=dist-lib-$target" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore dependencies from cache
|
||||
@@ -462,14 +462,14 @@ jobs:
|
||||
run: |
|
||||
scripts/ci/prune-old-builds.sh dist-newstyle
|
||||
cabal update
|
||||
cabal build -j --enable-tests ${{ env.ghc_options }}
|
||||
cabal build -j --enable-tests ${{ env.ghc_options }} ${{ env.cabal_targets }}
|
||||
mkdir -p /out
|
||||
for i in simplex-chat simplex-chat-test; do
|
||||
for i in ${{ env.bins || 'simplex-chat simplex-chat-test' }}; do
|
||||
bin=$(find /project/dist-newstyle -name "$i" -type f -executable)
|
||||
chmod +x "$bin"
|
||||
cp "$bin" /out/
|
||||
done
|
||||
strip /out/simplex-chat
|
||||
[ ! -f /out/simplex-chat ] || strip /out/simplex-chat
|
||||
|
||||
# Also for pull requests that change the chat core, for the package tests.
|
||||
- name: Build library
|
||||
@@ -646,6 +646,36 @@ jobs:
|
||||
github_ref: ${{ github.ref }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Setup Node.js for tests
|
||||
if: matrix.should_run == true && matrix.arch == 'x86_64'
|
||||
uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Build badge web app for tests
|
||||
if: matrix.should_run == true && matrix.arch == 'x86_64'
|
||||
working-directory: apps/simplex-badge-service/web
|
||||
run: |
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- name: Install PostgreSQL 15 client tools
|
||||
if: matrix.postgres == true
|
||||
shell: bash
|
||||
run: |
|
||||
sudo install -d /usr/share/postgresql-common/pgdg
|
||||
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
|
||||
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
sudo apt update
|
||||
sudo apt -y install postgresql-client-15
|
||||
|
||||
- name: Start PostgreSQL
|
||||
if: matrix.postgres == true
|
||||
shell: bash
|
||||
run: |
|
||||
docker run -d --name postgres -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:15 -c max_connections=3000 -c fsync=off
|
||||
timeout 60 sh -c 'until pg_isready -h localhost; do sleep 1; done'
|
||||
|
||||
- name: Mount RAM disk for tests
|
||||
if: matrix.should_run == true && matrix.arch == 'x86_64'
|
||||
shell: bash
|
||||
@@ -655,6 +685,7 @@ jobs:
|
||||
sudo chown $(id -u):$(id -g) tests/tmp
|
||||
|
||||
- name: Run tests
|
||||
id: tests
|
||||
if: matrix.should_run == true && matrix.arch == 'x86_64'
|
||||
timeout-minutes: 120
|
||||
shell: bash
|
||||
@@ -663,7 +694,22 @@ jobs:
|
||||
TESTS: ${{ github.event_name == 'workflow_dispatch' && inputs.tests || '' }}
|
||||
PR_BODY: ${{ github.event.pull_request.draft == true && github.event.pull_request.body || '' }}
|
||||
ATTEMPTS: ${{ (github.ref == 'refs/heads/stable' || startsWith(github.ref, 'refs/tags/v')) && 3 || 1 }}
|
||||
run: scripts/ci/run-tests.sh timeout 35m ./simplex-chat-test
|
||||
run: scripts/ci/run-tests.sh timeout ${{ env.test_timeout || '35m' }} ./simplex-chat-test
|
||||
|
||||
- name: Check generated files
|
||||
id: generated
|
||||
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
|
||||
shell: bash
|
||||
run: |
|
||||
git diff > "$RUNNER_TEMP/generated-files.patch"
|
||||
git diff --stat --exit-code
|
||||
|
||||
- name: Upload generated files
|
||||
if: ${{ !cancelled() && steps.generated.outcome == 'failure' }}
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: generated-files-ubuntu-${{ matrix.os }}-ghc${{ matrix.ghc }}${{ matrix.postgres && '-postgres' || '' }}
|
||||
path: ${{ runner.temp }}/generated-files.patch
|
||||
|
||||
# Compiling the desktop and Android targets of :common in parallel exceeds the 2 GB Kotlin daemon heap.
|
||||
# cmakeBuildAndCopy links the JNI library against libsimplex, which this job does not build.
|
||||
@@ -992,6 +1038,46 @@ jobs:
|
||||
TAG: ${{ needs.maybe-release.outputs.libs_tag }}
|
||||
run: gh release upload "$TAG" postgres-libs/*.zip --clobber --repo "${{ github.repository }}-libs"
|
||||
|
||||
# =================================
|
||||
# Linux PostgreSQL Tests
|
||||
# =================================
|
||||
|
||||
test-postgres:
|
||||
name: "ubuntu-${{ matrix.os }}-${{ matrix.arch }} (PostgreSQL tests), GHC: ${{ matrix.ghc }}"
|
||||
needs: [maybe-release, variables]
|
||||
if: needs.maybe-release.outputs.haskell == 'true' && !(github.ref == 'refs/heads/stable' || startsWith(github.ref, 'refs/tags/v'))
|
||||
runs-on: ${{ matrix.runner }}
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
env:
|
||||
image_cache: ghcr.io/${{ github.repository_owner }}/simplex-chat-build-cache:${{ matrix.os }}-${{ matrix.arch }}-ghc${{ matrix.ghc }}
|
||||
source_hashes: dist-newstyle/sources.sha256
|
||||
opt: O0
|
||||
ghc_options: --ghc-options=-O0
|
||||
cache_o0: false
|
||||
cabal_targets: --constraint 'simplexmq +client_postgres' --constraint 'simplex-chat +client_postgres' test:simplex-chat-test
|
||||
bins: simplex-chat-test
|
||||
dist_name: dist-postgres
|
||||
test_timeout: 60m
|
||||
PGHOST: localhost
|
||||
ALLOW_EMPTY: true
|
||||
concurrency: *linux-concurrency
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: 22.04
|
||||
os_underscore: 22_04
|
||||
arch: x86_64
|
||||
runner: "ubuntu-22.04"
|
||||
should_run: true
|
||||
ghc: ${{ needs.variables.outputs.GHC_VER }}
|
||||
hash: 'sha256:5c8b2c0a6c745bc177669abfaa716b4bc57d58e2ea3882fb5da67f4d59e3dda5'
|
||||
kotlin: false
|
||||
postgres: true
|
||||
steps: *linux-steps
|
||||
|
||||
# =========================
|
||||
# MacOS Build
|
||||
# =========================
|
||||
@@ -1231,6 +1317,7 @@ jobs:
|
||||
ln -s /Volumes/tests tests/tmp
|
||||
|
||||
- name: Run tests
|
||||
id: tests
|
||||
if: matrix.should_run == true && matrix.arch == 'aarch64'
|
||||
timeout-minutes: 120
|
||||
shell: bash
|
||||
@@ -1252,6 +1339,21 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check generated files
|
||||
id: generated
|
||||
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
|
||||
shell: bash
|
||||
run: |
|
||||
git diff > "$RUNNER_TEMP/generated-files.patch"
|
||||
git diff --stat --exit-code
|
||||
|
||||
- name: Upload generated files
|
||||
if: ${{ !cancelled() && steps.generated.outcome == 'failure' }}
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: generated-files-${{ matrix.os }}
|
||||
path: ${{ runner.temp }}/generated-files.patch
|
||||
|
||||
- name: Build library
|
||||
id: mac_lib_build
|
||||
if: ${{ !cancelled() && matrix.should_run == true && needs.maybe-release.outputs.libs_tag && steps.mac_cli_build.outcome == 'success' }}
|
||||
|
||||
@@ -2,10 +2,13 @@ module Main where
|
||||
|
||||
import Broadcast.Bot
|
||||
import Broadcast.Options
|
||||
import Control.Concurrent.Async
|
||||
import Control.Monad
|
||||
import Simplex.Chat.Core
|
||||
import Simplex.Chat.Terminal (terminalChatConfig)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
opts <- welcomeGetOpts
|
||||
simplexChatCore terminalChatConfig (mkChatOpts opts) $ broadcastBot opts
|
||||
simplexChatCore terminalChatConfig (mkChatOpts opts) $ \user cc ->
|
||||
race_ (forever $ void getLine) $ broadcastBot opts user cc
|
||||
@@ -8,7 +8,6 @@
|
||||
module Broadcast.Bot where
|
||||
|
||||
import Control.Concurrent (forkIO)
|
||||
import Control.Concurrent.Async
|
||||
import Control.Concurrent.STM
|
||||
import Control.Monad
|
||||
import qualified Data.Text as T
|
||||
@@ -36,7 +35,7 @@ welcomeGetOpts = do
|
||||
broadcastBot :: BroadcastBotOpts -> User -> ChatController -> IO ()
|
||||
broadcastBot BroadcastBotOpts {publishers, welcomeMessage, prohibitedMessage} _user cc = do
|
||||
initializeBotAddress cc
|
||||
race_ (forever $ void getLine) . forever $ do
|
||||
forever $ do
|
||||
(_, evt) <- atomically . readTBQueue $ outputQ cc
|
||||
case evt of
|
||||
Right (CEvtContactConnected _ ct _) -> do
|
||||
|
||||
@@ -89,13 +89,14 @@ For some complex features we create feature branches that will be merged once re
|
||||
|
||||
## Pull requests and CI
|
||||
|
||||
1. Open a pull request to `master` as a draft. On a draft, CI runs the reduced build: one Linux job that builds and tests the changed scopes, and one macOS job only when iOS code changed (CI guide: scripts/ci/README.md).
|
||||
1. Open a pull request to `master` as a draft. On a draft, CI runs the reduced build: one Linux job that builds and tests the changed scopes, one Linux job that runs the core tests on PostgreSQL when core code changed, and one macOS job only when iOS code changed (CI guide: scripts/ci/README.md).
|
||||
2. Select the core tests in a `ci-tests` block in the description, one hspec match pattern per line. `/` runs all tests; without a block, the reduced build runs no core tests.
|
||||
3. Push further changes to the same branch; on a draft, each push runs the reduced build.
|
||||
4. Mark the pull request ready for review once it is ready. CI then runs the full matrix on each push, and the code owners are requested for review.
|
||||
5. Mark it as a draft again when more work is needed. After the approval, the pull request is merged by squash once CI passes.
|
||||
6. A change to a scope without CI tests adds its build and tests to CI in the same pull request.
|
||||
7. A change of the apps' code adds, in the same pull request, app tests of all its changes on the core's real responses: core tests record the responses and events in tests/fixtures/api, and the Kotlin and iOS tests run the app code on them, with any platform service the code calls mocked (CI guide: "App test fixtures").
|
||||
8. Files that tests generate (schema dumps, query plans, API docs) are committed as CI generates them: when a test changes one, the step "Check generated files" fails, and the run's artifact `generated-files-<job>` holds the change as a patch.
|
||||
|
||||
## Differences between GHC 8.10.7 and GHC 9.6.3
|
||||
|
||||
|
||||
+20
-3
@@ -27,15 +27,16 @@ Endpoint: https://docs.github.com/en/rest/actions/workflows#create-a-workflow-di
|
||||
| `tests` | empty | hspec match patterns, one per line (`\n` in JSON); `/` runs the whole suite, and an empty value builds without tests |
|
||||
| `base` | `master` | the branch that the changes are compared with:<br>`stable` for a branch cut from stable<br>the parent branch for a stacked branch |
|
||||
|
||||
When a newer dispatch on the same branch starts build-linux or build-ios, GitHub cancels the unfinished job of the older one (`cancel-in-progress`).
|
||||
When a newer dispatch on the same branch starts build-linux, test-postgres or build-ios, GitHub cancels the unfinished job of the older one (`cancel-in-progress`).
|
||||
|
||||
Results:
|
||||
- Run and jobs: `GET /repos/<owner>/simplex-chat/actions/runs?head_sha=<commit>&event=workflow_dispatch` returns the run id; `GET /repos/<owner>/simplex-chat/actions/runs/<run id>/jobs` returns each step with its start, end and conclusion.
|
||||
- Job log: `GET /repos/<owner>/simplex-chat/actions/jobs/<job id>/logs` returns a redirect to a text file, valid for 1 minute (https://docs.github.com/en/rest/actions/workflow-jobs#download-job-logs-for-a-workflow-run). The test summary is printed as "Finished in N seconds" and "N examples, N failures".
|
||||
- Generated files: `GET /repos/<owner>/simplex-chat/actions/runs/<run id>/artifacts` lists an artifact `generated-files-<job>` for each job in which a test changed a tracked file (step "Check generated files"). It holds generated-files.patch, which `git apply` applies to the tested commit.
|
||||
|
||||
### Scopes
|
||||
|
||||
The reduced build runs one Linux job, build-linux (ubuntu-22.04 x86_64), for every scope except ios, and one macOS job, build-ios (macos-latest), for ios.
|
||||
The reduced build runs the Linux job build-linux (ubuntu-22.04 x86_64) for every scope except ios, the Linux job test-postgres (ubuntu-22.04 x86_64) for core, and the macOS job build-ios (macos-latest) for ios.
|
||||
|
||||
#### core
|
||||
|
||||
@@ -44,8 +45,17 @@ The reduced build runs one Linux job, build-linux (ubuntu-22.04 x86_64), for eve
|
||||
- Docker image (step "Build and cache Docker image");
|
||||
- caches (the steps "Restore ... from cache");
|
||||
- `cabal build -j --enable-tests --ghc-options=-O0` (step "Build CLI");
|
||||
- simplex-chat-test with the selected tests (step "Run tests"), each attempt limited to 35 minutes by `timeout`; an attempt that reaches the limit fails, and "Attempt <n> timed out." is printed.
|
||||
- the badge service web app, `npm ci` and `npm run build` in apps/simplex-badge-service/web with Node.js 22, for the test "serves the built web app" (step "Build badge web app for tests");
|
||||
- simplex-chat-test with the selected tests (step "Run tests"), each attempt limited to 35 minutes by `timeout`; an attempt that reaches the limit fails, and "Attempt <n> timed out." is printed;
|
||||
- step "Check generated files": it fails if a test changed a tracked file, and uploads the change as artifact `generated-files-<job>`. The tests "verify and overwrite schema dump", "verify and overwrite query plans" and the "generate ..." tests of the API docs overwrite their files, so a stale file fails here even when the test passes on retry.
|
||||
- App test fixtures: core tests write the core's responses and events that the app tests use to tests/fixtures/api (`/names tests/` to tests/fixtures/api/names; `/contact via address/`, `/should validate link type/` and `/reject contact and notify the sender/` to tests/fixtures/api/connect; `/updated item event has the previous item/`, `/should send updated item with mentions added and removed by edit/` and `/mark call invitation missed when the caller ends the call/` to tests/fixtures/api/updates), and fail when a recording differs from the committed file; the rewritten files are committed, and the kotlin and ios scopes run for them.
|
||||
- CI, in test-postgres, except on stable and v* tags: the steps of build-linux with the matrix parameter `postgres` and these job settings:
|
||||
- the Docker image and dependency cache of build-linux, and its own build directory cache `dist-postgres-<target>`;
|
||||
- simplex-chat-test built with `--constraint 'simplexmq +client_postgres' --constraint 'simplex-chat +client_postgres'` at -O0 (step "Build CLI");
|
||||
- PostgreSQL 15 in Docker, with trust authentication and `max_connections=3000`, and postgresql-client-15 for pg_dump;
|
||||
- the selected tests with `PGHOST=localhost`, each attempt limited to 60 minutes; `ALLOW_EMPTY=true` omits `--fail-on=empty`, so a selection of SQLite-only tests runs nothing here;
|
||||
- step "Check generated files", artifact `generated-files-ubuntu-22.04-ghc<version>-postgres`.
|
||||
- Query plans: the test "verify and overwrite query plans" runs on Linux only. It explains the queries recorded in the run and the queries of the saved files (src/Simplex/Chat/Store/SQLite/Migrations/*_query_plans.txt), writes each query once, and fails when a file changed: a recorded query was missing, a plan changed, or a merge left two entries of one query. Saved queries that the run did not record are kept, except those whose plan became an error. Queries that run only on retries or other timing-dependent paths are added by the first run that records them.
|
||||
- Local:
|
||||
```sh
|
||||
cp scripts/cabal.project.local.linux cabal.project.local
|
||||
@@ -59,6 +69,13 @@ The reduced build runs one Linux job, build-linux (ubuntu-22.04 x86_64), for eve
|
||||
```
|
||||
`--ghc-options=-O0` matches the reduced build; the library and test-suite stanzas of simplex-chat.cabal set -O2. Test directories are created under tests/tmp (`tmpBracket` in tests/Test.hs).
|
||||
|
||||
On PostgreSQL, with pg_dump 15 or newer on PATH:
|
||||
```sh
|
||||
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:15 -c max_connections=3000
|
||||
cabal build --enable-tests --ghc-options=-O0 --constraint 'simplexmq +client_postgres' --constraint 'simplex-chat +client_postgres' test:simplex-chat-test
|
||||
PGHOST=localhost ALLOW_EMPTY=true TESTS='/SimpleX chat client/group tests/' scripts/ci/run-tests.sh "$(cabal list-bin --enable-tests --ghc-options=-O0 --constraint 'simplexmq +client_postgres' --constraint 'simplex-chat +client_postgres' test:simplex-chat-test)"
|
||||
```
|
||||
|
||||
#### kotlin
|
||||
|
||||
- Globs: `BUILD_CHANGES["kotlin"]` in packages_release.py.
|
||||
|
||||
@@ -15,7 +15,7 @@ while read -r p; do
|
||||
if [ -n "$p" ]; then args+=(-m "$p"); fi
|
||||
done <<< "${TESTS:-}"
|
||||
if [ "${#args[@]}" -gt 0 ]; then
|
||||
args+=(--fail-on=empty)
|
||||
if [ "${ALLOW_EMPTY:-}" != true ]; then args+=(--fail-on=empty); fi
|
||||
elif [ "${REDUCED:-}" = true ]; then
|
||||
echo "No tests selected"
|
||||
exit 0
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
@@ -1212,7 +1213,7 @@ CREATE TABLE test_chat_schema.groups (
|
||||
public_member_count bigint,
|
||||
relay_request_retries bigint DEFAULT 0 NOT NULL,
|
||||
relay_request_delay bigint DEFAULT 0 NOT NULL,
|
||||
relay_request_execute_at timestamp with time zone DEFAULT '1970-01-01 04:00:00+04'::timestamp with time zone NOT NULL,
|
||||
relay_request_execute_at timestamp with time zone DEFAULT '1970-01-01 00:00:00+00'::timestamp with time zone NOT NULL,
|
||||
relay_inactive_at timestamp with time zone,
|
||||
relay_sent_web_domain text,
|
||||
roster_version bigint,
|
||||
@@ -3782,3 +3783,4 @@ ALTER TABLE ONLY test_chat_schema.xftp_file_descriptions
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1371,6 +1371,10 @@ Query: SELECT 1 FROM snd_message_deliveries WHERE conn_id = ? AND failed = 0 LIM
|
||||
Plan:
|
||||
SEARCH snd_message_deliveries USING COVERING INDEX idx_snd_message_deliveries_expired (conn_id=?)
|
||||
|
||||
Query: SELECT 1 FROM snd_queues WHERE host = ? AND port = ? AND snd_id = ? AND status != ? LIMIT 1
|
||||
Plan:
|
||||
SEARCH snd_queues USING PRIMARY KEY (host=? AND port=? AND snd_id=?)
|
||||
|
||||
Query: SELECT conn_id FROM connections WHERE deleted = 0
|
||||
Plan:
|
||||
SEARCH connections USING COVERING INDEX idx_connections_deleted (deleted=?)
|
||||
@@ -1531,6 +1535,10 @@ Query: UPDATE connections SET smp_agent_version = ?, pq_support = ?, enable_ntfs
|
||||
Plan:
|
||||
SEARCH connections USING PRIMARY KEY (conn_id=?)
|
||||
|
||||
Query: UPDATE deleted_snd_chunk_replicas SET delay = ?, retries = retries + 1, updated_at = ? WHERE deleted_snd_chunk_replica_id = ?
|
||||
Plan:
|
||||
SEARCH deleted_snd_chunk_replicas USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: UPDATE messages SET msg_body = x'' WHERE conn_id = ? AND internal_id = ?
|
||||
Plan:
|
||||
SEARCH messages USING PRIMARY KEY (conn_id=? AND internal_id=?)
|
||||
@@ -1539,6 +1547,10 @@ Query: UPDATE ratchets SET ratchet_state = ? WHERE conn_id = ?
|
||||
Plan:
|
||||
SEARCH ratchets USING PRIMARY KEY (conn_id=?)
|
||||
|
||||
Query: UPDATE rcv_file_chunk_replicas SET delay = ?, retries = retries + 1, updated_at = ? WHERE rcv_file_chunk_replica_id = ?
|
||||
Plan:
|
||||
SEARCH rcv_file_chunk_replicas USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: UPDATE rcv_file_chunk_replicas SET received = 1, updated_at = ? WHERE rcv_file_chunk_replica_id = ?
|
||||
Plan:
|
||||
SEARCH rcv_file_chunk_replicas USING INTEGER PRIMARY KEY (rowid=?)
|
||||
@@ -1575,6 +1587,10 @@ Query: UPDATE rcv_messages SET user_ack = ? WHERE conn_id = ? AND internal_id =
|
||||
Plan:
|
||||
SEARCH rcv_messages USING COVERING INDEX idx_rcv_messages_conn_id_internal_id (conn_id=? AND internal_id=?)
|
||||
|
||||
Query: UPDATE rcv_queues SET delete_errors = delete_errors + 1 WHERE conn_id = ? AND rcv_queue_id = ?
|
||||
Plan:
|
||||
SEARCH rcv_queues USING COVERING INDEX idx_rcv_queue_id (conn_id=? AND rcv_queue_id=?)
|
||||
|
||||
Query: UPDATE rcv_queues SET last_broker_ts = ? WHERE conn_id = ? AND rcv_queue_id = ? AND (last_broker_ts IS NULL OR last_broker_ts < ?)
|
||||
Plan:
|
||||
SEARCH rcv_queues USING INDEX idx_rcv_queue_id (conn_id=? AND rcv_queue_id=?)
|
||||
|
||||
@@ -5111,6 +5111,13 @@ Query:
|
||||
|
||||
Plan:
|
||||
|
||||
Query:
|
||||
INSERT INTO chat_item_moderations
|
||||
(group_id, moderator_member_id, item_member_id, shared_msg_id, created_by_msg_id, moderated_at)
|
||||
VALUES (?,?,?,?,?,?)
|
||||
|
||||
Plan:
|
||||
|
||||
Query:
|
||||
INSERT INTO chat_item_versions (chat_item_id, msg_content, item_version_ts)
|
||||
VALUES (?,?,?)
|
||||
@@ -6058,6 +6065,68 @@ SEARCH gp USING INTEGER PRIMARY KEY (rowid=?)
|
||||
SEARCH mu USING INDEX idx_group_members_group_id (user_id=? AND group_id=?)
|
||||
SEARCH pu USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query:
|
||||
SELECT
|
||||
-- GroupInfo
|
||||
g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id,
|
||||
gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof,
|
||||
g.enable_ntfs, g.send_rcpts, g.favorite, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout,
|
||||
g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at,
|
||||
g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id,
|
||||
g.business_chat, g.business_member_id, g.customer_member_id,
|
||||
g.use_relays, g.relay_own_status,
|
||||
g.ui_themes, g.summary_current_members_count, g.public_member_count, g.roster_version, g.custom_data, g.chat_item_ttl, g.members_require_attention, g.via_group_link_uri, g.group_domain_verified,
|
||||
g.root_priv_key, g.root_pub_key, g.member_priv_key,
|
||||
-- GroupMember - membership
|
||||
mu.group_member_id, mu.group_id, mu.index_in_group, mu.member_id, mu.peer_chat_min_version, mu.peer_chat_max_version, mu.member_role, mu.member_category,
|
||||
mu.member_status, mu.show_messages, mu.member_restriction, mu.invited_by, mu.invited_by_group_member_id, mu.local_display_name, mu.contact_id, mu.contact_profile_id, pu.contact_profile_id,
|
||||
pu.display_name, pu.full_name, pu.short_descr, pu.description, pu.image, pu.contact_link, pu.chat_peer_type, pu.local_alias, pu.preferences, pu.preferences_json,
|
||||
pu.badge_proof, pu.badge_pres_header, pu.badge_expiry, pu.badge_type, pu.badge_verified, pu.badge_extra, pu.badge_master_key, pu.badge_signature, pu.badge_key_idx, pu.contact_domain, pu.contact_domain_proof, pu.contact_domain_verified,
|
||||
mu.created_at, mu.updated_at,
|
||||
mu.support_chat_ts, mu.support_chat_items_unread, mu.support_chat_items_member_attention, mu.support_chat_items_mentions, mu.support_chat_last_msg_from_member_ts, mu.member_pub_key, mu.relay_link, mu.member_security_code, mu.member_security_code_verified_at
|
||||
|
||||
FROM groups g
|
||||
JOIN group_profiles gp ON gp.group_profile_id = g.group_profile_id
|
||||
JOIN group_members mu ON mu.group_id = g.group_id
|
||||
JOIN contact_profiles pu ON pu.contact_profile_id = COALESCE(mu.member_profile_id, mu.contact_profile_id)
|
||||
WHERE g.user_id = ? AND mu.contact_id = ? AND g.relay_own_status = ? AND g.relay_inactive_at IS NOT NULL AND g.relay_inactive_at <= ?
|
||||
Plan:
|
||||
SEARCH mu USING INDEX idx_group_members_contact_id (contact_id=?)
|
||||
SEARCH g USING INTEGER PRIMARY KEY (rowid=?)
|
||||
SEARCH gp USING INTEGER PRIMARY KEY (rowid=?)
|
||||
SEARCH pu USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query:
|
||||
SELECT
|
||||
-- GroupInfo
|
||||
g.group_id, g.local_display_name, gp.display_name, gp.full_name, gp.short_descr, g.local_alias, gp.description, gp.image, gp.group_type, gp.group_link, gp.public_group_id,
|
||||
gp.group_web_page, gp.group_domain, gp.domain_web_page, gp.allow_embedding, gp.group_domain_proof,
|
||||
g.enable_ntfs, g.send_rcpts, g.favorite, gp.preferences, gp.preferences_json, gp.member_admission, gp.chat_layout,
|
||||
g.created_at, g.updated_at, g.chat_ts, g.user_member_profile_sent_at,
|
||||
g.conn_full_link_to_connect, g.conn_short_link_to_connect, g.conn_link_prepared_connection, g.conn_link_started_connection, g.welcome_shared_msg_id, g.request_shared_msg_id,
|
||||
g.business_chat, g.business_member_id, g.customer_member_id,
|
||||
g.use_relays, g.relay_own_status,
|
||||
g.ui_themes, g.summary_current_members_count, g.public_member_count, g.roster_version, g.custom_data, g.chat_item_ttl, g.members_require_attention, g.via_group_link_uri, g.group_domain_verified,
|
||||
g.root_priv_key, g.root_pub_key, g.member_priv_key,
|
||||
-- GroupMember - membership
|
||||
mu.group_member_id, mu.group_id, mu.index_in_group, mu.member_id, mu.peer_chat_min_version, mu.peer_chat_max_version, mu.member_role, mu.member_category,
|
||||
mu.member_status, mu.show_messages, mu.member_restriction, mu.invited_by, mu.invited_by_group_member_id, mu.local_display_name, mu.contact_id, mu.contact_profile_id, pu.contact_profile_id,
|
||||
pu.display_name, pu.full_name, pu.short_descr, pu.description, pu.image, pu.contact_link, pu.chat_peer_type, pu.local_alias, pu.preferences, pu.preferences_json,
|
||||
pu.badge_proof, pu.badge_pres_header, pu.badge_expiry, pu.badge_type, pu.badge_verified, pu.badge_extra, pu.badge_master_key, pu.badge_signature, pu.badge_key_idx, pu.contact_domain, pu.contact_domain_proof, pu.contact_domain_verified,
|
||||
mu.created_at, mu.updated_at,
|
||||
mu.support_chat_ts, mu.support_chat_items_unread, mu.support_chat_items_member_attention, mu.support_chat_items_mentions, mu.support_chat_last_msg_from_member_ts, mu.member_pub_key, mu.relay_link, mu.member_security_code, mu.member_security_code_verified_at
|
||||
|
||||
FROM groups g
|
||||
JOIN group_profiles gp ON gp.group_profile_id = g.group_profile_id
|
||||
JOIN group_members mu ON mu.group_id = g.group_id
|
||||
JOIN contact_profiles pu ON pu.contact_profile_id = COALESCE(mu.member_profile_id, mu.contact_profile_id)
|
||||
WHERE g.user_id = ? AND mu.contact_id = ? AND g.relay_own_status IN (?, ?, ?)
|
||||
Plan:
|
||||
SEARCH mu USING INDEX idx_group_members_contact_id (contact_id=?)
|
||||
SEARCH g USING INTEGER PRIMARY KEY (rowid=?)
|
||||
SEARCH gp USING INTEGER PRIMARY KEY (rowid=?)
|
||||
SEARCH pu USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query:
|
||||
SELECT
|
||||
cr.contact_request_id, cr.local_display_name, cr.agent_invitation_id,
|
||||
@@ -6957,6 +7026,10 @@ Query: DELETE FROM chat_item_mentions WHERE chat_item_id = ?
|
||||
Plan:
|
||||
SEARCH chat_item_mentions USING COVERING INDEX idx_chat_item_mentions_chat_item_id (chat_item_id=?)
|
||||
|
||||
Query: DELETE FROM chat_item_moderations WHERE group_id = ? AND item_member_id = ? AND shared_msg_id = ?
|
||||
Plan:
|
||||
SEARCH chat_item_moderations USING COVERING INDEX idx_chat_item_moderations_group (group_id=? AND item_member_id=? AND shared_msg_id=?)
|
||||
|
||||
Query: DELETE FROM chat_item_reactions WHERE contact_id = ?
|
||||
Plan:
|
||||
SEARCH chat_item_reactions USING COVERING INDEX idx_chat_item_reactions_contact_id (contact_id=?)
|
||||
@@ -7745,6 +7818,11 @@ Plan:
|
||||
SCAN m USING COVERING INDEX idx_group_members_user_id_local_display_name
|
||||
SEARCH c USING INDEX idx_connections_group_member_id (group_member_id=?)
|
||||
|
||||
Query: SELECT c.agent_conn_id FROM connections c JOIN user_contact_links l ON l.user_contact_link_id = c.user_contact_link_id WHERE l.group_id IS NOT NULL
|
||||
Plan:
|
||||
SCAN c
|
||||
SEARCH l USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: SELECT chat_item_id FROM chat_items WHERE group_scope_tag = 'member_support' ORDER BY chat_item_id DESC LIMIT 1
|
||||
Plan:
|
||||
SCAN chat_items
|
||||
@@ -8003,6 +8081,10 @@ Query: SELECT item_content FROM chat_items WHERE group_id = 1 ORDER BY chat_item
|
||||
Plan:
|
||||
SEARCH chat_items USING INDEX idx_chat_items_group_id (group_id=?)
|
||||
|
||||
Query: SELECT item_status FROM chat_items WHERE item_text = ?
|
||||
Plan:
|
||||
SCAN chat_items
|
||||
|
||||
Query: SELECT last_insert_rowid()
|
||||
Plan:
|
||||
SCAN CONSTANT ROW
|
||||
@@ -8128,6 +8210,10 @@ Query: SELECT quota_err_counter FROM connections WHERE user_id = ? AND connectio
|
||||
Plan:
|
||||
SEARCH connections USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: SELECT relay_own_status FROM groups
|
||||
Plan:
|
||||
SCAN groups
|
||||
|
||||
Query: SELECT relay_own_status FROM groups WHERE group_id = ?
|
||||
Plan:
|
||||
SEARCH groups USING INTEGER PRIMARY KEY (rowid=?)
|
||||
@@ -8370,6 +8456,10 @@ Query: UPDATE chat_items SET timed_delete_at = ? WHERE user_id = ? AND group_id
|
||||
Plan:
|
||||
SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: UPDATE chat_items SET user_mention = ? WHERE user_id = ? AND chat_item_id = ?
|
||||
Plan:
|
||||
SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
||||
Query: UPDATE chat_items SET via_proxy = ? WHERE user_id = ? AND contact_id = ? AND chat_item_id = ?
|
||||
Plan:
|
||||
SEARCH chat_items USING INTEGER PRIMARY KEY (rowid=?)
|
||||
@@ -8648,6 +8738,10 @@ Query: UPDATE group_profiles SET short_descr = 'earlier copy'
|
||||
Plan:
|
||||
SCAN group_profiles
|
||||
|
||||
Query: UPDATE group_profiles SET short_descr = 'local copy'
|
||||
Plan:
|
||||
SCAN group_profiles
|
||||
|
||||
Query: UPDATE group_profiles SET short_descr = 'relay copy'
|
||||
Plan:
|
||||
SCAN group_profiles
|
||||
|
||||
@@ -3146,6 +3146,7 @@ testRestoreMovesBack ps =
|
||||
nextClaimCheck env
|
||||
bob `send` restoredCmd 1 subscriptionPlay
|
||||
waitShownBadge (chatController bob) (Just 1)
|
||||
waitWakeArmed (chatController bob)
|
||||
setClockAt bsClock renewalAt
|
||||
alice `send` "/_app activate"
|
||||
waitShownBadge (chatController alice) Nothing
|
||||
|
||||
@@ -364,7 +364,7 @@ testRetryConnectingClientTimeout ps = do
|
||||
{ quotaExceededTimeout = 1,
|
||||
messageRetryInterval = RetryInterval2 {riFast = fastRetryInterval, riSlow = fastRetryInterval}
|
||||
},
|
||||
presetServers = presetSrvs {netCfg = (netCfg :: NetworkConfig) {tcpTimeout = NetworkTimeout 10 10}}
|
||||
presetServers = presetSrvs {netCfg = (netCfg :: NetworkConfig) {tcpTimeout = NetworkTimeout 0 0}}
|
||||
}
|
||||
opts' =
|
||||
testOpts
|
||||
@@ -1023,17 +1023,18 @@ testRepeatAuthErrorsDisableContact =
|
||||
threadDelay 500000
|
||||
bob ##> "/_delete @2 notify=off"
|
||||
bob <## "alice: contact is deleted"
|
||||
forM_ [1 .. authErrDisableCount] $ \_ -> sendAuth alice
|
||||
alice <## "[bob] connection is disabled, to enable: /enable bob, to delete: /d bob"
|
||||
(withCCAgentTransaction bob $ \db -> DB.query_ db "SELECT count(1) FROM connections" :: IO [[Int]]) `shouldEventuallyReturn` [[0]]
|
||||
forM_ [1 .. authErrDisableCount - 1] $ \_ -> sendAuth alice []
|
||||
sendAuth alice ["[bob] connection is disabled, to enable: /enable bob, to delete: /d bob"]
|
||||
alice ##> "@bob hey"
|
||||
alice <## "bob: disabled, to enable: /enable bob, to delete: /d bob"
|
||||
alice ##> "/enable bob"
|
||||
alice <## "ok"
|
||||
sendAuth alice
|
||||
sendAuth alice []
|
||||
where
|
||||
sendAuth alice = do
|
||||
alice #> "@bob hey"
|
||||
alice <## "[bob, contactId: 2, connId: 1] error: connection authorization failed - this could happen if connection was deleted, secured with different credentials, or due to a bug - please re-create the connection"
|
||||
sendAuth alice disabled = do
|
||||
alice `send` "@bob hey"
|
||||
alice <### (WithTime "@bob hey" : "[bob, contactId: 2, connId: 1] error: connection authorization failed - this could happen if connection was deleted, secured with different credentials, or due to a bug - please re-create the connection" : disabled)
|
||||
|
||||
testMultilineMessage :: HasCallStack => TestParams -> IO ()
|
||||
testMultilineMessage = testChat3 aliceProfile bobProfile cathProfile $ \alice bob cath -> do
|
||||
|
||||
@@ -70,7 +70,7 @@ chatFileTests = do
|
||||
it "delete uploaded file" testXFTPDeleteUploadedFile
|
||||
it "delete uploaded file in group" testXFTPDeleteUploadedFileGroup
|
||||
it "with relative paths: send and receive file" testXFTPWithRelativePaths
|
||||
xit' "continue receiving file after restart" testXFTPContinueRcv
|
||||
it "continue receiving file after restart" testXFTPContinueRcv
|
||||
it "receive file marked to receive on chat start" testXFTPMarkToReceive
|
||||
it "error receiving file" testXFTPRcvError
|
||||
it "cancel receiving file, repeat receive" testXFTPCancelRcvRepeat
|
||||
@@ -83,7 +83,7 @@ chatFileTests = do
|
||||
it "send and receive large standalone file" testXFTPStandaloneLarge
|
||||
it "send and receive large standalone file with extra information" testXFTPStandaloneLargeInfo
|
||||
it "send and receive large standalone file using relative paths" testXFTPStandaloneRelativePaths
|
||||
xit "removes sent file from server" testXFTPStandaloneCancelSnd -- no error shown in tests
|
||||
it "removes sent file from server" testXFTPStandaloneCancelSnd
|
||||
it "removes received temporary files" testXFTPStandaloneCancelRcv
|
||||
describe "send larger files with badges" $ do
|
||||
it "send and receive file with badge proof" testXFTPFileBadgeProof
|
||||
@@ -1503,9 +1503,8 @@ testXFTPStandaloneCancelSnd = testChat2 aliceProfile aliceDesktopProfile $ \src
|
||||
dst ##> ("/_download 1 " <> uri <> " " <> tmpFile dst "should.not.extist")
|
||||
dst <## "started standalone receiving file 1 (should.not.extist)"
|
||||
threadDelay 100000
|
||||
logWarn "no error?"
|
||||
dst <## "error receiving file 1 (should.not.extist)"
|
||||
dst <## "INTERNAL {internalErr = \"XFTP {xftpErr = AUTH}\"}"
|
||||
dst <## "error standalone receiving file 1 (should.not.extist)"
|
||||
dst .<## ", xftpErr = AUTH}"
|
||||
|
||||
testXFTPStandaloneRelativePaths :: HasCallStack => TestParams -> IO ()
|
||||
testXFTPStandaloneRelativePaths = testChat2 aliceProfile aliceDesktopProfile $ \src dst -> do
|
||||
|
||||
+79
-68
@@ -110,8 +110,8 @@ chatGroupTests = do
|
||||
it "moderate own message (should process as deletion)" testGroupModerateOwn
|
||||
it "moderate multiple messages" testGroupModerateMultiple
|
||||
it "moderate message of another group member (full delete)" testGroupModerateFullDelete
|
||||
xit "moderate message that arrives after the event of moderation" testGroupDelayedModeration
|
||||
xit "moderate message that arrives after the event of moderation (full delete)" testGroupDelayedModerationFullDelete
|
||||
it "moderate message that arrives after the event of moderation" testGroupDelayedModeration
|
||||
it "moderate message that arrives after the event of moderation (full delete)" testGroupDelayedModerationFullDelete
|
||||
it "remove member with messages (full deletion is enabled)" testDeleteMemberWithMessages
|
||||
it "remove member with messages mark deleted" testDeleteMemberMarkMessagesDeleted
|
||||
it "remove member - delete messages of left/removed members" testDeleteMemberMessagesLeftRemoved
|
||||
@@ -127,7 +127,7 @@ chatGroupTests = do
|
||||
it "all old members group upgrades to current version" testGroupAllOldThenUpgrade
|
||||
it "member key is generated at the first read of a group created without one" testGroupMemberKeyGenerated
|
||||
describe "async group connections" $ do
|
||||
xit "create and join group when clients go offline" testGroupAsync
|
||||
it "create and join group when clients go offline" testGroupAsync
|
||||
describe "group links" $ do
|
||||
it "create group link, join via group link" testGroupLink
|
||||
it "join via group link with group profile near the size limit" testGroupLinkLargeGroupProfile
|
||||
@@ -2048,36 +2048,24 @@ testGroupDelayedModeration ps = do
|
||||
[ alice <## "#team: cath joined the group",
|
||||
cath <## "#team: you joined the group"
|
||||
]
|
||||
threadDelay 1000000
|
||||
|
||||
-- imitate not implemented group forwarding
|
||||
-- (real client wouldn't have forwarding code, but tests use "current code" with configured version,
|
||||
-- and forwarding client doesn't check compatibility)
|
||||
updateGroupForwardingVectors alice "bob" "cath" MRConnected
|
||||
|
||||
cath #> "#team hi" -- message is pending for bob
|
||||
cath #> "#team hi"
|
||||
alice <# "#team cath> hi"
|
||||
alice ##> "\\\\ #team @cath hi"
|
||||
alice <## "message marked deleted by you"
|
||||
cath <# "#team cath> [marked deleted by alice] hi"
|
||||
withTestChatCfg ps cfg "bob" $ \bob -> do
|
||||
bob <## "subscribed 2 connections on server localhost"
|
||||
bob <## "#team: alice added cath (Catherine) to the group (connecting...)"
|
||||
bob <### ["subscribed 2 connections on server localhost", "#team: alice added cath (Catherine) to the group (connecting...)"]
|
||||
bob <# "#team cath> [marked deleted by alice] hi"
|
||||
withTestChatCfg ps cfg "cath" $ \cath -> do
|
||||
cath <## "subscribed 3 connections on server localhost"
|
||||
cath <## "#team: member bob (Bob) is connected"
|
||||
bob
|
||||
<### [ "#team: new member cath is connected",
|
||||
EndsWith "#team cath> [marked deleted by alice] hi"
|
||||
]
|
||||
cath <### ["subscribed 3 connections on server localhost", "#team: member bob (Bob) is connected"]
|
||||
bob <## "#team: new member cath is connected"
|
||||
alice #$> ("/_get chat #1 count=1", chat, [(0, "hi [marked deleted by you]")])
|
||||
cath #$> ("/_get chat #1 count=2", chat, [(1, "hi [marked deleted by alice]"), (0, "connected")])
|
||||
bob ##> "/_get chat #1 count=2"
|
||||
r <- chat <$> getTermLine bob
|
||||
r `shouldMatchList` [(0, "connected"), (0, "hi [marked deleted by alice]")]
|
||||
where
|
||||
-- version before forwarding, so cath doesn't expect alice to forward messages (groupForwardVersion = 4)
|
||||
cfg = testCfg {chatVRange = mkVersionRange (VersionChat 1) (VersionChat 3)}
|
||||
cfg = testCfg {deliveryWorkerDelay = 3000000}
|
||||
|
||||
testGroupDelayedModerationFullDelete :: HasCallStack => TestParams -> IO ()
|
||||
testGroupDelayedModerationFullDelete ps = do
|
||||
@@ -2093,20 +2081,11 @@ testGroupDelayedModerationFullDelete ps = do
|
||||
[ alice <## "#team: cath joined the group",
|
||||
cath <## "#team: you joined the group"
|
||||
]
|
||||
threadDelay 1000000
|
||||
|
||||
-- imitate not implemented group forwarding
|
||||
-- (real client wouldn't have forwarding code, but tests use "current code" with configured version,
|
||||
-- and forwarding client doesn't check compatibility)
|
||||
updateGroupForwardingVectors alice "bob" "cath" MRConnected
|
||||
|
||||
cath #> "#team hi" -- message is pending for bob
|
||||
cath #> "#team hi"
|
||||
alice <# "#team cath> hi"
|
||||
alice ##> "\\\\ #team @cath hi"
|
||||
alice <## "message marked deleted by you"
|
||||
cath <# "#team cath> [marked deleted by alice] hi"
|
||||
-- if full deletion was enabled at time of moderation, cath would delete pending message as well,
|
||||
-- that's why we set it afterwards to test delayed moderation for bob
|
||||
alice ##> "/set delete #team on"
|
||||
alice <## "updated group preferences:"
|
||||
alice <## "Full deletion: on"
|
||||
@@ -2114,26 +2093,21 @@ testGroupDelayedModerationFullDelete ps = do
|
||||
cath <## "updated group preferences:"
|
||||
cath <## "Full deletion: on"
|
||||
withTestChatCfg ps cfg "bob" $ \bob -> do
|
||||
bob <## "subscribed 2 connections on server localhost"
|
||||
bob <## "#team: alice added cath (Catherine) to the group (connecting...)"
|
||||
bob <### ["subscribed 2 connections on server localhost", "#team: alice added cath (Catherine) to the group (connecting...)"]
|
||||
bob <## "alice updated group #team: (signed)"
|
||||
bob <## "updated group preferences:"
|
||||
bob <## "Full deletion: on"
|
||||
bob <# "#team cath> moderated [deleted by alice] [>>]"
|
||||
withTestChatCfg ps cfg "cath" $ \cath -> do
|
||||
cath <## "subscribed 3 connections on server localhost"
|
||||
cath <## "#team: member bob (Bob) is connected"
|
||||
bob
|
||||
<### [ "#team: new member cath is connected",
|
||||
EndsWith "#team cath> moderated [deleted by alice]"
|
||||
]
|
||||
cath <### ["subscribed 3 connections on server localhost", "#team: member bob (Bob) is connected"]
|
||||
bob <## "#team: new member cath is connected"
|
||||
alice #$> ("/_get chat #1 count=2", chat, [(0, "hi [marked deleted by you]"), (1, "Full deletion: on")])
|
||||
cath #$> ("/_get chat #1 count=3", chat, [(1, "hi [marked deleted by alice]"), (0, "Full deletion: on"), (0, "connected")])
|
||||
bob ##> "/_get chat #1 count=3"
|
||||
r <- chat <$> getTermLine bob
|
||||
r `shouldMatchList` [(0, "Full deletion: on"), (0, "connected"), (0, "moderated [deleted by alice]")]
|
||||
where
|
||||
-- version before forwarding, so cath doesn't expect alice to forward messages (groupForwardVersion = 4)
|
||||
cfg = testCfg {chatVRange = mkVersionRange (VersionChat 1) (VersionChat 3)}
|
||||
cfg = testCfg {deliveryWorkerDelay = 3000000}
|
||||
|
||||
testDeleteMemberWithMessages :: HasCallStack => TestParams -> IO ()
|
||||
testDeleteMemberWithMessages =
|
||||
@@ -2836,7 +2810,7 @@ testGroupAsync ps = do
|
||||
alice ##> "/g team"
|
||||
alice <## "group #team is created"
|
||||
alice <## "to add members use /a team <name> or /create link #team"
|
||||
alice ##> "/a team bob"
|
||||
alice ##> "/a team bob admin"
|
||||
concurrentlyN_
|
||||
[ alice <## "invitation to join the group #team sent to bob",
|
||||
do
|
||||
@@ -2857,13 +2831,15 @@ testGroupAsync ps = do
|
||||
concurrentlyN_
|
||||
[ alice <## "invitation to join the group #team sent to cath",
|
||||
do
|
||||
cath <## "#team: alice invites you to join the group as admin"
|
||||
cath <## "#team: alice invites you to join the group as member"
|
||||
cath <## "use /j team to accept"
|
||||
]
|
||||
cath ##> "/j team"
|
||||
concurrentlyN_
|
||||
[ alice <## "#team: cath joined the group",
|
||||
cath <## "#team: you joined the group"
|
||||
do
|
||||
cath <## "#team: you joined the group"
|
||||
cath <# "#team alice> hello bob [>>]"
|
||||
]
|
||||
alice #> "#team hello cath"
|
||||
cath <# "#team alice> hello cath"
|
||||
@@ -2871,30 +2847,30 @@ testGroupAsync ps = do
|
||||
withTestChat ps "cath" $ \cath -> do
|
||||
concurrentlyN_
|
||||
[ do
|
||||
bob <## "subscribed 2 connections on server localhost"
|
||||
bob <## "#team: alice added cath (Catherine) to the group (connecting...)"
|
||||
bob <### ["subscribed 2 connections on server localhost", "#team: alice added cath (Catherine) to the group (connecting...)"]
|
||||
bob <# "#team alice> hello cath"
|
||||
bob <## "#team: new member cath is connected",
|
||||
do
|
||||
cath <## "subscribed 3 connections on server localhost"
|
||||
cath <## "#team: member bob (Bob) is connected"
|
||||
cath <### ["subscribed 3 connections on server localhost", "#team: member bob (Bob) is connected"]
|
||||
]
|
||||
threadDelay 500000
|
||||
withTestChat ps "bob" $ \bob -> do
|
||||
withNewTestChat ps "dan" danProfile $ \dan -> do
|
||||
bob <## "subscribed 4 connections on server localhost"
|
||||
bob <## "subscribed 3 connections on server localhost"
|
||||
connectUsers bob dan
|
||||
bob ##> "/a team dan"
|
||||
concurrentlyN_
|
||||
[ bob <## "invitation to join the group #team sent to dan",
|
||||
do
|
||||
dan <## "#team: bob invites you to join the group as admin"
|
||||
dan <## "#team: bob invites you to join the group as member"
|
||||
dan <## "use /j team to accept"
|
||||
]
|
||||
dan ##> "/j team"
|
||||
concurrentlyN_
|
||||
[ bob <## "#team: dan joined the group",
|
||||
dan <## "#team: you joined the group"
|
||||
do
|
||||
dan <## "#team: you joined the group"
|
||||
dan <# "#team alice> hello bob [>>]"
|
||||
dan <# "#team alice> hello cath [>>]"
|
||||
]
|
||||
threadDelay 1000000
|
||||
threadDelay 1000000
|
||||
@@ -2903,17 +2879,16 @@ testGroupAsync ps = do
|
||||
withTestChat ps "dan" $ \dan -> do
|
||||
concurrentlyN_
|
||||
[ do
|
||||
alice <## "subscribed 4 connections on server localhost"
|
||||
alice <## "#team: bob added dan (Daniel) to the group (connecting...)"
|
||||
alice <### ["subscribed 4 connections on server localhost", "#team: bob added dan (Daniel) to the group (connecting...)"]
|
||||
alice <## "#team: new member dan is connected",
|
||||
do
|
||||
cath <## "subscribed 4 connections on server localhost"
|
||||
cath <## "#team: bob added dan (Daniel) to the group (connecting...)"
|
||||
cath <### ["subscribed 3 connections on server localhost", "#team: bob added dan (Daniel) to the group (connecting...)"]
|
||||
cath <## "#team: new member dan is connected",
|
||||
do
|
||||
dan <## "subscribed 5 connections on server localhost"
|
||||
dan <## "#team: member alice (Alice) is connected"
|
||||
dan <## "#team: member cath (Catherine) is connected"
|
||||
dan
|
||||
<### [ "subscribed 4 connections on server localhost",
|
||||
"#team: member alice (Alice) is connected",
|
||||
"#team: member cath (Catherine) is connected"
|
||||
]
|
||||
]
|
||||
threadDelay 1000000
|
||||
withTestChat ps "alice" $ \alice -> do
|
||||
@@ -2921,10 +2896,10 @@ testGroupAsync ps = do
|
||||
withTestChat ps "cath" $ \cath -> do
|
||||
withTestChat ps "dan" $ \dan -> do
|
||||
concurrentlyN_
|
||||
[ alice <## "subscribed 6 connections server localhost",
|
||||
bob <## "subscribed 6 connections server localhost",
|
||||
cath <## "subscribed 6 connections server localhost",
|
||||
dan <## "subscribed 6 connections server localhost"
|
||||
[ alice <## "subscribed 5 connections on server localhost",
|
||||
bob <## "subscribed 5 connections on server localhost",
|
||||
cath <## "subscribed 4 connections on server localhost",
|
||||
dan <## "subscribed 4 connections on server localhost"
|
||||
]
|
||||
alice #> "#team hello"
|
||||
concurrentlyN_
|
||||
@@ -2950,9 +2925,45 @@ testGroupAsync ps = do
|
||||
bob <# "#team dan> how is it going?",
|
||||
cath <# "#team dan> how is it going?"
|
||||
]
|
||||
bob <##> cath
|
||||
dan <##> cath
|
||||
dan <##> alice
|
||||
bob `send` "@cath hi"
|
||||
bob
|
||||
<### [ "member #team cath does not have direct connection, creating",
|
||||
"contact for member #team cath is created",
|
||||
"sent invitation to connect directly to member #team cath",
|
||||
WithTime "@cath hi"
|
||||
]
|
||||
cath
|
||||
<### [ "#team bob requests to create direct contact with you",
|
||||
"to accept: /accept_member_contact @bob",
|
||||
"to reject: /delete @bob (the sender will NOT be notified)",
|
||||
WithTime "bob> hi"
|
||||
]
|
||||
dan `send` "@cath hi"
|
||||
dan
|
||||
<### [ "member #team cath does not have direct connection, creating",
|
||||
"contact for member #team cath is created",
|
||||
"sent invitation to connect directly to member #team cath",
|
||||
WithTime "@cath hi"
|
||||
]
|
||||
cath
|
||||
<### [ "#team dan requests to create direct contact with you",
|
||||
"to accept: /accept_member_contact @dan",
|
||||
"to reject: /delete @dan (the sender will NOT be notified)",
|
||||
WithTime "dan> hi"
|
||||
]
|
||||
dan `send` "@alice hi"
|
||||
dan
|
||||
<### [ "member #team alice does not have direct connection, creating",
|
||||
"contact for member #team alice is created",
|
||||
"sent invitation to connect directly to member #team alice",
|
||||
WithTime "@alice hi"
|
||||
]
|
||||
alice
|
||||
<### [ "#team dan requests to create direct contact with you",
|
||||
"to accept: /accept_member_contact @dan",
|
||||
"to reject: /delete @dan (the sender will NOT be notified)",
|
||||
WithTime "dan> hi"
|
||||
]
|
||||
|
||||
testGroupLinkDeleteGroupRejoin :: HasCallStack => TestParams -> IO ()
|
||||
testGroupLinkDeleteGroupRejoin =
|
||||
@@ -8240,7 +8251,7 @@ testBlockForAllLeftRemoved =
|
||||
testGroupMemberInactive :: HasCallStack => TestParams -> IO ()
|
||||
testGroupMemberInactive ps = do
|
||||
withSmpServer' serverCfg' $ do
|
||||
withNewTestChatCfgOpts ps cfg' opts' "alice" aliceProfile $ \alice -> do
|
||||
withNewTestChatCfgOpts ps cfg' testOpts "alice" aliceProfile $ \alice -> do
|
||||
withNewTestChatCfgOpts ps cfg' opts' "bob" bobProfile $ \bob -> do
|
||||
createGroup2 "team" alice bob
|
||||
|
||||
|
||||
@@ -164,9 +164,9 @@ chatProfileTests = do
|
||||
it "allow full deletion to contact" testAllowFullDeletionContact
|
||||
it "allow full deletion to group" testAllowFullDeletionGroup
|
||||
it "prohibit direct messages to group members" testProhibitDirectMessages
|
||||
xit'' "enable timed messages with contact" testEnableTimedMessagesContact
|
||||
it "enable timed messages with contact" testEnableTimedMessagesContact
|
||||
it "enable timed messages in group" testEnableTimedMessagesGroup
|
||||
xit'' "timed messages enabled globally, contact turns on" testTimedMessagesEnabledGlobally
|
||||
it "timed messages enabled globally, contact turns on" testTimedMessagesEnabledGlobally
|
||||
it "update multiple user preferences for multiple contacts" testUpdateMultipleUserPrefs
|
||||
describe "group preferences for specific member role" $ do
|
||||
it "direct messages" testGroupPrefsDirectForRole
|
||||
@@ -933,11 +933,14 @@ testUserBadgeGroupLinkJoiner ps = do
|
||||
alice <## "to add members use /a team <name> or /create link #team"
|
||||
alice ##> "/create link #team"
|
||||
gLink <- getGroupLink alice "team" GRMember True
|
||||
alice ##> "/_stop"
|
||||
alice <## "chat stopped"
|
||||
bob ##> ("/c " <> gLink)
|
||||
bob <## "connection request sent!"
|
||||
bob ##> "/_stop"
|
||||
bob <## "chat stopped"
|
||||
alice <## "bob (Bob): accepting request to join group #team..."
|
||||
alice ##> "/_start"
|
||||
alice <### ["chat started", "subscribed 1 connections on server localhost", "bob (Bob): accepting request to join group #team..."]
|
||||
memberBadgeHeader alice "team" "bob" `shouldReturn` Just ("R", BSActive)
|
||||
bob ##> "/_start"
|
||||
concurrentlyN_
|
||||
@@ -1922,6 +1925,7 @@ testRejectContactAndDeleteUserContact = testChat3 aliceProfile bobProfile cathPr
|
||||
alice ##> "/_delete_address 1"
|
||||
alice <## "Your chat address is deleted - accepted contacts will remain connected."
|
||||
alice <## "To create a new chat address use /ad"
|
||||
(withCCAgentTransaction alice $ \db -> DB.query_ db "SELECT count(1) FROM connections" :: IO [[Int]]) `shouldEventuallyReturn` [[0]]
|
||||
|
||||
cath ##> ("/c " <> cLink)
|
||||
cath <## "error: connection authorization failed - this could happen if connection was deleted, secured with different credentials, or due to a bug - please re-create the connection"
|
||||
@@ -4643,6 +4647,7 @@ testShortLinkDeletedInvitation = testChat2 aliceProfile bobProfile test
|
||||
alice @@@ [(":1","")]
|
||||
alice ##> "/_delete :1"
|
||||
alice <## "connection :1 deleted"
|
||||
(withCCAgentTransaction alice $ \db -> DB.query_ db "SELECT count(1) FROM connections" :: IO [[Int]]) `shouldEventuallyReturn` [[0]]
|
||||
bob ##> "/_connect contact @2"
|
||||
bob <##. "error: connection authorization failed"
|
||||
bob ##> "/_connect contact @2"
|
||||
@@ -4662,6 +4667,7 @@ testShortLinkDeletedAddress = testChat2 aliceProfile bobProfile test
|
||||
alice ##> "/da"
|
||||
alice <## "Your chat address is deleted - accepted contacts will remain connected."
|
||||
alice <## "To create a new chat address use /ad"
|
||||
(withCCAgentTransaction alice $ \db -> DB.query_ db "SELECT count(1) FROM connections" :: IO [[Int]]) `shouldEventuallyReturn` [[0]]
|
||||
bob ##> "/_connect contact @2"
|
||||
bob <##. "error: connection authorization failed"
|
||||
bob ##> "/_connect contact @2"
|
||||
|
||||
@@ -109,26 +109,14 @@ it name test =
|
||||
where
|
||||
t = 180 * 1000000
|
||||
|
||||
xit' :: HasCallStack => String -> (ps -> Expectation) -> SpecWith (Arg (ps -> Expectation))
|
||||
xit' = if os == "linux" then xit else it
|
||||
|
||||
xit'' :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
|
||||
xit'' = ifCI xit Hspec.it
|
||||
|
||||
xitMacCI :: HasCallStack => String -> (ps -> Expectation) -> SpecWith (Arg (ps -> Expectation))
|
||||
xitMacCI = ifCI (if os == "darwin" then xit else it) it
|
||||
|
||||
xdescribe'' :: HasCallStack => String -> SpecWith a -> SpecWith a
|
||||
xdescribe'' = ifCI xdescribe describe
|
||||
|
||||
ifCI :: HasCallStack => (HasCallStack => String -> a -> SpecWith b) -> (HasCallStack => String -> a -> SpecWith b) -> String -> a -> SpecWith b
|
||||
ifCI xrun run d t = do
|
||||
ci <- runIO $ lookupEnv "CI"
|
||||
(if ci == Just "true" then xrun else run) d t
|
||||
|
||||
envCI :: IO Bool
|
||||
envCI = (Just "true" ==) <$> lookupEnv "CI"
|
||||
|
||||
skip :: String -> SpecWith a -> SpecWith a
|
||||
skip = before_ . pendingWith
|
||||
|
||||
@@ -1038,6 +1026,9 @@ eventsFixture fixture events steps = do
|
||||
readTVarIO events >>= writeFixture fixture . stableJSON . J.toJSON
|
||||
|
||||
writeFixture :: String -> J.Value -> IO ()
|
||||
#if defined(dbPostgres)
|
||||
writeFixture _ _ = pure ()
|
||||
#else
|
||||
writeFixture fixture = testGenerate ("tests/fixtures/api/" <> fixture <> ".json") . prettyJSON
|
||||
where
|
||||
prettyJSON = (<> "\n") . pretty ""
|
||||
@@ -1047,6 +1038,7 @@ writeFixture fixture = testGenerate ("tests/fixtures/api/" <> fixture <> ".json"
|
||||
v -> jsonText v
|
||||
block indent open close items = open <> "\n" <> T.intercalate ",\n" (map ((indent <> " ") <>) items) <> "\n" <> indent <> close
|
||||
jsonText = safeDecodeUtf8 . LB.toStrict . J.encode
|
||||
#endif
|
||||
|
||||
stableJSON :: J.Value -> J.Value
|
||||
stableJSON = \case
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
module PostgresSchemaDump (postgresSchemaDumpTest) where
|
||||
|
||||
import ChatTests.Utils hiding (it)
|
||||
import Control.Concurrent (threadDelay)
|
||||
import Control.DeepSeq
|
||||
import Control.Monad (unless, void)
|
||||
@@ -17,6 +16,7 @@ import qualified Simplex.Messaging.Agent.Store.Postgres.Migrations as Migrations
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..), MigrationConfig (..), MigrationConfirmation (..), MigrationsToRun (..), toDownMigration)
|
||||
import Simplex.Messaging.Util (ifM, whenM)
|
||||
import System.Directory (doesFileExist, removeFile)
|
||||
import System.Info (os)
|
||||
import System.Process (readCreateProcess, shell)
|
||||
import Test.Hspec
|
||||
|
||||
@@ -61,15 +61,14 @@ postgresSchemaDumpTest migrations testDBOpts@DBOpts {connstr, schema = testDBSch
|
||||
|
||||
getSchema :: FilePath -> IO String
|
||||
getSchema schemaPath = do
|
||||
ci <- envCI
|
||||
let cmd =
|
||||
("pg_dump " <> B.unpack connstr <> " --schema " <> B.unpack testDBSchema)
|
||||
("PGTZ=UTC pg_dump " <> B.unpack connstr <> " --schema " <> B.unpack testDBSchema)
|
||||
<> " --schema-only --no-owner --no-privileges --no-acl --no-subscriptions --no-tablespaces > "
|
||||
<> schemaPath
|
||||
void $ readCreateProcess (shell cmd) ""
|
||||
threadDelay 20000
|
||||
let sed = (if ci then "sed -i" else "sed -i ''")
|
||||
void $ readCreateProcess (shell $ sed <> " '/^--/d' " <> schemaPath) ""
|
||||
let sed = (if os == "linux" then "sed -i" else "sed -i ''")
|
||||
void $ readCreateProcess (shell $ sed <> " '/^--/d; /^\\\\restrict/d; /^\\\\unrestrict/d' " <> schemaPath) ""
|
||||
sch <- readFile schemaPath
|
||||
sch `deepseq` pure sch
|
||||
|
||||
|
||||
+25
-24
@@ -96,9 +96,9 @@ remoteTests = describe "Remote" $ do
|
||||
r `shouldSatisfy` \case
|
||||
Left (RPEInvalidBody _) -> True
|
||||
_ -> False
|
||||
xdescribe "No compression" $ aroundWith (. ((False, False),)) runRemoteTests
|
||||
xdescribe "Mobile offers compression" $ aroundWith (. ((True, False),)) runRemoteTests
|
||||
xdescribe "Desktop offers compression" $ aroundWith (. ((False, True),)) runRemoteTests
|
||||
describe "No compression" $ aroundWith (. ((False, False),)) runRemoteTests
|
||||
describe "Mobile offers compression" $ aroundWith (. ((True, False),)) runRemoteTests
|
||||
describe "Desktop offers compression" $ aroundWith (. ((False, True),)) runRemoteTests
|
||||
describe "With compression" $ aroundWith (. ((True, True),)) runRemoteTests
|
||||
where
|
||||
fileNames :: [FilePath]
|
||||
@@ -195,12 +195,16 @@ remoteHandshakeRejectTest = testRemote3 $ \compress mobile desktop mobileBob ->
|
||||
mobileBob <## "ok"
|
||||
desktop ##> "/start remote host 1"
|
||||
desktop <##. "remote host 1 started on "
|
||||
desktop <##. "other addresses: "
|
||||
desktop <## "Remote session invitation:"
|
||||
inv <- getTermLine desktop
|
||||
(_, inv) <- getRemoteInvitation desktop
|
||||
mobileBob ##> ("/connect remote ctrl " <> inv)
|
||||
mobileBob <## ("connecting new remote controller: My desktop, v" <> versionNumber)
|
||||
mobileBob <## "remote controller stopped: this link was used with another controller, please create a new link on the host"
|
||||
getTermLine mobileBob >>= \case
|
||||
"new remote controller connected" -> do
|
||||
mobileBob <## "Compare session code with controller and use:"
|
||||
void $ getTermLine mobileBob
|
||||
mobileBob ##> "/stop remote ctrl"
|
||||
mobileBob <## "ok"
|
||||
l -> l `shouldBe` "remote controller stopped: this link was used with another controller, please create a new link on the host"
|
||||
|
||||
-- the server remains active after rejecting invalid client
|
||||
mobile ##> ("/connect remote ctrl " <> inv)
|
||||
@@ -224,19 +228,15 @@ storedBindingsTest = testRemote $ \compress mobile desktop -> do
|
||||
mobile <## "ok"
|
||||
|
||||
desktop ##> "/start remote host new"
|
||||
desktop <##. "new remote host started on "
|
||||
addrs <- words . dropStrPrefix "other addresses: " <$> getTermLine desktop
|
||||
Just localAddress <- pure $ find ("127." `isPrefixOf`) addrs
|
||||
desktop <## "Remote session invitation:"
|
||||
void $ getTermLine desktop
|
||||
started <- dropStrPrefix "new remote host started on " <$> getTermLine desktop
|
||||
(addrs, _) <- getRemoteInvitation desktop
|
||||
Just localAddress <- pure $ find ("127." `isPrefixOf`) $ takeWhile (/= ':') started : addrs
|
||||
desktop ##> "/stop remote host new"
|
||||
desktop <## "ok"
|
||||
|
||||
desktop ##> ("/start remote host new addr=" <> localAddress <> " iface=\"lo\" port=" <> remoteTestPort desktop)
|
||||
desktop <## ("new remote host started on " <> localAddress <> ":" <> remoteTestPort desktop)
|
||||
desktop <##. "other addresses: "
|
||||
desktop <## "Remote session invitation:"
|
||||
inv <- getTermLine desktop
|
||||
(_, inv) <- getRemoteInvitation desktop
|
||||
|
||||
mobile ##> ("/connect remote ctrl " <> inv)
|
||||
mobile <## ("connecting new remote controller: My desktop, v" <> versionNumber)
|
||||
@@ -629,9 +629,7 @@ startRemote compress mobile desktop = do
|
||||
mobile <## "ok"
|
||||
desktop ##> "/start remote host new"
|
||||
desktop <##. "new remote host started on "
|
||||
desktop <##. "other addresses: "
|
||||
desktop <## "Remote session invitation:"
|
||||
inv <- getTermLine desktop
|
||||
(_, inv) <- getRemoteInvitation desktop
|
||||
mobile ##> ("/connect remote ctrl " <> inv)
|
||||
mobile <## ("connecting new remote controller: My desktop, v" <> versionNumber)
|
||||
desktop <## "new remote host connecting"
|
||||
@@ -645,9 +643,7 @@ startRemoteStored :: String -> TestCC -> TestCC -> IO ()
|
||||
startRemoteStored compress mobile desktop = do
|
||||
desktop ##> "/start remote host 1"
|
||||
desktop <##. "remote host 1 started on "
|
||||
desktop <##. "other addresses: "
|
||||
desktop <## "Remote session invitation:"
|
||||
inv <- getTermLine desktop
|
||||
(_, inv) <- getRemoteInvitation desktop
|
||||
mobile ##> ("/connect remote ctrl " <> inv)
|
||||
mobile <## ("connecting remote controller 1: My desktop, v" <> versionNumber)
|
||||
desktop <## "remote host 1 connecting"
|
||||
@@ -660,9 +656,7 @@ startRemoteDiscover :: String -> TestCC -> TestCC -> IO ()
|
||||
startRemoteDiscover compress mobile desktop = do
|
||||
desktop ##> "/start remote host 1 multicast=on"
|
||||
desktop <##. "remote host 1 started on "
|
||||
desktop <##. "other addresses: "
|
||||
desktop <## "Remote session invitation:"
|
||||
_inv <- getTermLine desktop -- will use multicast instead
|
||||
void $ getRemoteInvitation desktop -- will use multicast instead
|
||||
mobile ##> "/find remote ctrl"
|
||||
mobile <## "ok"
|
||||
mobile <## ("remote controller 1 found: My desktop, v" <> versionNumber)
|
||||
@@ -676,6 +670,13 @@ startRemoteDiscover compress mobile desktop = do
|
||||
mobile <## ("remote controller 1 session started with My desktop" <> compress)
|
||||
desktop <## ("remote host 1 connected" <> compress)
|
||||
|
||||
getRemoteInvitation :: HasCallStack => TestCC -> IO ([String], String)
|
||||
getRemoteInvitation desktop = do
|
||||
addrs <- getTermLine desktop >>= \case
|
||||
"Remote session invitation:" -> pure []
|
||||
l -> evaluate (words $ dropStrPrefix "other addresses: " l) <* desktop <## "Remote session invitation:"
|
||||
(addrs,) <$> getTermLine desktop
|
||||
|
||||
verifyRemoteCtrl :: TestCC -> TestCC -> IO ()
|
||||
verifyRemoteCtrl mobile desktop = do
|
||||
desktop <## "Compare session code with host:"
|
||||
|
||||
+16
-10
@@ -10,7 +10,7 @@ import Control.Concurrent.STM
|
||||
import Control.DeepSeq
|
||||
import qualified Control.Exception as E
|
||||
import Control.Monad (unless, void)
|
||||
import Data.List (dropWhileEnd, sort)
|
||||
import Data.List (dropWhileEnd)
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe (fromJust, isJust)
|
||||
import Data.Text (Text)
|
||||
@@ -187,19 +187,25 @@ saveQueryPlans = it "verify and overwrite query plans" $ \TestParams {chatQueryS
|
||||
updatePlans plansFile statsSel createStore prepareStore = do
|
||||
savedPlans <- ifM (doesFileExist plansFile) (T.readFile plansFile) (pure "")
|
||||
savedPlans `deepseq` pure ()
|
||||
queries <- sort . M.keys <$> readTVarIO statsSel
|
||||
recorded <- readTVarIO statsSel
|
||||
Right st <- createStore
|
||||
plans' <- withConnection st $ \db -> do
|
||||
void $ prepareStore db
|
||||
mapM (getQueryPlan db) queries
|
||||
let savedPlans' = T.unlines plans'
|
||||
M.traverseMaybeWithKey (getQueryPlan db) $ M.union (True <$ recorded) (savedQueries savedPlans)
|
||||
let savedPlans' = T.unlines $ M.elems plans'
|
||||
T.writeFile plansFile savedPlans'
|
||||
pure (savedPlans, savedPlans')
|
||||
getQueryPlan :: DB.Connection -> Query -> IO Text
|
||||
getQueryPlan db q =
|
||||
(("Query: " <> fromQuery q) <>) . result <$> E.try (DB.query_ db $ "explain query plan " <> q)
|
||||
result = \case
|
||||
Right r -> "\nPlan:\n" <> T.unlines (map planDetail r)
|
||||
Left (e :: E.SomeException) -> "\nError: " <> tshow e <> "\n"
|
||||
savedQueries = M.fromList . map savedQuery . drop 1 . T.splitOn "\nQuery: " . ("\n" <>)
|
||||
savedQuery entry = case T.breakOn "\nError: " entry of
|
||||
(_, "") -> (Query $ fst $ T.breakOn "\nPlan:\n" entry, False)
|
||||
(q, _) -> (Query q, True)
|
||||
getQueryPlan :: DB.Connection -> Query -> Bool -> IO (Maybe Text)
|
||||
getQueryPlan db q keepError =
|
||||
fmap (("Query: " <> fromQuery q) <>) . result keepError <$> E.try (DB.query_ db $ "explain query plan " <> q)
|
||||
result keepError = \case
|
||||
Right r -> Just $ "\nPlan:\n" <> T.unlines (map planDetail r)
|
||||
Left (e :: E.SomeException)
|
||||
| keepError -> Just $ "\nError: " <> tshow e <> "\n"
|
||||
| otherwise -> Nothing
|
||||
planDetail :: (Int, Int, Int, Text) -> Text
|
||||
planDetail (_, _, _, detail) = detail
|
||||
+3
-3
@@ -18,7 +18,6 @@ import Bots.DirectoryTests
|
||||
import ChatClient
|
||||
import ChatTests
|
||||
import ChatTests.DBUtils
|
||||
import ChatTests.Utils (xdescribe'')
|
||||
import Control.Logger.Simple
|
||||
import Data.Time.Clock.System
|
||||
import BadgeTests
|
||||
@@ -49,6 +48,7 @@ import ChatTests.Names (chatNamesTests)
|
||||
import qualified Simplex.Messaging.TMap as TM
|
||||
import MobileTests
|
||||
import SchemaDump
|
||||
import System.Info (os)
|
||||
import WebRTCTests
|
||||
#endif
|
||||
|
||||
@@ -110,14 +110,14 @@ main = do
|
||||
describe "Mobile API Tests" mobileTests
|
||||
#endif
|
||||
describe "SimpleX chat client" chatTests
|
||||
xdescribe'' "SimpleX Broadcast bot" broadcastBotTests
|
||||
describe "SimpleX Broadcast bot" broadcastBotTests
|
||||
describe "SimpleX Directory service bot" directoryServiceTests
|
||||
describe "SimpleX badge service e2e" $ do
|
||||
badgeServiceTests
|
||||
describe "managed group" badgeGroupIntegrationTests
|
||||
describe "Remote session" remoteTests
|
||||
#if !defined(dbPostgres)
|
||||
sequential $ xdescribe'' "Save query plans" saveQueryPlans
|
||||
sequential $ (if os == "linux" then describe else xdescribe) "Save query plans" saveQueryPlans
|
||||
#endif
|
||||
where
|
||||
#if defined(dbPostgres)
|
||||
|
||||
Reference in new issue
Block a user