@@ -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' ;
4546import { verifyInstance } from '../test/util/helpers' ;
4647import {
4748 ATTRIBUTE_GCP_RESOURCE_NAME ,
@@ -159,6 +160,7 @@ class SpanData {
159160
160161describe . 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 {
@@ -768,7 +771,7 @@ describe.skipEnterprise('Tracing Tests', () => {
768771 function runTestCases ( ) {
769772 it ( 'document reference get()' , async ( ) => {
770773 await runFirestoreOperationInRootSpan ( ( ) =>
771- firestore . collection ( 'foo' ) . doc ( 'bar' ) . get ( ) ,
774+ randomCol . doc ( 'bar' ) . get ( ) ,
772775 ) ;
773776 await waitForCompletedSpans ( 3 ) ;
774777 expectSpanHierarchy (
@@ -789,7 +792,7 @@ describe.skipEnterprise('Tracing Tests', () => {
789792
790793 it ( 'document reference create()' , async ( ) => {
791794 await runFirestoreOperationInRootSpan ( ( ) =>
792- firestore . collection ( 'foo' ) . doc ( ) . create ( { } ) ,
795+ randomCol . doc ( ) . create ( { } ) ,
793796 ) ;
794797 await waitForCompletedSpans ( 3 ) ;
795798 expectSpanHierarchy (
@@ -805,7 +808,7 @@ describe.skipEnterprise('Tracing Tests', () => {
805808
806809 it ( 'document reference delete()' , async ( ) => {
807810 await runFirestoreOperationInRootSpan ( ( ) =>
808- firestore . collection ( 'foo' ) . doc ( 'bar' ) . delete ( ) ,
811+ randomCol . doc ( 'bar' ) . delete ( ) ,
809812 ) ;
810813 await waitForCompletedSpans ( 3 ) ;
811814 expectSpanHierarchy (
@@ -821,7 +824,7 @@ describe.skipEnterprise('Tracing Tests', () => {
821824
822825 it ( 'document reference set()' , async ( ) => {
823826 await runFirestoreOperationInRootSpan ( ( ) =>
824- firestore . collection ( 'foo' ) . doc ( 'bar' ) . set ( { foo : 'bar' } ) ,
827+ randomCol . doc ( 'bar' ) . set ( { foo : 'bar' } ) ,
825828 ) ;
826829 await waitForCompletedSpans ( 3 ) ;
827830 expectSpanHierarchy (
@@ -838,10 +841,10 @@ describe.skipEnterprise('Tracing Tests', () => {
838841 it ( 'document reference update()' , async ( ) => {
839842 // Make sure the document exists before updating it.
840843 // Perform the `set` operation outside of the root span.
841- await firestore . collection ( 'foo' ) . doc ( 'bar' ) . set ( { foo : 'bar' } ) ;
844+ await randomCol . doc ( 'bar' ) . set ( { foo : 'bar' } ) ;
842845
843846 await runFirestoreOperationInRootSpan ( ( ) =>
844- firestore . collection ( 'foo' ) . doc ( 'bar' ) . update ( 'foo' , 'bar2' ) ,
847+ randomCol . doc ( 'bar' ) . update ( 'foo' , 'bar2' ) ,
845848 ) ;
846849 await waitForCompletedSpans ( 3 ) ;
847850 expectSpanHierarchy (
@@ -857,7 +860,7 @@ describe.skipEnterprise('Tracing Tests', () => {
857860
858861 it ( 'document reference list collections' , async ( ) => {
859862 await runFirestoreOperationInRootSpan ( ( ) =>
860- firestore . collection ( 'foo' ) . doc ( 'bar' ) . listCollections ( ) ,
863+ randomCol . doc ( 'bar' ) . listCollections ( ) ,
861864 ) ;
862865 await waitForCompletedSpans ( 2 ) ;
863866 expectSpanHierarchy (
@@ -872,7 +875,7 @@ describe.skipEnterprise('Tracing Tests', () => {
872875
873876 it ( 'aggregate query get()' , async ( ) => {
874877 await runFirestoreOperationInRootSpan ( ( ) =>
875- firestore . collection ( 'foo' ) . count ( ) . get ( ) ,
878+ randomCol . count ( ) . get ( ) ,
876879 ) ;
877880 await waitForCompletedSpans ( 2 ) ;
878881 expectSpanHierarchy ( SPAN_NAME_TEST_ROOT , SPAN_NAME_AGGREGATION_QUERY_GET ) ;
@@ -885,7 +888,7 @@ describe.skipEnterprise('Tracing Tests', () => {
885888
886889 it ( 'collection reference add()' , async ( ) => {
887890 await runFirestoreOperationInRootSpan ( ( ) =>
888- firestore . collection ( 'foo' ) . add ( { foo : 'bar' } ) ,
891+ randomCol . add ( { foo : 'bar' } ) ,
889892 ) ;
890893 await waitForCompletedSpans ( 4 ) ;
891894 expectSpanHierarchy (
@@ -903,7 +906,7 @@ describe.skipEnterprise('Tracing Tests', () => {
903906 // Enterprise: field mask is not supported
904907 it . skipEnterprise ( 'collection reference list documents' , async ( ) => {
905908 await runFirestoreOperationInRootSpan ( ( ) =>
906- firestore . collection ( 'foo' ) . listDocuments ( ) ,
909+ randomCol . listDocuments ( ) ,
907910 ) ;
908911 await waitForCompletedSpans ( 2 ) ;
909912 expectSpanHierarchy (
@@ -918,7 +921,7 @@ describe.skipEnterprise('Tracing Tests', () => {
918921
919922 it ( 'query get()' , async ( ) => {
920923 await runFirestoreOperationInRootSpan ( ( ) =>
921- firestore . collection ( 'foo' ) . where ( 'foo' , '==' , 'bar' ) . limit ( 1 ) . get ( ) ,
924+ randomCol . where ( 'foo' , '==' , 'bar' ) . limit ( 1 ) . get ( ) ,
922925 ) ;
923926 await waitForCompletedSpans ( 2 ) ;
924927 expectSpanHierarchy ( SPAN_NAME_TEST_ROOT , SPAN_NAME_QUERY_GET ) ;
@@ -935,8 +938,8 @@ describe.skipEnterprise('Tracing Tests', () => {
935938 } ) ;
936939
937940 it ( 'firestore getAll()' , async ( ) => {
938- const docRef1 = firestore . collection ( 'foo' ) . doc ( '1' ) ;
939- const docRef2 = firestore . collection ( 'foo' ) . doc ( '2' ) ;
941+ const docRef1 = randomCol . doc ( '1' ) ;
942+ const docRef2 = randomCol . doc ( '2' ) ;
940943 await runFirestoreOperationInRootSpan ( ( ) =>
941944 firestore . getAll ( docRef1 , docRef2 ) ,
942945 ) ;
@@ -954,16 +957,16 @@ describe.skipEnterprise('Tracing Tests', () => {
954957 } ) ;
955958
956959 it ( 'transaction' , async ( ) => {
957- const docRef1 = firestore . collection ( 'foo' ) . doc ( 'bar' ) ;
958- const docRef2 = firestore . collection ( 'foo' ) . doc ( 'bar' ) ;
960+ const docRef1 = randomCol . doc ( 'bar' ) ;
961+ const docRef2 = randomCol . doc ( 'bar' ) ;
959962
960963 await runFirestoreOperationInRootSpan ( async ( ) => {
961964 return firestore . runTransaction ( async transaction => {
962965 await transaction . get ( docRef1 ) ;
963966 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' } ) ;
967+ await transaction . get ( randomCol . limit ( 1 ) ) ;
968+ await transaction . get ( firestore . collection ( 'nonexistent_' + autoId ( ) ) . count ( ) ) ;
969+ transaction . set ( randomCol . doc ( ) , { foo : 'bar' } ) ;
967970 } ) ;
968971 } ) ;
969972
@@ -1032,7 +1035,7 @@ describe.skipEnterprise('Tracing Tests', () => {
10321035 // Service not implemented for Enterprise DB: PartitionQuery
10331036 it . skipEnterprise ( 'partition query' , async ( ) => {
10341037 await runFirestoreOperationInRootSpan ( async ( ) => {
1035- const query = firestore . collectionGroup ( 'foo' ) ;
1038+ const query = firestore . collectionGroup ( 'node_cg_' + autoId ( ) ) ;
10361039 let numPartitions = 0 ;
10371040 // eslint-disable-next-line @typescript-eslint/no-unused-vars
10381041 for await ( const partition of query . getPartitions ( 3 ) ) {
@@ -1052,11 +1055,11 @@ describe.skipEnterprise('Tracing Tests', () => {
10521055 await runFirestoreOperationInRootSpan ( async ( ) => {
10531056 const bulkWriter = firestore . bulkWriter ( ) ;
10541057 // 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 } ) ;
1058+ void bulkWriter . set ( randomCol . doc ( ) , { foo : 1 } ) ;
1059+ void bulkWriter . set ( randomCol . doc ( ) , { foo : 2 } ) ;
1060+ void bulkWriter . set ( randomCol . doc ( ) , { foo : 3 } ) ;
1061+ void bulkWriter . set ( randomCol . doc ( ) , { foo : 4 } ) ;
1062+ void bulkWriter . set ( randomCol . doc ( ) , { foo : 5 } ) ;
10601063 await bulkWriter . close ( ) ;
10611064 } ) ;
10621065
0 commit comments