Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 5c3de88

Browse files
committed
Move complement setup stuff into the Synapse repo
1 parent ae01a7e commit 5c3de88

File tree

8 files changed

+206
-29
lines changed

8 files changed

+206
-29
lines changed

.github/workflows/tests.yml

+1-17
Original file line numberDiff line numberDiff line change
@@ -361,27 +361,11 @@ jobs:
361361
(wget -O - "https://github.com/matrix-org/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
362362
done
363363
364-
# Build initial Synapse image
365-
- run: docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile .
366-
working-directory: synapse
367-
env:
368-
DOCKER_BUILDKIT: 1
369-
370-
# Build a ready-to-run Synapse image based on the initial image above.
371-
# This new image includes a config file, keys for signing and TLS, and
372-
# other settings to make it suitable for testing under Complement.
373-
- run: docker build -t complement-synapse -f Synapse.Dockerfile .
374-
working-directory: complement/dockerfiles
375-
376-
# Run Complement
377364
- run: |
378365
set -o pipefail
379-
go test -v -json -tags synapse_blacklist,msc2716,msc3030 ./tests/... 2>&1 | gotestfmt
366+
COMPLEMENT_DIR=complement ./scripts-dev/complement.sh -json 2>&1 | gotestfmt
380367
shell: bash
381368
name: Run Complement Tests
382-
env:
383-
COMPLEMENT_BASE_IMAGE: complement-synapse:latest
384-
working-directory: complement
385369
386370
# a job which marks all the other jobs as complete, thus allowing PRs to be merged.
387371
tests-done:

changelog.d/12404.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add files used to build the Docker image used for complement testing into the Synapse repository.

docker/complement/Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# A dockerfile which builds an image suitable for testing Synapse under
2+
# complement.
3+
4+
ARG SYNAPSE_VERSION=latest
5+
6+
FROM matrixdotorg/synapse:${SYNAPSE_VERSION}
7+
8+
ENV SERVER_NAME=localhost
9+
10+
COPY conf/* /conf/
11+
12+
# generate a signing key
13+
RUN generate_signing_key -o /conf/server.signing.key
14+
15+
WORKDIR /data
16+
17+
EXPOSE 8008 8448
18+
19+
ENTRYPOINT ["/conf/start.sh"]
20+
21+
HEALTHCHECK --start-period=5s --interval=1s --timeout=1s \
22+
CMD curl -fSs http://localhost:8008/health || exit 1

docker/complement/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stuff for building the docker image used for testing under complement.
+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
## Server ##
2+
3+
server_name: SERVER_NAME
4+
log_config: /conf/log_config.yaml
5+
report_stats: False
6+
signing_key_path: /conf/server.signing.key
7+
trusted_key_servers: []
8+
enable_registration: true
9+
enable_registration_without_verification: true
10+
11+
## Listeners ##
12+
13+
tls_certificate_path: /conf/server.tls.crt
14+
tls_private_key_path: /conf/server.tls.key
15+
bcrypt_rounds: 4
16+
registration_shared_secret: complement
17+
18+
listeners:
19+
- port: 8448
20+
bind_addresses: ['::']
21+
type: http
22+
tls: true
23+
resources:
24+
- names: [federation]
25+
26+
- port: 8008
27+
bind_addresses: ['::']
28+
type: http
29+
30+
resources:
31+
- names: [client]
32+
33+
## Database ##
34+
35+
database:
36+
name: "sqlite3"
37+
args:
38+
# We avoid /data, as it is a volume and is not transferred when the container is committed,
39+
# which is a fundamental necessity in complement.
40+
database: "/conf/homeserver.db"
41+
42+
## Federation ##
43+
44+
45+
# disable verification of federation certificates
46+
#
47+
# TODO: this is temporary; see
48+
# https://github.com/matrix-org/synapse/issues/11803
49+
federation_verify_certificates: false
50+
51+
# trust certs signed by the complement CA
52+
federation_custom_ca_list:
53+
- /complement/ca/ca.crt
54+
55+
# unblacklist RFC1918 addresses
56+
ip_range_blacklist: []
57+
58+
# Disable server rate-limiting
59+
rc_federation:
60+
window_size: 1000
61+
sleep_limit: 10
62+
sleep_delay: 500
63+
reject_limit: 99999
64+
concurrent: 3
65+
66+
rc_message:
67+
per_second: 9999
68+
burst_count: 9999
69+
70+
rc_registration:
71+
per_second: 9999
72+
burst_count: 9999
73+
74+
rc_login:
75+
address:
76+
per_second: 9999
77+
burst_count: 9999
78+
account:
79+
per_second: 9999
80+
burst_count: 9999
81+
failed_attempts:
82+
per_second: 9999
83+
burst_count: 9999
84+
85+
rc_admin_redaction:
86+
per_second: 9999
87+
burst_count: 9999
88+
89+
rc_joins:
90+
local:
91+
per_second: 9999
92+
burst_count: 9999
93+
remote:
94+
per_second: 9999
95+
burst_count: 9999
96+
97+
federation_rr_transactions_per_room_per_second: 9999
98+
99+
## API Configuration ##
100+
101+
# A list of application service config files to use
102+
#
103+
app_service_config_files:
104+
AS_REGISTRATION_FILES
105+
106+
## Experimental Features ##
107+
108+
experimental_features:
109+
# Enable spaces support
110+
spaces_enabled: true
111+
# Enable history backfilling support
112+
msc2716_enabled: true
113+
# server-side support for partial state in /send_join
114+
msc3706_enabled: true
115+
# Enable jump to date endpoint
116+
msc3030_enabled: true
117+
118+
server_notices:
119+
system_mxid_localpart: _server
120+
system_mxid_display_name: "Server Alert"
121+
system_mxid_avatar_url: ""
122+
room_name: "Server Alert"
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 1
2+
3+
formatters:
4+
precise:
5+
format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
6+
7+
filters:
8+
context:
9+
(): synapse.logging.context.LoggingContextFilter
10+
request: ""
11+
12+
handlers:
13+
console:
14+
class: logging.StreamHandler
15+
formatter: precise
16+
filters: [context]
17+
# log to stdout, for easier use with 'docker logs'
18+
stream: 'ext://sys.stdout'
19+
20+
root:
21+
level: INFO
22+
handlers: [console]
23+
24+
disable_existing_loggers: false

docker/complement/conf/start.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
sed -i "s/SERVER_NAME/${SERVER_NAME}/g" /conf/homeserver.yaml
6+
7+
# Add the application service registration files to the homeserver.yaml config
8+
for filename in /complement/appservice/*.yaml; do
9+
[ -f "$filename" ] || break
10+
11+
as_id=$(basename "$filename" .yaml)
12+
13+
# Insert the path to the registration file and the AS_REGISTRATION_FILES marker after
14+
# so we can add the next application service in the next iteration of this for loop
15+
sed -i "s/AS_REGISTRATION_FILES/ - \/complement\/appservice\/${as_id}.yaml\nAS_REGISTRATION_FILES/g" /conf/homeserver.yaml
16+
done
17+
# Remove the AS_REGISTRATION_FILES entry
18+
sed -i "s/AS_REGISTRATION_FILES//g" /conf/homeserver.yaml
19+
20+
# generate an ssl key and cert for the server, signed by the complement CA
21+
openssl genrsa -out /conf/server.tls.key 2048
22+
23+
openssl req -new -key /conf/server.tls.key -out /conf/server.tls.csr \
24+
-subj "/CN=${SERVER_NAME}"
25+
openssl x509 -req -in /conf/server.tls.csr \
26+
-CA /complement/ca/ca.crt -CAkey /complement/ca/ca.key -set_serial 1 \
27+
-out /conf/server.tls.crt
28+
29+
exec python -m synapse.app.homeserver -c /conf/homeserver.yaml "$@"
30+

scripts-dev/complement.sh

+5-12
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,18 @@ if [[ -n "$WORKERS" ]]; then
5050

5151
export COMPLEMENT_BASE_IMAGE=complement-synapse-workers
5252
COMPLEMENT_DOCKERFILE=SynapseWorkers.Dockerfile
53+
5354
# And provide some more configuration to complement.
54-
export COMPLEMENT_CA=true
5555
export COMPLEMENT_SPAWN_HS_TIMEOUT_SECS=25
5656
else
5757
export COMPLEMENT_BASE_IMAGE=complement-synapse
58-
COMPLEMENT_DOCKERFILE=Synapse.Dockerfile
58+
COMPLEMENT_DOCKERFILE=Dockerfile
5959
fi
6060

6161
# Build the Complement image from the Synapse image we just built.
62-
docker build -t $COMPLEMENT_BASE_IMAGE -f "$COMPLEMENT_DIR/dockerfiles/$COMPLEMENT_DOCKERFILE" "$COMPLEMENT_DIR/dockerfiles"
63-
64-
cd "$COMPLEMENT_DIR"
65-
66-
EXTRA_COMPLEMENT_ARGS=""
67-
if [[ -n "$1" ]]; then
68-
# A test name regex has been set, supply it to Complement
69-
EXTRA_COMPLEMENT_ARGS+="-run $1 "
70-
fi
62+
docker build -t $COMPLEMENT_BASE_IMAGE -f "docker/complement/$COMPLEMENT_DOCKERFILE" "docker/complement"
7163

7264
# Run the tests!
7365
echo "Images built; running complement"
74-
go test -v -tags synapse_blacklist,msc2716,msc3030 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests/...
66+
cd "$COMPLEMENT_DIR"
67+
go test -v -tags synapse_blacklist,msc2716,msc3030 -count=1 "$@" ./tests/...

0 commit comments

Comments
 (0)