mirror of https://github.com/OpenVidu/openvidu.git
openvidu-dashboard: the rooms summary plan test bounds what the partial index reads
The planner may count the active standard participants on status_lastStatsAt_open, which examines the active participants of every kind; the bound only allowed the standard ones, so the test failed now and then.chore/update-openvidu-actions-1.0.25
parent
dab3b8295b
commit
da6e6a84f6
|
|
@ -238,8 +238,9 @@ describe.skipIf(mongoUri === '')(`rooms query plan at scenario ${scenario}`, ()
|
||||||
|
|
||||||
it('summary counts', async () => {
|
it('summary counts', async () => {
|
||||||
const range = { $gte: new Date(now.getTime() - DAY), $lt: now };
|
const range = { $gte: new Date(now.getTime() - DAY), $lt: now };
|
||||||
// Any index with the right prefix serves a count; the planner may prefer the smaller partial one.
|
// Any index with the right prefix serves a count; the planner may prefer the smaller partial one, which reads
|
||||||
const counts: [string, Document, string[]][] = [
|
// every active session and checks the kind after the fetch, so the documents it may examine bound the count.
|
||||||
|
const counts: [string, Document, string[], Document?][] = [
|
||||||
[
|
[
|
||||||
Collection.ROOMS,
|
Collection.ROOMS,
|
||||||
{ status: RoomStatus.ACTIVE },
|
{ status: RoomStatus.ACTIVE },
|
||||||
|
|
@ -248,17 +249,18 @@ describe.skipIf(mongoUri === '')(`rooms query plan at scenario ${scenario}`, ()
|
||||||
[
|
[
|
||||||
Collection.PARTICIPANTS,
|
Collection.PARTICIPANTS,
|
||||||
{ status: ParticipantStatus.ACTIVE, kind: ParticipantKind.STANDARD },
|
{ status: ParticipantStatus.ACTIVE, kind: ParticipantKind.STANDARD },
|
||||||
['status_kind', 'status_lastStatsAt_open', 'kind_status_joinedAt_id']
|
['status_kind', 'status_lastStatsAt_open', 'kind_status_joinedAt_id'],
|
||||||
|
{ status: ParticipantStatus.ACTIVE }
|
||||||
],
|
],
|
||||||
[Collection.ROOMS, { createdAt: range }, ['createdAt_id']],
|
[Collection.ROOMS, { createdAt: range }, ['createdAt_id']],
|
||||||
[Collection.PARTICIPANTS, { ...STANDARD_SESSIONS, joinedAt: range }, ['kind_status_joinedAt_id']]
|
[Collection.PARTICIPANTS, { ...STANDARD_SESSIONS, joinedAt: range }, ['kind_status_joinedAt_id']]
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const [collection, match, allowed] of counts) {
|
for (const [collection, match, allowed, examined = match] of counts) {
|
||||||
const plan = await expectIndexBacked(
|
const plan = await expectIndexBacked(
|
||||||
db,
|
db,
|
||||||
{ collection, pipeline: [{ $match: match }, { $count: 'n' }] },
|
{ collection, pipeline: [{ $match: match }, { $count: 'n' }] },
|
||||||
{ maxDocsExamined: await matched(collection, match)() }
|
{ maxDocsExamined: await matched(collection, examined)() }
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(plan.collscan).toBe(false);
|
expect(plan.collscan).toBe(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue