Skip to content

Commit

Permalink
Update the SyTest docker images to ones that work on Buildkite (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkowl authored Jul 12, 2019
1 parent 885169a commit 7d52124
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 58 deletions.
3 changes: 2 additions & 1 deletion docker/Dockerfile-dendrite
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ RUN mkdir -p /src
# repo root, not the docker folder
ADD docker/dendrite_sytest.sh /dendrite_sytest.sh
RUN dos2unix /dendrite_sytest.sh
ENTRYPOINT ["/dendrite_sytest.sh"]

CMD ["/usr/bin/bash" "/dendrite_sytest.sh"]
35 changes: 0 additions & 35 deletions docker/Dockerfile-synapsepy2

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ RUN dos2unix /synapse_sytest.sh

ADD docker/pydron.py /pydron.py

ENTRYPOINT ["/synapse_sytest.sh"]
CMD ["/usr/bin/bash" "/synapse_sytest.sh"]
10 changes: 4 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ are.
Included currently is:

- matrixdotorg/sytest, a base container with SyTest dependencies installed
- 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
- matrixdotorg/sytest-synapse:py35, a container which will run SyTest against Synapse on Python 3.5
- matrixdotorg/sytest-dendrite, a container which will run SyTest against Dendrite

## Using the containers
Expand All @@ -18,7 +17,7 @@ Once pulled from Docker Hub, a container can be run on a homeserver checkout:
### Synapse

```
docker run --rm -it -v /path/to/synapse\:/src -v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapsepy3
docker run --rm -it -v /path/to/synapse\:/src -v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapse:py35
```

### Dendrite
Expand All @@ -37,7 +36,7 @@ You can pass arguments to sytest by adding them at the end of the docker
command. For example, you can use

```
docker run --rm -it ... matrixdotorg/sytest-synapsepy3 tests/20profile-events.pl
docker run --rm -it ... matrixdotorg/sytest-synapse:py35 tests/20profile-events.pl
```

to run only a single test.
Expand All @@ -64,7 +63,6 @@ them up to Docker Hub:

```
docker push matrixdotorg/sytest
docker push matrixdotorg/sytest-synapsepy2
docker push matrixdotorg/sytest-synapsepy3
docker push matrixdotorg/sytest-synapse:py35
docker push matrixdotorg/sytest-dendrite
```
7 changes: 3 additions & 4 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set -e

cd `dirname $0`
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
docker build ../ -f Dockerfile-dendrite -t matrixdotorg/sytest-dendrite
docker build --pull ../ -f Dockerfile -t matrixdotorg/sytest:latest
docker build ../ -f Dockerfile-synapsepy35 -t matrixdotorg/sytest-synapse:py35
docker build ../ -f Dockerfile-dendrite -t matrixdotorg/sytest-dendrite:latest
37 changes: 26 additions & 11 deletions docker/synapse_sytest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ if [ -d "/sytest" ]; then
ln -sf /sytest/keys /work
SYTEST_LIB="/sytest/lib"
else
# Otherwise, try and find out what the branch that the Synapse checkout is using. Fall back to develop if it's not a branch.
branch_name="$(git --git-dir=/src/.git symbolic-ref HEAD 2>/dev/null)" || branch_name="develop"
if [ -n "BUILDKITE_BRANCH" ]
then
branch_name=$BUILDKITE_BRANCH
else
# Otherwise, try and find out what the branch that the Synapse checkout is using. Fall back to develop if it's not a branch.
branch_name="$(git --git-dir=/src/.git symbolic-ref HEAD 2>/dev/null)" || branch_name="develop"
fi

# Try and fetch the branch
echo "Trying to get same-named sytest branch..."
Expand Down Expand Up @@ -68,9 +73,9 @@ if [ -n "$OFFLINE" ]; then
else
# We've already created the virtualenv, but lets double check we have all
# deps.
/venv/bin/pip install -q --upgrade --no-cache-dir -e /src/
/venv/bin/pip install -q --upgrade --no-cache-dir -e /src
/venv/bin/pip install -q --upgrade --no-cache-dir \
lxml psycopg2 coverage codecov
lxml psycopg2 coverage codecov tap.py

# Make sure all Perl deps are installed -- this is done in the docker build
# so will only install packages added since the last Docker build
Expand Down Expand Up @@ -106,18 +111,28 @@ fi
# Copy out the logs
mkdir -p /logs
cp results.tap /logs/results.tap
rsync --ignore-missing-args -av server-0 server-1 /logs --include "*/" --include="*.log.*" --include="*.log" --exclude="*"
rsync --ignore-missing-args --min-size=1B -av server-0 server-1 /logs --include "*/" --include="*.log.*" --include="*.log" --exclude="*"

# Write out JUnit for CircleCI
mkdir -p /logs/sytest
perl ./tap-to-junit-xml.pl --puretap --input=/logs/results.tap --output=/logs/sytest/results.xml "SyTest"

# Upload coverage to codecov, if running on CircleCI
if [ -n "$CIRCLECI" ]
# Upload coverage to codecov and upload files, if running on Buildkite
if [ -n "$BUILDKITE" ]
then
/venv/bin/coverage combine || true
/venv/bin/coverage xml || true
/venv/bin/codecov -X gcov -f coverage.xml

wget -O buildkite.tar.gz https://github.com/buildkite/agent/releases/download/v3.13.0/buildkite-agent-linux-amd64-3.13.0.tar.gz
tar xvf buildkite.tar.gz
chmod +x ./buildkite-agent

# Upload the files
./buildkite-agent artifact upload "/logs/**/*.log*"
./buildkite-agent artifact upload "/logs/results.tap"

if [ $TEST_STATUS -ne 0 ]; then
# Annotate, if failure
/venv/bin/python /src/.buildkite/format_tap.py /logs/results.tap "$BUILDKITE_LABEL" | ./buildkite-agent annotate --style="error" --context="$BUILDKITE_LABEL"
fi
fi


exit $TEST_STATUS

0 comments on commit 7d52124

Please sign in to comment.