This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a way to run tests in PostgreSQL in Docker (#3699)
- Loading branch information
Showing
8 changed files
with
79 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
*.pyc | ||
.*.swp | ||
*~ | ||
*.lock | ||
|
||
.DS_Store | ||
_trial_temp/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Unit tests can now be run under PostgreSQL in Docker using | ||
``test_postgresql.sh``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Use the Sytest image that comes with a lot of the build dependencies | ||
# pre-installed | ||
FROM matrixdotorg/sytest:latest | ||
|
||
# The Sytest image doesn't come with python, so install that | ||
RUN apt-get -qq install -y python python-dev python-pip | ||
|
||
# We need tox to run the tests in run_pg_tests.sh | ||
RUN pip install tox | ||
|
||
ADD run_pg_tests.sh /pg_tests.sh | ||
ENTRYPOINT /pg_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# This script runs the PostgreSQL tests inside a Docker container. It expects | ||
# the relevant source files to be mounted into /src (done automatically by the | ||
# caller script). It will set up the database, run it, and then use the tox | ||
# configuration to run the tests. | ||
|
||
set -e | ||
|
||
# Set PGUSER so Synapse's tests know what user to connect to the database with | ||
export PGUSER=postgres | ||
|
||
# Initialise & start the database | ||
su -c '/usr/lib/postgresql/9.6/bin/initdb -D /var/lib/postgresql/data -E "UTF-8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --username=postgres' postgres | ||
su -c '/usr/lib/postgresql/9.6/bin/pg_ctl -w -D /var/lib/postgresql/data start' postgres | ||
|
||
# Run the tests | ||
cd /src | ||
export TRIAL_FLAGS="-j 4" | ||
tox --workdir=/tmp -e py27-postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# This script builds the Docker image to run the PostgreSQL tests, and then runs | ||
# the tests. | ||
|
||
set -e | ||
|
||
# Build, and tag | ||
docker build docker/ -f docker/Dockerfile-pgtests -t synapsepgtests | ||
|
||
# Run, mounting the current directory into /src | ||
docker run --rm -it -v $(pwd)\:/src synapsepgtests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
741571c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, How to run this unit tests on CI/CD pipeline by connecting to postgres?
I am getting this error: the input device is not a TTY