Skip to content

Commit 62b4680

Browse files
author
Brian Chen
authored
Run persistence and node tests in travis, update tests to not timeout (#1991)
1 parent c9a881e commit 62b4680

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

packages/firestore/test/unit/local/lru_garbage_collector.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ function genericLruGarbageCollectorTests(
942942
await initializeTestResources(LruParams.withCacheSize(100));
943943
expect(persistence.started).to.be.true;
944944

945-
// Add 50 targets and 10 documents to each.
945+
// Add 50 targets and 5 documents to each.
946946
for (let i = 0; i < 50; i++) {
947947
// Use separate transactions so that each target and associated documents get their own
948948
// sequence number.
@@ -953,7 +953,7 @@ function genericLruGarbageCollectorTests(
953953
return addNextTargetInTransaction(txn).next(queryData => {
954954
const targetId = queryData.targetId;
955955
const promises: Array<PersistencePromise<void>> = [];
956-
for (let j = 0; j < 10; j++) {
956+
for (let j = 0; j < 5; j++) {
957957
promises.push(
958958
cacheADocumentInTransaction(txn).next(docKey =>
959959
queryCache.addMatchingKeys(
@@ -987,7 +987,7 @@ function genericLruGarbageCollectorTests(
987987
);
988988
expect(results.didRun).to.be.true;
989989
expect(results.targetsRemoved).to.equal(5);
990-
expect(results.documentsRemoved).to.equal(50);
990+
expect(results.documentsRemoved).to.equal(25);
991991

992992
// Verify that we updated the cache size by checking that it's smaller now.
993993
const finalCacheSize = await persistence.runTransaction(
@@ -1004,8 +1004,8 @@ function genericLruGarbageCollectorTests(
10041004
const params = new LruParams(100, 100, 5);
10051005
await initializeTestResources(params);
10061006

1007-
// Add 50 targets and 10 documents to each.
1008-
for (let i = 0; i < 50; i++) {
1007+
// Add 25 targets and 5 documents to each.
1008+
for (let i = 0; i < 25; i++) {
10091009
// Use separate transactions so that each target and associated documents get their own
10101010
// sequence number.
10111011
await persistence.runTransaction(
@@ -1015,7 +1015,7 @@ function genericLruGarbageCollectorTests(
10151015
return addNextTargetInTransaction(txn).next(queryData => {
10161016
const targetId = queryData.targetId;
10171017
const promises: Array<PersistencePromise<void>> = [];
1018-
for (let j = 0; j < 10; j++) {
1018+
for (let j = 0; j < 5; j++) {
10191019
promises.push(
10201020
cacheADocumentInTransaction(txn).next(docKey =>
10211021
queryCache.addMatchingKeys(

scripts/emulator-testing/firestore-test-runner.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ import * as freePortFinder from 'find-free-port';
2424
import { ChildProcessPromise } from './emulators/emulator';
2525
import { FirestoreEmulator } from './emulators/firestore-emulator';
2626

27-
function runTest(port: number, projectId: string): ChildProcessPromise {
27+
function runTest(
28+
port: number,
29+
projectId: string,
30+
withPersistence: boolean
31+
): ChildProcessPromise {
2832
const options = {
2933
cwd: path.resolve(__dirname, '../../packages/firestore'),
3034
env: Object.assign({}, process.env, {
@@ -35,8 +39,12 @@ function runTest(port: number, projectId: string): ChildProcessPromise {
3539
};
3640
// TODO(b/113267261): Include browser test once WebChannel support is
3741
// ready in Firestore emulator.
38-
// Use test:node:prod to allow runner's env var overrides to work.
39-
return spawn('yarn', ['test:node:prod'], options);
42+
// Use `prod` to allow test runner's env variable overrides to work.
43+
if (withPersistence) {
44+
return spawn('yarn', ['test:node:persistence:prod'], options);
45+
} else {
46+
return spawn('yarn', ['test:node:prod'], options);
47+
}
4048
}
4149

4250
async function run(): Promise<void> {
@@ -45,7 +53,8 @@ async function run(): Promise<void> {
4553
try {
4654
await emulator.download();
4755
await emulator.setUp();
48-
await runTest(emulator.port, emulator.projectId);
56+
await runTest(emulator.port, emulator.projectId, true);
57+
await runTest(emulator.port, emulator.projectId, false);
4958
} finally {
5059
await emulator.tearDown();
5160
}

0 commit comments

Comments
 (0)