2024-04-21 15:28:35 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
2025-12-22 22:31:06 +00:00
|
|
|
# The root path where complement is available.
|
2024-07-06 21:15:44 -04:00
|
|
|
COMPLEMENT_SRC="${COMPLEMENT_SRC:-$1}"
|
2024-04-21 15:28:35 -07:00
|
|
|
|
|
|
|
|
# A `.jsonl` file to write test logs to
|
2026-02-24 12:19:31 -05:00
|
|
|
LOG_FILE="${2:-tests/test_results/complement/test_logs.jsonl}"
|
2024-04-21 15:28:35 -07:00
|
|
|
|
|
|
|
|
# A `.jsonl` file to write test results to
|
2026-02-24 12:19:31 -05:00
|
|
|
RESULTS_FILE="${3:-tests/test_results/complement/test_results.jsonl}"
|
2024-04-21 15:28:35 -07:00
|
|
|
|
2025-12-22 22:31:06 +00:00
|
|
|
# The base docker image to use for complement tests
|
|
|
|
|
# You can build the default with `docker build -t continuwuity:complement -f ./docker/complement.Dockerfile .`
|
|
|
|
|
# after running `cargo build`. Only the debug binary is used.
|
|
|
|
|
COMPLEMENT_BASE_IMAGE="${COMPLEMENT_BASE_IMAGE:-continuwuity:complement}"
|
2024-04-21 15:28:35 -07:00
|
|
|
|
2025-03-08 00:15:13 -05:00
|
|
|
# Complement tests that are skipped due to flakiness/reliability issues or we don't implement such features and won't for a long time
|
2025-03-14 15:57:18 -04:00
|
|
|
SKIPPED_COMPLEMENT_TESTS='TestPartialStateJoin.*|TestRoomDeleteAlias/Parallel/Regular_users_can_add_and_delete_aliases_when_m.*|TestRoomDeleteAlias/Parallel/Can_delete_canonical_alias|TestUnbanViaInvite.*|TestRoomState/Parallel/GET_/publicRooms_lists.*"|TestRoomDeleteAlias/Parallel/Users_with_sufficient_power-level_can_delete_other.*'
|
2024-05-21 20:59:45 -04:00
|
|
|
|
2024-07-06 21:15:44 -04:00
|
|
|
# $COMPLEMENT_SRC needs to be a directory to Complement source code
|
|
|
|
|
if [ -f "$COMPLEMENT_SRC" ]; then
|
|
|
|
|
echo "\$COMPLEMENT_SRC must be a directory/path to Complement source code"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# quick test to make sure we can actually write to $LOG_FILE and $RESULTS_FILE
|
|
|
|
|
touch $LOG_FILE && rm -v $LOG_FILE
|
|
|
|
|
touch $RESULTS_FILE && rm -v $RESULTS_FILE
|
|
|
|
|
|
2024-05-01 23:30:49 -04:00
|
|
|
toplevel="$(git rev-parse --show-toplevel)"
|
|
|
|
|
|
|
|
|
|
pushd "$toplevel" > /dev/null
|
2024-05-06 01:09:51 -04:00
|
|
|
|
2025-03-08 01:35:26 -05:00
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "running go test with:"
|
|
|
|
|
echo "\$COMPLEMENT_SRC: $COMPLEMENT_SRC"
|
|
|
|
|
echo "\$COMPLEMENT_BASE_IMAGE: $COMPLEMENT_BASE_IMAGE"
|
|
|
|
|
echo "\$RESULTS_FILE: $RESULTS_FILE"
|
|
|
|
|
echo "\$LOG_FILE: $LOG_FILE"
|
|
|
|
|
echo ""
|
2024-04-21 15:28:35 -07:00
|
|
|
|
|
|
|
|
# It's okay (likely, even) that `go test` exits nonzero
|
2025-03-08 15:48:23 -05:00
|
|
|
# `COMPLEMENT_ENABLE_DIRTY_RUNS=1` reuses the same complement container for faster complement, at the possible expense of test environment pollution
|
2024-04-21 15:28:35 -07:00
|
|
|
set +o pipefail
|
|
|
|
|
env \
|
|
|
|
|
-C "$COMPLEMENT_SRC" \
|
2025-03-08 15:48:23 -05:00
|
|
|
COMPLEMENT_BASE_IMAGE="$COMPLEMENT_BASE_IMAGE" \
|
2025-03-14 15:57:18 -04:00
|
|
|
go test -tags="conduwuit_blacklist" -skip="$SKIPPED_COMPLEMENT_TESTS" -v -timeout 1h -json ./tests/... | tee "$LOG_FILE"
|
2024-04-21 15:28:35 -07:00
|
|
|
set -o pipefail
|
|
|
|
|
|
2024-05-02 10:32:30 -04:00
|
|
|
# Post-process the results into an easy-to-compare format, sorted by Test name for reproducible results
|
2025-12-22 22:31:06 +00:00
|
|
|
jq -s -c 'sort_by(.Test)[]' < "$LOG_FILE" | jq -c '
|
2024-04-21 15:28:35 -07:00
|
|
|
select(
|
|
|
|
|
(.Action == "pass" or .Action == "fail" or .Action == "skip")
|
|
|
|
|
and .Test != null
|
|
|
|
|
) | {Action: .Action, Test: .Test}
|
2024-05-02 10:32:30 -04:00
|
|
|
' > "$RESULTS_FILE"
|
2025-03-08 00:15:13 -05:00
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo ""
|
|
|
|
|
echo "complement logs saved at $LOG_FILE"
|
|
|
|
|
echo "complement results saved at $RESULTS_FILE"
|
|
|
|
|
echo ""
|
|
|
|
|
echo ""
|