From 900e49ebf1a454dfb77f12cdc4d3b16194abd315 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 14 Jan 2026 00:00:17 -0300 Subject: [PATCH 01/10] chore: Remove debug flag from Jest configuration and adjust error handling in integration test script --- ee/packages/federation-matrix/jest.config.federation.ts | 1 - .../federation-matrix/tests/scripts/run-integration-tests.sh | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ee/packages/federation-matrix/jest.config.federation.ts b/ee/packages/federation-matrix/jest.config.federation.ts index 85e34daae709c..aa685c2daf12d 100644 --- a/ee/packages/federation-matrix/jest.config.federation.ts +++ b/ee/packages/federation-matrix/jest.config.federation.ts @@ -55,7 +55,6 @@ export default { complete: true, }, }, - debug: true, }, ] as [string, { [x: string]: unknown }], ] diff --git a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh index b2b5e8bd7b293..7c6088f28b6ec 100755 --- a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh +++ b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh @@ -327,8 +327,10 @@ if [ "$NO_TEST" = false ]; then log_info "Running end-to-end tests..." cd "$PACKAGE_ROOT" + set +e IS_EE=true NODE_EXTRA_CA_CERTS=$(pwd)/docker-compose/traefik/certs/ca/rootCA.crt yarn test:federation TEST_EXIT_CODE=$? + set -e else log_info "No-test mode: skipping test execution" log_info "Services are ready and running. You can now:" From 5c2f0e686a6830830f0b138eada3d878f2e50c58 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 14 Jan 2026 13:04:49 -0300 Subject: [PATCH 02/10] chore: Update CI workflow and integration test scripts to improve logging and test execution flow --- .github/workflows/ci.yml | 16 ++++- ee/packages/federation-matrix/package.json | 3 + .../tests/scripts/run-integration-tests.sh | 70 +++++++++++++------ 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d589614476d6..d68e13778650e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -655,14 +655,26 @@ jobs: # List loaded images docker images - - name: Run federation integration tests with pre-built image + - name: Start federation services working-directory: ./ee/packages/federation-matrix env: ROCKETCHAT_IMAGE: ghcr.io/${{ needs.release-versions.outputs.lowercase-repo }}/rocket.chat:${{ needs.release-versions.outputs.gh-docker-tag }}-amd64 ENTERPRISE_LICENSE_RC1: ZAikY+LLaal7mT6RNYxpyWEmMQyucrl50/7pYBXqHczc90j+RLwF+T0xuCT2pIpKMC5DxcZ1TtkV6MYJk5whrwmap+mQ0FV+VpILJlL0i4T21K4vMfzZXTWm/pzcAy2fMTUNH+mUA9HTBD6lYYh40KnbGXPAd80VbZk0MO/WbWBm2dOT0YCwfvlRyurRqkDAQrftLaffzCNUsMKk0fh+MKs73UDHZQDp1yvs7WoGpPu5ZVi5mTBOt3ZKVz5KjGfClLwJptFPmW1w6nKelAiJBDPpjcX1ylfjxpnBoixko7uN52zlyaeoAYwfRcdDLnZ8k0Ou6tui/vTQUXjGIjHw2AhMaKwonn4E9LYpuA1KEXt08qJL5J3ZtjSCV1T+A9Z3zFhhLgp5dxP/PPUbxDn/P8XKp7nXM9duIfcCMlnea7V8ixEyCHwwvKQaXVVidcsUGtB8CwS0GlsAEBLOzqMehuQUK2rdQ4WgEz3AYveikeVvSzgBHvyXsxssWAThc0Mht0eEJqdDhUB2QeZ2WmPsaSSD639Z4WgjSUoR0zh8bfqepH+2XRcUryXe2yN+iU+3POzi9wfg0k65MxXT8pBg3PD5RHnR8oflEP0tpZts33JiBhYRxX3MKplAFm4dMuphTsDJTh+e534pT7IPuZF79QSVaLEWZfVVVb7nGFtmMwA= QASE_TESTOPS_JEST_API_TOKEN: ${{ secrets.QASE_TESTOPS_JEST_API_TOKEN }} PR_NUMBER: ${{ github.event.number }} - run: yarn test:integration --image "${ROCKETCHAT_IMAGE}" + run: yarn test:integration:start-containers-only --image "${ROCKETCHAT_IMAGE}" + + - name: Run federation integration tests + working-directory: ./ee/packages/federation-matrix + env: + QASE_TESTOPS_JEST_API_TOKEN: ${{ secrets.QASE_TESTOPS_JEST_API_TOKEN }} + PR_NUMBER: ${{ github.event.number }} + run: yarn test:integration:ci + + - name: Show federation integration tests logs + if: failure() + working-directory: ./ee/packages/federation-matrix + run: yarn test:integration:logs - name: Show rc server logs if tests failed if: failure() diff --git a/ee/packages/federation-matrix/package.json b/ee/packages/federation-matrix/package.json index 529f74173da43..fe08d98e86018 100644 --- a/ee/packages/federation-matrix/package.json +++ b/ee/packages/federation-matrix/package.json @@ -13,7 +13,10 @@ "lint": "eslint .", "lint:fix": "eslint --fix .", "test": "jest", + "test:integration:logs": "./tests/scripts/run-integration-tests.sh --logs", + "test:integration:start-containers-only": "./tests/scripts/run-integration-tests.sh --start-containers-only", "test:integration": "./tests/scripts/run-integration-tests.sh", + "test:integration:ci": "./tests/scripts/run-integration-tests.sh --ci", "test:federation": "jest --config jest.config.federation.ts", "testunit": "jest", "typecheck": "tsc --noEmit" diff --git a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh index 7c6088f28b6ec..5cbaac0d0d8a9 100755 --- a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh +++ b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh @@ -34,9 +34,28 @@ USE_PREBUILT_IMAGE=false PREBUILT_IMAGE="" INTERRUPTED=false NO_TEST=false +CI=false +LOGS=false + while [[ $# -gt 0 ]]; do case $1 in + --start-containers-only) + NO_TEST=true + KEEP_RUNNING=true + shift + ;; + --ci) + CI=true + KEEP_RUNNING=true + USE_PREBUILT_IMAGE=true + shift + ;; + --logs) + LOGS=true + NO_TEST=true + shift + ;; --keep-running) KEEP_RUNNING=true shift @@ -101,8 +120,35 @@ log_error() { echo -e "${RED}❌ [$(date '+%Y-%m-%d %H:%M:%S')] $1${NC}" } +docker_log() { + local container=$1 + if docker ps -q -f name=$container | grep -q .; then + docker logs $container 2>&1 | sed 's/^/ /' + else + echo " $container container not found or no logs" + fi +} + +docker_logs() { + echo "" + echo "ROCKET.CHAT (rc1) LOGS:" + echo "----------------------------------------" + docker_log "rc1" + + echo "" + echo "SYNAPSE (hs1) LOGS:" + echo "----------------------------------------" + docker_log "hs1" + + echo "" + echo "==========================================" +} + # Cleanup function cleanup() { + if [ "$CI" = true ]; then + return + fi # Show container logs if tests failed if [ -n "${TEST_EXIT_CODE:-}" ] && [ "$TEST_EXIT_CODE" -ne 0 ]; then echo "" @@ -110,26 +156,7 @@ cleanup() { echo "CONTAINER LOGS (Test Failed)" echo "==========================================" - echo "" - echo "ROCKET.CHAT (rc1) LOGS:" - echo "----------------------------------------" - if docker ps -q -f name=rc1 | grep -q .; then - docker logs rc1 2>&1 | sed 's/^/ /' - else - echo " Rocket.Chat container not found or no logs" - fi - - echo "" - echo "SYNAPSE (hs1) LOGS:" - echo "----------------------------------------" - if docker ps -q -f name=hs1 | grep -q .; then - docker logs hs1 2>&1 | sed 's/^/ /' - else - echo " Synapse container not found or no logs" - fi - - echo "" - echo "==========================================" + docker_logs fi if [ "$KEEP_RUNNING" = true ]; then @@ -331,6 +358,9 @@ if [ "$NO_TEST" = false ]; then IS_EE=true NODE_EXTRA_CA_CERTS=$(pwd)/docker-compose/traefik/certs/ca/rootCA.crt yarn test:federation TEST_EXIT_CODE=$? set -e +elif [ "$LOGS" = true ]; then + docker_logs + exit 0 else log_info "No-test mode: skipping test execution" log_info "Services are ready and running. You can now:" From f4b75ca1cc64951296d1ba3cd367044a8cfaf618 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 14 Jan 2026 15:56:08 -0300 Subject: [PATCH 03/10] chore: Enhance integration test script to manage container startup and improve error handling --- .../tests/scripts/run-integration-tests.sh | 239 +++++++++--------- 1 file changed, 122 insertions(+), 117 deletions(-) diff --git a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh index 5cbaac0d0d8a9..bf18a3119f4d6 100755 --- a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh +++ b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh @@ -36,6 +36,7 @@ INTERRUPTED=false NO_TEST=false CI=false LOGS=false +START_CONTAINERS=true while [[ $# -gt 0 ]]; do @@ -48,6 +49,7 @@ while [[ $# -gt 0 ]]; do --ci) CI=true KEEP_RUNNING=true + START_CONTAINERS=false USE_PREBUILT_IMAGE=true shift ;; @@ -147,7 +149,10 @@ docker_logs() { # Cleanup function cleanup() { if [ "$CI" = true ]; then - return + # Exit with the test result code + if [ -n "${TEST_EXIT_CODE:-}" ]; then + exit $TEST_EXIT_CODE + fi fi # Show container logs if tests failed if [ -n "${TEST_EXIT_CODE:-}" ] && [ "$TEST_EXIT_CODE" -ne 0 ]; then @@ -208,145 +213,145 @@ if [ ! -f "$DOCKER_COMPOSE_FILE" ]; then exit 1 fi -# Build Rocket.Chat locally if not using pre-built image -if [ "$USE_PREBUILT_IMAGE" = false ]; then - log_info "🚀 Building Rocket.Chat locally..." - log_info "=====================================" - - # Clean up any existing build - log_info "Cleaning up previous build..." - rm -rf "$BUILD_DIR" - # Build the project - log_info "Building packages from project root..." - cd "$ROCKETCHAT_ROOT" - yarn build +if [ "$START_CONTAINERS" = true ]; then + # Build Rocket.Chat locally if not using pre-built image + if [ "$USE_PREBUILT_IMAGE" = false ]; then + log_info "🚀 Building Rocket.Chat locally..." + log_info "=====================================" - # Build the Meteor bundle (must be run from the meteor directory) - log_info "Building Meteor bundle..." - cd "$ROCKETCHAT_ROOT/apps/meteor" - METEOR_DISABLE_OPTIMISTIC_CACHING=1 meteor build --server-only --directory "$BUILD_DIR" + # Clean up any existing build + log_info "Cleaning up previous build..." + rm -rf "$BUILD_DIR" - log_success "Build completed!" -else - log_info "🚀 Using pre-built image: $PREBUILT_IMAGE" - log_info "=====================================" -fi + # Build the project + log_info "Building packages from project root..." + cd "$ROCKETCHAT_ROOT" + yarn build -log_info "🚀 Starting Federation Integration Tests" -log_info "=====================================" + # Build the Meteor bundle (must be run from the meteor directory) + log_info "Building Meteor bundle..." + cd "$ROCKETCHAT_ROOT/apps/meteor" + METEOR_DISABLE_OPTIMISTIC_CACHING=1 meteor build --server-only --directory "$BUILD_DIR" -BUILD_PARAM="" + log_success "Build completed!" + else + log_info "🚀 Using pre-built image: $PREBUILT_IMAGE" + log_info "=====================================" + fi -# Set environment variables for Docker Compose -if [ "$USE_PREBUILT_IMAGE" = true ]; then - export ROCKETCHAT_IMAGE="$PREBUILT_IMAGE" - log_info "Using pre-built image: $PREBUILT_IMAGE" -else - export ROCKETCHAT_BUILD_CONTEXT="$BUILD_DIR" - export ROCKETCHAT_DOCKERFILE="$ROCKETCHAT_ROOT/apps/meteor/.docker/Dockerfile.alpine" - BUILD_PARAM="--build" - log_info "Building from local context: $BUILD_DIR" -fi + log_info "🚀 Starting Federation Integration Tests" + log_info "=====================================" -# Start services -if [ "$INCLUDE_ELEMENT" = true ]; then - log_info "Starting all federation services including Element web client..." - docker compose -f "$DOCKER_COMPOSE_FILE" --profile "element" up -d $BUILD_PARAM -else - log_info "Starting federation services (test profile only)..." - docker compose -f "$DOCKER_COMPOSE_FILE" --profile "test" up -d $BUILD_PARAM -fi + # Set environment variables for Docker Compose + if [ "$USE_PREBUILT_IMAGE" = true ]; then + export ROCKETCHAT_IMAGE="$PREBUILT_IMAGE" + log_info "Using pre-built image: $PREBUILT_IMAGE" + else + export ROCKETCHAT_BUILD_CONTEXT="$BUILD_DIR" + export ROCKETCHAT_DOCKERFILE="$ROCKETCHAT_ROOT/apps/meteor/.docker/Dockerfile.alpine" + log_info "Building from local context: $BUILD_DIR" + fi -# Wait for rc1 container to be running -log_info "Waiting for rc1 container to start..." -timeout=60 -while [ $timeout -gt 0 ] && [ "$INTERRUPTED" = false ]; do - if docker ps --filter "name=$RC1_CONTAINER" --filter "status=running" | grep -q "$RC1_CONTAINER"; then - log_success "rc1 container is running" - break + # Start services + if [ "$INCLUDE_ELEMENT" = true ]; then + log_info "Starting all federation services including Element web client..." + docker compose -f "$DOCKER_COMPOSE_FILE" --profile element up -d --build + else + log_info "Starting federation services (test profile only)..." + docker compose -f "$DOCKER_COMPOSE_FILE" --profile test up -d --build fi - sleep 2 - timeout=$((timeout - 2)) -done -if [ "$INTERRUPTED" = true ]; then - log_info "Container startup interrupted by user" - exit 130 -fi + # Wait for rc1 container to be running + log_info "Waiting for rc1 container to start..." + timeout=60 + while [ $timeout -gt 0 ] && [ "$INTERRUPTED" = false ]; do + if docker ps --filter "name=$RC1_CONTAINER" --filter "status=running" | grep -q "$RC1_CONTAINER"; then + log_success "rc1 container is running" + break + fi + sleep 2 + timeout=$((timeout - 2)) + done -if [ $timeout -le 0 ]; then - log_error "rc1 container failed to start within 60 seconds" - exit 1 -fi + if [ "$INTERRUPTED" = true ]; then + log_info "Container startup interrupted by user" + exit 130 + fi -# Wait for both Rocket.Chat and Synapse to be ready -log_info "Waiting for Rocket.Chat and Synapse servers to be ready..." - -# Function to wait for a service to be ready -wait_for_service() { - local url=$1 - local name=$2 - local host=$3 - local elapsed=0 - local ca_cert="${CA_CERT:-$PACKAGE_ROOT/docker-compose/traefik/certs/ca/rootCA.crt}" - - # Derive host/port from URL when not explicitly provided - local host_with_port="${url#*://}" - host_with_port="${host_with_port%%/*}" - if [ -z "$host" ]; then - host="${host_with_port%%:*}" + if [ $timeout -le 0 ]; then + log_error "rc1 container failed to start within 60 seconds" + exit 1 fi - local port - if [[ "$host_with_port" == *:* ]]; then - port="${host_with_port##*:}" - else - if [[ "$url" == https://* ]]; then - port=443 + + # Wait for both Rocket.Chat and Synapse to be ready + log_info "Waiting for Rocket.Chat and Synapse servers to be ready..." + + # Function to wait for a service to be ready + wait_for_service() { + local url=$1 + local name=$2 + local host=$3 + local elapsed=0 + local ca_cert="${CA_CERT:-$PACKAGE_ROOT/docker-compose/traefik/certs/ca/rootCA.crt}" + + # Derive host/port from URL when not explicitly provided + local host_with_port="${url#*://}" + host_with_port="${host_with_port%%/*}" + if [ -z "$host" ]; then + host="${host_with_port%%:*}" + fi + local port + if [[ "$host_with_port" == *:* ]]; then + port="${host_with_port##*:}" else - port=80 + if [[ "$url" == https://* ]]; then + port=443 + else + port=80 + fi fi - fi - log_info "Checking $name at $url (host $host -> 127.0.0.1:$port)..." + log_info "Checking $name at $url (host $host -> 127.0.0.1:$port)..." - while [ $elapsed -lt $MAX_WAIT_TIME ] && [ "$INTERRUPTED" = false ]; do - # Capture curl output and error for debugging - curl_output=$(curl -fsS --cacert "$ca_cert" --resolve "${host}:${port}:127.0.0.1" "$url" 2>&1) - curl_exit_code=$? + while [ $elapsed -lt $MAX_WAIT_TIME ] && [ "$INTERRUPTED" = false ]; do + # Capture curl output and error for debugging + curl_output=$(curl -fsS --cacert "$ca_cert" --resolve "${host}:${port}:127.0.0.1" "$url" 2>&1) + curl_exit_code=$? - if [ $curl_exit_code -eq 0 ]; then - log_success "$name is ready!" - return 0 - fi + if [ $curl_exit_code -eq 0 ]; then + log_success "$name is ready!" + return 0 + fi - log_info "$name not ready yet, waiting... (${elapsed}s/${MAX_WAIT_TIME}s)" - log_info "Curl error: $curl_output" - sleep $CHECK_INTERVAL - elapsed=$((elapsed + CHECK_INTERVAL)) - done + log_info "$name not ready yet, waiting... (${elapsed}s/${MAX_WAIT_TIME}s)" + log_info "Curl error: $curl_output" + sleep $CHECK_INTERVAL + elapsed=$((elapsed + CHECK_INTERVAL)) + done - if [ "$INTERRUPTED" = true ]; then - log_info "Service check interrupted by user" - return 1 - fi + if [ "$INTERRUPTED" = true ]; then + log_info "Service check interrupted by user" + return 1 + fi - log_error "$name failed to become ready within ${MAX_WAIT_TIME} seconds" - return 1 -} + log_error "$name failed to become ready within ${MAX_WAIT_TIME} seconds" + return 1 + } -# Wait for Rocket.Chat -if ! wait_for_service "https://rc1/api/info" "Rocket.Chat" "rc1"; then - log_error "Last 50 lines of rc1 logs:" - docker logs --tail 50 "$RC1_CONTAINER" 2>&1 | sed 's/^/ /' - exit 1 -fi + # Wait for Rocket.Chat + if ! wait_for_service "https://rc1/api/info" "Rocket.Chat" "rc1"; then + log_error "Last 50 lines of rc1 logs:" + docker logs --tail 50 "$RC1_CONTAINER" 2>&1 | sed 's/^/ /' + exit 1 + fi -# Wait for Synapse -if ! wait_for_service "https://hs1/_matrix/client/versions" "Synapse" "hs1"; then - log_error "Last 50 lines of hs1 logs:" - docker logs --tail 50 "hs1" 2>&1 | sed 's/^/ /' - exit 1 + # Wait for Synapse + if ! wait_for_service "https://hs1/_matrix/client/versions" "Synapse" "hs1"; then + log_error "Last 50 lines of hs1 logs:" + docker logs --tail 50 "hs1" 2>&1 | sed 's/^/ /' + exit 1 + fi fi # Run the end-to-end tests From 6d308ea01316186e70c3debf1011596fb581b5ab Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 14 Jan 2026 16:26:27 -0300 Subject: [PATCH 04/10] chore: Suppress logger output in synapse-client test helper for cleaner test execution --- .../federation-matrix/tests/helper/synapse-client.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ee/packages/federation-matrix/tests/helper/synapse-client.ts b/ee/packages/federation-matrix/tests/helper/synapse-client.ts index 17b61af16cc69..8a23b43c3f3a9 100644 --- a/ee/packages/federation-matrix/tests/helper/synapse-client.ts +++ b/ee/packages/federation-matrix/tests/helper/synapse-client.ts @@ -8,6 +8,12 @@ import * as fs from 'fs'; import * as path from 'path'; import { createClient, type MatrixClient, KnownMembership, type Room, type RoomMember, Visibility } from 'matrix-js-sdk'; +import { logger } from 'matrix-js-sdk/lib/logger'; + +logger.debug = () => void 0; +logger.info = () => void 0; +logger.warn = () => void 0; +logger.error = () => void 0; /** * Creates a promise that resolves after the specified delay. From 516913a6882d5ce860ca72a88d89ef39ad823b4e Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Wed, 14 Jan 2026 16:41:44 -0300 Subject: [PATCH 05/10] no need multiple scripts --- .github/workflows/ci.yml | 6 +++--- ee/packages/federation-matrix/package.json | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d68e13778650e..7dcc2fea48f42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -662,19 +662,19 @@ jobs: ENTERPRISE_LICENSE_RC1: ZAikY+LLaal7mT6RNYxpyWEmMQyucrl50/7pYBXqHczc90j+RLwF+T0xuCT2pIpKMC5DxcZ1TtkV6MYJk5whrwmap+mQ0FV+VpILJlL0i4T21K4vMfzZXTWm/pzcAy2fMTUNH+mUA9HTBD6lYYh40KnbGXPAd80VbZk0MO/WbWBm2dOT0YCwfvlRyurRqkDAQrftLaffzCNUsMKk0fh+MKs73UDHZQDp1yvs7WoGpPu5ZVi5mTBOt3ZKVz5KjGfClLwJptFPmW1w6nKelAiJBDPpjcX1ylfjxpnBoixko7uN52zlyaeoAYwfRcdDLnZ8k0Ou6tui/vTQUXjGIjHw2AhMaKwonn4E9LYpuA1KEXt08qJL5J3ZtjSCV1T+A9Z3zFhhLgp5dxP/PPUbxDn/P8XKp7nXM9duIfcCMlnea7V8ixEyCHwwvKQaXVVidcsUGtB8CwS0GlsAEBLOzqMehuQUK2rdQ4WgEz3AYveikeVvSzgBHvyXsxssWAThc0Mht0eEJqdDhUB2QeZ2WmPsaSSD639Z4WgjSUoR0zh8bfqepH+2XRcUryXe2yN+iU+3POzi9wfg0k65MxXT8pBg3PD5RHnR8oflEP0tpZts33JiBhYRxX3MKplAFm4dMuphTsDJTh+e534pT7IPuZF79QSVaLEWZfVVVb7nGFtmMwA= QASE_TESTOPS_JEST_API_TOKEN: ${{ secrets.QASE_TESTOPS_JEST_API_TOKEN }} PR_NUMBER: ${{ github.event.number }} - run: yarn test:integration:start-containers-only --image "${ROCKETCHAT_IMAGE}" + run: yarn test:integration --start-containers-only --image "${ROCKETCHAT_IMAGE}" - name: Run federation integration tests working-directory: ./ee/packages/federation-matrix env: QASE_TESTOPS_JEST_API_TOKEN: ${{ secrets.QASE_TESTOPS_JEST_API_TOKEN }} PR_NUMBER: ${{ github.event.number }} - run: yarn test:integration:ci + run: yarn test:integration --ci - name: Show federation integration tests logs if: failure() working-directory: ./ee/packages/federation-matrix - run: yarn test:integration:logs + run: yarn test:integration --logs - name: Show rc server logs if tests failed if: failure() diff --git a/ee/packages/federation-matrix/package.json b/ee/packages/federation-matrix/package.json index fe08d98e86018..529f74173da43 100644 --- a/ee/packages/federation-matrix/package.json +++ b/ee/packages/federation-matrix/package.json @@ -13,10 +13,7 @@ "lint": "eslint .", "lint:fix": "eslint --fix .", "test": "jest", - "test:integration:logs": "./tests/scripts/run-integration-tests.sh --logs", - "test:integration:start-containers-only": "./tests/scripts/run-integration-tests.sh --start-containers-only", "test:integration": "./tests/scripts/run-integration-tests.sh", - "test:integration:ci": "./tests/scripts/run-integration-tests.sh --ci", "test:federation": "jest --config jest.config.federation.ts", "testunit": "jest", "typecheck": "tsc --noEmit" From 880d756a07984bedd95a8ad1cd85174166d556be Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Wed, 14 Jan 2026 16:42:00 -0300 Subject: [PATCH 06/10] improve logs --- .github/workflows/ci.yml | 10 ----- .../tests/scripts/run-integration-tests.sh | 38 +++++++++---------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7dcc2fea48f42..8b1e812e67ea3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -676,16 +676,6 @@ jobs: working-directory: ./ee/packages/federation-matrix run: yarn test:integration --logs - - name: Show rc server logs if tests failed - if: failure() - working-directory: ./ee/packages/federation-matrix - run: docker compose -f docker-compose.test.yml logs rc1-prebuilt - - - name: Show hs server logs if tests failed - if: failure() - working-directory: ./ee/packages/federation-matrix - run: docker compose -f docker-compose.test.yml logs hs1 - - name: Show mongo logs if tests failed if: failure() working-directory: ./ee/packages/federation-matrix diff --git a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh index bf18a3119f4d6..175e1e62535bc 100755 --- a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh +++ b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh @@ -122,25 +122,16 @@ log_error() { echo -e "${RED}❌ [$(date '+%Y-%m-%d %H:%M:%S')] $1${NC}" } -docker_log() { - local container=$1 - if docker ps -q -f name=$container | grep -q .; then - docker logs $container 2>&1 | sed 's/^/ /' - else - echo " $container container not found or no logs" - fi -} - docker_logs() { echo "" echo "ROCKET.CHAT (rc1) LOGS:" echo "----------------------------------------" - docker_log "rc1" + docker compose -f "$DOCKER_COMPOSE_FILE" --profile "$COMPOSE_PROFILE" logs rc1 echo "" echo "SYNAPSE (hs1) LOGS:" echo "----------------------------------------" - docker_log "hs1" + docker compose -f "$DOCKER_COMPOSE_FILE" --profile "$COMPOSE_PROFILE" logs hs1 echo "" echo "==========================================" @@ -180,13 +171,9 @@ cleanup() { fi else log_info "Cleaning up services..." - if [ -f "$DOCKER_COMPOSE_FILE" ]; then - if [ "$INCLUDE_ELEMENT" = true ]; then - docker compose -f "$DOCKER_COMPOSE_FILE" --profile "element" down -v 2>/dev/null || true - else - docker compose -f "$DOCKER_COMPOSE_FILE" --profile "test" down -v 2>/dev/null || true - fi - fi + + docker compose -f "$DOCKER_COMPOSE_FILE" --profile "$COMPOSE_PROFILE" down -v 2>/dev/null || true + log_success "Cleanup completed" fi @@ -213,6 +200,17 @@ if [ ! -f "$DOCKER_COMPOSE_FILE" ]; then exit 1 fi +if [ "$USE_PREBUILT_IMAGE" = true ]; then + PROFILE_PREFIX="prebuilt" +else + PROFILE_PREFIX="local" +fi + +if [ "$INCLUDE_ELEMENT" = true ]; then + COMPOSE_PROFILE="element-$PROFILE_PREFIX" +else + COMPOSE_PROFILE="test-$PROFILE_PREFIX" +fi if [ "$START_CONTAINERS" = true ]; then # Build Rocket.Chat locally if not using pre-built image @@ -256,12 +254,12 @@ if [ "$START_CONTAINERS" = true ]; then # Start services if [ "$INCLUDE_ELEMENT" = true ]; then log_info "Starting all federation services including Element web client..." - docker compose -f "$DOCKER_COMPOSE_FILE" --profile element up -d --build else log_info "Starting federation services (test profile only)..." - docker compose -f "$DOCKER_COMPOSE_FILE" --profile test up -d --build fi + docker compose -f "$DOCKER_COMPOSE_FILE" --profile "$COMPOSE_PROFILE" up -d --build + # Wait for rc1 container to be running log_info "Waiting for rc1 container to start..." timeout=60 From 5ca40652f1dd8f32ed0b94cb83ddb8f1b1225b0e Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Wed, 14 Jan 2026 17:14:57 -0300 Subject: [PATCH 07/10] bring back BUILD_PARAM --- .../tests/scripts/run-integration-tests.sh | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh index 175e1e62535bc..35a7261f2c60b 100755 --- a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh +++ b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh @@ -164,11 +164,7 @@ cleanup() { if [ "$INCLUDE_ELEMENT" = true ]; then log_info " - Element: https://element" fi - if [ "$INCLUDE_ELEMENT" = true ]; then - log_info "To stop containers manually, run: docker compose -f $DOCKER_COMPOSE_FILE --profile element down -v" - else - log_info "To stop containers manually, run: docker compose -f $DOCKER_COMPOSE_FILE --profile test down -v" - fi + log_info "To stop containers manually, run: docker compose -f "$DOCKER_COMPOSE_FILE" --profile "$COMPOSE_PROFILE" down -v" else log_info "Cleaning up services..." @@ -200,16 +196,10 @@ if [ ! -f "$DOCKER_COMPOSE_FILE" ]; then exit 1 fi -if [ "$USE_PREBUILT_IMAGE" = true ]; then - PROFILE_PREFIX="prebuilt" -else - PROFILE_PREFIX="local" -fi - if [ "$INCLUDE_ELEMENT" = true ]; then - COMPOSE_PROFILE="element-$PROFILE_PREFIX" + COMPOSE_PROFILE="element" else - COMPOSE_PROFILE="test-$PROFILE_PREFIX" + COMPOSE_PROFILE="test" fi if [ "$START_CONTAINERS" = true ]; then @@ -241,6 +231,8 @@ if [ "$START_CONTAINERS" = true ]; then log_info "🚀 Starting Federation Integration Tests" log_info "=====================================" + BUILD_PARAM="" + # Set environment variables for Docker Compose if [ "$USE_PREBUILT_IMAGE" = true ]; then export ROCKETCHAT_IMAGE="$PREBUILT_IMAGE" @@ -248,6 +240,7 @@ if [ "$START_CONTAINERS" = true ]; then else export ROCKETCHAT_BUILD_CONTEXT="$BUILD_DIR" export ROCKETCHAT_DOCKERFILE="$ROCKETCHAT_ROOT/apps/meteor/.docker/Dockerfile.alpine" + BUILD_PARAM="--build" log_info "Building from local context: $BUILD_DIR" fi @@ -258,7 +251,7 @@ if [ "$START_CONTAINERS" = true ]; then log_info "Starting federation services (test profile only)..." fi - docker compose -f "$DOCKER_COMPOSE_FILE" --profile "$COMPOSE_PROFILE" up -d --build + docker compose -f "$DOCKER_COMPOSE_FILE" --profile "$COMPOSE_PROFILE" up -d $BUILD_PARAM # Wait for rc1 container to be running log_info "Waiting for rc1 container to start..." From fe047ce0767aa270ff0f3d94e9cd3fb0a7a26960 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Wed, 14 Jan 2026 18:00:45 -0300 Subject: [PATCH 08/10] add new flags to --help --- .../tests/scripts/run-integration-tests.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh index 35a7261f2c60b..af96b8b50374d 100755 --- a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh +++ b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh @@ -50,12 +50,12 @@ while [[ $# -gt 0 ]]; do CI=true KEEP_RUNNING=true START_CONTAINERS=false - USE_PREBUILT_IMAGE=true shift ;; --logs) LOGS=true NO_TEST=true + START_CONTAINERS=false shift ;; --keep-running) @@ -84,11 +84,14 @@ while [[ $# -gt 0 ]]; do --help|-h) echo "Usage: $0 [OPTIONS]" echo "Options:" - echo " --keep-running Keep Docker containers running after tests complete" - echo " --element Include Element web client in the test environment" - echo " --no-test Start containers and skip running tests" - echo " --image [IMAGE] Use a pre-built Docker image instead of building locally" - echo " --help, -h Show this help message" + echo " --start-containers-only Start containers and skip running tests" + echo " --ci Run tests in CI mode (keep containers running, no cleanup)" + echo " --logs Show logs of rc1 and hs1 containers" + echo " --keep-running Keep Docker containers running after tests complete" + echo " --element Include Element web client in the test environment" + echo " --no-test Start containers and skip running tests" + echo " --image [IMAGE] Use a pre-built Docker image instead of building locally" + echo " --help, -h Show this help message" echo "" echo "By default, builds Rocket.Chat locally and runs the 'test' profile" echo "Use --image to test against a pre-built image (e.g., --image rocketchat/rocket.chat:latest)" @@ -145,6 +148,7 @@ cleanup() { exit $TEST_EXIT_CODE fi fi + # Show container logs if tests failed if [ -n "${TEST_EXIT_CODE:-}" ] && [ "$TEST_EXIT_CODE" -ne 0 ]; then echo "" @@ -164,7 +168,7 @@ cleanup() { if [ "$INCLUDE_ELEMENT" = true ]; then log_info " - Element: https://element" fi - log_info "To stop containers manually, run: docker compose -f "$DOCKER_COMPOSE_FILE" --profile "$COMPOSE_PROFILE" down -v" + log_info "To stop containers manually, run: docker compose -f \"$DOCKER_COMPOSE_FILE\" --profile \"$COMPOSE_PROFILE\" down -v" else log_info "Cleaning up services..." From 5069880733dd818a1b3b5b84dc89042c81c6ea97 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Wed, 14 Jan 2026 18:13:20 -0300 Subject: [PATCH 09/10] remove RC1_CONTAINER variable --- .../tests/scripts/run-integration-tests.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh index af96b8b50374d..64fe8b066e6a5 100755 --- a/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh +++ b/ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh @@ -20,7 +20,6 @@ PACKAGE_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")" DOCKER_COMPOSE_FILE="$PACKAGE_ROOT/docker-compose.test.yml" MAX_WAIT_TIME=240 # 4 minutes CHECK_INTERVAL=5 # Check every 5 seconds -RC1_CONTAINER="rc1" # Build configuration # Use a temporary directory outside the repo to avoid symlink traversal issues during Meteor build @@ -261,7 +260,7 @@ if [ "$START_CONTAINERS" = true ]; then log_info "Waiting for rc1 container to start..." timeout=60 while [ $timeout -gt 0 ] && [ "$INTERRUPTED" = false ]; do - if docker ps --filter "name=$RC1_CONTAINER" --filter "status=running" | grep -q "$RC1_CONTAINER"; then + if docker compose -f "$DOCKER_COMPOSE_FILE" ps rc1 --filter "status=running" | grep -q "rc1"; then log_success "rc1 container is running" break fi @@ -337,14 +336,14 @@ if [ "$START_CONTAINERS" = true ]; then # Wait for Rocket.Chat if ! wait_for_service "https://rc1/api/info" "Rocket.Chat" "rc1"; then log_error "Last 50 lines of rc1 logs:" - docker logs --tail 50 "$RC1_CONTAINER" 2>&1 | sed 's/^/ /' + docker compose -f "$DOCKER_COMPOSE_FILE" logs --tail 50 rc1 exit 1 fi # Wait for Synapse if ! wait_for_service "https://hs1/_matrix/client/versions" "Synapse" "hs1"; then log_error "Last 50 lines of hs1 logs:" - docker logs --tail 50 "hs1" 2>&1 | sed 's/^/ /' + docker compose -f "$DOCKER_COMPOSE_FILE" logs --tail 50 hs1 exit 1 fi fi From 9d4c4d3ee6206a59d7b01f49082769722675bca0 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Thu, 15 Jan 2026 14:15:36 -0300 Subject: [PATCH 10/10] chore: update @rocket.chat/federation-sdk to version 0.3.9 across multiple package.json and yarn.lock files --- apps/meteor/package.json | 2 +- ee/packages/federation-matrix/package.json | 2 +- packages/core-services/package.json | 2 +- yarn.lock | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/meteor/package.json b/apps/meteor/package.json index d33faf9c0e72b..f3119ef09c0b7 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -99,7 +99,7 @@ "@rocket.chat/emitter": "~0.31.25", "@rocket.chat/favicon": "workspace:^", "@rocket.chat/federation-matrix": "workspace:^", - "@rocket.chat/federation-sdk": "0.3.8", + "@rocket.chat/federation-sdk": "0.3.9", "@rocket.chat/fuselage": "^0.70.0", "@rocket.chat/fuselage-forms": "~0.1.1", "@rocket.chat/fuselage-hooks": "~0.38.1", diff --git a/ee/packages/federation-matrix/package.json b/ee/packages/federation-matrix/package.json index 529f74173da43..7e205339a76df 100644 --- a/ee/packages/federation-matrix/package.json +++ b/ee/packages/federation-matrix/package.json @@ -22,7 +22,7 @@ "@rocket.chat/core-services": "workspace:^", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/emitter": "^0.31.25", - "@rocket.chat/federation-sdk": "0.3.8", + "@rocket.chat/federation-sdk": "0.3.9", "@rocket.chat/http-router": "workspace:^", "@rocket.chat/license": "workspace:^", "@rocket.chat/models": "workspace:^", diff --git a/packages/core-services/package.json b/packages/core-services/package.json index 2f64d2f435a3c..333ad1da9e9f6 100644 --- a/packages/core-services/package.json +++ b/packages/core-services/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "@rocket.chat/core-typings": "workspace:^", - "@rocket.chat/federation-sdk": "0.3.8", + "@rocket.chat/federation-sdk": "0.3.9", "@rocket.chat/http-router": "workspace:^", "@rocket.chat/icons": "~0.46.0", "@rocket.chat/media-signaling": "workspace:^", diff --git a/yarn.lock b/yarn.lock index d5299688aead2..1651c307f759f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8266,7 +8266,7 @@ __metadata: "@rocket.chat/apps-engine": "workspace:^" "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/eslint-config": "workspace:^" - "@rocket.chat/federation-sdk": "npm:0.3.8" + "@rocket.chat/federation-sdk": "npm:0.3.9" "@rocket.chat/http-router": "workspace:^" "@rocket.chat/icons": "npm:~0.46.0" "@rocket.chat/jest-presets": "workspace:~" @@ -8472,7 +8472,7 @@ __metadata: "@rocket.chat/ddp-client": "workspace:^" "@rocket.chat/emitter": "npm:^0.31.25" "@rocket.chat/eslint-config": "workspace:^" - "@rocket.chat/federation-sdk": "npm:0.3.8" + "@rocket.chat/federation-sdk": "npm:0.3.9" "@rocket.chat/http-router": "workspace:^" "@rocket.chat/license": "workspace:^" "@rocket.chat/models": "workspace:^" @@ -8498,9 +8498,9 @@ __metadata: languageName: unknown linkType: soft -"@rocket.chat/federation-sdk@npm:0.3.8": - version: 0.3.8 - resolution: "@rocket.chat/federation-sdk@npm:0.3.8" +"@rocket.chat/federation-sdk@npm:0.3.9": + version: 0.3.9 + resolution: "@rocket.chat/federation-sdk@npm:0.3.9" dependencies: "@datastructures-js/priority-queue": "npm:^6.3.5" "@noble/ed25519": "npm:^3.0.0" @@ -8513,7 +8513,7 @@ __metadata: zod: "npm:^3.24.1" peerDependencies: typescript: ~5.9.2 - checksum: 10/c8a3e8d7bdf68798d20d1d42c7bafd354c934e9d80b94796ef09f073585b1de501ba181b059a3c4b40b92660fd8ee04db6535610932bc64c1c2d147f3a24286c + checksum: 10/8bf215c37fa3c181d12731a2b2f5068656b64736c05560a070ad8dde6177e48cd262a2a26d8cc56e8cee7850f25a3bc5dd069537c4a1ee3f638b0d94cb11519c languageName: node linkType: hard @@ -9140,7 +9140,7 @@ __metadata: "@rocket.chat/eslint-config": "workspace:^" "@rocket.chat/favicon": "workspace:^" "@rocket.chat/federation-matrix": "workspace:^" - "@rocket.chat/federation-sdk": "npm:0.3.8" + "@rocket.chat/federation-sdk": "npm:0.3.9" "@rocket.chat/fuselage": "npm:^0.70.0" "@rocket.chat/fuselage-forms": "npm:~0.1.1" "@rocket.chat/fuselage-hooks": "npm:~0.38.1"