Skip to content

Conversation

@dhulke
Copy link
Contributor

@dhulke dhulke commented Oct 13, 2025

https://rocketchat.atlassian.net/browse/FDR-212

Proposed changes (including videos or screenshots)

Federation integration tests

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Tests

    • Added comprehensive end-to-end federation test suite validating room creation, membership, and history across federated servers.
    • Integrated federation tests into CI pipeline.
  • Chores

    • Extended test infrastructure with federation environment setup, helper utilities, and Docker configuration for cross-server testing scenarios.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 13, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

⚠️ No Changeset found

Latest commit: c6b526c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Oct 13, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

Walkthrough

This PR extends test helper APIs to support injected request configurations and establishes comprehensive federation-matrix end-to-end testing infrastructure, including Jest configuration, Docker orchestration, SynapseClient wrapper, federation test scenarios, and CI integration.

Changes

Cohort / File(s) Summary
Test Helpers - Request Config Abstraction
apps/meteor/tests/data/users.helper.ts, apps/meteor/tests/data/rooms.helper.ts
Added RequestConfig abstraction and updated function signatures across user and room helpers (createUser, login, deleteUser, getUserByUsername, getMe, setUserActiveStatus, setUserStatus, setUserAway, setUserOnline, removeRoleFromUser, createRoom, getRoomInfo, getRoomMembers, findRoomMember, getGroupHistory) to accept optional config parameter for injecting custom request/credentials; new getRequestConfig() function for constructing config instances.
Federation Jest & Build Config
ee/packages/federation-matrix/jest.config.federation.ts, ee/packages/federation-matrix/package.json
Added Jest configuration for federation end-to-end tests with 30s timeout, test discovery patterns, and transformIgnorePatterns; added devDependencies (matrix-js-sdk ^38.4.0, mocha ^11.7.4) and new test-end-to-end script.
Federation Test Helpers
ee/packages/federation-matrix/tests/helper/config.ts, ee/packages/federation-matrix/tests/helper/synapse-client.ts
Added FederationConfig interface and getFederationConfig() helper; implemented SynapseClient wrapper around matrix-js-sdk with methods for room retrieval, member lookup, invitation acceptance, and lifecycle management; includes retry logic with configurable backoff.
Federation Test Infrastructure
ee/packages/federation-matrix/tests/teardown.ts, ee/packages/federation-matrix/.env.example
Added global Jest teardown to close Matrix SDK connections; added example environment file with placeholder license and signing key variables.
Docker Compose Orchestration
ee/packages/federation-matrix/docker-compose.test.yml, ee/packages/federation-matrix/docker-compose/.../*
Added complete Docker compose stack with Traefik, Synapse (hs1), Rocket.Chat (rc1), MongoDB replica set, and Element Web; includes service configurations, Traefik routing/TLS setup, Synapse logging and homeserver configuration, and certificate files.
End-to-End Federation Tests
ee/packages/federation-matrix/tests/end-to-end/room.spec.ts
Added comprehensive federation room test suite validating room creation with federated members, membership across servers, room visibility, and system messages; tests federated user combinations and cross-view consistency.
CI Integration
.github/workflows/ci.yml
Added test-federation-matrix job to CI pipeline with Docker setup, image building, hosts configuration, and federation test execution; integrated into tests-done aggregation.
Git Configuration
.gitignore
Added negated pattern !**/tests/data/ to re-allow tracking of test data files previously ignored.

Sequence Diagram(s)

sequenceDiagram
    participant RC1 as Rocket.Chat (RC1)
    participant HS1 as Synapse (HS1)
    participant Admin as Test Admin
    participant User as Test User
    
    Admin->>RC1: Create federated room with HS1 user
    RC1->>HS1: Send room invitation (federation)
    HS1->>User: Notify room invitation
    User->>HS1: Accept invitation
    HS1->>RC1: Confirm acceptance (federation)
    RC1->>RC1: Update room membership
    Admin->>RC1: Query room info & members
    RC1-->>Admin: Return room state with federated members
    Admin->>HS1: Verify room via SynapseClient
    HS1-->>Admin: Confirm membership across servers
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • apps/meteor/tests/data/users.helper.ts: Review 10+ function signatures for correct RequestConfig threading and fallback logic preservation
  • apps/meteor/tests/data/rooms.helper.ts: Validate createRoom config initialization and new public APIs (getRoomInfo, getRoomMembers, findRoomMember, getGroupHistory) including retry logic
  • ee/packages/federation-matrix/tests/helper/synapse-client.ts: Complex client wrapper with matrix-js-sdk integration, error handling, retry mechanisms, and lifecycle management
  • ee/packages/federation-matrix/tests/end-to-end/room.spec.ts: Extensive federation scenarios with multiple assertions, cross-system validation, and setup/teardown complexity
  • Docker compose configuration: Validate multi-network setup, Traefik routing, TLS configuration, and service provisioning scripts

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • rodrigok
  • sampaiodiego

Poem

🐰 A rabbit hops through federation's maze,
With helpers refined in countless ways,
Matrix clients dance, Docker containers align,
Tests weave threads across the server line,
Synapse and Rocket in harmony combine! 🔗

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: federation-matrix integration tests' clearly summarizes the main change - adding federation-matrix integration tests infrastructure. It is concise, specific, and directly related to the substantial additions of test helpers, configuration, Docker setup, and end-to-end test suite throughout the changeset.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/federation-integration

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 929c0e1 and c6b526c.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (5)
.github/workflows/ci.yml (5)

282-287: Formatting adjustment for matrix service declaration.

The multi-line formatting with trailing commas is a stylistic change that improves readability. No functional changes detected.


614-614: Runner selection for federation tests is intentional.

The job uses ubuntu-24.04-arm (line 614), which is consistent with other heavy-lifting jobs in the workflow (build, packages-build, build-gh-docker-publish) and distinct from lightweight jobs like report-coverage which use ubuntu-24.04 without -arm. This is appropriate for federation testing workloads.


647-650: Host configuration for federation services.

The /etc/hosts configuration (lines 649–650) adds entries for Synapse and Rocket.Chat federation nodes. Confirm these hostnames (hs1, rc1) align with your Synapse deployment configuration and Docker Compose setup for federation tests.


714-714: Federation matrix test integrated into CI completion criteria.

The tests-done job now correctly:

  • Declares dependency on test-federation-matrix (line 714)
  • Enforces success result check (lines 747–749)

This ensures CI will fail if federation tests fail, preventing regressions. Integration looks correct.

Also applies to: 747-749


611-657: Verify ENTERPRISE_LICENSE_RC1 secret is configured in repository settings.

The federation test setup is properly configured: yarn test:integration script is defined in ee/packages/federation-matrix/package.json pointing to ./tests/scripts/run-integration-tests.sh, and all required federation test infrastructure exists (Jest configuration, Synapse client wrapper, and end-to-end tests).

Confirm that the ENTERPRISE_LICENSE_RC1 secret is configured in the repository settings before merging, as it is required by the CI job at line 656.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dhulke dhulke changed the title Test/federation integration DRAFT: Test/federation integration Oct 13, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

♻️ Duplicate comments (4)
apps/meteor/tests/data/rooms.helper.ts (1)

224-239: LGTM!

The getGroupHistory function correctly implements the config pattern and provides proper type safety.

Note: The code duplication concern was already raised in the review comment for getRoomMembers (lines 169-184).

apps/meteor/tests/data/users.helper.ts (3)

159-193: Inconsistent config.credentials handling in both functions.

Both setUserAway and setUserOnline suffer from the same inconsistency: they only use config?.request and ignore config?.credentials, using overrideCredentials instead.

Apply the same fix to both functions:

 export const setUserAway = (
   overrideCredentials = credentials,
   config?: RequestConfig
 ) => {
   const requestInstance = config?.request || request;
+  const credentialsInstance = config?.credentials || overrideCredentials;
   return requestInstance
     .post(methodCall('UserPresence:away'))
-    .set(overrideCredentials)
+    .set(credentialsInstance)
     .send({
       // ...
     });
 };

 export const setUserOnline = (
   overrideCredentials = credentials,
   config?: RequestConfig
 ) => {
   const requestInstance = config?.request || request;
+  const credentialsInstance = config?.credentials || overrideCredentials;
   return requestInstance
     .post(methodCall('UserPresence:online'))
-    .set(overrideCredentials)
+    .set(credentialsInstance)
     .send({
       // ...
     });
 };

147-157: Inconsistent config.credentials handling.

Similar to getMe (lines 112-126), this function only uses config?.request and ignores config?.credentials, using overrideCredentials instead. This inconsistency should be addressed.

Apply the same fix as suggested for getMe:

 export const setUserStatus = (
   overrideCredentials = credentials, 
   status = UserStatus.ONLINE,
   config?: RequestConfig
 ) => {
   const requestInstance = config?.request || request;
+  const credentialsInstance = config?.credentials || overrideCredentials;
-  return requestInstance.post(api('users.setStatus')).set(overrideCredentials).send({
+  return requestInstance.post(api('users.setStatus')).set(credentialsInstance).send({
     message: '',
     status,
   });
 };

195-211: Inconsistent config.credentials handling.

The function correctly passes config to getUserByUsername but then ignores config?.credentials when making the update request, using overrideCredentials instead.

Apply this diff:

 export const removeRoleFromUser = (
   username: string, 
   roleId: string, 
   overrideCredentials = credentials,
   config?: RequestConfig
 ) =>
   getUserByUsername(username, config).then((user) => {
     const requestInstance = config?.request || request;
+    const credentialsInstance = config?.credentials || overrideCredentials;
     return requestInstance
       .post(api('users.update'))
-      .set(overrideCredentials)
+      .set(credentialsInstance)
       .send({
         userId: user._id,
         data: { roles: user.roles.filter((role) => role !== roleId) },
       })
       .expect(200);
   });
🧹 Nitpick comments (12)
apps/meteor/tests/data/rooms.helper.ts (2)

169-184: Prefer a helper function to reduce duplication.

The config resolution and promise wrapper pattern is repeated across getRoomInfo, getRoomMembers, and getGroupHistory. Consider extracting a generic helper function to reduce duplication.

Example helper:

const makeRoomRequest = <TEndpoint extends keyof Endpoints>(
  endpoint: TEndpoint,
  query: Record<string, any>,
  config?: RequestConfig
): Promise<ReturnType<Endpoints[TEndpoint]['GET']>> => {
  const requestInstance = config?.request || request;
  const credentialsInstance = config?.credentials || credentials;
  
  return new Promise((resolve) => {
    void requestInstance
      .get(api(endpoint))
      .set(credentialsInstance)
      .query(query)
      .end((_err: any, req: any) => {
        resolve(req.body);
      });
  });
};

Then simplify each function to:

export const getRoomMembers = (roomId: IRoom['_id'], config?: RequestConfig) =>
  makeRoomRequest('rooms.membersOrderedByRole', { roomId }, config);

186-222: LGTM! Optional: Consider structured logging.

The retry logic with configurable delays and error handling is well-implemented. The function correctly handles the initial delay, retry loop, and returns null when the member is not found.

The console.warn on line 213 may create noisy test output. Consider using a structured logging approach or a debug flag to control logging verbosity in test environments.

apps/meteor/tests/data/users.helper.ts (3)

10-13: Consider typing the request property.

The request property is typed as any, which sacrifices type safety. Consider typing it as supertest.SuperTest<supertest.Test> to enable better IntelliSense and catch type errors at compile time.

Apply this diff:

+import type supertest from 'supertest';
+
 export interface RequestConfig {
   credentials: Credentials;
-  request: any;
+  request: supertest.SuperTest<supertest.Test>;
 }

15-23: Consider refactoring the credentials bootstrapping.

The function works correctly but has two areas for improvement:

  1. Line 17: Casting an empty object as Credentials ({} as Credentials) is a type-safety escape hatch. While this works because login doesn't use the credentials parameter when building the login request itself, it's fragile.

  2. Line 21: The object property can use shorthand syntax.

Consider one of these approaches:

Option 1: Make the dependency explicit

 export async function getRequestConfig(domain: string, user: string, password: string): Promise<RequestConfig> {
   const request = supertest(domain);
-  const credentials = await login(user, password, { request, credentials: {} as Credentials });
+  // Login doesn't need credentials parameter for the initial login call itself
+  const credentials = await login(user, password, { request, credentials: null as any as Credentials });
   
   return {
     credentials,
-    request: request,
+    request,
   };
 }

Option 2: Add an overload to login that doesn't require credentials in config

This would require changes to the login signature and RequestConfig interface to make credentials optional.


42-48: Remove redundant password in send payload.

Line 48 includes password: userData.password and then spreads ...userData. If userData contains a password property, it will override the explicit one, making the explicit declaration redundant. If userData.password is undefined, spreading it would still work correctly.

Apply this diff:

 void requestInstance
   .post(api('users.create'))
   .set(credentialsInstance)
-  .send({ email, name: username, username, password: userData.password, ...userData })
+  .send({ email, name: username, username, ...userData })

Note: This assumes userData.password is meant to be passed via the spread operator.

ee/packages/federation-matrix/tests/helper/config.ts (1)

4-15: Add rc1.homeserver to config (avoid deriving Matrix domain from API URL)

Tests currently derive the RC Matrix ID domain from rc1.apiUrl by string replacement. That’s brittle if the URL includes ports/paths. Mirror hs1.homeserver with rc1.homeserver.

Example change:

 export interface FederationConfig {
   rc1: {
     apiUrl: string;
+    homeserver: string;
     adminUser: string;
     adminPassword: string;
     adminMatrixUserId: string;
     additionalUser1: {
       username: string;
       password: string;
       matrixUserId: string;
     };
   };
 rc1: {
   apiUrl: validateEnvVar('FEDERATION_RC1_API_URL', process.env.FEDERATION_RC1_API_URL, 'https://rc1'),
+  homeserver: validateEnvVar('FEDERATION_RC1_HOMESERVER', process.env.FEDERATION_RC1_HOMESERVER, 'rc1'),
   adminUser: validateEnvVar('FEDERATION_RC1_ADMIN_USER', process.env.FEDERATION_RC1_ADMIN_USER, 'admin'),
   ...
 },

Also applies to: 49-59

ee/packages/federation-matrix/tests/teardown.ts (1)

6-15: Teardown should explicitly stop Matrix clients/websockets

Relying on GC + delay won’t close SDK connections. Prefer an explicit registry and stop/logout all clients (e.g., client.stopClient(), remove listeners, close transports). This reduces reliance on forceExit/detectOpenHandles.

If feasible, expose a lightweight global registry (register/unregister) from your Synapse client helper and drain it here.

ee/packages/federation-matrix/tests/end-to-end/federation.spec.ts (3)

1-5: Simplify noisy relative import paths

../../.././../../ is harder to read and maintain. Use clean relative paths or TS path aliases.

Example:

-import { IS_EE } from '../../.././../../apps/meteor/tests/e2e/config/constants';
+import { IS_EE } from '../../../../apps/meteor/tests/e2e/config/constants';

33-37: Avoid deriving Matrix IDs from API URL

rc1User1MatrixId is built by stripping schemes from apiUrl. Use a dedicated rc1.homeserver from config (mirrors hs1.homeserver) to compute @user:domain.

Use: @${rc1User1Username}:${federationConfig.rc1.homeserver}


24-81: Consider removing per-hook timeouts; rely on Jest’s 30s E2E default

beforeAll(..., 10000/15000) may be tight for federation propagation. Prefer the 30s default from Jest config (or increase if flakes observed).

Remove the numeric timeout arg or bump to match global.

Also applies to: 200-238, 355-386

ee/packages/federation-matrix/tests/helper/synapse-client.ts (2)

26-31: Wait for initial sync before using the client

startClient() may return before rooms/memberships are available. Wait for first sync event to reduce flakiness.

 async initialize(): Promise<void> {
   const client = await this.createClient(this.username, this.password, this.url);
-  await client.startClient();
+  await client.startClient();
+  await new Promise<void>((resolve) => {
+    client.once('sync', () => resolve());
+  });
   this.matrixClient = client;
 }

180-189: Harden cleanup to avoid unhandled rejections during teardown

Wrap cleanup in try/catch to keep tests from failing on logout/clear errors.

 async close(): Promise<void> {
   if (this.matrixClient) {
-    this.matrixClient.stopClient();
-    await this.matrixClient.store?.deleteAllData?.();
-    await this.matrixClient.clearStores?.();
-    this.matrixClient.removeAllListeners();
-    await this.matrixClient.logout(true);
+    try {
+      this.matrixClient.stopClient();
+      await this.matrixClient.store?.deleteAllData?.();
+      await this.matrixClient.clearStores?.();
+      this.matrixClient.removeAllListeners();
+      await this.matrixClient.logout(true);
+    } catch {
+      // swallow cleanup errors in tests
+    }
     this.matrixClient = null;
   }
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4711b48 and 10f3ea2.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (11)
  • apps/meteor/.mocharc.federation.js (1 hunks)
  • apps/meteor/package.json (1 hunks)
  • apps/meteor/tests/data/api-data.ts (1 hunks)
  • apps/meteor/tests/data/rooms.helper.ts (5 hunks)
  • apps/meteor/tests/data/users.helper.ts (4 hunks)
  • ee/packages/federation-matrix/jest.config.federation.ts (1 hunks)
  • ee/packages/federation-matrix/package.json (1 hunks)
  • ee/packages/federation-matrix/tests/end-to-end/federation.spec.ts (1 hunks)
  • ee/packages/federation-matrix/tests/helper/config.ts (1 hunks)
  • ee/packages/federation-matrix/tests/helper/synapse-client.ts (1 hunks)
  • ee/packages/federation-matrix/tests/teardown.ts (1 hunks)
🔇 Additional comments (14)
apps/meteor/tests/data/api-data.ts (1)

3-7: Import spacing looks good

Blank line cleanly separates third-party imports from local modules; no issues here.

apps/meteor/.mocharc.federation.js (1)

7-20: Verify that referenced paths exist in the repository.

The configuration looks correct overall. The timeout, bail, and retries settings are appropriate for integration tests. However, ensure that the referenced files and directories exist:

  • .mocharc.base.json (base configuration)
  • tests/end-to-end/teardown.ts (teardown file)
  • tests/end-to-end/federation/**/* (test spec pattern)
  • tests/setup/chaiPlugins.ts (Chai plugins setup)

Run the following script to verify the paths:

apps/meteor/tests/data/rooms.helper.ts (5)

2-6: LGTM!

The new imports are necessary for the added functionality: IUser for the findRoomMember return type, Endpoints for typed API responses, and RequestConfig for the new config parameter pattern.


18-18: LGTM!

Adding the optional config parameter aligns with the pattern established in users.helper.ts and maintains backward compatibility.


31-38: LGTM!

The config-based request/credentials resolution is well-designed. The three-way fallback for credentialsInstance (config?.credentials || customCredentials || credentials) correctly maintains backward compatibility with the existing customCredentials parameter while supporting the new config mechanism.


46-50: LGTM!

The room creation logic correctly uses the derived requestInstance and credentialsInstance, maintaining consistency across both voip and generic room creation paths.

Also applies to: 68-75


152-167: LGTM!

The getRoomInfo function correctly implements the config pattern and provides proper type safety with ReturnType<Endpoints['/v1/rooms.info']['GET']>.

apps/meteor/tests/data/users.helper.ts (4)

57-76: LGTM!

The login function correctly implements the config pattern, using only config?.request (credentials are not applicable for the login operation itself).


95-110: LGTM!

The getUserByUsername function correctly implements the config pattern with proper type safety.


128-145: LGTM!

The setUserActiveStatus function correctly implements the config pattern.


78-93: Verify that the async function change is non-breaking.

The function signature changed from a synchronous function returning a request object to an async function. Ensure that all callers of deleteUser are updated to handle the new async signature.

Run the following script to check all usages of deleteUser:

ee/packages/federation-matrix/jest.config.federation.ts (1)

4-21: Jest federation config looks good

Preset, E2E matchers, teardown, and transformIgnore for matrix-js-sdk are correctly set.

ee/packages/federation-matrix/package.json (1)

17-18: Remove unused Mocha and drop duplicated CLI flags in test script

  • Jest is the configured runner; Mocha appears unused here. Remove it to avoid drift.
  • --forceExit and --testTimeout are already set in jest.config.federation.ts; keep config as single source of truth.

Run this to confirm Mocha is unused:

Proposed edits:

 "devDependencies": {
   ...
-  "matrix-js-sdk": "^38.4.0",
-  "mocha": "^11.7.4",
+  "matrix-js-sdk": "^38.4.0",
   ...
 },
 "scripts": {
   ...
-  "testendtoend": "IS_EE=true jest --config jest.config.federation.ts --forceExit --testTimeout=30000",
+  "testendtoend": "IS_EE=true jest --config jest.config.federation.ts",
   ...
 }

Also applies to: 26-26

ee/packages/federation-matrix/tests/helper/synapse-client.ts (1)

152-177: Constructing userId from URL is fragile; add timeout to admin fetch and ensure Node fetch availability

String replace can leave trailing slashes/paths in the homeserver part (invalid userId). Use URL.host. Add an AbortController timeout to avoid hanging tests. Ensure Node provides global fetch or polyfill.

-		const userId = `@${username}:${this.url.replace('https://', '').replace('http://', '')}`;
+		const host = new URL(this.url).host; // e.g., synapse:8008
+		const userId = `@${username}:${host}`;
 		
 		try {
 			// Use the admin API to create a user
-			const response = await fetch(`${this.url}/_synapse/admin/v2/users/${encodeURIComponent(userId)}`, {
+			const controller = new AbortController();
+			const timeout = setTimeout(() => controller.abort(), 20_000);
+			const response = await fetch(`${this.url}/_synapse/admin/v2/users/${encodeURIComponent(userId)}`, {
 				method: 'PUT',
 				headers: {
 					'Authorization': `Bearer ${this.matrixClient.getAccessToken()}`,
 					'Content-Type': 'application/json',
 				},
 				body: JSON.stringify({
 					password,
 					displayname: displayName || username,
 					admin: false,
 				}),
-			});
+				signal: controller.signal,
+			}).finally(() => clearTimeout(timeout));

Action: Confirm CI/test Node version exposes global fetch; otherwise import a polyfill (e.g., undici or node-fetch) for the test environment.

@dhulke dhulke force-pushed the test/federation-integration branch from 10f3ea2 to a80be3a Compare October 15, 2025 12:12
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (5)
apps/meteor/.mocharc.federation.js (1)

3-5: Update the comment to reflect federation tests.

The comment incorrectly states "REST API integration tests" but this file configures federation integration tests.

ee/packages/federation-matrix/tests/helper/config.ts (1)

55-57: Align label strings with env var keys for additionalUser1

Labels should match the actual envs to avoid misleading errors.

- username: validateEnvVar('FEDERATION_RC1_ADDITIONAL_USER', process.env.FEDERATION_RC1_ADDITIONAL_USER1, 'user2'),
- password: validateEnvVar('FEDERATION_RC1_ADDITIONAL_PASSWORD', process.env.FEDERATION_RC1_ADDITIONAL_USER1_PASSWORD, 'user2pass'),
- matrixUserId: validateEnvVar('FEDERATION_RC1_ADDITIONAL_USER_ID', process.env.FEDERATION_RC1_ADDITIONAL_USER1_MATRIX_ID, '@user2:rc1'),
+ username: validateEnvVar('FEDERATION_RC1_ADDITIONAL_USER1', process.env.FEDERATION_RC1_ADDITIONAL_USER1, 'user2'),
+ password: validateEnvVar('FEDERATION_RC1_ADDITIONAL_USER1_PASSWORD', process.env.FEDERATION_RC1_ADDITIONAL_USER1_PASSWORD, 'user2pass'),
+ matrixUserId: validateEnvVar('FEDERATION_RC1_ADDITIONAL_USER1_MATRIX_ID', process.env.FEDERATION_RC1_ADDITIONAL_USER1_MATRIX_ID, '@user2:rc1'),
@@
- username: validateEnvVar('FEDERATION_SYNAPSE_ADDITIONAL_USER', process.env.FEDERATION_SYNAPSE_ADDITIONAL_USER1, 'user2'),
- password: validateEnvVar('FEDERATION_SYNAPSE_ADDITIONAL_PASSWORD', process.env.FEDERATION_SYNAPSE_ADDITIONAL_USER1_PASSWORD, 'user2pass'),
- matrixUserId: validateEnvVar('FEDERATION_SYNAPSE_ADDITIONAL_USER_ID', process.env.FEDERATION_SYNAPSE_ADDITIONAL_USER1_MATRIX_ID, '@user2:hs1'),
+ username: validateEnvVar('FEDERATION_SYNAPSE_ADDITIONAL_USER1', process.env.FEDERATION_SYNAPSE_ADDITIONAL_USER1, 'user2'),
+ password: validateEnvVar('FEDERATION_SYNAPSE_ADDITIONAL_USER1_PASSWORD', process.env.FEDERATION_SYNAPSE_ADDITIONAL_USER1_PASSWORD, 'user2pass'),
+ matrixUserId: validateEnvVar('FEDERATION_SYNAPSE_ADDITIONAL_USER1_MATRIX_ID', process.env.FEDERATION_SYNAPSE_ADDITIONAL_USER1_MATRIX_ID, '@user2:hs1'),

Also applies to: 68-70

ee/packages/federation-matrix/tests/helper/synapse-client.ts (3)

67-76: Same guard for membership lookup; simplify error message

-getRoomIdByRoomNameAndMembership(roomName: string, membership: KnownMembership): string {
-    const room = this.matrixClient?.getRooms()
-        .find(room => room.name === roomName && room.getMyMembership() === membership);
+getRoomIdByRoomNameAndMembership(roomName: string, membership: KnownMembership): string {
+    if (!this.matrixClient) {
+        throw new Error('Matrix client not initialized');
+    }
+    const room = this.matrixClient.getRooms().find(
+        (room) => room.name === roomName && room.getMyMembership() === membership,
+    );
     
     if (room) {
         return room.roomId;
     }
 
-    throw new Error(`No room found with name ${roomName} and membership ${membership.toString()}`);
+    throw new Error(`No room found with name ${roomName} and membership ${membership}`);
 }

56-65: Guard client initialization; avoid calling .find on undefined

-getRoom(roomName: string): Room {
-    const room = this.matrixClient?.getRooms()
-        .find(room => room.name === roomName);
+getRoom(roomName: string): Room {
+    if (!this.matrixClient) {
+        throw new Error('Matrix client not initialized');
+    }
+    const room = this.matrixClient.getRooms().find((room) => room.name === roomName);
     
     if (room) {
         return room;
     }
 
     throw new Error(`No room found with name ${roomName}`);
 }

78-102: Invitation acceptance: guard init, clamp retries, remove optional join, don’t throw null

 async acceptInvitationForRoomName(
   roomName: string,
   maxRetries: number = 5,
   retryDelay: number = 1000,
   initialDelay: number = 5000
 ): Promise<string> {
-    if (initialDelay) {
+    if (!this.matrixClient) {
+        throw new Error('Matrix client not initialized');
+    }
+    if (initialDelay) {
         await wait(initialDelay);
     }
-    let lastError: Error | null = null;
-    for (let attempt = 1; attempt <= maxRetries; attempt++) {
+    const retries = Math.max(1, maxRetries);
+    let lastError: unknown = null;
+    for (let attempt = 1; attempt <= retries; attempt++) {
         try {
             const roomId = this.getRoomIdByRoomNameAndMembership(roomName, KnownMembership.Invite);
-            await this.matrixClient?.joinRoom(roomId);
+            await this.matrixClient.joinRoom(roomId);
             return roomId;
         } catch (error) {
-            if (attempt < maxRetries) {
+            if (attempt < retries) {
                 await wait(retryDelay);
             }
-            lastError = error as Error;
+            lastError = error;
         }
     }
-    
-    throw lastError;
+
+    throw new Error(
+        `Failed to accept invitation for "${roomName}" after ${retries} attempts: ${
+            (lastError as Error | undefined)?.message ?? lastError
+        }`,
+    );
 }
🧹 Nitpick comments (6)
ee/packages/federation-matrix/docker-compose/traefik/dynamic_conf.yml (1)

33-37: Avoid hard-coding host.docker.internal; prefer container DNS or config flag.

host.docker.internal can fail on Linux. Consider pointing to the Rocket.Chat container by name on the Docker network, or make the backend URL configurable for CI/dev.

Example (if RC container is named rc1):

-        servers:
-          - url: "http://host.docker.internal:3000"
+        servers:
+          - url: "http://rc1:3000"

If you must reach the host, document Linux setup (extra_hosts) or gate the URL behind an env template used to generate this file.

apps/meteor/tests/data/rooms.helper.ts (2)

186-222: Optional: make retry helper cancellable and surface final error.

To improve test ergonomics, add an optional AbortSignal/timeout and throw last error when no match is found (behind a flag) to aid debugging.

Example minimal tweaks:

  • Accept options: { signal?: AbortSignal; throwOnNotFound?: boolean }.
  • Before each wait, check signal?.aborted.
  • After loop, if throwOnNotFound, throw new Error with username/roomId context.

152-167: Minor: use ‘res’ in callbacks for clarity, and consider rejecting on HTTP errors.

Current pattern ignores _err; optionally reject on non-2xx to fail fast in tests. Variable rename improves readability.

- .end((_err: any, req: any) => {
-   resolve(req.body);
- });
+ .end((err: any, res: any) => {
+   if (err) return reject(err);
+   resolve(res.body);
+ });

Also applies to: 224-239

ee/packages/federation-matrix/scripts/run-integration-tests.sh (2)

16-23: Fix SC2155 and reuse CA path

Avoid command-substitution in export and define a reusable CA_CERT:

@@
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-PACKAGE_ROOT="$(dirname "$SCRIPT_DIR")"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+PACKAGE_ROOT="$(dirname "$SCRIPT_DIR")"
+CA_CERT="$PACKAGE_ROOT/docker-compose/traefik/certs/ca/rootCA.crt"
@@
-# Set NODE_EXTRA_CA_CERTS to use the custom CA certificate
-export NODE_EXTRA_CA_CERTS="$(pwd)/docker-compose/traefik/certs/ca/rootCA.crt"
+# Set NODE_EXTRA_CA_CERTS to use the custom CA certificate
+export NODE_EXTRA_CA_CERTS="$CA_CERT"

Also applies to: 200-208


124-131: Compose v2 compatibility: use docker compose when available

Many environments only ship the v2 plugin. Prefer docker compose, fallback to docker-compose.

@@
-# Start services
+# Start services
+COMPOSE_CMD="docker compose"
+if ! $COMPOSE_CMD version >/dev/null 2>&1; then
+  COMPOSE_CMD="docker-compose"
+fi
@@
-    docker-compose -f "$DOCKER_COMPOSE_FILE" --profile test --profile element up -d --build
+    $COMPOSE_CMD -f "$DOCKER_COMPOSE_FILE" --profile test --profile element up -d --build
@@
-    docker-compose -f "$DOCKER_COMPOSE_FILE" --profile test up -d --build
+    $COMPOSE_CMD -f "$DOCKER_COMPOSE_FILE" --profile test up -d --build

And in cleanup:

-                docker-compose -f "$DOCKER_COMPOSE_FILE" --profile test --profile element down -v 2>/dev/null || true
+                $COMPOSE_CMD -f "$DOCKER_COMPOSE_FILE" --profile test --profile element down -v 2>/dev/null || true
@@
-                docker-compose -f "$DOCKER_COMPOSE_FILE" --profile test down -v 2>/dev/null || true
+                $COMPOSE_CMD -f "$DOCKER_COMPOSE_FILE" --profile test down -v 2>/dev/null || true

Also applies to: 91-100, 93-97

ee/packages/federation-matrix/tests/end-to-end/room.spec.ts (1)

114-121: Reduce flakiness: increase retries or initial delays for federation joins

Federation syncs can be slow; current delays may be tight. Consider bumping initialDelay/retry counts in acceptInvitationForRoomName/findRoomMember calls to reduce intermittent failures.

Also applies to: 219-230, 374-377, 447-467

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 10f3ea2 and 38eec4b.

📒 Files selected for processing (21)
  • apps/meteor/.mocharc.federation.js (1 hunks)
  • apps/meteor/package.json (1 hunks)
  • apps/meteor/tests/data/api-data.ts (1 hunks)
  • apps/meteor/tests/data/rooms.helper.ts (5 hunks)
  • apps/meteor/tests/data/users.helper.ts (4 hunks)
  • ee/packages/federation-matrix/.env.example (1 hunks)
  • ee/packages/federation-matrix/docker-compose.test.yml (1 hunks)
  • ee/packages/federation-matrix/docker-compose/element/config.json (1 hunks)
  • ee/packages/federation-matrix/docker-compose/hs1/homeserver.yaml (1 hunks)
  • ee/packages/federation-matrix/docker-compose/hs1/hs1.log.config (1 hunks)
  • ee/packages/federation-matrix/docker-compose/hs1/hs1.signing.key (1 hunks)
  • ee/packages/federation-matrix/docker-compose/traefik/certs/ca/rootCA.crt (1 hunks)
  • ee/packages/federation-matrix/docker-compose/traefik/dynamic_conf.yml (1 hunks)
  • ee/packages/federation-matrix/docker-compose/traefik/traefik.yml (1 hunks)
  • ee/packages/federation-matrix/jest.config.federation.ts (1 hunks)
  • ee/packages/federation-matrix/package.json (1 hunks)
  • ee/packages/federation-matrix/scripts/run-integration-tests.sh (1 hunks)
  • ee/packages/federation-matrix/tests/end-to-end/room.spec.ts (1 hunks)
  • ee/packages/federation-matrix/tests/helper/config.ts (1 hunks)
  • ee/packages/federation-matrix/tests/helper/synapse-client.ts (1 hunks)
  • ee/packages/federation-matrix/tests/teardown.ts (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • ee/packages/federation-matrix/docker-compose/element/config.json
  • ee/packages/federation-matrix/docker-compose/hs1/hs1.signing.key
  • ee/packages/federation-matrix/.env.example
  • ee/packages/federation-matrix/docker-compose/traefik/certs/ca/rootCA.crt
🚧 Files skipped from review as they are similar to previous changes (6)
  • ee/packages/federation-matrix/tests/teardown.ts
  • ee/packages/federation-matrix/jest.config.federation.ts
  • apps/meteor/tests/data/api-data.ts
  • apps/meteor/tests/data/users.helper.ts
  • ee/packages/federation-matrix/package.json
  • apps/meteor/package.json
🧰 Additional context used
🧬 Code graph analysis (3)
ee/packages/federation-matrix/tests/end-to-end/room.spec.ts (4)
ee/packages/federation-matrix/tests/helper/synapse-client.ts (2)
  • SynapseClient (13-157)
  • findRoomMember (110-145)
apps/meteor/tests/data/users.helper.ts (2)
  • getRequestConfig (15-23)
  • createUser (25-55)
apps/meteor/tests/data/rooms.helper.ts (1)
  • getGroupHistory (224-239)
packages/core-typings/src/IMessage/IMessage.ts (1)
  • IMessage (138-239)
ee/packages/federation-matrix/tests/helper/synapse-client.ts (1)
apps/meteor/tests/data/api-data.ts (1)
  • wait (14-16)
apps/meteor/tests/data/rooms.helper.ts (4)
apps/meteor/tests/data/users.helper.ts (1)
  • RequestConfig (10-13)
apps/meteor/tests/data/api-data.ts (3)
  • request (11-11)
  • credentials (40-43)
  • api (47-49)
packages/rest-typings/src/index.ts (1)
  • Endpoints (51-98)
packages/core-typings/src/IUser.ts (1)
  • IUser (186-255)
🪛 Shellcheck (0.11.0)
ee/packages/federation-matrix/scripts/run-integration-tests.sh

[warning] 205-205: Declare and assign separately to avoid masking return values.

(SC2155)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (4)
apps/meteor/.mocharc.federation.js (1)

7-20: LGTM! Configuration is appropriate for federation integration tests.

The Mocha configuration is well-structured:

  • Appropriate timeout (10s) and slow threshold (6s) for integration tests
  • bail: true ensures fail-fast behavior
  • Spec pattern correctly targets federation tests
  • Required modules (ts-node, chai plugins) are properly configured
apps/meteor/tests/data/rooms.helper.ts (2)

31-39: Config-driven request/credentials injection looks good.

Using requestInstance/credentialsInstance with config fallbacks is clean and backward compatible.

Also applies to: 46-50, 68-75


169-184: No action needed: endpoint ‘rooms.membersOrderedByRole’ is defined in rest-typings and implemented in the server.

ee/packages/federation-matrix/docker-compose/hs1/hs1.log.config (1)

24-28: Logging config is appropriate for tests.

Console-only with SQL logger at INFO avoids sensitive debug logs. LGTM.

Also applies to: 32-37

Base automatically changed from release-7.11.0 to master October 17, 2025 18:29
@ggazzo ggazzo marked this pull request as draft October 18, 2025 11:20
@dhulke dhulke changed the base branch from master to develop October 20, 2025 14:46
@dhulke dhulke force-pushed the test/federation-integration branch 2 times, most recently from 374e5a7 to 7d34b34 Compare October 21, 2025 13:56
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.96%. Comparing base (de830b6) to head (c6b526c).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37219      +/-   ##
===========================================
- Coverage    68.97%   68.96%   -0.01%     
===========================================
  Files         3358     3358              
  Lines       114228   114228              
  Branches     20537    20537              
===========================================
- Hits         78786    78782       -4     
- Misses       33349    33353       +4     
  Partials      2093     2093              
Flag Coverage Δ
e2e 57.42% <ø> (-0.02%) ⬇️
e2e-api 42.87% <ø> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dhulke dhulke changed the title DRAFT: Test/federation integration chore: federation-matrix integration tests Oct 22, 2025
@dhulke dhulke force-pushed the test/federation-integration branch 2 times, most recently from 190130b to a595175 Compare October 25, 2025 23:12
@dhulke dhulke force-pushed the test/federation-integration branch 2 times, most recently from f386011 to 5b13ae1 Compare October 28, 2025 13:45
@dhulke dhulke marked this pull request as ready for review November 14, 2025 14:44
@dhulke dhulke requested a review from a team as a code owner November 14, 2025 14:44
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/meteor/app/lib/server/functions/createRoom.ts (1)

123-123: Consider refactoring to reduce complexity in future work.

The complexity directive suppresses a legitimate maintainability concern. The createRoom function handles numerous responsibilities across ~190 lines: validation, permission checks, Apps engine integration, room creation, subscriptions, callbacks, and federation logic. While acceptable for this test-focused PR, consider decomposing this function in future work—for example, extracting validation, permission checks, and Apps engine interactions into separate helper functions.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 38eec4b and 4ff80ac.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml (6 hunks)
  • .gitignore (1 hunks)
  • apps/meteor/app/lib/server/functions/createRoom.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37357
File: ee/packages/federation-matrix/src/setup.ts:103-120
Timestamp: 2025-11-05T21:04:35.787Z
Learning: In Rocket.Chat's federation-matrix setup (ee/packages/federation-matrix/src/setup.ts and apps/meteor/ee/server/startup/federation.ts), configureFederationMatrixSettings does not need to be called before setupFederationMatrix. The SDK's init() establishes infrastructure (database, event handlers, APIs) first, and the configuration can be applied later via settings watchers before actual federation events are processed. The config only matters when events actually occur, at which point all infrastructure is already configured.
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Learnt from: rodrigok
Repo: RocketChat/Rocket.Chat PR: 36991
File: apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts:219-221
Timestamp: 2025-09-19T15:15:04.642Z
Learning: The Federation_Matrix_homeserver_domain setting in apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts is part of the old federation system and is being deprecated/removed, so configuration issues with this setting should not be flagged for improvement.
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.

Applied to files:

  • apps/meteor/app/lib/server/functions/createRoom.ts
📚 Learning: 2025-11-04T16:49:19.107Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.

Applied to files:

  • apps/meteor/app/lib/server/functions/createRoom.ts
🔇 Additional comments (6)
.gitignore (1)

57-58: Pattern allows test data to be tracked as intended for federation tests.

The negation rule on Line 58 correctly re-includes tests/data/ directories while preserving the parent data/ ignore rule. This is consistent with existing negation patterns in the file (e.g., .yarn/ exceptions on lines 39–42) and aligns with the PR objective to introduce federation-matrix integration tests.

.github/workflows/ci.yml (5)

633-633: Verify that the ENTERPRISE_LICENSE_RC1 secret is defined.

The step references secrets.ENTERPRISE_LICENSE_RC1, but this secret may not be configured in the repository. The release-versions job uses a dummy enterprise license (enterprise-license) for similar purposes. Confirm that this secret exists and is properly configured in the repository settings.

To verify the secret is defined, you can check the repository secrets via GitHub CLI or web interface. If this is a new secret, ensure it's added to the repository settings.


592-592: Clarify the runner architecture choice.

This job uses ubuntu-24.04 (x86-64), while most other test jobs in the workflow use ubuntu-24.04-arm. If this is intentional for federation testing compatibility or docker requirements, consider adding a comment. Otherwise, ensure consistency with the workflow pattern.

Verify whether ubuntu-24.04-arm would also work for federation integration tests or if x86-64 is a requirement.


624-627: Verify sudo availability and /etc/hosts modification persistence.

The steps modify /etc/hosts via sudo, assuming passwordless sudo is available on the runner. Confirm:

  1. The Ubuntu 24.04 runner allows passwordless sudo for these commands.
  2. These changes persist for the duration of the docker-compose services that follow.

Consider whether a docker compose extra_hosts configuration would be more reliable than modifying the host file.


691-691: Verify the integration of test-federation-matrix into the dependency chain.

The test-federation-matrix job is now a dependency of tests-done, and the aggregation logic checks its result. Ensure that:

  1. The job is properly configured to fail on test failures.
  2. The aggregation check (lines 724–726) is correct and consistent with other test job checks.

630-634: No issues found.

The yarn test:integration --image command is properly defined in the federation-matrix package and correctly accepts the --image parameter. The script at ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh handles the parameter as expected, with documentation at lines 70-75 confirming it supports both explicit image values and defaults to rocketchat/rocket.chat:latest when provided without a value.

@ggazzo ggazzo modified the milestones: 7.10.3, 7.13.0 Nov 14, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

608-611: Inconsistent artifact download action version.

This step uses actions/download-artifact@v4, but other download-artifact steps throughout the workflow use @v6 (lines 304, 399, 650, 745, 816). Update to @v6 for consistency unless there's a specific reason for the older version.

       - name: Restore turbo build
-        uses: actions/download-artifact@v4
+        uses: actions/download-artifact@v6
         with:
           name: turbo-build
           path: .turbo/cache
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4ff80ac and 79abaef.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (6 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37357
File: ee/packages/federation-matrix/src/setup.ts:103-120
Timestamp: 2025-11-05T21:04:35.787Z
Learning: In Rocket.Chat's federation-matrix setup (ee/packages/federation-matrix/src/setup.ts and apps/meteor/ee/server/startup/federation.ts), configureFederationMatrixSettings does not need to be called before setupFederationMatrix. The SDK's init() establishes infrastructure (database, event handlers, APIs) first, and the configuration can be applied later via settings watchers before actual federation events are processed. The config only matters when events actually occur, at which point all infrastructure is already configured.
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: 🚢 Build Docker (amd64, authorization-service, queue-worker-service, ddp-streamer-service, cove...
  • GitHub Check: 🚢 Build Docker (amd64, rocketchat, coverage)
  • GitHub Check: 🚢 Build Docker (arm64, rocketchat, coverage)
  • GitHub Check: 🚢 Build Docker (amd64, account-service, presence-service, stream-hub-service, omnichannel-tran...
  • GitHub Check: 🚢 Build Docker (arm64, account-service, presence-service, stream-hub-service, omnichannel-tran...
  • GitHub Check: 🚢 Build Docker (arm64, authorization-service, queue-worker-service, ddp-streamer-service, cove...
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (3)
.github/workflows/ci.yml (3)

589-592: Verify runner OS selection for federation tests.

Line 592 uses ubuntu-24.04 while all other e2e test jobs (test-api, test-ui, test-api-ee, test-ui-ee, test-ui-ee-watcher) use ubuntu-24.04-arm. Confirm this is intentional (e.g., federation tests require x86 architecture or have unsupported tooling on ARM) or update for consistency.


632-634: Verify ENTERPRISE_LICENSE_RC1 secret is available.

The federation test step references ${{ secrets.ENTERPRISE_LICENSE_RC1 }}, but this secret is not visible in the release-versions outputs or common secret definitions in the workflow. Confirm this secret is defined in the repository settings and available for federation matrix tests.


689-726: Federation test integration into test aggregation is correct.

The test-federation-matrix job has been properly integrated into the tests-done aggregation: it's added as a dependency (line 691) and its result is checked (lines 724-726) to fail the overall test suite if federation tests do not succeed. This ensures federation test failures block the pipeline, aligning with other e2e test enforcement.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

624-627: Add error handling to /etc/hosts configuration.

The /etc/hosts modifications (lines 624–627) don't check for success. If these modifications fail, the tests will proceed and fail downstream when trying to reach the federation services. Consider using set -e or checking for errors explicitly.

Suggested improvement:

- - name: Configure /etc/hosts for federation services
-   run: |
-     sudo -- sh -c "echo '127.0.0.1 hs1' >> /etc/hosts"
-     sudo -- sh -c "echo '127.0.0.1 rc1' >> /etc/hosts"
+ - name: Configure /etc/hosts for federation services
+   run: |
+     set -e
+     sudo -- sh -c "echo '127.0.0.1 hs1' >> /etc/hosts"
+     sudo -- sh -c "echo '127.0.0.1 rc1' >> /etc/hosts"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 79abaef and 5865fdc.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (6 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37357
File: ee/packages/federation-matrix/src/setup.ts:103-120
Timestamp: 2025-11-05T21:04:35.787Z
Learning: In Rocket.Chat's federation-matrix setup (ee/packages/federation-matrix/src/setup.ts and apps/meteor/ee/server/startup/federation.ts), configureFederationMatrixSettings does not need to be called before setupFederationMatrix. The SDK's init() establishes infrastructure (database, event handlers, APIs) first, and the configuration can be applied later via settings watchers before actual federation events are processed. The config only matters when events actually occur, at which point all infrastructure is already configured.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: 🚢 Build Docker (arm64, rocketchat, coverage)
  • GitHub Check: 🚢 Build Docker (arm64, authorization-service, queue-worker-service, ddp-streamer-service, cove...
  • GitHub Check: 🚢 Build Docker (amd64, account-service, presence-service, stream-hub-service, omnichannel-tran...
  • GitHub Check: 🚢 Build Docker (arm64, account-service, presence-service, stream-hub-service, omnichannel-tran...
  • GitHub Check: 🚢 Build Docker (amd64, authorization-service, queue-worker-service, ddp-streamer-service, cove...
  • GitHub Check: 🚢 Build Docker (amd64, rocketchat, coverage)
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (5)
.github/workflows/ci.yml (5)

282-287: Formatting change only—no functional impact.

The service matrix is restructured for readability; the content remains unchanged.


691-691: Federation test properly integrated into test aggregation.

The tests-done job correctly includes test-federation-matrix in its needs (line 691) and checks its result (lines 724–726), following the established pattern for other test jobs. This ensures the CI pipeline fails if federation tests fail.

Also applies to: 724-726


830-830: Whitespace/formatting adjustment only.

This line contains no functional changes.


862-862: Whitespace/formatting adjustment only.

This line contains no functional changes.


589-634: Original concern about runner architecture is not an issue; Docker login timing has minor risk.

The non-arm runner choice (ubuntu-24.04) is intentional and consistent with the report-coverage job. No flags needed there.

The Docker login condition (lines 616–622) does create a minor timing asymmetry: login is conditional on repo ownership/release/develop branches, but the federation test (lines 629–634) runs unconditionally. On forks, the test will attempt to pull the pre-built image from ghcr.io without authentication. Since the container registry is public, this should work, but you may encounter rate-limiting on unauthenticated pulls during concurrent test runs. The workflow already handles similar fork limitations elsewhere (see the dummy enterprise license in release-versions), so this is an acceptable trade-off.

The ee/packages/federation-matrix directory, test:integration script, and working directory path are all correct.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

592-592: Verify runner OS choice and consider setting timeout.

The job runs on ubuntu-24.04 (without -arm), which differs from most other test jobs in this workflow that use ubuntu-24.04-arm. Confirm this is intentional (e.g., for Synapse/Matrix compatibility or federation-specific requirements).

Additionally, consider adding timeout-minutes to the job to prevent indefinite hangs if federation tests stall or deadlock.

Example timeout addition:

  test-federation-matrix:
    name: 🔨 Test Federation Matrix
    needs: [checks, build-gh-docker-publish, packages-build, release-versions]
    runs-on: ubuntu-24.04
+   timeout-minutes: 30

Also applies to: 618-623

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5865fdc and 66b8907.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (6 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37357
File: ee/packages/federation-matrix/src/setup.ts:103-120
Timestamp: 2025-11-05T21:04:35.787Z
Learning: In Rocket.Chat's federation-matrix setup (ee/packages/federation-matrix/src/setup.ts and apps/meteor/ee/server/startup/federation.ts), configureFederationMatrixSettings does not need to be called before setupFederationMatrix. The SDK's init() establishes infrastructure (database, event handlers, APIs) first, and the configuration can be applied later via settings watchers before actual federation events are processed. The config only matters when events actually occur, at which point all infrastructure is already configured.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (4)
.github/workflows/ci.yml (4)

282-287: Matrix formatting improvement.

The service matrix declaration is now more readable in multi-line format. No functional changes.


634-634: Verify ENTERPRISE_LICENSE_RC1 secret exists.

The job references ENTERPRISE_LICENSE_RC1, but this secret is not visible in the provided context. Verify that this secret is defined in the repository settings, or confirm whether a different secret or the enterprise-license output from release-versions should be used instead.


635-635: Verify yarn test:integration command exists.

Ensure that the yarn test:integration command is defined and functional in the ee/packages/federation-matrix package. Confirm that the --image flag is supported and that the command executes as expected.


692-692: Pipeline integration for federation tests.

The federation test job is properly integrated into the test aggregation. The dependency declaration and result check follow the established pattern for other test jobs.

Also applies to: 725-727

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 66b8907 and e6d5115.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (6 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37357
File: ee/packages/federation-matrix/src/setup.ts:103-120
Timestamp: 2025-11-05T21:04:35.787Z
Learning: In Rocket.Chat's federation-matrix setup (ee/packages/federation-matrix/src/setup.ts and apps/meteor/ee/server/startup/federation.ts), configureFederationMatrixSettings does not need to be called before setupFederationMatrix. The SDK's init() establishes infrastructure (database, event handlers, APIs) first, and the configuration can be applied later via settings watchers before actual federation events are processed. The config only matters when events actually occur, at which point all infrastructure is already configured.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: 🚢 Build Docker (amd64, authorization-service, queue-worker-service, ddp-streamer-service, cove...
  • GitHub Check: 🚢 Build Docker (amd64, account-service, presence-service, stream-hub-service, omnichannel-tran...
  • GitHub Check: 🚢 Build Docker (amd64, rocketchat, coverage)
  • GitHub Check: 🚢 Build Docker (arm64, rocketchat, coverage)
  • GitHub Check: 🚢 Build Docker (arm64, account-service, presence-service, stream-hub-service, omnichannel-tran...
  • GitHub Check: 🚢 Build Docker (arm64, authorization-service, queue-worker-service, ddp-streamer-service, cove...
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (2)
.github/workflows/ci.yml (2)

692-692: Integration of federation test results into overall CI status looks good.

The test-federation-matrix job is properly wired into the workflow:

  • Dependency declared in tests-done (line 692)
  • Result check added to fail if federation tests don't succeed (lines 725-727)
  • Consistent pattern with other test jobs

Also applies to: 725-727


282-287: Minor formatting improvement to build matrix.

Reformatted the build-gh-docker matrix's service field to multi-line format for readability. No functional changes.

ggazzo
ggazzo previously approved these changes Nov 17, 2025
@github-actions
Copy link
Contributor

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.2GiB 1.2GiB +12MiB
rocketchat 365MiB 354MiB +12MiB
omnichannel-transcript-service 141MiB 141MiB +1.3KiB
queue-worker-service 141MiB 141MiB +869B
ddp-streamer-service 127MiB 127MiB -84B
account-service 114MiB 114MiB +2.4KiB
stream-hub-service 111MiB 111MiB +1.2KiB
authorization-service 111MiB 111MiB +504B
presence-service 111MiB 111MiB +857B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/15 19:34", "11/15 19:47", "11/15 20:39", "11/15 21:23", "11/15 21:37", "11/15 22:04", "11/15 22:28", "11/16 00:55", "11/16 01:28", "11/17 12:35", "11/17 12:48", "11/17 12:54", "11/17 13:21 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "queue-worker-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14]
  line "rocketchat" [0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.35, 0.35, 0.35, 0.36]
  line "stream-hub-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
Loading

Statistics (last 12 days):

  • 📊 Average: 1.3GiB
  • ⬇️ Minimum: 1.2GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.2GiB
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-37219
  • Baseline: develop
  • Timestamp: 2025-11-17 13:21:52 UTC
  • Historical data points: 12

Updated: Mon, 17 Nov 2025 13:21:52 GMT

@ggazzo ggazzo merged commit 9a57017 into develop Nov 17, 2025
89 of 91 checks passed
@ggazzo ggazzo deleted the test/federation-integration branch November 17, 2025 13:58
@coderabbitai coderabbitai bot mentioned this pull request Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants