Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple service from global state #186

Merged
merged 21 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: E2E tests

on:
push:
branches: ["master"]
pull_request:
workflow_dispatch:

jobs:
build-homerunner:
runs-on: ubuntu-latest
outputs:
homerunnersha: ${{ steps.gitsha.outputs.sha }}
steps:
- name: Checkout matrix-org/complement
uses: actions/checkout@v3
with:
repository: matrix-org/complement
- name: Get complement git sha
id: gitsha
run: echo sha=`git rev-parse --short HEAD` >> "$GITHUB_OUTPUT"
- name: Cache homerunner
id: cached
uses: actions/cache@v3
with:
path: homerunner
key: ${{ runner.os }}-homerunner-${{ steps.gitsha.outputs.sha }}
- name: "Set Go Version"
if: ${{ steps.cached.outputs.cache-hit != 'true' }}
run: |
echo "$GOROOT_1_18_X64/bin" >> $GITHUB_PATH
echo "~/go/bin" >> $GITHUB_PATH
# Build and install homerunner
- name: Install Complement Dependencies
if: ${{ steps.cached.outputs.cache-hit != 'true' }}
run: |
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
- name: Build homerunner
if: ${{ steps.cached.outputs.cache-hit != 'true' }}
run: |
go build ./cmd/homerunner


integration-test:
runs-on: ubuntu-latest
timeout-minutes: 30
needs:
- build-homerunner
steps:
- name: Install Complement Dependencies
run: |
sudo apt-get update && sudo apt-get install -y libolm3
- name: Load cached homerunner bin
uses: actions/cache@v3
with:
path: homerunner
key: ${{ runner.os }}-homerunner-${{ needs.build-synapse.outputs.homerunnersha }}
fail-on-cache-miss: true # Shouldn't happen, we build this in the needs step.
- name: Checkout conference-bot
uses: actions/checkout@v3
with:
path: conference-bot
# Setup node & run tests
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: conference-bot/.node-version
- name: Run Homerunner tests
timeout-minutes: 10
env:
HOMERUNNER_IMAGE: ghcr.io/matrix-org/synapse/complement-synapse:latest
HOMERUNNER_SPAWN_HS_TIMEOUT_SECS: 100
NODE_OPTIONS: --dns-result-order ipv4first
run: |
docker pull $HOMERUNNER_IMAGE
cd conference-bot
yarn --strict-semver --frozen-lockfile
../homerunner &
bash -ic 'yarn test:e2e'
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"build:ts": "tsc",
"build:web": "webpack",
"run:merge-roles": "yarn build && node lib/scripts/merge-roles.js",
"test": "jest"
"test": "jest src/__tests__",
"test:e2e": "jest spec/"
},
"dependencies": {
"@tsconfig/node18": "^1.0.1",
Expand All @@ -33,7 +34,7 @@
"js-yaml": "^3.14.1",
"jsrsasign": "^10.1.4",
"liquidjs": "^9.19.0",
"matrix-bot-sdk": "^0.6.3",
"matrix-bot-sdk": "npm:@vector-im/matrix-bot-sdk@^0.6.7-element.1",
"matrix-widget-api": "^0.1.0-beta.11",
"moment": "^2.29.4",
"node-fetch": "^2.6.1",
Expand All @@ -48,12 +49,13 @@
"@types/pg": "^7.14.7",
"clean-webpack-plugin": "^3.0.0",
"css-loader": "^5.0.1",
"homerunner-client": "^0.0.6",
"html-webpack-plugin": "^4.5.1",
"jest": "^29.3.1",
"jest": "^29.7.0",
"json-schema-to-typescript": "^11.0.2",
"postcss-loader": "^4.1.0",
"style-loader": "^2.0.0",
"ts-jest": "^29.0.3",
"ts-jest": "^29.1.1",
"ts-loader": "^9.4.2",
"typescript": "^4.9.4",
"webpack": "^5.12.1",
Expand Down
48 changes: 48 additions & 0 deletions spec/basic.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { E2ESetupTestTimeout, E2ETestEnv } from "./util/e2e-test";
import { describe, it, beforeEach, afterEach, expect } from "@jest/globals";


describe('Basic test setup', () => {
let testEnv: E2ETestEnv;
beforeEach(async () => {
testEnv = await E2ETestEnv.createTestEnv({
fixture: 'basic-conference',
});
await testEnv.setUp();
}, E2ESetupTestTimeout);
afterEach(() => {
return testEnv?.tearDown();
});
it('should start up successfully', async () => {
const { event } = await testEnv.sendAdminCommand('!conference status');
console.log(event.content.body);
// Check that we're generally okay.
expect(event.content.body).toMatch('Scheduled tasks yet to run: 0');
expect(event.content.body).toMatch('Schedule source healthy: true');
});
it('should be able to build successfully', async () => {
let spaceBuilt, supportRoomsBuilt, conferenceBuilt = false;
const waitForFinish = new Promise<void>((resolve, reject) => {
const timeout = setTimeout(() => reject(new Error(
`Build incomplete. spaceBuild: ${spaceBuilt}, supportRoomsBuilt: ${supportRoomsBuilt}, conferenceBuilt: ${conferenceBuilt}`
)), 5000);
testEnv.adminClient.on('room.message', (_, event) => {
if (event.content.body.includes("Your conference's space is at")) {
spaceBuilt = true;
} else if (event.content.body.includes("Support rooms have been created")) {
supportRoomsBuilt = true;
} else if (event.content.body.includes("CONFERENCE BUILT")) {
conferenceBuilt = true;
}

if (spaceBuilt && supportRoomsBuilt && conferenceBuilt) {
resolve();
clearTimeout(timeout);
}
})
});
await testEnv.sendAdminCommand('!conference build');
await waitForFinish;
// TODO: Now test that all the expected rooms are there.
}, 7000);
});
19 changes: 19 additions & 0 deletions spec/fixtures/basic-conference.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"title": "Testing Conference",
"streams": [{
"stream_name": "Main Stream",
"talks": [{
"id": 1,
"title": "Main Talk 1",
"description": "First talk",
"start": "2019-10-12T07:20:50.52Z",
"end": "2019-10-12T07:21:50.52Z",
"tracks": ["main_track"],
"speakers": [{
"display_name": "Alice",
"matrix_id": "@alice:example.com",
"email": "@alice:example.com"
}]
}]
}]
}
Loading