-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerised SyTest #484
Dockerised SyTest #484
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.git/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,7 @@ | |
/.synapse-base | ||
/synapse | ||
/var | ||
*~ | ||
\#* | ||
logs/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we make these |
||
results.tap |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,26 @@ | ||
FROM ubuntu:14.04 | ||
FROM debian:stretch | ||
|
||
ENV PERL5LIB=$HOME/lib/perl5 | ||
ENV PERL_MB_OPT=--install_base=$HOME | ||
ENV PERL_MM_OPT=INSTALL_BASE=$HOME | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
ADD MyConfig.pm /root/.cpan/CPAN/MyConfig.pm | ||
RUN apt-get -qq update | ||
RUN apt-get -qq install -y build-essential perl wget postgresql postgresql-client libpq-dev libssl-dev libz-dev libffi-dev sqlite3 libjpeg-dev libxslt1-dev git locales | ||
|
||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y \ | ||
build-essential \ | ||
python2.7-dev \ | ||
libffi-dev \ | ||
python-pip \ | ||
python-setuptools \ | ||
sqlite3 \ | ||
libssl-dev \ | ||
python-virtualenv \ | ||
libjpeg-dev \ | ||
libxslt1-dev \ | ||
git \ | ||
postgresql \ | ||
libpq-dev \ | ||
&& cd /root \ | ||
&& git clone https://github.com/matrix-org/sytest \ | ||
&& git clone https://github.com/matrix-org/synapse \ | ||
&& pip install --upgrade setuptools \ | ||
&& mkdir -p /root/.cpan/CPAN \ | ||
&& cd /root/sytest \ | ||
&& ./install-deps.pl \ | ||
&& cd ../synapse \ | ||
&& git checkout develop \ | ||
&& python synapse/python_dependencies.py | xargs -n1 pip install \ | ||
&& pip install lxml \ | ||
&& python setup.py develop --user \ | ||
&& python setup.py test | ||
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ | ||
dpkg-reconfigure --frontend=noninteractive locales && \ | ||
update-locale LANG=en_US.UTF-8 | ||
|
||
WORKDIR /root/sytest | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
|
||
# The dockerfile context, when ran by the buildscript, will actually be the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "when run by" |
||
# repo root, not the docker folder | ||
ADD install-deps.pl ./install-deps.pl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. having added these to the docker image, are they ever actually used? |
||
ADD cpanfile ./cpanfile | ||
RUN perl ./install-deps.pl | ||
|
||
# /logs is where we should expect logs to end up | ||
RUN mkdir /logs | ||
# /test is where sytest will live | ||
RUN mkdir /test | ||
WORKDIR /test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM matrixdotorg/sytest:latest | ||
|
||
RUN apt-get -qq install -y python python-dev python-virtualenv | ||
|
||
ENV PYTHON=python2 | ||
|
||
# /src is where we expect Synapse to be | ||
RUN mkdir /src | ||
|
||
# The dockerfile context, when ran by the buildscript, will actually be the | ||
# repo root, not the docker folder | ||
ADD docker/synapse_sytest.sh /synapse_sytest.sh | ||
ENTRYPOINT /synapse_sytest.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM matrixdotorg/sytest:latest | ||
|
||
RUN apt-get -qq install -y python3 python3-dev python3-virtualenv | ||
|
||
ENV PYTHON=python3 | ||
|
||
# /src is where we expect Synapse to be | ||
RUN mkdir /src | ||
|
||
# The dockerfile context, when ran by the buildscript, will actually be the | ||
# repo root, not the docker folder | ||
ADD docker/synapse_sytest.sh /synapse_sytest.sh | ||
ENTRYPOINT /synapse_sytest.sh |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,33 @@ | ||
# SyTest Docker | ||
# SyTest Docker Images | ||
|
||
Herein lies a Dockerfile for building a functional SyTest test environment. | ||
SyTest and synapse are cloned from the HEAD of their develop branches. You can | ||
run the tests as follows: | ||
These Dockerfiles create containers for running SyTest in various configurations. | ||
|
||
``` | ||
cd /path/to/sytest/docker | ||
docker build -t sytest . | ||
docker run --rm -it sytest bash | ||
``` | ||
Included currently is: | ||
|
||
And then at the shell prompt: | ||
|
||
``` | ||
./run-tests.pl | ||
``` | ||
- matrixdotorg/sytest, a base container with SyTest dependencies installed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one thing that I didn't quite grok at first was that the docker images don't in fact include Sytest itself, which will be pulled from git. I realise it's alluded to below, but it might be worth making explicit? |
||
- matrixdotorg/sytest-synapsepy2, a container which will run SyTest against Synapse on Python 2.7 | ||
- matrixdotorg/sytest-synapsepy3, a container which will run SyTest against Synapse on Python 3.5 | ||
|
||
Or other commands as per [the main SyTest | ||
documentation](https://github.com/matrix-org/sytest#running). | ||
## Using the Synapse containers | ||
|
||
Alternatively: | ||
Once pulled from Docker Hub, the container can be ran on a Synapse checkout: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "can be run on" |
||
|
||
``` | ||
docker run --rm sytest <command> | ||
$ docker run --rm -it -v /path/to/synapse\:/src -v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapsepy2 | ||
``` | ||
|
||
Where `<command>` is `./run-tests.pl` or similar. | ||
This will run on the same branch in SyTest as the Synapse checkout, if possible, but will fall back to using develop. | ||
|
||
If you want to use a checkout of SyTest, mount it to `/test` inside the container by adding `-v /path/to/sytest\:/test` to the docker command. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/a checkout/an existing checkout/ ? |
||
|
||
If you want to test against a PostgreSQL database, pass `-e POSTGRES=1` to the docker command. | ||
|
||
To use sytest and synapse from the host, so that you can iterate on test | ||
implementation and execute the tests in the container, you can do as follows: | ||
## Building the containers | ||
|
||
The containers are built by executing `build.sh`. You will then have to push them up to Docker Hub: | ||
|
||
``` | ||
docker run --rm -it -v /path/to/sytest:/src/sytest -v /path/to/synapse:/src/synapse sytest bash | ||
$ docker push matrixdotorg/sytest | ||
$ docker push matrixdotorg/sytest-synapsepy2 | ||
$ docker push matrixdotorg/sytest-synapsepy3 | ||
``` | ||
|
||
Then at the prompt, `cd /src/sytest` and then you can run `./run-tests.pl` and | ||
iterate developing a new test or modifying an existing test using your | ||
favourite editor on your host. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#! /usr/bin/env bash | ||
docker build ../ -f Dockerfile -t matrixdotorg/sytest | ||
docker build ../ -f Dockerfile-synapsepy2 -t matrixdotorg/sytest-synapsepy2 | ||
docker build ../ -f Dockerfile-synapsepy3 -t matrixdotorg/sytest-synapsepy3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -x | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like we're going to need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (with some faffery around the wget) |
||
|
||
if [ -e "/test/run-tests.pl" ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this this |
||
then | ||
echo "Using local sytests..." | ||
else | ||
branch_name="$(git --git-dir=/src/.git symbolic-ref HEAD 2>/dev/null)" || branch_name="(unnamed branch)" | ||
|
||
echo "Trying to get same-named sytest..." | ||
wget -q https://github.com/matrix-org/sytest/archive/$branch_name.tar.gz -O sytest.tar.gz | ||
4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 4? I raise you 5. |
||
if [ $? -eq 0 ] | ||
then | ||
echo "Using $branch_name!" | ||
else | ||
echo "Using develop instead..." | ||
wget -q https://github.com/matrix-org/sytest/archive/develop.tar.gz -O sytest.tar.gz | ||
fi | ||
|
||
tar --strip-components=1 -xf sytest.tar.gz | ||
|
||
fi | ||
|
||
# PostgreSQL setup | ||
if [ -n "$POSTGRES" ] | ||
then | ||
|
||
export PGDATA=/var/lib/postgresql/data | ||
export PGUSER=postgres | ||
export POSTGRES_DB_1=pg1 | ||
export POSTGRES_DB_2=pg2 | ||
|
||
su -c '/usr/lib/postgresql/9.6/bin/initdb -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 | ||
|
||
jenkins/prep_sytest_for_postgres.sh | ||
|
||
su -c 'psql -c "CREATE DATABASE pg1;"' postgres | ||
su -c 'psql -c "CREATE DATABASE pg2;"' postgres | ||
|
||
fi | ||
|
||
# Build the virtualenv | ||
$PYTHON -m virtualenv -p $PYTHON /venv/ | ||
/venv/bin/pip install -q --no-cache-dir -e /src/ | ||
/venv/bin/pip install -q --no-cache-dir lxml psycopg2 | ||
|
||
# Make sure all deps are installed -- this is done in the docker build so it shouldn't be too many | ||
./install-deps.pl | ||
|
||
# Run the tests | ||
./run-tests.pl -I Synapse --python=/venv/bin/python -O tap --all > results.tap | ||
|
||
# Copy out the logs | ||
cp results.tap /logs/results.tap | ||
cp server-0/homeserver.log /logs/homeserver-0.log | ||
cp server-1/homeserver.log /logs/homeserver-1.log |
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.
there's some attempt to sort this file; this and the below probably want to go alongside
.*.swp