Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Dockerised sytest #3660

Merged
merged 10 commits into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: 2
jobs:
sytestpy2:
machine: true
steps:
- checkout
- run: docker pull hawkowl/sytestpy2
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs hawkowl/sytestpy2
- store_artifacts:
path: ~/project/logs
destination: logs
sytestpy2postgres:
machine: true
steps:
- checkout
- run: docker pull hawkowl/sytestpy2
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs -e POSTGRES=1 hawkowl/sytestpy2
- store_artifacts:
path: ~/project/logs
destination: logs
sytestpy3:
machine: true
steps:
- checkout
- run: docker pull hawkowl/sytestpy3
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs hawkowl/sytestpy3
- store_artifacts:
path: ~/project/logs
destination: logs

workflows:
version: 2
build:
jobs:
- sytestpy2
- sytestpy2postgres
# Currently broken!
# - sytestpy3
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ Dockerfile
.gitignore
demo/etc
tox.ini
synctl
.git/*
.tox/*
26 changes: 26 additions & 0 deletions Dockerfile-sytest
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM debian:stretch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be in the sytest repo rather than here?


ENV DEBIAN_FRONTEND noninteractive

RUN apt-get -qq update
RUN apt-get -qq install -y python python-dev python-virtualenv python3-virtualenv python3-dev build-essential perl wget postgresql postgresql-client libpq-dev libssl-dev libz-dev libffi-dev sqlite3 libjpeg-dev libxslt1-dev git locales

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

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN wget -q https://github.com/matrix-org/sytest/raw/develop/install-deps.pl
RUN wget -q https://github.com/matrix-org/sytest/raw/develop/cpanfile
RUN perl install-deps.pl

RUN mkdir /test
RUN mkdir /src
RUN mkdir /logs
WORKDIR /test

ADD docker_sytest.sh /docker_sytest.sh
ENTRYPOINT /docker_sytest.sh
3 changes: 3 additions & 0 deletions Dockerfile-sytestpy2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM hawkowl/sytest:latest

ENV PYTHON=python2
3 changes: 3 additions & 0 deletions Dockerfile-sytestpy3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM hawkowl/sytest:latest

ENV PYTHON=python3.5
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ exclude jenkins.sh
exclude jenkins*.sh
exclude jenkins*
exclude Dockerfile
exclude Dockerfile*
exclude docker_sytest.sh
exclude .dockerignore
recursive-exclude jenkins *.sh

Expand All @@ -36,3 +38,4 @@ recursive-include changelog.d *
prune .github
prune demo/etc
prune docker
prune .circleci
1 change: 1 addition & 0 deletions changelog.d/3660.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sytests can now be run inside a Docker container.
59 changes: 59 additions & 0 deletions docker_sytest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#! /usr/bin/env bash

set -x

if [ -e "/test/run-tests.pl" ]
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
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