Skip to content

Commit 9a57017

Browse files
dhulkeDanilo Morãesggazzo
authored
chore: federation-matrix integration tests (#37219)
Co-authored-by: Danilo Morães <danilo.moraes@rocket.chat> Co-authored-by: Guilherme Gazzo <guilherme@gazzo.xyz>
1 parent de830b6 commit 9a57017

33 files changed

+4493
-11
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,12 @@ jobs:
279279
fail-fast: false
280280
matrix:
281281
arch: [arm64, amd64]
282-
service: [
283-
[authorization-service, queue-worker-service, ddp-streamer-service],
284-
[account-service, presence-service, stream-hub-service, omnichannel-transcript-service],
285-
[rocketchat]
286-
]
282+
service:
283+
[
284+
[authorization-service, queue-worker-service, ddp-streamer-service],
285+
[account-service, presence-service, stream-hub-service, omnichannel-transcript-service],
286+
[rocketchat],
287+
]
287288
type:
288289
# if running in a PR build with coverage
289290
- ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}
@@ -607,6 +608,54 @@ jobs:
607608
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
608609
REPORTER_JIRA_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_JIRA_ROCKETCHAT_API_KEY }}
609610

611+
test-federation-matrix:
612+
name: 🔨 Test Federation Matrix
613+
needs: [checks, build-gh-docker-publish, packages-build, release-versions]
614+
runs-on: ubuntu-24.04-arm
615+
616+
steps:
617+
- uses: actions/checkout@v5
618+
619+
- name: Setup NodeJS
620+
uses: ./.github/actions/setup-node
621+
with:
622+
node-version: ${{ needs.release-versions.outputs.node-version }}
623+
deno-version: ${{ needs.release-versions.outputs.deno-version }}
624+
cache-modules: true
625+
install: true
626+
627+
- uses: rharkor/caching-for-turbo@v1.8
628+
629+
- name: Restore turbo build
630+
uses: actions/download-artifact@v6
631+
continue-on-error: true
632+
with:
633+
name: turbo-build
634+
path: .turbo/cache
635+
636+
- name: Build packages
637+
run: yarn build
638+
639+
- name: Login to GitHub Container Registry
640+
if: (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop') && github.actor != 'dependabot[bot]'
641+
uses: docker/login-action@v3
642+
with:
643+
registry: ghcr.io
644+
username: ${{ secrets.CR_USER }}
645+
password: ${{ secrets.CR_PAT }}
646+
647+
- name: Configure /etc/hosts for federation services
648+
run: |
649+
sudo -- sh -c "echo '127.0.0.1 hs1' >> /etc/hosts"
650+
sudo -- sh -c "echo '127.0.0.1 rc1' >> /etc/hosts"
651+
652+
- name: Run federation integration tests with pre-built image
653+
working-directory: ./ee/packages/federation-matrix
654+
env:
655+
ROCKETCHAT_IMAGE: ghcr.io/${{ needs.release-versions.outputs.lowercase-repo }}/rocket.chat:${{ needs.release-versions.outputs.gh-docker-tag }}
656+
ENTERPRISE_LICENSE_RC1: ${{ secrets.ENTERPRISE_LICENSE_RC1 }}
657+
run: yarn test:integration --image "${ROCKETCHAT_IMAGE}"
658+
610659
report-coverage:
611660
name: 📊 Report Coverage
612661
runs-on: ubuntu-24.04
@@ -662,7 +711,7 @@ jobs:
662711
tests-done:
663712
name: ✅ Tests Done
664713
runs-on: ubuntu-24.04-arm
665-
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee, test-ui-ee-watcher]
714+
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee, test-ui-ee-watcher, test-federation-matrix]
666715
if: always()
667716
steps:
668717
- name: Test finish aggregation
@@ -695,6 +744,10 @@ jobs:
695744
exit 1
696745
fi
697746
747+
if [[ '${{ needs.test-federation-matrix.result }}' != 'success' ]]; then
748+
exit 1
749+
fi
750+
698751
echo finished
699752
700753
deploy:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ storybook-static
5555
**/.vim/
5656

5757
data/
58+
!**/tests/data/
5859
registration.yaml
5960

6061
storybook-static
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import type { IRoom } from '@rocket.chat/core-typings';
2+
3+
import { credentials, methodCall, request } from './api-data';
4+
import type { IRequestConfig } from './users.helper';
5+
6+
type SendMessageParams = {
7+
rid: IRoom['_id'];
8+
msg: string;
9+
config?: IRequestConfig;
10+
};
11+
12+
/**
13+
* Sends a text message to a room using the method.call/sendMessage DDP endpoint.
14+
*
15+
* This helper function allows sending messages to rooms (channels, groups, DMs)
16+
* for federation testing scenarios using the DDP method format. It supports
17+
* custom request configurations for cross-domain federation testing.
18+
*
19+
* @param rid - The unique identifier of the room
20+
* @param msg - The message text to send
21+
* @param config - Optional request configuration for custom domains
22+
* @returns Promise resolving to the API response
23+
*/
24+
export const sendMessage = ({ rid, msg, config }: SendMessageParams) => {
25+
if (!rid) {
26+
throw new Error('"rid" is required in "sendMessage" test helper');
27+
}
28+
if (!msg) {
29+
throw new Error('"msg" is required in "sendMessage" test helper');
30+
}
31+
32+
const requestInstance = config?.request || request;
33+
const credentialsInstance = config?.credentials || credentials;
34+
35+
return requestInstance
36+
.post(methodCall('sendMessage'))
37+
.set(credentialsInstance)
38+
.send({
39+
message: JSON.stringify({
40+
method: 'sendMessage',
41+
params: [
42+
{
43+
_id: `${Date.now()}-${Math.random()}`,
44+
rid,
45+
msg,
46+
},
47+
],
48+
id: `${Date.now()}-${Math.random()}`,
49+
msg: 'method',
50+
}),
51+
});
52+
};

0 commit comments

Comments
 (0)