11#! /usr/bin/env bash
22# 
33#  Test script for 'synapse_port_db'.
4- #    - sets up  synapse and deps 
4+ #    - configures  synapse and a postgres server. 
55#    - runs the port script on a prepopulated test sqlite db
66#    - also runs it against an new sqlite db
7- 
7+ # 
8+ #  Expects Synapse to have been already installed with `poetry install --extras postgres`.
9+ #  Expects `poetry` to be available on the `PATH`.
810
911set  -xe
1012cd  " $( dirname " $0 " ) " 
1113
12- echo  " --- Install dependencies" 
13- 
14- #  Install dependencies for this test.
15- pip install psycopg2 coverage coverage-enable-subprocess
16- 
17- #  Install Synapse itself. This won't update any libraries.
18- pip install -e . 
19- 
2014echo  " --- Generate the signing key" 
2115
2216#  Generate the server's signing key.
23- python -m synapse.app.homeserver  --generate-keys -c .ci/sqlite-config.yaml
17+ poetry run synapse_homeserver  --generate-keys -c .ci/sqlite-config.yaml
2418
2519echo  " --- Prepare test database" 
2620
2721#  Make sure the SQLite3 database is using the latest schema and has no pending background update.
28- update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
22+ poetry run  update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
2923
3024#  Create the PostgreSQL database.
31- .ci/scripts/postgres_exec.py " CREATE DATABASE synapse" 
25+ poetry run  .ci/scripts/postgres_exec.py " CREATE DATABASE synapse" 
3226
3327echo  " +++ Run synapse_port_db against test database" 
3428#  TODO: this invocation of synapse_port_db (and others below) used to be prepended with `coverage run`,
3529#  but coverage seems unable to find the entrypoints installed by `pip install -e .`.
36- synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
30+ poetry run  synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
3731
3832#  We should be able to run twice against the same database.
3933echo  " +++ Run synapse_port_db a second time" 
40- synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
34+ poetry run  synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
4135
4236# ####
4337
@@ -48,12 +42,12 @@ echo "--- Prepare empty SQLite database"
4842#  we do this by deleting the sqlite db, and then doing the same again.
4943rm .ci/test_db.db
5044
51- update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
45+ poetry run  update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
5246
5347#  re-create the PostgreSQL database.
54- .ci/scripts/postgres_exec.py \
48+ poetry run  .ci/scripts/postgres_exec.py \
5549  " DROP DATABASE synapse" 
5650  " CREATE DATABASE synapse" 
5751
5852echo  " +++ Run synapse_port_db against empty database" 
59- synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
53+ poetry run  synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
0 commit comments