Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Synapse: Add a step for running Complement tests in worker mode #122

Closed
wants to merge 11 commits into from

Conversation

anoadragon453
Copy link
Member

@anoadragon453 anoadragon453 commented Jan 21, 2021

This PR extends the Complement section of Synapse's pipeline to run Complement tests under worker mode. This PR is ready for review, but should not be merged until the relevant Synapse and Complement PRs are.

How does this work?

We start with the official Synapse docker image. This creates a python environment with all of Synapse's dependencies installed. Then we make use of the new Dockerfile-workers to install supervisord, redis and nginx. Redis is used for inter-process communication, nginx is used for routing network requests to each worker and supervisord will start and maintain each process.

Finally, we use the SynapseWorkers dockerfile in Complement to install postgresql into the container, set up caddy server to easily take advantage of Complement's CA, inject some Synapse options to disable rate-limiting, enable registration etc. and then finally run a script which generates config files supervisord, nginx and Synapse depending on which workers you want to run.

@anoadragon453 anoadragon453 changed the title Add a step for running Complement tests in worker mode Synapse: Add a step for running Complement tests in worker mode Jan 21, 2021
@anoadragon453 anoadragon453 requested review from a team and kegsay and removed request for a team January 21, 2021 16:17
@anoadragon453 anoadragon453 force-pushed the anoa/synapse_pipeline_workers_complement branch from 0e0ddcc to 3029ae5 Compare January 21, 2021 16:57
@anoadragon453 anoadragon453 removed the request for review from kegsay January 21, 2021 18:11
@anoadragon453 anoadragon453 force-pushed the anoa/synapse_pipeline_workers_complement branch from 3029ae5 to 36793d8 Compare January 21, 2021 18:13
synapse/pipeline.yml Outdated Show resolved Hide resolved
synapse/pipeline.yml Outdated Show resolved Hide resolved
Comment on lines 600 to 601
# Complement needs to know if it is running under CI
- "CI=true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matrix-org/complement#60

I'm planning to change that myself once these PRs are in :)

synapse/pipeline.yml Outdated Show resolved Hide resolved
Comment on lines 604 to 606
# Enabled Complement's certificate authority for authentication of
# federation requests
- "COMPLEMENT_CA=true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be optional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly not, though existing images expecting to fill the /ca directory with their own files (for example, Synapse Monolith's) will need to be updated if this option is on by default.

I've created an issue for discussion on the Complement repo here: matrix-org/complement#65

Comment on lines 574 to 615
- command:
# Build a docker image from the checked out Synapse source
- "docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile ."
# Build a second docker image on top of the above image. This one sets up Synapse workers
# as well as everything else it needs to run a federating setup
- "docker build -t matrixdotorg/synapse:workers -f docker/Dockerfile-workers ."
# We use the complement:latest image to provide Complement's dependencies, but want
# to actually run against the master branch of Complement, so download it here.
- "wget https://github.com/matrix-org/complement/archive/master.tar.gz"
- "tar -xzf master.tar.gz"
# Build an image for running the above worker setup in Complement. This involves
# disabling rate-limiting, using Complement's CA etc.
- "docker build -t complement-synapse -f complement-master/dockerfiles/SynapseWorkers.Dockerfile complement-master/dockerfiles"
# Finally, compile and run the tests.
- "cd complement-master"
- "COMPLEMENT_BASE_IMAGE=complement-synapse:latest go test -v -tags synapse_blacklist ./tests"
label: "\U0001F9EA Complement | Synapse Workers"
agents:
# Running every worker takes a beefy system
queue: "xlarge"
plugins:
- docker#v3.7.0:
# The dockerfile for this image is at https://github.com/matrix-org/complement/blob/master/dockerfiles/ComplementCIBuildkite.Dockerfile.
image: "matrixdotorg/complement:latest"
mount-buildkite-agent: false
environment:
# Complement needs to know if it is running under CI
- "CI=true"
# Enable debug logging
- "COMPLEMENT_DEBUG=1"
# Enabled Complement's certificate authority for authentication of
# federation requests
- "COMPLEMENT_CA=true"
# Starting up all the processes in this container can take a little while.
# The default is 200. Let's wait a bit longer to decrease the chance of a
# startup timeout
- "COMPLEMENT_VERSION_CHECK_ITERATIONS=500"
publish: [ "8448:8448" ]
# Complement uses Docker so pass through the docker socket. This means Complement shares
# the hosts Docker.
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to make use of yaml entities so that the bits that are shared between the complement runs (the docker-plugin settings, and some of the commands) don't have to be C&Ped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reduce the plugins section quite significantly, but didn't see as clear a path with commands: as there's some differences and commonalities interspersed with one another.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks the same apart from the name of the dockerfile? so have two yaml entities, one which does the bits before that, and one which does the bits after?

or even: stick the name of a dockerfile in an env var and set it somewhere else in the step config?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems as though environment variables specified in environment aren't used when launching commands specified in commands. The environment variables that seem to work there are those found in docker-compose-env. But that doesn't really help us much.

@anoadragon453 anoadragon453 force-pushed the anoa/synapse_pipeline_workers_complement branch from d41ddf5 to c6a4e8a Compare January 25, 2021 17:54
Synapse's pipeline shouldn't really have this turned on.
@richvdh
Copy link
Member

richvdh commented Jan 17, 2022

closing this, because synapse has moved its CI to GHA.

@richvdh richvdh closed this Jan 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants