Skip to content

Mila/bloom filter add integration test #7045

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 6 commits into from
Feb 17, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
skip test if persistence is enabled
milaGGL committed Feb 17, 2023
commit 5eb19a18dea35d778f310edc59d092992c92c97c
50 changes: 27 additions & 23 deletions packages/firestore/test/integration/api/query.test.ts
Original file line number Diff line number Diff line change
@@ -1615,30 +1615,34 @@ apiDescribe('Queries', (persistence: boolean) => {
});
});
});

it('can raise expected snapshot when resume query after deleting docs', () => {
const testDocs = {};
for (let i = 1; i <= 100; i++) {
Object.assign(testDocs, { ['doc' + i]: { key: i } });
}
return withTestCollection(persistence, testDocs, async (coll, db) => {
const snapshot1 = await getDocs(coll);
expect(snapshot1.size).to.equal(100);
// Delete 50 docs in transaction so that it doesn't affect local cache.
await runTransaction(db, async txn => {
for (let i = 1; i <= 50; i++) {
txn.delete(doc(coll, 'doc' + i));
}

// eslint-disable-next-line no-restricted-properties
(persistence ? it.skip: it)(
'can raise expected snapshot when resume query after deleting docs',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming this test to something like "resuming a query should remove deleted documents indicated by existence filter"

() => {
const testDocs = {};
for (let i = 1; i <= 100; i++) {
Object.assign(testDocs, { ['doc' + i]: { key: i } });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can

Object.assign(testDocs, { ['doc' + i]: { key: i } })

be simplified to

testDocs['doc' + i] = { key: i }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typescript is not quite happy about with that:
Screenshot 2023-02-16 at 6 26 04 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can convince TypeScript to be happy. Does this work:

Change

const testDocs = {};

to

const testDocs: { [key: string]: Object } = {}; 

}
return withTestCollection(persistence, testDocs, async (coll, db) => {
const snapshot1 = await getDocs(coll);
expect(snapshot1.size).to.equal(100);
// Delete 50 docs in transaction so that it doesn't affect local cache.
await runTransaction(db, async txn => {
for (let i = 1; i <= 50; i++) {
txn.delete(doc(coll, 'doc' + i));
}
});
// Wait 10 seconds, during which the watch will stop tracking the query
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "the watch" -> "Watch" (with a capital "W")

// and will send an existence filter rather than "delete" events.
await (function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can

await (function () {
  return new Promise(resolve => setTimeout(resolve, 10000));
})();

be simplified to

await new Promise(resolve => setTimeout(resolve, 10000));

return new Promise(resolve => setTimeout(resolve, 10000));
})();
const snapshot2 = await getDocs(coll);
expect(snapshot2.size).to.equal(50);
});
// Wait 10 seconds, during which the watch will stop tracking the query
// and will send an existence filter rather than "delete" events.
await (function () {
return new Promise(resolve => setTimeout(resolve, 10000));
})();
const snapshot2 = await getDocs(coll);
expect(snapshot2.size).to.equal(50);
});
}).timeout('15s');
}
).timeout('20s');
});

function verifyDocumentChange<T>(