CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Test (windows-latest) (push) Canceled after 0s
CI / Storage tests on PostgreSQL (push) Canceled after 0s
CI / Complement (federation off) (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
CI / Smoke test the binary (push) Canceled after 0s
Implements PLAN.md Phase 5: the Server-Server API. Warp joins rooms on other servers and lets their users join its rooms, invites across servers with the invitee's server countersigning, rejects remote invites (locally if the inviter is unreachable), and exchanges events, typing, receipts and to-device messages with other homeservers — all behind the runtime switch, which now starts and stops real outbound traffic. The protocol lives in internal/federation with no knowledge of rooms: X-Matrix signing (fuzzed parser), the spec's discovery algorithm keeping the dial address and the TLS name apart, a signed client that refuses every request while the switch is off or the policy denies the destination, and a key ring that caches other servers' keys for at most a week, with optional notaries. The roomserver takes events from elsewhere through the spec's intake: signatures and hashes (a hash mismatch keeps the redacted form), the rules against the event's own auth events, against the state before it — with /get_missing_events for small gaps and /state_ids for wide ones — and against the current state, where a failure is a soft failure. Events held without their state are outliers: a column on roomserver_events, because the current state of a room joined over federation is almost all outliers, and excluded from every timeline query. Forks are resolved at the room's head. Membership across servers is make_join/send_join, make_leave/send_leave and countersigned invites, in both directions; m.room.server_acl is enforced on everything another server sends. History before a remote join is backfilled when /messages pages past it, stored at negative stream positions. internal/federationapi is the running component: the inbound endpoints, and an outbound queue that persists what it owes each destination, sends it in transactions of 50 PDUs and 100 EDUs, backs off from ten seconds to six hours, survives restarts, and drops events persisted while federation is off rather than delivering a backlog in one burst. Its Module is what the switch starts and stops. Also: a TLS listener for port 8448, trusted key servers, key validity and an outbound CA bundle in the config; per-destination health and backoff reset in the admin API; remote profiles, aliases and directories in the Client-Server API; a Complement federation profile. See docs/federation.md, including its known gaps (no partial-state joins, no key rotation). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
4.4 KiB
Bash
Executable File
93 lines
4.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Run Complement against a freshly built Warp image.
|
|
#
|
|
# server/test/complement/run.sh # the C-S test set, federation off
|
|
# COMPLEMENT_PROFILE=federation server/test/complement/run.sh # the federation test set
|
|
# server/test/complement/run.sh TestLogin # one test
|
|
# COMPLEMENT_TESTS='Test.*' server/test/complement/run.sh
|
|
#
|
|
# Complement is a separate Go module, so it has to be checked out and run on
|
|
# its own. This script keeps that checkout in a cache directory rather than
|
|
# vendoring it: it is a test harness we track, not a dependency we pin.
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
|
|
|
: "${COMPLEMENT_REPO:=https://github.com/matrix-org/complement.git}"
|
|
: "${COMPLEMENT_REF:=main}"
|
|
: "${COMPLEMENT_DIR:=${REPO_ROOT}/.complement}"
|
|
: "${COMPLEMENT_IMAGE:=complement-warp}"
|
|
: "${COMPLEMENT_PROFILE:=csapi}"
|
|
|
|
# The target sets for the phases that are done, from PLAN.md section 7. Add
|
|
# to them as phases land rather than switching to the whole suite: a pass
|
|
# count that goes down because a later phase is missing is noise.
|
|
#
|
|
# csapi: the Client-Server tests, with federation off. Phase 4 added the
|
|
# stream tests: /sync in all its forms, /messages, /context, filters,
|
|
# typing, receipts and to-device messaging. What is still out is anything
|
|
# needing a later phase — the notification counts of the push rules
|
|
# (Phase 8) and the device lists of the keyserver (Phase 7).
|
|
CSAPI_TESTS='TestRegistration|TestLogin|TestDeviceManagement|TestRoomCreate|TestRoomState|TestRoomAlias|TestRoomForget|TestMembership.*|TestRedaction.*|TestJoinRoom.*|TestLeaveRoom.*|TestKickRoom.*|TestBanRoom.*|TestPublicRoom.*|TestSync.*|TestMessages.*|TestContext.*|TestFilter.*|TestTyping.*|TestReceipt.*|TestToDevice.*|TestRoomCreationReportsEventsToMyself|TestLazyLoading.*|TestWriteMDirectAccountData'
|
|
|
|
# federation: Phase 5. Joins, leaves and invites across servers, keys,
|
|
# transactions, missing events, server ACLs and the queries. Partial-state
|
|
# joins (MSC3706, TestPartialStateJoin*) are not implemented and are left
|
|
# out; so is anything needing an application service (Phase 9) or device
|
|
# lists (Phase 7).
|
|
FEDERATION_TESTS='TestFederation.*|TestJoinViaRoomIDAndServerName|TestJoinFederatedRoom.*|TestBannedUserCannotSendJoin|TestCannotSendNon.*Via.*|TestCannotSendKnockViaSend.*|TestOutboundFederation.*|TestInboundFederation.*|TestInboundCanReturnMissingEvents|TestRemoteAliasRequestsUnderstandUnicode|TestNetworkPartitionOrdering|TestACLs|TestGetMissingEventsGapFilling|TestEventAuth|TestUnbanViaInvite|TestJoinRoomWithFederation.*|TestRemote.*'
|
|
|
|
case "$COMPLEMENT_PROFILE" in
|
|
csapi)
|
|
: "${COMPLEMENT_TESTS:=$CSAPI_TESTS}"
|
|
PACKAGES=(./tests/csapi/...)
|
|
FEDERATION_ENABLED=false
|
|
;;
|
|
federation)
|
|
: "${COMPLEMENT_TESTS:=$FEDERATION_TESTS}"
|
|
PACKAGES=(./tests/... )
|
|
FEDERATION_ENABLED=true
|
|
;;
|
|
*)
|
|
echo "complement: unknown COMPLEMENT_PROFILE '$COMPLEMENT_PROFILE' (want csapi or federation)" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
if [[ $# -gt 0 ]]; then
|
|
COMPLEMENT_TESTS="$(IFS='|'; echo "$*")"
|
|
fi
|
|
|
|
docker="${DOCKER:-docker}"
|
|
if ! command -v "$docker" >/dev/null 2>&1; then
|
|
echo "complement: $docker is not installed; Complement needs a container runtime" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "complement: building $COMPLEMENT_IMAGE"
|
|
"$docker" build -t "$COMPLEMENT_IMAGE" -f "${REPO_ROOT}/server/test/complement/Dockerfile" "$REPO_ROOT"
|
|
|
|
if [[ ! -d "$COMPLEMENT_DIR" ]]; then
|
|
echo "complement: cloning $COMPLEMENT_REPO into $COMPLEMENT_DIR"
|
|
git clone --depth 1 --branch "$COMPLEMENT_REF" "$COMPLEMENT_REPO" "$COMPLEMENT_DIR"
|
|
else
|
|
git -C "$COMPLEMENT_DIR" fetch --depth 1 origin "$COMPLEMENT_REF"
|
|
git -C "$COMPLEMENT_DIR" checkout -q FETCH_HEAD
|
|
fi
|
|
|
|
echo "complement: running '${COMPLEMENT_TESTS}' (profile ${COMPLEMENT_PROFILE}, federation ${FEDERATION_ENABLED})"
|
|
cd "$COMPLEMENT_DIR"
|
|
|
|
# COMPLEMENT_SPAWN_HS_TIMEOUT_SECS is generous because the first container
|
|
# of a run has to apply the migrations on a cold SQLite file.
|
|
#
|
|
# COMPLEMENT_SHARE_ENV_PREFIX hands every host variable starting with
|
|
# PASS_ to the homeserver containers, prefix removed: it is how the profile
|
|
# reaches the entrypoint's federation switch.
|
|
COMPLEMENT_BASE_IMAGE="$COMPLEMENT_IMAGE" \
|
|
COMPLEMENT_SPAWN_HS_TIMEOUT_SECS="${COMPLEMENT_SPAWN_HS_TIMEOUT_SECS:-60}" \
|
|
COMPLEMENT_DEBUG="${COMPLEMENT_DEBUG:-0}" \
|
|
COMPLEMENT_SHARE_ENV_PREFIX=PASS_ \
|
|
PASS_WARP_FEDERATION_ENABLED="$FEDERATION_ENABLED" \
|
|
go test -count=1 -v -timeout 30m -run "^(${COMPLEMENT_TESTS})$" "${PACKAGES[@]}"
|