Implements PLAN.md Phase 8. internal/pushrules is the rule language: the spec's default ruleset, all six condition kinds, glob and word-boundary matching, intentional mentions switching off the legacy body rules, and rule ordering as Synapse has it. internal/pushserver keeps the rules, pushers and notifications and talks to push gateways. Push rules are the m.push_rules account data, written only by the push server; reads keep the user's own rules and the enabled/actions of each default and take the rest from the current defaults, so new default rules reach every user without a migration. PUT account_data/m.push_rules is refused with 405. The push server listens on the roomserver's emit stage and evaluates each event on its own worker for every local member and an invite's target. Notifications and per-room unread counts are stored in migration 0010; counts are a seventh sync token stream, so /sync reports unread_notifications and picks up count changes made after the event or by a receipt from another device. m.read and m.read.private receipts clear the counts; leaving a room clears it. Pushers (http kind only) push through a bounded sender pool with retries, honour event_id_only, drop push keys the gateway rejects, and go away with their device. GET /notifications pages the history. New config section push: enabled, include_content, gateway_timeout, notification_retention. Account data writes now wake the user's blocked syncs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
5.0 KiB
Bash
Executable File
97 lines
5.0 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. Phase 6 added the media
|
|
# tests: uploads, async uploads, downloads with their file names and
|
|
# thumbnails. The remote-media tests are in the federation set, which
|
|
# TestRemote.* already covers. Phase 7 added the keyserver's: key uploads,
|
|
# claims, changes, device lists, fallback keys, cross-signing and key
|
|
# backup. Phase 8 added the push rule tests: the rules API, and rule
|
|
# changes arriving through /sync.
|
|
CSAPI_TESTS='TestPushRuleCacheHealth|TestPushSync|TestUploadKey.*|TestKeyClaimOrdering|TestKeyChanges.*|TestDeviceListUpdates.*|TestE2EKeyBackup.*|TestFallbackKeys.*|TestCrossSigning.*|TestMedia.*|TestContent.*|TestLocalPngThumbnail|TestAsyncUpload.*|TestUploadLimit|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). Phase 7
|
|
# added device lists across servers.
|
|
FEDERATION_TESTS='TestDeviceListUpdates.*|TestDeviceListsUpdateOverFederation.*|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[@]}"
|