mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-04 00:38:10 +00:00
fix(web-svc-coturn): size the TURN allocation quota for Talk calls and test a six-person call
coturn ran with a fixed --total-quota=100 for the whole server. A Nextcloud Talk call through the HPB opens N peer connections per participant and one allocation per TURN transport, about 2*N^2 allocations, so calls of more than about five participants ran out. services.coturn.total_quota now sets the quota, 2000 by default; on echoserver eight participants held connected media with it. The Nextcloud Playwright suite gains test-talk-call-capacity, gated like the Talk admin test: as administrator it creates a public room through the Talk API, joins six guests in separate contexts with fake media, and requires every guest to hold a connected peer connection to every participant and no TURN 486 Allocation Quota Reached. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
49e053806c
commit
812ca4e3d7
6 files changed
+114
-1
No files matched your search
@@ -19,6 +19,7 @@ test.use({
|
||||
test.beforeEach(shared.beforeEach);
|
||||
|
||||
require("./test-talk-admin-settings").register(shared);
|
||||
require("./test-talk-call-capacity").register(shared);
|
||||
require("./test-login-admin-oidc").register(shared);
|
||||
require("./test-login-admin-native").register(shared);
|
||||
require("./test-login-biber-oidc").register(shared);
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
const { test, expect } = require("@playwright/test");
|
||||
const { resolveTimeout, isOnionTarget } = require("./timeouts");
|
||||
const { decodeDotenvQuotedValue, gotoOnion } = require("./personas");
|
||||
|
||||
const talkEnabled = decodeDotenvQuotedValue(process.env.NEXTCLOUD_TALK_SETTINGS_CHECK_ENABLED) === "true";
|
||||
const callParticipants = 6;
|
||||
const ocsHeaders = { "OCS-APIRequest": "true", Accept: "application/json" };
|
||||
const joinCallPattern = /^(join call|start call|anruf beitreten|anruf starten)$/i;
|
||||
const leaveCallPattern = /^(leave call|anruf verlassen)$/i;
|
||||
const displayNamePattern = /display name|anzeigename/i;
|
||||
const turnQuotaReachedCode = 486;
|
||||
|
||||
function trackPeerConnections() {
|
||||
const Original = window.RTCPeerConnection;
|
||||
const stats = { connections: [], iceErrorCodes: [] };
|
||||
window.__talkCallStats = stats;
|
||||
function Tracked(...args) {
|
||||
const connection = new Original(...args);
|
||||
stats.connections.push(connection);
|
||||
connection.addEventListener("icecandidateerror", (event) => stats.iceErrorCodes.push(event.errorCode));
|
||||
return connection;
|
||||
}
|
||||
Tracked.prototype = Original.prototype;
|
||||
Object.setPrototypeOf(Tracked, Original);
|
||||
window.RTCPeerConnection = Tracked;
|
||||
}
|
||||
|
||||
function readCallStats(page) {
|
||||
return page.evaluate(() => {
|
||||
const stats = window.__talkCallStats;
|
||||
return {
|
||||
connected: stats.connections.filter((connection) => connection.connectionState === "connected").length,
|
||||
iceErrorCodes: stats.iceErrorCodes,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function createPublicRoom(page, baseUrl) {
|
||||
const response = await page.request.post(`${baseUrl}/ocs/v2.php/apps/spreed/api/v4/room`, {
|
||||
headers: ocsHeaders,
|
||||
data: { roomType: 3, roomName: `Playwright call capacity ${Date.now()}` },
|
||||
});
|
||||
expect(response.ok(), `creating the public Talk room answered HTTP ${response.status()}`).toBeTruthy();
|
||||
return (await response.json()).ocs.data.token;
|
||||
}
|
||||
|
||||
async function joinCallAsGuest(browser, roomUrl, name) {
|
||||
const context = await browser.newContext({ ignoreHTTPSErrors: true, permissions: ["camera", "microphone"] });
|
||||
await context.addInitScript(trackPeerConnections);
|
||||
const page = await context.newPage();
|
||||
await gotoOnion(page, roomUrl, { waitUntil: "domcontentloaded", timeout: resolveTimeout(60_000) });
|
||||
const dialog = page.getByRole("dialog");
|
||||
await dialog.getByLabel(displayNamePattern).first().fill(name, { timeout: resolveTimeout(60_000) });
|
||||
const joinButton = dialog.getByRole("button", { name: joinCallPattern }).last();
|
||||
await expect(joinButton, `${name}: the join button stays disabled after the display name`).toBeEnabled({
|
||||
timeout: resolveTimeout(30_000),
|
||||
});
|
||||
await joinButton.click({ timeout: resolveTimeout(30_000) });
|
||||
await expect(page.getByRole("button", { name: leaveCallPattern }).first(), `${name} never entered the call`).toBeVisible({
|
||||
timeout: resolveTimeout(60_000),
|
||||
});
|
||||
return { name, page, context };
|
||||
}
|
||||
|
||||
exports.register = function (shared) {
|
||||
test("nextcloud talk call holds more than five participants", async ({ browser }) => {
|
||||
test.skip(!talkEnabled, "Talk is disabled in the current Playwright env");
|
||||
test.skip(isOnionTarget(), "Nextcloud Talk realtime (HPB signaling + STUN/TURN) is WebRTC; not reachable over Tor");
|
||||
test.setTimeout(resolveTimeout(15 * 60_000));
|
||||
|
||||
const baseUrl = shared.env.nextcloudBaseUrl;
|
||||
const adminContext = await browser.newContext({ ignoreHTTPSErrors: true });
|
||||
const adminPage = await adminContext.newPage();
|
||||
const guests = [];
|
||||
let token = "";
|
||||
|
||||
try {
|
||||
await shared.loginToStandaloneNextcloud(adminPage);
|
||||
token = await createPublicRoom(adminPage, baseUrl);
|
||||
|
||||
for (let index = 1; index <= callParticipants; index += 1) {
|
||||
guests.push(await joinCallAsGuest(browser, `${baseUrl}/call/${token}`, `Playwright guest ${index}`));
|
||||
}
|
||||
|
||||
for (const guest of guests) {
|
||||
await expect
|
||||
.poll(async () => (await readCallStats(guest.page)).connected, {
|
||||
timeout: resolveTimeout(120_000),
|
||||
message: `${guest.name} must hold a connected peer connection to every participant of the ${callParticipants}-person call`,
|
||||
})
|
||||
.toBeGreaterThanOrEqual(callParticipants);
|
||||
expect(
|
||||
(await readCallStats(guest.page)).iceErrorCodes,
|
||||
`${guest.name}: TURN answered ${turnQuotaReachedCode} Allocation Quota Reached`,
|
||||
).not.toContain(turnQuotaReachedCode);
|
||||
}
|
||||
} finally {
|
||||
for (const guest of guests) {
|
||||
await guest.context.close().catch(() => {});
|
||||
}
|
||||
if (token) {
|
||||
await adminPage.request
|
||||
.delete(`${baseUrl}/ocs/v2.php/apps/spreed/api/v4/room/${token}`, { headers: ocsHeaders })
|
||||
.catch(() => {});
|
||||
}
|
||||
await adminContext.close().catch(() => {});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -77,6 +77,7 @@ Solid `1:1` edges are fixed relationships; dashed `0..1` edges are conditional (
|
||||
- Automatic TLS handling via `sys-stk-front-base`
|
||||
- TURN and STUN support over TCP and UDP
|
||||
- Configurable relay port ranges for scaling
|
||||
- Configurable server-wide allocation quota (`services.coturn.total_quota`, default 2000); size it at about 2·N² for every concurrent Nextcloud Talk call with N participants, as each participant opens N peer connections and requests one allocation per TURN transport
|
||||
- Integration into Infinito.Nexus inventory/variable system
|
||||
|
||||
## Quick Setup
|
||||
|
||||
@@ -12,6 +12,7 @@ coturn:
|
||||
version: 4.18.0
|
||||
min_storage: 246MB
|
||||
user_auth_enabled: false
|
||||
total_quota: 2000
|
||||
cpus: 1.0
|
||||
mem_reservation: 512m
|
||||
mem_limit: 1g
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
{% endif %}
|
||||
--realm="${COTURN_REALM}"
|
||||
--fingerprint
|
||||
--total-quota=100
|
||||
--total-quota={{ COTURN_TOTAL_QUOTA }}
|
||||
--stale-nonce
|
||||
--no-multicast-peers
|
||||
--no-cli
|
||||
|
||||
@@ -11,6 +11,7 @@ COTURN_STUN_TURN_PORT: "{{ lookup('config', application_id, 'services.coturn.por
|
||||
COTURN_STUN_TURN_PORT_TLS: "{{ lookup('config', application_id, 'services.coturn.ports.public.stun_turn_tls') }}"
|
||||
COTURN_RELAY_PORT_START: "{{ lookup('config', application_id, 'services.coturn.ports.public.relay.start') }}"
|
||||
COTURN_RELAY_PORT_END: "{{ lookup('config', application_id, 'services.coturn.ports.public.relay.end') }}"
|
||||
COTURN_TOTAL_QUOTA: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.total_quota') }}"
|
||||
|
||||
COTURN_USER_NAME: "{{ lookup('users', 'coturnconsumer').username }}"
|
||||
COTURN_USER_PASSWORD: "{{ lookup('users', 'coturnconsumer').password }}"
|
||||
|
||||
Reference in new issue
Block a user