#!/usr/bin/env bash # Run Complement against a freshly built Warp image. # # server/test/complement/run.sh # the test set for the phases that are done # 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}" # The target set for the phases that are done, from PLAN.md section 7. Add # to it as phases land rather than switching to the whole suite: a pass # count that goes down because a later phase is missing is noise. # # Phase 3 adds the room tests. TestRoomCreationReportsEventsToMyself and # anything that pages a room's history are left for Phase 4, which is where # /sync and /messages arrive. : "${COMPLEMENT_TESTS:=TestRegistration|TestLogin|TestDeviceManagement|TestRoomCreate|TestRoomState|TestRoomAlias|TestRoomForget|TestMembership.*|TestRedaction.*|TestJoinRoom.*|TestLeaveRoom.*|TestKickRoom.*|TestBanRoom.*|TestPublicRoom.*}" 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}' with federation off" 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_BASE_IMAGE="$COMPLEMENT_IMAGE" \ COMPLEMENT_SPAWN_HS_TIMEOUT_SECS="${COMPLEMENT_SPAWN_HS_TIMEOUT_SECS:-60}" \ COMPLEMENT_DEBUG="${COMPLEMENT_DEBUG:-0}" \ go test -count=1 -v -timeout 20m -run "^(${COMPLEMENT_TESTS})$" ./tests/csapi/...