From e763fb87d84167c94cd8b8738ea3fe01257062bf Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 21:26:24 +1000 Subject: [PATCH 01/28] add --- .buildkite/pipeline.yml | 16 ++++++++++++++++ changelog.d/5459.misc | 1 + 2 files changed, 17 insertions(+) create mode 100644 changelog.d/5459.misc diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 8eddf8b93199..e6d384712c47 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -46,6 +46,22 @@ steps: - wait + - label: "SyTest - :python: 3.6 / SQLite" + env: + TRIAL_FLAGS: "-j 4" + command: + - "bash .circleci/merge_base_branch.sh" + - "bash -c '/synapse_sytest.sh'" + plugins: + - docker-compose#v2.1.0: + image: "matrixdotorg/sytest-synapsepy3" + retry: + automatic: + - exit_status: -1 + limit: 2 + - exit_status: 2 + limit: 2 + - command: - "python -m pip install tox" - "tox -e py35-old,codecov" diff --git a/changelog.d/5459.misc b/changelog.d/5459.misc new file mode 100644 index 000000000000..904e45f66b04 --- /dev/null +++ b/changelog.d/5459.misc @@ -0,0 +1 @@ +SyTest has been moved to Buildkite. From 7a97b2a17ad80c06b9f872bd5819c97223a49c3d Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 21:31:35 +1000 Subject: [PATCH 02/28] add --- .buildkite/pipeline.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index e6d384712c47..3b16c6318bf6 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -47,13 +47,11 @@ steps: - wait - label: "SyTest - :python: 3.6 / SQLite" - env: - TRIAL_FLAGS: "-j 4" command: - "bash .circleci/merge_base_branch.sh" - - "bash -c '/synapse_sytest.sh'" + - "bash /synapse_sytest.sh" plugins: - - docker-compose#v2.1.0: + - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" retry: automatic: From 3a8e6bf3a2943388bba1be1502b4aac8951575d7 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 21:50:47 +1000 Subject: [PATCH 03/28] fix --- .../merge_base_branch.sh | 11 +-- .buildkite/pipeline.yml | 3 +- .circleci/config.yml | 67 ------------------- 3 files changed, 5 insertions(+), 76 deletions(-) rename {.circleci => .buildkite}/merge_base_branch.sh (53%) diff --git a/.circleci/merge_base_branch.sh b/.buildkite/merge_base_branch.sh similarity index 53% rename from .circleci/merge_base_branch.sh rename to .buildkite/merge_base_branch.sh index 4c19fa70d745..4e23a4ac88b8 100755 --- a/.circleci/merge_base_branch.sh +++ b/.buildkite/merge_base_branch.sh @@ -2,21 +2,16 @@ set -e -# CircleCI doesn't give CIRCLE_PR_NUMBER in the environment for non-forked PRs. Wonderful. -# In this case, we just need to do some ~shell magic~ to strip it out of the PULL_REQUEST URL. -echo 'export CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"' >> $BASH_ENV -source $BASH_ENV - -if [[ -z "${CIRCLE_PR_NUMBER}" ]] +if [[ -z "$BUILDKITE_PULL_REQUEST_BASE_BRANCH"]] then - echo "Can't figure out what the PR number is! Assuming merge target is develop." + echo "Not a pull request, or hasn't had a PR opened yet..." # It probably hasn't had a PR opened yet. Since all PRs land on develop, we # can probably assume it's based on it and will be merged into it. GITBASE="develop" else # Get the reference, using the GitHub API - GITBASE=`wget -O- https://api.github.com/repos/matrix-org/synapse/pulls/${CIRCLE_PR_NUMBER} | jq -r '.base.ref'` + GITBASE=$BUILDKITE_PULL_REQUEST_BASE_BRANCH fi # Show what we are before diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 3b16c6318bf6..4b318fdcf468 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -48,11 +48,12 @@ steps: - label: "SyTest - :python: 3.6 / SQLite" command: - - "bash .circleci/merge_base_branch.sh" + - "bash .buildkite/merge_base_branch.sh" - "bash /synapse_sytest.sh" plugins: - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" + propagate-environment: true retry: automatic: - exit_status: -1 diff --git a/.circleci/config.yml b/.circleci/config.yml index 3c2b32c015cb..e4fd5ffa6b48 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,77 +17,10 @@ jobs: - run: docker push matrixdotorg/synapse:latest - run: docker push matrixdotorg/synapse:latest-py3 - sytestpy3: - docker: - - image: matrixdotorg/sytest-synapsepy3 - working_directory: /src - steps: - - checkout - - run: /synapse_sytest.sh - - store_artifacts: - path: /logs - destination: logs - - store_test_results: - path: /logs - sytestpy3postgres: - docker: - - image: matrixdotorg/sytest-synapsepy3 - working_directory: /src - steps: - - checkout - - run: POSTGRES=1 /synapse_sytest.sh - - store_artifacts: - path: /logs - destination: logs - - store_test_results: - path: /logs - sytestpy3merged: - docker: - - image: matrixdotorg/sytest-synapsepy3 - working_directory: /src - steps: - - checkout - - run: bash .circleci/merge_base_branch.sh - - run: /synapse_sytest.sh - - store_artifacts: - path: /logs - destination: logs - - store_test_results: - path: /logs - sytestpy3postgresmerged: - docker: - - image: matrixdotorg/sytest-synapsepy3 - working_directory: /src - steps: - - checkout - - run: bash .circleci/merge_base_branch.sh - - run: POSTGRES=1 /synapse_sytest.sh - - store_artifacts: - path: /logs - destination: logs - - store_test_results: - path: /logs - workflows: version: 2 build: jobs: - - sytestpy3: - filters: - branches: - only: /develop|master|release-.*/ - - sytestpy3postgres: - filters: - branches: - only: /develop|master|release-.*/ - - sytestpy3merged: - filters: - branches: - ignore: /develop|master|release-.*/ - - sytestpy3postgresmerged: - filters: - branches: - ignore: /develop|master|release-.*/ - dockerhubuploadrelease: filters: tags: From da487a4a7a64b6d839b9799af78da0e3bdf53f0e Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:04:56 +1000 Subject: [PATCH 04/28] fix --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 4b318fdcf468..421933d552ac 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -49,7 +49,7 @@ steps: - label: "SyTest - :python: 3.6 / SQLite" command: - "bash .buildkite/merge_base_branch.sh" - - "bash /synapse_sytest.sh" + - "bash .buildkite/synapse_sytest.sh" plugins: - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" From 9de301dcf2a416b02ee3293c072d6437a75694c6 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:08:22 +1000 Subject: [PATCH 05/28] fix --- .buildkite/synapse_sytest.sh | 136 +++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 .buildkite/synapse_sytest.sh diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh new file mode 100644 index 000000000000..d05dcebcae7a --- /dev/null +++ b/.buildkite/synapse_sytest.sh @@ -0,0 +1,136 @@ +#!/bin/bash +# +# Fetch sytest, and then run the tests for synapse. The entrypoint for the +# sytest-synapse docker images. + +set -ex + +if [-n "$BUILDKITE"] +then + SYNAPSE_DIR=`pwd` +else + SYNAPSE_DIR="/src" +fi + +# Attempt to find a sytest to use. +# If /sytest exists, it means that a SyTest checkout has been mounted into the Docker image. +if [ -d "/sytest" ]; then + # If the user has mounted in a SyTest checkout, use that. + echo "Using local sytests..." + + # create ourselves a working directory and dos2unix some scripts therein + mkdir -p /work/jenkins + for i in install-deps.pl run-tests.pl tap-to-junit-xml.pl jenkins/prep_sytest_for_postgres.sh; do + dos2unix -n "/sytest/$i" "/work/$i" + done + ln -sf /sytest/tests /work + 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" + + # Try and fetch the branch + echo "Trying to get same-named sytest branch..." + wget -q https://github.com/matrix-org/sytest/archive/$branch_name.tar.gz -O sytest.tar.gz || { + # Probably a 404, fall back to develop + echo "Using develop instead..." + wget -q https://github.com/matrix-org/sytest/archive/develop.tar.gz -O sytest.tar.gz + } + + mkdir -p /work + tar -C /work --strip-components=1 -xf sytest.tar.gz + SYTEST_LIB="/work/lib" +fi + +cd /work + +# PostgreSQL setup +if [ -n "$POSTGRES" ] +then + export PGUSER=postgres + export POSTGRES_DB_1=pg1 + export POSTGRES_DB_2=pg2 + + # Start the database + su -c 'eatmydata /usr/lib/postgresql/9.6/bin/pg_ctl -w -D /var/lib/postgresql/data start' postgres + + # Use the Jenkins script to write out the configuration for a PostgreSQL using Synapse + jenkins/prep_sytest_for_postgres.sh + + # Make the test databases for the two Synapse servers that will be spun up + su -c 'psql -c "CREATE DATABASE pg1;"' postgres + su -c 'psql -c "CREATE DATABASE pg2;"' postgres + +fi + +if [ -n "$OFFLINE" ]; then + # if we're in offline mode, just put synapse into the virtualenv, and + # hope that the deps are up-to-date. + # + # (`pip install -e` likes to reinstall setuptools even if it's already installed, + # so we just run setup.py explicitly.) + # + (cd $SYNAPSE_DIR && /venv/bin/python setup.py -q develop) +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 $SYNAPSE_DIR + /venv/bin/pip install -q --upgrade --no-cache-dir \ + lxml psycopg2 coverage codecov + + # 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 + ./install-deps.pl +fi + + +# Run the tests +>&2 echo "+++ Running tests" + +RUN_TESTS=( + perl -I "$SYTEST_LIB" ./run-tests.pl --python=/venv/bin/python --synapse-directory=$SYNAPSE_DIR --coverage -O tap --all +) + +TEST_STATUS=0 + +if [ -n "$WORKERS" ]; then + RUN_TESTS+=(-I Synapse::ViaHaproxy --dendron-binary=/pydron.py) +else + RUN_TESTS+=(-I Synapse) +fi + +"${RUN_TESTS[@]}" "$@" > results.tap || TEST_STATUS=$? + +if [ $TEST_STATUS -ne 0 ]; then + >&2 echo -e "run-tests \e[31mFAILED\e[0m: exit code $TEST_STATUS" +else + >&2 echo -e "run-tests \e[32mPASSED\e[0m" +fi + +>&2 echo "--- Copying assets" + +# 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="*" + +# Write out JUnit +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 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 + ./buildkite-agent upload "/logs/**/*" +fi + + +exit $TEST_STATUS From 4a4d486e198c301cb79267e6ffeb4cc4be12f950 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:16:46 +1000 Subject: [PATCH 06/28] try this? --- .buildkite/merge_base_branch.sh | 2 +- .buildkite/synapse_sytest.sh | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.buildkite/merge_base_branch.sh b/.buildkite/merge_base_branch.sh index 4e23a4ac88b8..342aa9a2d8e3 100755 --- a/.buildkite/merge_base_branch.sh +++ b/.buildkite/merge_base_branch.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -ex if [[ -z "$BUILDKITE_PULL_REQUEST_BASE_BRANCH"]] then diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh index d05dcebcae7a..8a4691c4d7d3 100644 --- a/.buildkite/synapse_sytest.sh +++ b/.buildkite/synapse_sytest.sh @@ -5,9 +5,15 @@ set -ex -if [-n "$BUILDKITE"] +echo `pwd` + +if [ -n "$BUILDKITE" ] then - SYNAPSE_DIR=`pwd` + mkdir -p /src + /venv/bin/python setup.py sdist + cp dist/*.tar.gz /src + cd /src + tar xvf --strip-components=1 *.tar.gz else SYNAPSE_DIR="/src" fi @@ -27,8 +33,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..." From 846b256e2b95e751439d50527b22ef7c5595b04a Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:18:16 +1000 Subject: [PATCH 07/28] ugh --- .buildkite/pipeline.yml | 5 +++-- .buildkite/synapse_sytest.sh | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 421933d552ac..07008ec8ca61 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -44,8 +44,6 @@ steps: - docker#v3.0.1: image: "python:3.6" - - wait - - label: "SyTest - :python: 3.6 / SQLite" command: - "bash .buildkite/merge_base_branch.sh" @@ -61,6 +59,9 @@ steps: - exit_status: 2 limit: 2 + - wait + + - command: - "python -m pip install tox" - "tox -e py35-old,codecov" diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh index 8a4691c4d7d3..2adbad4af112 100644 --- a/.buildkite/synapse_sytest.sh +++ b/.buildkite/synapse_sytest.sh @@ -6,6 +6,7 @@ set -ex echo `pwd` +echo $BUILDKITE if [ -n "$BUILDKITE" ] then From 55ec7a45d9f11f4bc010a74bf257b4e4ddc7b3cd Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:21:44 +1000 Subject: [PATCH 08/28] try this, then --- .buildkite/pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 07008ec8ca61..6c70c6eb4bb1 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,6 +51,7 @@ steps: plugins: - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" + entrypoint: "false" propagate-environment: true retry: automatic: From bc82ae3e93d9afebb09625052fbf5ca0cd364d4a Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:23:38 +1000 Subject: [PATCH 09/28] try this, then --- .buildkite/pipeline.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 6c70c6eb4bb1..e523b81b0b1e 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -45,13 +45,10 @@ steps: image: "python:3.6" - label: "SyTest - :python: 3.6 / SQLite" - command: - - "bash .buildkite/merge_base_branch.sh" - - "bash .buildkite/synapse_sytest.sh" plugins: - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" - entrypoint: "false" + entrypoint: "bash -c 'bash .buildkite/merge_base_branch.sh && bash .buildkite/synapse_sytest.sh'"" propagate-environment: true retry: automatic: From e0dec5138b17dadc2c1964c3ed1b3645994e4e31 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:24:45 +1000 Subject: [PATCH 10/28] try this, then --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index e523b81b0b1e..5ed1086f882f 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -48,7 +48,7 @@ steps: plugins: - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" - entrypoint: "bash -c 'bash .buildkite/merge_base_branch.sh && bash .buildkite/synapse_sytest.sh'"" + entrypoint: "bash -c 'bash .buildkite/merge_base_branch.sh && bash .buildkite/synapse_sytest.sh'" propagate-environment: true retry: automatic: From 77f1b9eb927fa14fabb1b630cf6e2681c17774dc Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:26:07 +1000 Subject: [PATCH 11/28] try this, then --- .buildkite/pipeline.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 5ed1086f882f..2528da646b32 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -45,10 +45,13 @@ steps: image: "python:3.6" - label: "SyTest - :python: 3.6 / SQLite" + command: + - "bash .buildkite/merge_base_branch.sh" + - "bash .buildkite/synapse_sytest.sh" plugins: - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" - entrypoint: "bash -c 'bash .buildkite/merge_base_branch.sh && bash .buildkite/synapse_sytest.sh'" + entrypoint: "bash -c" propagate-environment: true retry: automatic: From 61b328fc54bb2505923d33a9c8b37389d3066748 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:26:58 +1000 Subject: [PATCH 12/28] try this, then --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2528da646b32..4abfac99f1a7 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,7 +51,7 @@ steps: plugins: - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" - entrypoint: "bash -c" + entrypoint: "exec bash -c" propagate-environment: true retry: automatic: From 3d7a72b3cfe8287172fc1e2f8b99f874ebe4b074 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:27:41 +1000 Subject: [PATCH 13/28] try this, then --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 4abfac99f1a7..2528da646b32 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,7 +51,7 @@ steps: plugins: - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" - entrypoint: "exec bash -c" + entrypoint: "bash -c" propagate-environment: true retry: automatic: From 7d63a892574c57a1c977cb7e97845fae296e1fd4 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:28:24 +1000 Subject: [PATCH 14/28] use a full path then --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2528da646b32..e3e612361264 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,7 +51,7 @@ steps: plugins: - docker#v3.0.1: image: "matrixdotorg/sytest-synapsepy3" - entrypoint: "bash -c" + entrypoint: "/bin/bash -c" propagate-environment: true retry: automatic: From df7f095917b4890f8a44d3d875b97298ef5af8bb Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Fri, 14 Jun 2019 22:31:17 +1000 Subject: [PATCH 15/28] ??? --- .buildkite/pipeline.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index e3e612361264..e09f8bdbd327 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -50,8 +50,7 @@ steps: - "bash .buildkite/synapse_sytest.sh" plugins: - docker#v3.0.1: - image: "matrixdotorg/sytest-synapsepy3" - entrypoint: "/bin/bash -c" + image: "matrixdotorg/sytest" propagate-environment: true retry: automatic: From 7a43c657c1cd8f3bf74df41cc655e836277a23da Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 00:51:33 +1000 Subject: [PATCH 16/28] fix --- .buildkite/merge_base_branch.sh | 5 +++++ .buildkite/pipeline.yml | 31 ++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.buildkite/merge_base_branch.sh b/.buildkite/merge_base_branch.sh index 342aa9a2d8e3..c119b499a460 100755 --- a/.buildkite/merge_base_branch.sh +++ b/.buildkite/merge_base_branch.sh @@ -2,6 +2,11 @@ set -ex +if [[ "$BUILDKITE_BRANCH" =~ ^(develop|master|dinsic|shhs|release-*)$ ]]; then + echo "Not merging forward, as this is a release branch" + exit 0 +fi + if [[ -z "$BUILDKITE_PULL_REQUEST_BASE_BRANCH"]] then echo "Not a pull request, or hasn't had a PR opened yet..." diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index e09f8bdbd327..1a690c2df74f 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -2,6 +2,22 @@ env: CODECOV_TOKEN: "2dd7eb9b-0eda-45fe-a47c-9b5ac040045f" steps: + + - label: "SyTest - :python: 3.5 / SQLite" + command: + - "bash .buildkite/merge_base_branch.sh" + - "bash .buildkite/synapse_sytest.sh" + plugins: + - docker#v3.0.1: + image: "matrixdotorg/sytest-synapse:py35" + propagate-environment: true + retry: + automatic: + - exit_status: -1 + limit: 2 + - exit_status: 2 + limit: 2 + - command: - "python -m pip install tox" - "tox -e pep8" @@ -44,21 +60,6 @@ steps: - docker#v3.0.1: image: "python:3.6" - - label: "SyTest - :python: 3.6 / SQLite" - command: - - "bash .buildkite/merge_base_branch.sh" - - "bash .buildkite/synapse_sytest.sh" - plugins: - - docker#v3.0.1: - image: "matrixdotorg/sytest" - propagate-environment: true - retry: - automatic: - - exit_status: -1 - limit: 2 - - exit_status: 2 - limit: 2 - - wait From b4d8e4e91c290e4e5043dbde7a48e6164e41e144 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 00:58:37 +1000 Subject: [PATCH 17/28] fix --- .buildkite/merge_base_branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/merge_base_branch.sh b/.buildkite/merge_base_branch.sh index c119b499a460..d898101fdd89 100755 --- a/.buildkite/merge_base_branch.sh +++ b/.buildkite/merge_base_branch.sh @@ -2,7 +2,7 @@ set -ex -if [[ "$BUILDKITE_BRANCH" =~ ^(develop|master|dinsic|shhs|release-*)$ ]]; then +if [[ "$BUILDKITE_BRANCH" =~ ^(develop|master|dinsic|shhs|release-.*)$ ]]; then echo "Not merging forward, as this is a release branch" exit 0 fi From 9887918395df3c0fc07920f9a23d217c98ea403a Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 01:02:01 +1000 Subject: [PATCH 18/28] fix --- .buildkite/merge_base_branch.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.buildkite/merge_base_branch.sh b/.buildkite/merge_base_branch.sh index d898101fdd89..d898693e4c29 100755 --- a/.buildkite/merge_base_branch.sh +++ b/.buildkite/merge_base_branch.sh @@ -7,8 +7,7 @@ if [[ "$BUILDKITE_BRANCH" =~ ^(develop|master|dinsic|shhs|release-.*)$ ]]; then exit 0 fi -if [[ -z "$BUILDKITE_PULL_REQUEST_BASE_BRANCH"]] -then +if [[ -z "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" ]]; then echo "Not a pull request, or hasn't had a PR opened yet..." # It probably hasn't had a PR opened yet. Since all PRs land on develop, we From 7f1725f0d67b5a0b4a6ba45447262abf90b8189a Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 01:16:22 +1000 Subject: [PATCH 19/28] try --- .buildkite/merge_base_branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/merge_base_branch.sh b/.buildkite/merge_base_branch.sh index d898693e4c29..26176d6465c3 100755 --- a/.buildkite/merge_base_branch.sh +++ b/.buildkite/merge_base_branch.sh @@ -7,7 +7,7 @@ if [[ "$BUILDKITE_BRANCH" =~ ^(develop|master|dinsic|shhs|release-.*)$ ]]; then exit 0 fi -if [[ -z "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" ]]; then +if [[ -z $BUILDKITE_PULL_REQUEST_BASE_BRANCH ]]; then echo "Not a pull request, or hasn't had a PR opened yet..." # It probably hasn't had a PR opened yet. Since all PRs land on develop, we From 9c522eaadefe02207c79eafff271e85c0209e2f5 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 01:33:24 +1000 Subject: [PATCH 20/28] yay --- .buildkite/synapse_sytest.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh index 2adbad4af112..dcf586ce677e 100644 --- a/.buildkite/synapse_sytest.sh +++ b/.buildkite/synapse_sytest.sh @@ -5,16 +5,9 @@ set -ex -echo `pwd` -echo $BUILDKITE - if [ -n "$BUILDKITE" ] then - mkdir -p /src - /venv/bin/python setup.py sdist - cp dist/*.tar.gz /src - cd /src - tar xvf --strip-components=1 *.tar.gz + SYNAPSE_DIR=`pwd` else SYNAPSE_DIR="/src" fi From 0695d83b6d5173295bfaad2dff8c472991257823 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 01:58:55 +1000 Subject: [PATCH 21/28] yay --- .buildkite/synapse_sytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh index dcf586ce677e..5f0452616750 100644 --- a/.buildkite/synapse_sytest.sh +++ b/.buildkite/synapse_sytest.sh @@ -134,7 +134,7 @@ then 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 - ./buildkite-agent upload "/logs/**/*" + ./buildkite-agent artifact upload "/logs/**/*" fi From be8c3f1202b656eb46f600b62ae70d3d987e1164 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 02:32:05 +1000 Subject: [PATCH 22/28] try this --- .buildkite/pipeline.yml | 4 ++++ .buildkite/synapse_sytest.sh | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 1a690c2df74f..5143ffca03b5 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -4,6 +4,8 @@ env: steps: - label: "SyTest - :python: 3.5 / SQLite" + agents: + queue: "medium" command: - "bash .buildkite/merge_base_branch.sh" - "bash .buildkite/synapse_sytest.sh" @@ -18,6 +20,8 @@ steps: - exit_status: 2 limit: 2 + - wait + - command: - "python -m pip install tox" - "tox -e pep8" diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh index 5f0452616750..fd6eb1fa11cd 100644 --- a/.buildkite/synapse_sytest.sh +++ b/.buildkite/synapse_sytest.sh @@ -118,11 +118,7 @@ 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="*" - -# Write out JUnit -mkdir -p /logs/sytest -perl ./tap-to-junit-xml.pl --puretap --input=/logs/results.tap --output=/logs/sytest/results.xml "SyTest" +rsync --ignore-missing-args --min-size=1B -av server-0 server-1 /logs --include "*/" --include="*.log.*" --include="*.log" --exclude="*" # Upload coverage to codecov and upload files, if running on Buildkite if [ -n "$BUILDKITE" ] @@ -134,7 +130,14 @@ then 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 - ./buildkite-agent artifact upload "/logs/**/*" + + # Upload the files + ./buildkite-agent artifact upload "/logs/**/*.log*" "/logs/results.tap" + + if [ $TEST_STATUS -ne 0 ]; then + # Annotate, if failure + cat /logs/results.tap | tap-markdown | ./buildkite-agent annotate --style="error" --context="$BUILDKITE_LABEL" + fi fi From 229cde42de7be3c2c0c889f0a76d805f74b2ca00 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 02:45:13 +1000 Subject: [PATCH 23/28] sigh --- .buildkite/synapse_sytest.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh index fd6eb1fa11cd..16c0491353be 100644 --- a/.buildkite/synapse_sytest.sh +++ b/.buildkite/synapse_sytest.sh @@ -132,7 +132,8 @@ then chmod +x ./buildkite-agent # Upload the files - ./buildkite-agent artifact upload "/logs/**/*.log*" "/logs/results.tap" + ./buildkite-agent artifact upload "/logs/**/*.log*" + ./buildkite-agent artifact upload "/logs/results.tap" if [ $TEST_STATUS -ne 0 ]; then # Annotate, if failure From 3571c720cac07dfe79c6daea2eced302b722036d Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 02:56:24 +1000 Subject: [PATCH 24/28] fix --- .buildkite/pipeline.yml | 77 +++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 5143ffca03b5..6c6229a2058d 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -3,25 +3,6 @@ env: steps: - - label: "SyTest - :python: 3.5 / SQLite" - agents: - queue: "medium" - command: - - "bash .buildkite/merge_base_branch.sh" - - "bash .buildkite/synapse_sytest.sh" - plugins: - - docker#v3.0.1: - image: "matrixdotorg/sytest-synapse:py35" - propagate-environment: true - retry: - automatic: - - exit_status: -1 - limit: 2 - - exit_status: 2 - limit: 2 - - - wait - - command: - "python -m pip install tox" - "tox -e pep8" @@ -202,3 +183,61 @@ steps: limit: 2 - exit_status: 2 limit: 2 + + + - label: "SyTest - :python: 3.5 / SQLite / Monolith" + agents: + queue: "medium" + command: + - "bash .buildkite/merge_base_branch.sh" + - "bash .buildkite/synapse_sytest.sh" + plugins: + - docker#v3.0.1: + image: "matrixdotorg/sytest-synapse:py35" + propagate-environment: true + retry: + automatic: + - exit_status: -1 + limit: 2 + - exit_status: 2 + limit: 2 + + - label: "SyTest - :python: 3.5 / :postgres: 9.6 / Monolith" + agents: + queue: "medium" + env: + POSTGRES: "1" + command: + - "bash .buildkite/merge_base_branch.sh" + - "bash .buildkite/synapse_sytest.sh" + plugins: + - docker#v3.0.1: + image: "matrixdotorg/sytest-synapse:py35" + propagate-environment: true + retry: + automatic: + - exit_status: -1 + limit: 2 + - exit_status: 2 + limit: 2 + + - label: "SyTest - :python: 3.5 / :postgres: 9.6 / Workers" + agents: + queue: "medium" + env: + POSTGRES: "1" + WORKERS: "1" + command: + - "bash .buildkite/merge_base_branch.sh" + - "bash .buildkite/synapse_sytest.sh" + plugins: + - docker#v3.0.1: + image: "matrixdotorg/sytest-synapse:py35" + propagate-environment: true + soft_fail: true + retry: + automatic: + - exit_status: -1 + limit: 2 + - exit_status: 2 + limit: 2 From 106d043c2d06f9902e3cdf98526b2ec78f282184 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 03:11:10 +1000 Subject: [PATCH 25/28] fix posting failures --- .buildkite/synapse_sytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh index 16c0491353be..ab872de3c1ff 100644 --- a/.buildkite/synapse_sytest.sh +++ b/.buildkite/synapse_sytest.sh @@ -137,7 +137,7 @@ then if [ $TEST_STATUS -ne 0 ]; then # Annotate, if failure - cat /logs/results.tap | tap-markdown | ./buildkite-agent annotate --style="error" --context="$BUILDKITE_LABEL" + cat /logs/results.tap | tap-markdown --no-tidy | ./buildkite-agent annotate --style="error" --context="$BUILDKITE_LABEL" fi fi From 8542288d7f4344227027d77ca65324508398d007 Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 04:11:28 +1000 Subject: [PATCH 26/28] fix --- .buildkite/format_tap.py | 26 ++++++++++++++++++++++++++ .buildkite/synapse_sytest.sh | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .buildkite/format_tap.py diff --git a/.buildkite/format_tap.py b/.buildkite/format_tap.py new file mode 100644 index 000000000000..a2638d457a72 --- /dev/null +++ b/.buildkite/format_tap.py @@ -0,0 +1,26 @@ +import sys +from tap.parser import Parser +from tap.line import Result, Unknown, Diagnostic + +out = [] + +p = Parser() + +in_error = False + +for line in p.parse_file(sys.argv[1]): + if isinstance(line, Result): + in_error = False + + if not line.ok and not line.todo: + in_error = True + + out.append("- FAILURE Test #%d: %s" % (line.number, line.description)) + out.append("") + + elif isinstance(line, Diagnostic) and in_error: + out.append((" " * 7) + line.text) + + +for line in out: + print(line) diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh index ab872de3c1ff..885ab66a045c 100644 --- a/.buildkite/synapse_sytest.sh +++ b/.buildkite/synapse_sytest.sh @@ -82,7 +82,7 @@ else # deps. /venv/bin/pip install -q --upgrade --no-cache-dir -e $SYNAPSE_DIR /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 @@ -137,7 +137,7 @@ then if [ $TEST_STATUS -ne 0 ]; then # Annotate, if failure - cat /logs/results.tap | tap-markdown --no-tidy | ./buildkite-agent annotate --style="error" --context="$BUILDKITE_LABEL" + /venv/bin/python $SYNAPSE_DIR/.buildkite/format_tap.py /logs/results.tap | ./buildkite-agent annotate --style="error" --context="$BUILDKITE_LABEL" fi fi From 3b96adcde33a64766c169652c3970cb1a88d456f Mon Sep 17 00:00:00 2001 From: "Amber H. Brown" Date: Sat, 15 Jun 2019 04:36:12 +1000 Subject: [PATCH 27/28] make tap rendering nicer --- .buildkite/format_tap.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.buildkite/format_tap.py b/.buildkite/format_tap.py index a2638d457a72..6e9f93d665a2 100644 --- a/.buildkite/format_tap.py +++ b/.buildkite/format_tap.py @@ -10,17 +10,23 @@ for line in p.parse_file(sys.argv[1]): if isinstance(line, Result): + if in_error: + out.append("") + out.append("") + out.append("----") + out.append("") in_error = False if not line.ok and not line.todo: in_error = True - out.append("- FAILURE Test #%d: %s" % (line.number, line.description)) + out.append("FAILURE Test #%d: ``%s``" % (line.number, line.description)) out.append("") + out.append("
Show log
")
 
     elif isinstance(line, Diagnostic) and in_error:
-        out.append((" " * 7) + line.text)
-
+        out.append(line.text)
 
-for line in out:
-    print(line)
+if out:
+    for line in out[:-3]:
+        print(line)

From dd1d6b14550b3072e902ea08273504e737902d9b Mon Sep 17 00:00:00 2001
From: "Amber H. Brown" 
Date: Sat, 15 Jun 2019 04:53:45 +1000
Subject: [PATCH 28/28] fix

---
 .buildkite/format_tap.py     | 3 ++-
 .buildkite/synapse_sytest.sh | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.buildkite/format_tap.py b/.buildkite/format_tap.py
index 6e9f93d665a2..94582f557145 100644
--- a/.buildkite/format_tap.py
+++ b/.buildkite/format_tap.py
@@ -2,7 +2,7 @@
 from tap.parser import Parser
 from tap.line import Result, Unknown, Diagnostic
 
-out = []
+out = ["### TAP Output for " + sys.argv[2]]
 
 p = Parser()
 
@@ -11,6 +11,7 @@
 for line in p.parse_file(sys.argv[1]):
     if isinstance(line, Result):
         if in_error:
+            out.append("")
             out.append("
") out.append("") out.append("----") diff --git a/.buildkite/synapse_sytest.sh b/.buildkite/synapse_sytest.sh index 885ab66a045c..3011b88bb799 100644 --- a/.buildkite/synapse_sytest.sh +++ b/.buildkite/synapse_sytest.sh @@ -137,7 +137,7 @@ then if [ $TEST_STATUS -ne 0 ]; then # Annotate, if failure - /venv/bin/python $SYNAPSE_DIR/.buildkite/format_tap.py /logs/results.tap | ./buildkite-agent annotate --style="error" --context="$BUILDKITE_LABEL" + /venv/bin/python $SYNAPSE_DIR/.buildkite/format_tap.py /logs/results.tap "$BUILDKITE_LABEL" | ./buildkite-agent annotate --style="error" --context="$BUILDKITE_LABEL" fi fi