From 4563a16db27d27c22732b19ae478f823e1aa1358 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 21 May 2021 10:23:57 -0400 Subject: [PATCH 1/5] Run complement workers manually. --- docker/configure_workers_and_start.py | 4 ++-- scripts-dev/complement.sh | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py index 4be6afc65d9a..d02c04ae8d94 100755 --- a/docker/configure_workers_and_start.py +++ b/docker/configure_workers_and_start.py @@ -184,12 +184,12 @@ """ NGINX_LOCATION_CONFIG_BLOCK = """ - location ~* {endpoint} { + location ~* {endpoint} {{ proxy_pass {upstream}; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $host; - } + }} """ NGINX_UPSTREAM_CONFIG_BLOCK = """ diff --git a/scripts-dev/complement.sh b/scripts-dev/complement.sh index 1612ab522c33..a29b23fad966 100755 --- a/scripts-dev/complement.sh +++ b/scripts-dev/complement.sh @@ -32,10 +32,19 @@ if [[ -z "$COMPLEMENT_DIR" ]]; then echo "Checkout available at 'complement-master'" fi +# If we're using workers, modify the docker files slightly. +if [[ -n "$WORKERS" ]]; then + DOCKERTAG_SUFFIX=-workers + DOCKERFILE_SUFFIX=Workers + # And provide some more configuration to complement. + export COMPLEMENT_CA=true + export COMPLEMENT_VERSION_CHECK_ITERATIONS=500 +fi + # Build the base Synapse image from the local checkout -docker build -t matrixdotorg/synapse -f docker/Dockerfile . +docker build -t matrixdotorg/synapse$DOCKERTAG_SUFFIX -f docker/Dockerfile$DOCKERTAG_SUFFIX . # Build the Synapse monolith image from Complement, based on the above image we just built -docker build -t complement-synapse -f "$COMPLEMENT_DIR/dockerfiles/Synapse.Dockerfile" "$COMPLEMENT_DIR/dockerfiles" +docker build -t complement-synapse$DOCKERTAG_SUFFIX -f "$COMPLEMENT_DIR/dockerfiles/Synapse$DOCKERFILE_SUFFIX.Dockerfile" "$COMPLEMENT_DIR/dockerfiles" cd "$COMPLEMENT_DIR" @@ -46,4 +55,4 @@ if [[ -n "$1" ]]; then fi # Run the tests! -COMPLEMENT_BASE_IMAGE=complement-synapse go test -v -tags synapse_blacklist,msc2946,msc3083 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests +COMPLEMENT_BASE_IMAGE=complement-synapse$DOCKERTAG_SUFFIX go test -v -tags synapse_blacklist,msc2946,msc3083 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests From a4a8508ddb6a9c0f3cb67b69fd5b9a017d1a782b Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 21 May 2021 10:48:16 -0400 Subject: [PATCH 2/5] Newsfragment --- changelog.d/10039.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/10039.misc diff --git a/changelog.d/10039.misc b/changelog.d/10039.misc new file mode 100644 index 000000000000..8855f141d903 --- /dev/null +++ b/changelog.d/10039.misc @@ -0,0 +1 @@ +Fix running complement tests with Synapse workers. From b917bf4b9895da19f0b32e94e22b1239e7ed220b Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 21 May 2021 11:08:26 -0400 Subject: [PATCH 3/5] Fix another braces issue. --- docker/configure_workers_and_start.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py index d02c04ae8d94..1d22a4d5719d 100755 --- a/docker/configure_workers_and_start.py +++ b/docker/configure_workers_and_start.py @@ -193,9 +193,9 @@ """ NGINX_UPSTREAM_CONFIG_BLOCK = """ -upstream {upstream_worker_type} { +upstream {upstream_worker_type} {{ {body} -} +}} """ From 272858ff622961a192b0f59d02d645850262aca2 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 24 May 2021 13:35:04 -0400 Subject: [PATCH 4/5] Use variables instead of suffixes. --- scripts-dev/complement.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts-dev/complement.sh b/scripts-dev/complement.sh index a29b23fad966..2bfe693b8a30 100755 --- a/scripts-dev/complement.sh +++ b/scripts-dev/complement.sh @@ -34,17 +34,24 @@ fi # If we're using workers, modify the docker files slightly. if [[ -n "$WORKERS" ]]; then - DOCKERTAG_SUFFIX=-workers - DOCKERFILE_SUFFIX=Workers + BASE_IMAGE=matrixdotorg/synapse-workers + BASE_DOCKERFILE=docker/Dockerfile-workers + export COMPLEMENT_BASE_IMAGE=complement-synapse-workers + COMPLEMENT_DOCKERFILE=SynapseWorkers.Dockerfile # And provide some more configuration to complement. export COMPLEMENT_CA=true export COMPLEMENT_VERSION_CHECK_ITERATIONS=500 +else + BASE_IMAGE=matrixdotorg/synapse + BASE_DOCKERFILE=docker/Dockerfile + export COMPLEMENT_BASE_IMAGE=complement-synapse + COMPLEMENT_DOCKERFILE=Synapse.Dockerfile fi # Build the base Synapse image from the local checkout -docker build -t matrixdotorg/synapse$DOCKERTAG_SUFFIX -f docker/Dockerfile$DOCKERTAG_SUFFIX . +docker build -t $BASE_IMAGE -f "$BASE_DOCKERFILE" . # Build the Synapse monolith image from Complement, based on the above image we just built -docker build -t complement-synapse$DOCKERTAG_SUFFIX -f "$COMPLEMENT_DIR/dockerfiles/Synapse$DOCKERFILE_SUFFIX.Dockerfile" "$COMPLEMENT_DIR/dockerfiles" +docker build -t $COMPLEMENT_BASE_IMAGE -f "$COMPLEMENT_DIR/dockerfiles/$COMPLEMENT_DOCKERFILE" "$COMPLEMENT_DIR/dockerfiles" cd "$COMPLEMENT_DIR" @@ -55,4 +62,4 @@ if [[ -n "$1" ]]; then fi # Run the tests! -COMPLEMENT_BASE_IMAGE=complement-synapse$DOCKERTAG_SUFFIX go test -v -tags synapse_blacklist,msc2946,msc3083 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests +go test -v -tags synapse_blacklist,msc2946,msc3083 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests From cf04d9a8284d84ace1f493aebe03aa8832005c43 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 24 May 2021 14:09:08 -0400 Subject: [PATCH 5/5] Add documentation. --- scripts-dev/complement.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts-dev/complement.sh b/scripts-dev/complement.sh index 2bfe693b8a30..004396467378 100755 --- a/scripts-dev/complement.sh +++ b/scripts-dev/complement.sh @@ -10,6 +10,9 @@ # checkout by setting the COMPLEMENT_DIR environment variable to the # filepath of a local Complement checkout. # +# By default Synapse is run in monolith mode. This can be overridden by +# setting the WORKERS environment variable. +# # A regular expression of test method names can be supplied as the first # argument to the script. Complement will then only run those tests. If # no regex is supplied, all tests are run. For example;