Skip to content

Commit

Permalink
test: Merge the two integration test suites into a single one
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjbvr committed Oct 23, 2023
1 parent 7440ce0 commit 6368c69
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 265 deletions.
45 changes: 3 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:
- name: Test
run: |
cargo nextest run --workspace \
--exclude matrix-sdk-integration-testing --exclude sliding-sync-integration-test --features testing
--exclude matrix-sdk-integration-testing --features testing
- name: Test documentation
run: |
Expand Down Expand Up @@ -343,42 +343,6 @@ jobs:

runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Load cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Install nextest
uses: taiki-e/install-action@nextest

- uses: actions/setup-python@v4
with:
python-version: 3.8

- uses: michaelkaye/setup-matrix-synapse@main
with:
installer: venv # TODO revert to poetry once https://github.com/michaelkaye/setup-matrix-synapse/issues/95 is fixed
uploadLogs: true
httpPort: 8228
disableRateLimiting: true

- name: Test
run: |
cargo nextest run -p matrix-sdk-integration-testing
sliding-sync-integration-tests:
name: Sliding Sync Integration test
if: github.event_name == 'push' || !github.event.pull_request.draft

runs-on: ubuntu-latest
# run several docker containers with the same networking stack so the hostname 'postgres'
# maps to the postgres container, etc.
services:
Expand Down Expand Up @@ -422,6 +386,7 @@ jobs:
SERVER_NAME: synapse
ports:
- 8008:8008

steps:
- name: Checkout the repo
uses: actions/checkout@v3
Expand All @@ -437,15 +402,11 @@ jobs:
- name: Install nextest
uses: taiki-e/install-action@nextest

- uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Test
env:
RUST_LOG: "hyper=trace"
HOMESERVER_URL: "http://localhost:8008"
HOMESERVER_DOMAIN: "synapse"
SLIDING_SYNC_PROXY_URL: "http://localhost:8118"
run: |
cargo nextest run -p sliding-sync-integration-test
cargo nextest run -p matrix-sdk-integration-testing
54 changes: 47 additions & 7 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,50 @@ jobs:
runs-on: "ubuntu-latest"
if: github.event_name == 'push' || !github.event.pull_request.draft

# run several docker containers with the same networking stack so the hostname 'postgres'
# maps to the postgres container, etc.
services:
# sliding sync needs a postgres container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: syncv3
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
# run sliding sync and point it at the postgres container and synapse container.
# the postgres container needs to be above this to make sure it has started prior to this service.
slidingsync:
image: "ghcr.io/matrix-org/sliding-sync:v0.99.11"
env:
SYNCV3_SERVER: "http://synapse:8008"
SYNCV3_SECRET: "SUPER_CI_SECRET"
SYNCV3_BINDADDR: ":8118"
SYNCV3_DB: "user=postgres password=postgres dbname=syncv3 sslmode=disable host=postgres"
ports:
- 8118:8118
# tests need a synapse: this is a service and not michaelkaye/setup-matrix-synapse@main as the
# latter does not provide networking for services to communicate with it.
synapse:
# Custom image built from https://github.com/matrix-org/synapse/tree/v1.72.0/docker/complement
# with a dummy /complement/ca set
image: ghcr.io/matrix-org/synapse-service:v1.72.0
env:
SYNAPSE_COMPLEMENT_DATABASE: sqlite
SERVER_NAME: synapse
ports:
- 8008:8008

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -53,13 +97,6 @@ jobs:
with:
python-version: 3.8

- uses: michaelkaye/setup-matrix-synapse@main
with:
installer: venv # TODO revert to poetry once https://github.com/michaelkaye/setup-matrix-synapse/issues/95 is fixed
uploadLogs: true
httpPort: 8228
disableRateLimiting: true

- name: Run tarpaulin
run: |
rustup run stable cargo tarpaulin \
Expand All @@ -68,6 +105,9 @@ jobs:
env:
CARGO_PROFILE_COV_INHERITS: 'dev'
CARGO_PROFILE_COV_DEBUG: 'false'
HOMESERVER_URL: "http://localhost:8008"
HOMESERVER_DOMAIN: "synapse"
SLIDING_SYNC_PROXY_URL: "http://localhost:8118"

- name: Upload to codecov.io
uses: codecov/codecov-action@v3
Expand Down
17 changes: 0 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions tarpaulin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ exclude = [
# repo automation (ci, codegen)
"uniffi-bindgen",
"xtask",
# temporary: tiny test suite, expensive to run
"sliding-sync-integration-test",
]
8 changes: 1 addition & 7 deletions testing/matrix-sdk-integration-testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,5 @@ To drop the database of your docker-compose run:

```bash
docker-compose -f assets/docker-compose.yml stop
docker volume rm -f assets_matrix-rust-sdk-ci-data
```

or simply:

```bash
docker-compose -f assets/docker-compose.yml down -v
rm -rf ./assets/data
```
1 change: 1 addition & 0 deletions testing/matrix-sdk-integration-testing/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data/
35 changes: 31 additions & 4 deletions testing/matrix-sdk-integration-testing/assets/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@

version: '3'

services:

synapse:
build: .
restart: "no"
healthcheck:
disable: true
volumes:
- matrix-rust-sdk-ci-data:/data
- ./data/synapse:/data
ports:
- 8228:8008/tcp

volumes:
matrix-rust-sdk-ci-data:
postgres:
image: docker.io/postgres
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: syncv3
healthcheck:
test: ["CMD", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- ./data/db:/var/lib/postgresql/data

sliding-sync-proxy:
image: ghcr.io/matrix-org/sliding-sync:v0.99.4
depends_on:
postgres:
condition: service_healthy
links:
- synapse
- postgres
environment:
SYNCV3_SERVER: http://synapse:8008
SYNCV3_SECRET: SUPER_SECRET
SYNCV3_BINDADDR: ":8338"
SYNCV3_DB: "user=postgres password=postgres dbname=syncv3 sslmode=disable host=postgres"
ports:
- 8338:8338
1 change: 1 addition & 0 deletions testing/matrix-sdk-integration-testing/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ mod invitations;
mod reactions;
mod redaction;
mod repeated_join;
mod sliding_sync;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![cfg(test)]

use crate::helpers::get_client_for_user;
use anyhow::Context;
use futures_util::{pin_mut, stream::StreamExt};
use matrix_sdk::{Client, RoomListEntry, SlidingSyncBuilder, SlidingSyncList, SlidingSyncMode};
use matrix_sdk_integration_testing::helpers::get_client_for_user;
use matrix_sdk::{Client, SlidingSyncBuilder, SlidingSyncList, SlidingSyncMode};

mod notification_client;

Expand All @@ -20,23 +20,6 @@ async fn setup(
Ok((client, sliding_sync_builder))
}

#[derive(PartialEq, Eq, Clone, Debug)]
enum RoomListEntryEasy {
Empty,
Invalid,
Filled,
}

impl From<&RoomListEntry> for RoomListEntryEasy {
fn from(value: &RoomListEntry) -> Self {
match value {
RoomListEntry::Empty => RoomListEntryEasy::Empty,
RoomListEntry::Invalidated(_) => RoomListEntryEasy::Invalid,
RoomListEntry::Filled(_) => RoomListEntryEasy::Filled,
}
}
}

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn it_works_smoke_test() -> anyhow::Result<()> {
let (_client, sync_builder) = setup("odo".to_owned(), false).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use matrix_sdk::{
},
RoomState,
};
use matrix_sdk_integration_testing::helpers::get_client_for_user;
use matrix_sdk_ui::{
notification_client::{
Error, NotificationClient, NotificationEvent, NotificationItem, NotificationProcessSetup,
Expand All @@ -28,6 +27,8 @@ use matrix_sdk_ui::{
};
use tracing::warn;

use crate::helpers::get_client_for_user;

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_notification() -> Result<()> {
// Create new users for each test run, to avoid conflicts with invites existing
Expand Down
1 change: 0 additions & 1 deletion testing/sliding-sync-integration-test/.gitignore

This file was deleted.

18 changes: 0 additions & 18 deletions testing/sliding-sync-integration-test/Cargo.toml

This file was deleted.

36 changes: 0 additions & 36 deletions testing/sliding-sync-integration-test/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions testing/sliding-sync-integration-test/assets/Dockerfile

This file was deleted.

Loading

0 comments on commit 6368c69

Please sign in to comment.