Skip to content

Commit

Permalink
Merge branch 'develop' into rei/compl_pr_545
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Jul 23, 2024
2 parents a3755c6 + e0ef8d8 commit 1920fd4
Show file tree
Hide file tree
Showing 40 changed files with 525 additions and 981 deletions.
55 changes: 30 additions & 25 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ name: Build and deploy docker images
on:
push:
branches: [develop]
schedule:
- cron: 0 1 * * * # 1am, daily.
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-sytest-images:
name: "Build sytest:${{ matrix.tag }}"
Expand All @@ -19,32 +25,32 @@ jobs:
include:
- base_image: ubuntu:focal
tag: focal
- base_image: debian:buster
tag: buster
- base_image: ubuntu:mantic
tag: mantic
- base_image: debian:bullseye
tag: bullseye
- base_image: debian:testing
tag: testing
- base_image: debian:bookworm
tag: bookworm
steps:
- name: Set up QEMU
id: QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Inspect builder
run: docker buildx inspect

- name: Log in to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
pull: true
push: true
Expand All @@ -65,45 +71,44 @@ jobs:
dockerfile: synapse
tags: "matrixdotorg/sytest-synapse:focal"
build_args: "SYTEST_IMAGE_TAG=focal"
- sytest_image_tag: buster
- sytest_image_tag: mantic
dockerfile: synapse
tags: "matrixdotorg/sytest-synapse:mantic-3.12"
build_args: |
SYTEST_IMAGE_TAG=mantic
PYTHON_VERSION=python3.12
SYSTEM_PIP_INSTALL_SUFFIX=--break-system-packages
- sytest_image_tag: bullseye
dockerfile: synapse
tags: "matrixdotorg/sytest-synapse:buster"
build_args: "SYTEST_IMAGE_TAG=buster"
tags: "matrixdotorg/sytest-synapse:bullseye"
build_args: "SYTEST_IMAGE_TAG=bullseye"
- sytest_image_tag: testing
dockerfile: synapse
tags: "matrixdotorg/sytest-synapse:testing"
build_args: "SYTEST_IMAGE_TAG=testing"
- sytest_image_tag: bookworm
dockerfile: synapse
tags: "matrixdotorg/sytest-synapse:bookworm-python3.10"
build_args: |
SYTEST_IMAGE_TAG=bookworm
PYTHON_VERSION=python3.10
- sytest_image_tag: buster
dockerfile: dendrite
tags: "matrixdotorg/sytest-dendrite:latest"
build_args: "SYTEST_IMAGE_TAG=buster"
SYTEST_IMAGE_TAG=testing
SYSTEM_PIP_INSTALL_SUFFIX=--break-system-packages
steps:
- name: Set up QEMU
id: QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Inspect builder
run: docker buildx inspect

- name: Log in to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
pull: true
push: true
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches: ["develop", "release-*"]
pull_request:
workflow_dispatch:

# Only run this action once per pull request/branch; restart if a new commit arrives.
# C.f. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency
Expand Down Expand Up @@ -88,7 +89,7 @@ jobs:
if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
continue
fi
(wget -O - "https://github.com/matrix-org/synapse/archive/$BRANCH_NAME.tar.gz" \
(wget -O - "https://github.com/element-hq/synapse/archive/$BRANCH_NAME.tar.gz" \
| tar -xz --strip-components=1 -C /src/) \
&& echo "Successfully downloaded and extracted $BRANCH_NAME.tar.gz" \
&& break
Expand Down Expand Up @@ -129,16 +130,9 @@ jobs:
include:
- label: SQLite

- label: SQLite, full HTTP APIs
api: full-http

- label: Postgres
postgres: postgres

- label: Postgres, full HTTP APIs
postgres: postgres
api: full-http

container:
image: matrixdotorg/sytest-dendrite
volumes:
Expand Down
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ primarily at present the Synapse server. It performs "black-box" testing, by
starting up multiple home server instances and testing the interaction using
regular HTTP interaction much as any other Matrix client would do. It can
output test results either to an interactive terminal, or as a TAP-style test
report, for continuous-integration test harnsses such as Jenkins.
report, for continuous-integration test harnesses such as Jenkins.

SyTest is written in Perl, and is the original integration testing system for
Matrix. New tests tend to be written in Complement_, a Go-based integration
testing system.

.. _Complement: https://github.com/matrix-org/complement

Installing
----------
Expand Down
14 changes: 7 additions & 7 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ but its dependencies are.
Included currently is:

- `matrixdotorg/sytest` Base container with SyTest dependencies installed
- Tagged by underlying Debian/Ubuntu image: `focal`, `buster` or `testing`
- Tagged by underlying Debian/Ubuntu image: `focal`, `bullseye` or `testing`
- `matrixdotorg/sytest-synapse`: Runs SyTest against Synapse
- Tagged by underlying Debian/Ubunutu image: `focal`, `buster` or `testing`
- Tagged by underlying Debian/Ubunutu image: `focal`, `bullseye` or `testing`

## Target-specific details

Expand All @@ -23,7 +23,7 @@ it is useful to mount a volume there too.
For example:

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

The following environment variables can be set with `-e` to control the test run:
Expand All @@ -43,7 +43,7 @@ An example of running Synapse in worker mode:

```
docker run --rm -it -e POSTGRES=1 -e WORKERS=1 -v /path/to/synapse\:/src:ro \
-v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapse:buster
-v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapse:focal
```

### Dendrite
Expand All @@ -68,7 +68,7 @@ for example:
docker run --rm -it \
-e SYTEST_BRANCH="my-sytest-branch"
-v /path/to/synapse\:/src:ro -v /path/to/where/you/want/logs\:/logs
matrixdotorg/sytest-synapse:buster
matrixdotorg/sytest-synapse:focal
```

If the branch referred to by `SYTEST_BRANCH` does not exist, `develop` is used
Expand All @@ -80,7 +80,7 @@ the container:

```
docker run --rm -it -v /path/to/synapse\:/src:ro -v /path/to/where/you/want/logs\:/logs \
-v /path/to/code/sytest\:/sytest:ro matrixdotorg/sytest-synapse:buster
-v /path/to/code/sytest\:/sytest:ro matrixdotorg/sytest-synapse:focal
```

## Running a single test file, and other sytest commandline options
Expand All @@ -89,7 +89,7 @@ You can pass arguments to sytest by adding them at the end of the
docker command. For example:

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

## Building the containers
Expand Down
4 changes: 3 additions & 1 deletion docker/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=debian:buster
ARG BASE_IMAGE=debian:bullseye

FROM ${BASE_IMAGE}

Expand All @@ -24,6 +24,8 @@ RUN apt-get -qq update && apt-get -qq install -y \
rsync \
sqlite3 \
wget \
libicu-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

# Set up the locales, as the default Debian image only has C, and PostgreSQL needs the correct locales to make a UTF-8 database
Expand Down
14 changes: 5 additions & 9 deletions docker/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
set -ex

export SYTEST_TARGET="$1"
export SYTEST_DEFAULT_BRANCH="${SYTEST_DEFAULT_BRANCH:-develop}"
shift

if [ -d "/sytest" ]; then
Expand All @@ -19,20 +20,15 @@ else
branch_name="$SYTEST_BRANCH"
else
# Otherwise, try and find the branch that the Synapse/Dendrite checkout
# is using. Fall back to develop if unknown.
branch_name="$(git --git-dir=/src/.git symbolic-ref HEAD 2>/dev/null)" || branch_name="develop"
fi

if [ "$SYTEST_TARGET" == "dendrite" ] && [ "$branch_name" == "master" ]; then
# Dendrite uses master as its main branch. If the branch is master, we probably want sytest develop
branch_name="develop"
# is using. Fall back to the default branch if unknown.
branch_name="$(git --git-dir=/src/.git symbolic-ref HEAD 2>/dev/null)" || branch_name="${SYTEST_DEFAULT_BRANCH}"
fi

# Try and fetch the 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
echo "Using ${SYTEST_DEFAULT_BRANCH} instead..."
wget -q https://github.com/matrix-org/sytest/archive/${SYTEST_DEFAULT_BRANCH}.tar.gz -O sytest.tar.gz
}

mkdir -p /sytest
Expand Down
4 changes: 3 additions & 1 deletion docker/dendrite.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG SYTEST_IMAGE_TAG=buster
ARG SYTEST_IMAGE_TAG=bullseye
FROM matrixdotorg/sytest:${SYTEST_IMAGE_TAG}

ARG GO_VERSION=1.19.1
Expand All @@ -11,6 +11,8 @@ RUN tar xf go.tar.gz -C /goroot --strip-components=1
ENV GOROOT=/goroot
ENV GOPATH=/gopath
ENV PATH="/goroot/bin:${PATH}"
# This is used in bootstrap.sh to pull in a dendrite specific Sytest branch
ENV SYTEST_DEFAULT_BRANCH dendrite

# This is where we expect Dendrite to be binded to from the host
RUN mkdir -p /src
Expand Down
16 changes: 8 additions & 8 deletions docker/synapse.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
ARG SYTEST_IMAGE_TAG=buster
ARG SYTEST_IMAGE_TAG=bullseye

FROM matrixdotorg/sytest:${SYTEST_IMAGE_TAG}

ARG PYTHON_VERSION=python3
ARG SYSTEM_PIP_INSTALL_SUFFIX=""

ENV DEBIAN_FRONTEND noninteractive

Expand All @@ -20,11 +21,10 @@ RUN mkdir /rust /cargo

RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal

# Use the latest version of pip. This pulls in fixes not present in the
# pip version provided by Debian Buster. See
# https://github.com/pypa/setuptools/issues/3457#issuecomment-1190125849
RUN ${PYTHON_VERSION} -m pip install -q --upgrade pip
RUN ${PYTHON_VERSION} -m pip install -q --no-cache-dir poetry==1.2.0
# For now, we need to tell Debian we don't care that we're editing the system python
# installation.
# Some context in https://github.com/pypa/pip/issues/11381#issuecomment-1399263627
RUN ${PYTHON_VERSION} -m pip install -q --no-cache-dir poetry==1.3.2 ${SYSTEM_PIP_INSTALL_SUFFIX}

# As part of the Docker build, we attempt to pre-install Synapse's dependencies
# in the hope that it speeds up the real install of Synapse. To make this work,
Expand All @@ -51,7 +51,7 @@ RUN ${PYTHON_VERSION} -m pip download --dest /pypi-offline-cache \

# Create the virtual env upfront so we don't need to keep reinstalling
# dependencies.
RUN wget -q https://github.com/matrix-org/synapse/archive/develop.tar.gz \
RUN wget -q https://github.com/element-hq/synapse/archive/develop.tar.gz \
-O /synapse.tar.gz && \
mkdir /synapse && \
tar -C /synapse --strip-components=1 -xf synapse.tar.gz && \
Expand All @@ -77,7 +77,7 @@ RUN /venv/bin/pip install -q --no-cache-dir \
# value.
# See https://github.com/matrix-org/synapse/issues/12419
# TODO: Once poetry 1.2.0 has been released, use the `installer.max-workers`
# config option instead.
# or `installer.parallel` config option instead.
# poetry has a bug where this environment variable is not converted to a
# boolean, so we choose a falsy string value for it. It's fixed in 1.2.0,
# where we'll be wanting to use `installer.max-workers` anyway.
Expand Down
4 changes: 3 additions & 1 deletion docs/dendrite-setup.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# How to set up SyTest for Dendrite

See https://github.com/matrix-org/dendrite/blob/master/docs/sytest.md#using-the-sytest-docker-image
See [dendrite's developer documentation](https://github.com/matrix-org/dendrite/blob/main/docs/development/sytest.md#using-the-sytest-docker-image)

([permalink](https://github.com/matrix-org/dendrite/blob/3f727485d6e21a603e4df1cb31c3795cc1023caa/docs/development/sytest.md#using-the-sytest-docker-image)).
2 changes: 1 addition & 1 deletion lib/SyTest/ApplicationService.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sub new
my %futures_by_type;

my $f = repeat {
$await_http->( qr{^\Q$path\E/transactions/\d+$}, sub { 1 },
$await_http->( qr{^\Q$path\E/_matrix/app/v1/transactions/\d+$}, sub { 1 },
timeout => 0,
)->then( sub {
my ( $request ) = @_;
Expand Down
13 changes: 9 additions & 4 deletions lib/SyTest/Federation/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use SyTest::Assertions qw( :all );
use URI::Escape qw( uri_escape );

use constant SUPPORTED_ROOM_VERSIONS => [qw(
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10 11
)];

sub configure
Expand Down Expand Up @@ -92,10 +92,15 @@ sub do_request_json

my $signature = $signing_block{signatures}{$origin}{$key_id};

# Assume that there is no delegation in place, so the hostname and
# destination server name are the same.
my $destination = $params{hostname};

my $auth = "X-Matrix " . join_header_words(
[ origin => $origin ],
[ key => $key_id ],
[ sig => $signature ],
[ origin => $origin ],
[ key => $key_id ],
[ sig => $signature ],
[ destination => $destination ],
);

# TODO: SYN-437 synapse does not like OWS between auth-param elements
Expand Down
1 change: 1 addition & 0 deletions lib/SyTest/Federation/Room.pm
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ sub make_join_protoevent

auth_events => $auth_events,
content => { membership => "join" },
origin_server_ts => JSON::number( int( time() * 1000 )),
depth => JSON::number($self->next_depth),
prev_events => $prev_events,
room_id => $self->room_id,
Expand Down
Loading

0 comments on commit 1920fd4

Please sign in to comment.