Skip to content

Commit

Permalink
hopefully making life easier for future contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
avdb13 committed Feb 14, 2024
1 parent 58ba758 commit 21d169d
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 133 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@ jobs:
- name: Create a copy of `.env.example`
run: just dotenv

- name: Generate Synapse Configuration
run: |
just gen_synapse_conf
- name: Use Test Homeserver
run: |
sudo cp -f ./crates/test/fixtures/synapse/homeserver.yaml ./docker/synapse/homeserver.yaml
mkdir -p ./docker/synapse/media_stroe
cp -f ./crates/test/fixtures/synapse/* ./docker/synapse/homeserver.yaml
- name: Run Docker Containers
run: |
Expand All @@ -77,14 +74,12 @@ jobs:
- name: Retrieve Admin Access Token
run: |
just get_access_token
export COMMUNE_SYNAPSE_ADMIN_TOKEN=$(cat ./access_token.txt)
echo "COMMUNE_SYNAPSE_ADMIN_TOKEN=${COMMUNE_SYNAPSE_ADMIN_TOKEN}" >> $GITHUB_ENV
- name: E2E Tests
env:
COMMUNE_SYNAPSE_ADMIN_TOKEN: ${{ env.COMMUNE_SYNAPSE_ADMIN_TOKEN }}
run: |
cargo test -p test -- --test-threads=1
just e2e -- --show-output
- name: Print Logs
if: always()
Expand Down
20 changes: 0 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,6 @@ You must run Docker services as for development. In order to avoid messing up
the development environment, its recommended to use the synapse setup from
`crates/test/fixtures/synapse` replacing it with `docker/synapse`.

The only difference should be the `database` section, which uses SQLite instead.

```diff
database:
+ name: psycopg2
+ args:
+ database: /data/homeserver.db
- name: psycopg2
- txn_limit: 10000
- allow_unsafe_locale: true
- args:
- user: synapse_user
- password: secretpassword
- database: synapse
- host: localhost
- port: 5432
- cp_min: 5
- cp_max: 10
```

> Make sure the `.env` file is created from the contents on `.env.example`
### Application Layout
Expand Down
13 changes: 11 additions & 2 deletions crates/test/fixtures/synapse/homeserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ listeners:
- names: [client, federation]
compress: false
database:
name: sqlite3
name: psycopg2
txn_limit: 10000
allow_unsafe_locale: true
args:
database: /data/homeserver.db
user: synapse_user
password: secretpassword
database: synapse
host: localhost
port: 5432
cp_min: 5
cp_max: 10
log_config: "/data/matrix.localhost.log.config"
media_store_path: /data/media_store
registration_shared_secret: "m@;wYOUOh0f:CH5XA65sJB1^q01~DmIriOysRImot,OR_vzN&B"
Expand Down Expand Up @@ -70,4 +78,5 @@ rc_invites:
per_user:
per_second: 1000
burst_count: 1000

# vim:ft=yaml
30 changes: 13 additions & 17 deletions crates/test/fixtures/synapse/matrix.localhost.log.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,34 @@ version: 1

formatters:
precise:

format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'


handlers:

file:
class: logging.handlers.TimedRotatingFileHandler
formatter: precise
filename: /data/homeserver.log
when: midnight
backupCount: 3
encoding: utf8

buffer:
class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler
target: file
capacity: 10

console:
class: logging.StreamHandler
formatter: precise

loggers:
# This is just here so we can leave `loggers` in the config regardless of whether
# we configure other loggers below (avoid empty yaml dict error).
_placeholder:
level: "INFO"



synapse.storage.SQL:
# beware: increasing this to DEBUG will make synapse log sensitive
# information such as access tokens.
level: INFO




root:
level: INFO


handlers: [console]


disable_existing_loggers: false
disable_existing_loggers: false
39 changes: 39 additions & 0 deletions crates/test/src/matrix/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#[cfg(test)]
mod tests {
use std::sync::Once;

use matrix::{
admin::resources::room::{MessagesQuery, OrderBy},
ruma_common::{RoomId, ServerName},
ruma_events::AnyStateEvent,
};
use rand::Rng;
use tokio::sync::OnceCell;

#[tokio::test]
async fn send_room_message() {
let Test { client, .. } = TEST.get_or_init(util::init).await;

// first join
let result = join_helper().await;
let rooms: Vec<_> = result.iter().map(|r| &r.0).collect();
tracing::info!(?rooms, "joining all guests");

// check whether all guests are in the room and joined the expected room
for (room_id, guests, resps) in result {
let mut resp = AdminRoomService::get_members(&admin, &room_id)
.await
.unwrap();
resp.members.sort();

assert!(resps.iter().all(|r| r.is_ok()));
let resps: Vec<_> = resps.into_iter().flatten().collect();

assert!(resps.iter().all(|r| r.room_id == *room_id));

for guest in guests {
assert!(resp.members.contains(&guest));
}
}
}
}
Empty file removed docker/.gitkeep
Empty file.
Empty file removed docker/synapse/.gitkeep
Empty file.
Empty file.
46 changes: 0 additions & 46 deletions fixtures/synapse/homeserver.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions fixtures/synapse/matrix.localhost.log.config

This file was deleted.

1 change: 0 additions & 1 deletion fixtures/synapse/matrix.localhost.signing.key

This file was deleted.

0 comments on commit 21d169d

Please sign in to comment.