2026-11-03 11:26:40 +01:00
|
|
|
import { generate } from '@openvidu-dashboard/data-generator/generator';
|
|
|
|
|
import { Collection } from '@openvidu-dashboard/typings';
|
|
|
|
|
import { type Db, MongoClient } from 'mongodb';
|
|
|
|
|
import { afterAll, beforeAll, describe, expect, inject, it } from 'vitest';
|
|
|
|
|
|
|
|
|
|
import { oldestQuery } from '../../src/info/info-service.js';
|
|
|
|
|
import { expectIndexBacked } from '../support/query-plan.js';
|
|
|
|
|
|
|
|
|
|
/** The oldest-document query of every collection About dates, explained on a generated database. */
|
|
|
|
|
|
|
|
|
|
const mongoUri = inject('mongoUri');
|
|
|
|
|
const DATABASE = 'dashboard_test_info_plan';
|
|
|
|
|
|
|
|
|
|
const DATED = [
|
|
|
|
|
Collection.ROOMS,
|
|
|
|
|
Collection.PARTICIPANTS,
|
|
|
|
|
Collection.EGRESSES,
|
|
|
|
|
Collection.INGRESSES,
|
|
|
|
|
Collection.INGRESS_SESSIONS,
|
|
|
|
|
Collection.EVENTS,
|
|
|
|
|
Collection.ANALYTICS_5MIN,
|
|
|
|
|
Collection.ANALYTICS_HOURLY,
|
|
|
|
|
Collection.ANALYTICS_DAILY
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
describe.skipIf(mongoUri === '')('info oldest-document queries', () => {
|
|
|
|
|
let client: MongoClient;
|
|
|
|
|
let db: Db;
|
|
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
|
client = new MongoClient(mongoUri);
|
|
|
|
|
db = client.db(DATABASE);
|
|
|
|
|
await db.dropDatabase();
|
|
|
|
|
await generate(db, {
|
|
|
|
|
scenario: 'S',
|
|
|
|
|
days: 1,
|
|
|
|
|
statsMode: 'participant',
|
|
|
|
|
seed: 1,
|
|
|
|
|
retentionDays: { events: 7, stats: 7, tracks: 7, entities: 90 },
|
|
|
|
|
timeseries: true,
|
openvidu-dashboard: media node labels, and nothing about nodes in CE
The contract gains mediaNode on nodes, rooms and participants, stoppedAt on nodes and the
partial mediaNode index that replaces the nodeId one; the scenario's two servers are
labelled. The status reports the writer without node counts and with stoppedAt when the
server stopped, the rooms list filters by mediaNode, list items carry it, the overview
groups by it for editions and a node scope's media statistics coverage follows it.
CE renders nothing about nodes without per-node-breakdown: no nodes line, By node card,
Node select, scope selector or Node columns, not even locked; the Overview reads "Server
stopped at" for a stopped server. The generator gains --media-nodes, which node rollups
now require.
2026-11-04 12:13:58 +01:00
|
|
|
rollups: { fiveMinute: true, nodes: true, roomSums: true },
|
|
|
|
|
mediaNodes: true
|
2026-11-03 11:26:40 +01:00
|
|
|
});
|
|
|
|
|
}, 600_000);
|
|
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
|
await db.dropDatabase();
|
|
|
|
|
await client.close();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it.each(DATED)('%s reads one document through an index', async (name) => {
|
|
|
|
|
const query = oldestQuery(db, name);
|
|
|
|
|
|
|
|
|
|
if (query === null) {
|
|
|
|
|
throw new Error(`${name} has no oldest-document query`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await expectIndexBacked(db, query.cursor.clone(), { maxDocsExamined: 1, collscanThreshold: 0 });
|
|
|
|
|
|
|
|
|
|
const [oldest] = await query.cursor.toArray();
|
|
|
|
|
|
|
|
|
|
expect(oldest?.[query.field]).toBeInstanceOf(Date);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('dates nodes by their first heartbeat without an index', async () => {
|
|
|
|
|
const query = oldestQuery(db, Collection.NODES);
|
|
|
|
|
|
|
|
|
|
if (query === null) {
|
|
|
|
|
throw new Error('nodes has no oldest-document query');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expect(query.field).toBe('firstSeenAt');
|
|
|
|
|
await expectIndexBacked(db, query.cursor.clone(), { maxDocsExamined: 10, collscanThreshold: 10 });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('leaves tracks, subscriptions and stats undated', () => {
|
|
|
|
|
expect(oldestQuery(db, Collection.TRACKS)).toBeNull();
|
|
|
|
|
expect(oldestQuery(db, Collection.TRACK_SUBSCRIPTIONS)).toBeNull();
|
|
|
|
|
expect(oldestQuery(db, Collection.TRACK_STATS)).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
});
|