Skip to content

Add Watch update perf test #1059

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

Merged
merged 5 commits into from
Jul 30, 2018
Merged
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
49 changes: 48 additions & 1 deletion packages/firestore/test/unit/specs/perf_spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { Query } from '../../../src/core/query';
import { doc, orderBy, path } from '../../util/helpers';
import { doc, filter, orderBy, path } from '../../util/helpers';

import { describeSpec, specTest } from './describe_spec';
import { spec } from './spec_builder';
Expand Down Expand Up @@ -238,5 +238,52 @@ describeSpec(
return steps;
}
);

specTest('Process 25 target updates and wait for snapshot', [], () => {
const queriesPerStep = 25;

let currentVersion = 1;
let steps = spec().withGCEnabled(false);

for (let i = 1; i <= STEP_COUNT; ++i) {
// We use a different subcollection for each iteration to ensure
// that we use distinct and non-overlapping collection queries.
const collPath = `collection/${i}/coll`;
const matchingDoc = doc(`${collPath}/matches`, ++currentVersion, {
val: -1
});

const queries = [];

// Create `queriesPerStep` listens, each against collPath but with a
// unique query constraint.
for (let j = 0; j < queriesPerStep; ++j) {
const query = Query.atPath(path(collPath)).addFilter(
filter('val', '<=', j)
);
queries.push(query);
steps = steps.userListens(query).watchAcks(query);
}

steps = steps
.watchSends({ affects: queries }, matchingDoc)
.watchSnapshots(++currentVersion);

// Registers the snapshot expectations with the spec runner.
for (const query of queries) {
steps = steps.expectEvents(query, {
added: [matchingDoc],
fromCache: true
});
}

// Unlisten and clean up the query.
for (const query of queries) {
steps = steps.userUnlistens(query).watchRemoves(query);
}
}

return steps;
});
}
);