Skip to content

Commit 6f9c474

Browse files
authored
Merge branch 'main' into pearigee-fix-sinon-issue
2 parents 5f8de83 + 0e6487a commit 6f9c474

3 files changed

Lines changed: 37 additions & 39 deletions

File tree

handwritten/firestore/dev/system-test/firestore.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,8 @@ describe('DocumentReference class', () => {
17411741
},
17421742
};
17431743

1744-
const coll = firestore.collection('tests');
1744+
const coll = firestore.collection('node_tests_' + autoId());
1745+
17451746
const ref = coll.doc('number').withConverter(primitiveConverter);
17461747
await ref.set(3);
17471748
const result = await ref.get();
@@ -7436,7 +7437,8 @@ describe('BulkWriter class', () => {
74367437
// TODO enterprise b/469490062
74377438
it.skipEnterprise('does not affect other collections', async () => {
74387439
// Add other nested collection that shouldn't be deleted.
7439-
const collB = firestore.collection('doggos');
7440+
const collB = firestore.collection('node_doggos_' + autoId());
7441+
74407442
await collB.doc('doggo').set({name: 'goodboi'});
74417443

74427444
await firestore.recursiveDelete(collB);

handwritten/firestore/dev/system-test/tracing.ts

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ import {
4141
SpanProcessor,
4242
TimedEvent,
4343
} from '@opentelemetry/sdk-trace-node';
44-
import {setLogFunction, Firestore} from '../src';
44+
import {setLogFunction, Firestore, CollectionReference} from '../src';
45+
import {autoId} from '../src/util';
4546
import {verifyInstance} from '../test/util/helpers';
4647
import {
4748
ATTRIBUTE_GCP_RESOURCE_NAME,
@@ -159,6 +160,7 @@ class SpanData {
159160

160161
describe.skipEnterprise('Tracing Tests', () => {
161162
let firestore: Firestore;
163+
let randomCol: CollectionReference;
162164
let tracerProvider: NodeTracerProvider;
163165
let inMemorySpanExporter: InMemorySpanExporter;
164166
let consoleSpanExporter: ConsoleSpanExporter;
@@ -299,6 +301,7 @@ describe.skipEnterprise('Tracing Tests', () => {
299301
}
300302

301303
firestore = new Firestore(settings);
304+
randomCol = firestore.collection('node_tracing_' + autoId());
302305
}
303306

304307
function getSettingsAttributes(): Attributes {
@@ -767,9 +770,7 @@ describe.skipEnterprise('Tracing Tests', () => {
767770

768771
function runTestCases() {
769772
it('document reference get()', async () => {
770-
await runFirestoreOperationInRootSpan(() =>
771-
firestore.collection('foo').doc('bar').get(),
772-
);
773+
await runFirestoreOperationInRootSpan(() => randomCol.doc('bar').get());
773774
await waitForCompletedSpans(3);
774775
expectSpanHierarchy(
775776
SPAN_NAME_TEST_ROOT,
@@ -788,9 +789,7 @@ describe.skipEnterprise('Tracing Tests', () => {
788789
});
789790

790791
it('document reference create()', async () => {
791-
await runFirestoreOperationInRootSpan(() =>
792-
firestore.collection('foo').doc().create({}),
793-
);
792+
await runFirestoreOperationInRootSpan(() => randomCol.doc().create({}));
794793
await waitForCompletedSpans(3);
795794
expectSpanHierarchy(
796795
SPAN_NAME_TEST_ROOT,
@@ -805,7 +804,7 @@ describe.skipEnterprise('Tracing Tests', () => {
805804

806805
it('document reference delete()', async () => {
807806
await runFirestoreOperationInRootSpan(() =>
808-
firestore.collection('foo').doc('bar').delete(),
807+
randomCol.doc('bar').delete(),
809808
);
810809
await waitForCompletedSpans(3);
811810
expectSpanHierarchy(
@@ -821,7 +820,7 @@ describe.skipEnterprise('Tracing Tests', () => {
821820

822821
it('document reference set()', async () => {
823822
await runFirestoreOperationInRootSpan(() =>
824-
firestore.collection('foo').doc('bar').set({foo: 'bar'}),
823+
randomCol.doc('bar').set({foo: 'bar'}),
825824
);
826825
await waitForCompletedSpans(3);
827826
expectSpanHierarchy(
@@ -838,10 +837,10 @@ describe.skipEnterprise('Tracing Tests', () => {
838837
it('document reference update()', async () => {
839838
// Make sure the document exists before updating it.
840839
// Perform the `set` operation outside of the root span.
841-
await firestore.collection('foo').doc('bar').set({foo: 'bar'});
840+
await randomCol.doc('bar').set({foo: 'bar'});
842841

843842
await runFirestoreOperationInRootSpan(() =>
844-
firestore.collection('foo').doc('bar').update('foo', 'bar2'),
843+
randomCol.doc('bar').update('foo', 'bar2'),
845844
);
846845
await waitForCompletedSpans(3);
847846
expectSpanHierarchy(
@@ -857,7 +856,7 @@ describe.skipEnterprise('Tracing Tests', () => {
857856

858857
it('document reference list collections', async () => {
859858
await runFirestoreOperationInRootSpan(() =>
860-
firestore.collection('foo').doc('bar').listCollections(),
859+
randomCol.doc('bar').listCollections(),
861860
);
862861
await waitForCompletedSpans(2);
863862
expectSpanHierarchy(
@@ -871,9 +870,7 @@ describe.skipEnterprise('Tracing Tests', () => {
871870
});
872871

873872
it('aggregate query get()', async () => {
874-
await runFirestoreOperationInRootSpan(() =>
875-
firestore.collection('foo').count().get(),
876-
);
873+
await runFirestoreOperationInRootSpan(() => randomCol.count().get());
877874
await waitForCompletedSpans(2);
878875
expectSpanHierarchy(SPAN_NAME_TEST_ROOT, SPAN_NAME_AGGREGATION_QUERY_GET);
879876
expectSpanHasEvents(SPAN_NAME_AGGREGATION_QUERY_GET, [
@@ -884,9 +881,7 @@ describe.skipEnterprise('Tracing Tests', () => {
884881
});
885882

886883
it('collection reference add()', async () => {
887-
await runFirestoreOperationInRootSpan(() =>
888-
firestore.collection('foo').add({foo: 'bar'}),
889-
);
884+
await runFirestoreOperationInRootSpan(() => randomCol.add({foo: 'bar'}));
890885
await waitForCompletedSpans(4);
891886
expectSpanHierarchy(
892887
SPAN_NAME_TEST_ROOT,
@@ -902,9 +897,7 @@ describe.skipEnterprise('Tracing Tests', () => {
902897

903898
// Enterprise: field mask is not supported
904899
it.skipEnterprise('collection reference list documents', async () => {
905-
await runFirestoreOperationInRootSpan(() =>
906-
firestore.collection('foo').listDocuments(),
907-
);
900+
await runFirestoreOperationInRootSpan(() => randomCol.listDocuments());
908901
await waitForCompletedSpans(2);
909902
expectSpanHierarchy(
910903
SPAN_NAME_TEST_ROOT,
@@ -918,7 +911,7 @@ describe.skipEnterprise('Tracing Tests', () => {
918911

919912
it('query get()', async () => {
920913
await runFirestoreOperationInRootSpan(() =>
921-
firestore.collection('foo').where('foo', '==', 'bar').limit(1).get(),
914+
randomCol.where('foo', '==', 'bar').limit(1).get(),
922915
);
923916
await waitForCompletedSpans(2);
924917
expectSpanHierarchy(SPAN_NAME_TEST_ROOT, SPAN_NAME_QUERY_GET);
@@ -935,8 +928,8 @@ describe.skipEnterprise('Tracing Tests', () => {
935928
});
936929

937930
it('firestore getAll()', async () => {
938-
const docRef1 = firestore.collection('foo').doc('1');
939-
const docRef2 = firestore.collection('foo').doc('2');
931+
const docRef1 = randomCol.doc('1');
932+
const docRef2 = randomCol.doc('2');
940933
await runFirestoreOperationInRootSpan(() =>
941934
firestore.getAll(docRef1, docRef2),
942935
);
@@ -954,16 +947,18 @@ describe.skipEnterprise('Tracing Tests', () => {
954947
});
955948

956949
it('transaction', async () => {
957-
const docRef1 = firestore.collection('foo').doc('bar');
958-
const docRef2 = firestore.collection('foo').doc('bar');
950+
const docRef1 = randomCol.doc('bar');
951+
const docRef2 = randomCol.doc('bar');
959952

960953
await runFirestoreOperationInRootSpan(async () => {
961954
return firestore.runTransaction(async transaction => {
962955
await transaction.get(docRef1);
963956
await transaction.getAll(docRef1, docRef2);
964-
await transaction.get(firestore.collection('foo').limit(1));
965-
await transaction.get(firestore.collection('nonexistent').count());
966-
transaction.set(firestore.collection('foo').doc(), {foo: 'bar'});
957+
await transaction.get(randomCol.limit(1));
958+
await transaction.get(
959+
firestore.collection('nonexistent_' + autoId()).count(),
960+
);
961+
transaction.set(randomCol.doc(), {foo: 'bar'});
967962
});
968963
});
969964

@@ -1032,7 +1027,7 @@ describe.skipEnterprise('Tracing Tests', () => {
10321027
// Service not implemented for Enterprise DB: PartitionQuery
10331028
it.skipEnterprise('partition query', async () => {
10341029
await runFirestoreOperationInRootSpan(async () => {
1035-
const query = firestore.collectionGroup('foo');
1030+
const query = firestore.collectionGroup('node_cg_' + autoId());
10361031
let numPartitions = 0;
10371032
// eslint-disable-next-line @typescript-eslint/no-unused-vars
10381033
for await (const partition of query.getPartitions(3)) {
@@ -1052,11 +1047,11 @@ describe.skipEnterprise('Tracing Tests', () => {
10521047
await runFirestoreOperationInRootSpan(async () => {
10531048
const bulkWriter = firestore.bulkWriter();
10541049
// No need to await the set operations as 'close()' will commit all writes before closing.
1055-
void bulkWriter.set(firestore.collection('foo').doc(), {foo: 1});
1056-
void bulkWriter.set(firestore.collection('foo').doc(), {foo: 2});
1057-
void bulkWriter.set(firestore.collection('foo').doc(), {foo: 3});
1058-
void bulkWriter.set(firestore.collection('foo').doc(), {foo: 4});
1059-
void bulkWriter.set(firestore.collection('foo').doc(), {foo: 5});
1050+
void bulkWriter.set(randomCol.doc(), {foo: 1});
1051+
void bulkWriter.set(randomCol.doc(), {foo: 2});
1052+
void bulkWriter.set(randomCol.doc(), {foo: 3});
1053+
void bulkWriter.set(randomCol.doc(), {foo: 4});
1054+
void bulkWriter.set(randomCol.doc(), {foo: 5});
10601055
await bulkWriter.close();
10611056
});
10621057

handwritten/firestore/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"system-test:named-db:emulator:rest": "FIRESTORE_NAMED_DATABASE=test-db FIRESTORE_EMULATOR_HOST=localhost:8080 FIRESTORE_PREFER_REST=true mocha build/system-test --timeout 1200000",
4848
"system-test:emulator:grpc": "FIRESTORE_EMULATOR_HOST=localhost:8080 mocha build/system-test --timeout 1200000",
4949
"system-test:named-db:emulator:grpc": "FIRESTORE_NAMED_DATABASE=test-db FIRESTORE_EMULATOR_HOST=localhost:8080 mocha build/system-test --timeout 1200000",
50-
"system-test": "npm run system-test:grpc && npm run system-test:rest && npm run system-test:named-db:grpc && npm run system-test:named-db:rest",
50+
"system-test": "concurrently -p \"[{name}]\" -n \"grpc,rest,named-db-grpc,named-db-rest\" -c \"cyan,magenta,blue,yellow\" \"npm:system-test:grpc\" \"npm:system-test:rest\" \"npm:system-test:named-db:grpc\" \"npm:system-test:named-db:rest\"",
5151
"system-test:nightly": "FIRESTORE_TARGET_BACKEND=nightly FIRESTORE_NAMED_DATABASE=enterprise RUN_ENTERPRISE_TESTS=yes GCLOUD_PROJECT=firestore-sdk-nightly mocha build/system-test --timeout 1200000",
52-
"system-test:emulator": "npm run system-test:emulator:grpc && npm run system-test:emulator:rest && npm run system-test:named-db:emulator:grpc && npm run system-test:named-db:emulator:rest",
52+
"system-test:emulator": "concurrently -p \"[{name}]\" -n \"grpc,rest,named-db-grpc,named-db-rest\" -c \"cyan,magenta,blue,yellow\" \"npm:system-test:emulator:grpc\" \"npm:system-test:emulator:rest\" \"npm:system-test:named-db:emulator:grpc\" \"npm:system-test:named-db:emulator:rest\"",
5353
"presystem-test": "npm run compile",
5454
"samples-test": "npm link && cd samples/ && npm link ../ && npm test && cd ../",
5555
"conformance": "mocha build/conformance",
@@ -96,6 +96,7 @@
9696
"chai": "^4.5.0",
9797
"chai-as-promised": "^7.1.2",
9898
"codecov": "^3.8.3",
99+
"concurrently": "^9.1.2",
99100
"duplexify": "^4.1.3",
100101
"eslint-plugin-node": "^11.1.0",
101102
"execa": "^9.6.0",

0 commit comments

Comments
 (0)