Run complement with Synapse workers manually. (#10039)

Adds an option to complement.sh to run Synapse in worker
mode (instead of the default monolith mode).
This commit is contained in:
Patrick Cloke 2021-05-24 15:32:45 -04:00 committed by GitHub
parent 7adcb20fc0
commit 7d90d6ce9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 7 deletions

1
changelog.d/10039.misc Normal file
View file

@ -0,0 +1 @@
Fix running complement tests with Synapse workers.

View file

@ -184,18 +184,18 @@ stderr_logfile_maxbytes=0
""" """
NGINX_LOCATION_CONFIG_BLOCK = """ NGINX_LOCATION_CONFIG_BLOCK = """
location ~* {endpoint} { location ~* {endpoint} {{
proxy_pass {upstream}; proxy_pass {upstream};
proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host; proxy_set_header Host $host;
} }}
""" """
NGINX_UPSTREAM_CONFIG_BLOCK = """ NGINX_UPSTREAM_CONFIG_BLOCK = """
upstream {upstream_worker_type} { upstream {upstream_worker_type} {{
{body} {body}
} }}
""" """

View file

@ -10,6 +10,9 @@
# checkout by setting the COMPLEMENT_DIR environment variable to the # checkout by setting the COMPLEMENT_DIR environment variable to the
# filepath of a local Complement checkout. # 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 # 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 # argument to the script. Complement will then only run those tests. If
# no regex is supplied, all tests are run. For example; # no regex is supplied, all tests are run. For example;
@ -32,10 +35,26 @@ if [[ -z "$COMPLEMENT_DIR" ]]; then
echo "Checkout available at 'complement-master'" echo "Checkout available at 'complement-master'"
fi fi
# If we're using workers, modify the docker files slightly.
if [[ -n "$WORKERS" ]]; then
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 # Build the base Synapse image from the local checkout
docker build -t matrixdotorg/synapse -f docker/Dockerfile . docker build -t $BASE_IMAGE -f "$BASE_DOCKERFILE" .
# Build the Synapse monolith image from Complement, based on the above image we just built # 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_BASE_IMAGE -f "$COMPLEMENT_DIR/dockerfiles/$COMPLEMENT_DOCKERFILE" "$COMPLEMENT_DIR/dockerfiles"
cd "$COMPLEMENT_DIR" cd "$COMPLEMENT_DIR"
@ -46,4 +65,4 @@ if [[ -n "$1" ]]; then
fi fi
# Run the tests! # Run the tests!
COMPLEMENT_BASE_IMAGE=complement-synapse 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