test_synapse_port_db.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env bash
  2. #
  3. # Test script for 'synapse_port_db'.
  4. # - sets up synapse and deps
  5. # - runs the port script on a prepopulated test sqlite db
  6. # - also runs it against an new sqlite db
  7. set -xe
  8. cd `dirname $0`/../..
  9. echo "--- Install dependencies"
  10. # Install dependencies for this test.
  11. pip install psycopg2 coverage coverage-enable-subprocess
  12. # Install Synapse itself. This won't update any libraries.
  13. pip install -e .
  14. echo "--- Generate the signing key"
  15. # Generate the server's signing key.
  16. python -m synapse.app.homeserver --generate-keys -c .buildkite/sqlite-config.yaml
  17. echo "--- Prepare test database"
  18. # Make sure the SQLite3 database is using the latest schema and has no pending background update.
  19. scripts-dev/update_database --database-config .buildkite/sqlite-config.yaml
  20. # Create the PostgreSQL database.
  21. ./.buildkite/scripts/postgres_exec.py "CREATE DATABASE synapse"
  22. echo "+++ Run synapse_port_db against test database"
  23. coverage run scripts/synapse_port_db --sqlite-database .buildkite/test_db.db --postgres-config .buildkite/postgres-config.yaml
  24. #####
  25. # Now do the same again, on an empty database.
  26. echo "--- Prepare empty SQLite database"
  27. # we do this by deleting the sqlite db, and then doing the same again.
  28. rm .buildkite/test_db.db
  29. scripts-dev/update_database --database-config .buildkite/sqlite-config.yaml
  30. # re-create the PostgreSQL database.
  31. ./.buildkite/scripts/postgres_exec.py \
  32. "DROP DATABASE synapse" \
  33. "CREATE DATABASE synapse"
  34. echo "+++ Run synapse_port_db against empty database"
  35. coverage run scripts/synapse_port_db --sqlite-database .buildkite/test_db.db --postgres-config .buildkite/postgres-config.yaml