@@ -32,9 +32,9 @@ describeSpec('Performance Tests:', ['benchmark'], () => {
32
32
} ) ;
33
33
34
34
specTest ( 'Insert a new document and wait for snapshot' , [ ] , ( ) => {
35
- let version = 2 ;
36
-
35
+ let currentVersion = 1 ;
37
36
let steps = spec ( ) . withGCEnabled ( false ) ;
37
+
38
38
for ( let i = 0 ; i < STEP_COUNT ; ++ i ) {
39
39
const query = Query . atPath ( path ( `collection/${ i } ` ) ) ;
40
40
const docLocal = doc (
@@ -43,7 +43,7 @@ describeSpec('Performance Tests:', ['benchmark'], () => {
43
43
{ doc : i } ,
44
44
{ hasLocalMutations : true }
45
45
) ;
46
- const docRemote = doc ( `collection/${ i } ` , ++ version , { doc : i } ) ;
46
+ const docRemote = doc ( `collection/${ i } ` , ++ currentVersion , { doc : i } ) ;
47
47
48
48
steps = steps
49
49
. userListens ( query )
@@ -53,8 +53,8 @@ describeSpec('Performance Tests:', ['benchmark'], () => {
53
53
fromCache : true ,
54
54
hasPendingWrites : true
55
55
} )
56
- . writeAcks ( ++ version )
57
- . watchAcksFull ( query , ++ version , docRemote )
56
+ . writeAcks ( ++ currentVersion )
57
+ . watchAcksFull ( query , ++ currentVersion , docRemote )
58
58
. expectEvents ( query , { metadata : [ docRemote ] } )
59
59
. userUnlistens ( query )
60
60
. watchRemoves ( query ) ;
@@ -94,91 +94,88 @@ describeSpec('Performance Tests:', ['benchmark'], () => {
94
94
95
95
specTest ( 'Update a single document' , [ ] , ( ) => {
96
96
let steps = spec ( ) . withGCEnabled ( false ) ;
97
-
98
97
steps = steps . userSets ( `collection/doc` , { v : 0 } ) ;
99
98
for ( let i = 1 ; i <= STEP_COUNT ; ++ i ) {
100
99
steps = steps . userPatches ( `collection/doc` , { v : i } ) . writeAcks ( i ) ;
101
100
}
102
101
return steps ;
103
102
} ) ;
104
103
105
- specTest (
106
- 'Update a single document and wait for snapshot' ,
107
- [ ] ,
108
- ( ) => {
109
- let version = 1 ;
104
+ specTest ( 'Update a single document and wait for snapshot' , [ ] , ( ) => {
105
+ const query = Query . atPath ( path ( `collection/doc` ) ) ;
106
+
107
+ let currentVersion = 1 ;
108
+ let steps = spec ( ) . withGCEnabled ( false ) ;
109
+
110
+ let docLocal = doc (
111
+ `collection/doc` ,
112
+ 0 ,
113
+ { v : 0 } ,
114
+ { hasLocalMutations : true }
115
+ ) ;
116
+ let docRemote = doc ( `collection/doc` , ++ currentVersion , { v : 0 } ) ;
117
+ let lastRemoteVersion = currentVersion ;
110
118
111
- const query = Query . atPath ( path ( `collection/doc` ) ) ;
112
- let docLocal = doc (
119
+ steps = steps
120
+ . userListens ( query )
121
+ . userSets ( `collection/doc` , { v : 0 } )
122
+ . expectEvents ( query , {
123
+ added : [ docLocal ] ,
124
+ fromCache : true ,
125
+ hasPendingWrites : true
126
+ } )
127
+ . writeAcks ( ++ currentVersion )
128
+ . watchAcksFull ( query , ++ currentVersion , docRemote )
129
+ . expectEvents ( query , { metadata : [ docRemote ] } ) ;
130
+
131
+ for ( let i = 1 ; i <= STEP_COUNT ; ++ i ) {
132
+ docLocal = doc (
113
133
`collection/doc` ,
114
- 0 ,
115
- { v : 0 } ,
134
+ lastRemoteVersion ,
135
+ { v : i } ,
116
136
{ hasLocalMutations : true }
117
137
) ;
118
- let docRemote = doc ( `collection/doc` , ++ version , { v : 0 } ) ;
119
- let lastRemoteVersion = version ;
120
-
121
- let steps = spec ( ) . withGCEnabled ( false ) ;
138
+ docRemote = doc ( `collection/doc` , ++ currentVersion , { v : i } ) ;
139
+ lastRemoteVersion = currentVersion ;
122
140
123
141
steps = steps
124
- . userListens ( query )
125
- . userSets ( `collection/doc` , { v : 0 } )
126
- . expectEvents ( query , {
127
- added : [ docLocal ] ,
128
- fromCache : true ,
129
- hasPendingWrites : true
130
- } )
131
- . writeAcks ( ++ version )
132
- . watchAcksFull ( query , ++ version , docRemote )
142
+ . userPatches ( `collection/doc` , { v : i } )
143
+ . expectEvents ( query , { modified : [ docLocal ] , hasPendingWrites : true } )
144
+ . writeAcks ( ++ currentVersion )
145
+ . watchSends ( { affects : [ query ] } , docRemote )
146
+ . watchSnapshots ( ++ currentVersion )
133
147
. expectEvents ( query , { metadata : [ docRemote ] } ) ;
134
-
135
- for ( let i = 1 ; i <= STEP_COUNT ; ++ i ) {
136
- docLocal = doc (
137
- `collection/doc` ,
138
- lastRemoteVersion ,
139
- { v : i } ,
140
- { hasLocalMutations : true }
141
- ) ;
142
- docRemote = doc ( `collection/doc` , ++ version , { v : i } ) ;
143
- lastRemoteVersion = version ;
144
-
145
- steps = steps
146
- . userPatches ( `collection/doc` , { v : i } )
147
- . expectEvents ( query , { modified : [ docLocal ] , hasPendingWrites : true } )
148
- . writeAcks ( ++ version )
149
- . watchSends ( { affects : [ query ] } , docRemote )
150
- . watchSnapshots ( ++ version )
151
- . expectEvents ( query , { metadata : [ docRemote ] } ) ;
152
- }
153
- return steps ;
154
148
}
155
- ) ;
149
+ return steps ;
150
+ } ) ;
156
151
157
152
specTest ( 'Watch sends 100 documents' , [ ] , ( ) => {
158
- let version = 1 ;
159
153
const documentsPerStep = 100 ;
160
154
161
155
const query = Query . atPath ( path ( `collection` ) ) . addOrderBy ( orderBy ( 'v' ) ) ;
162
156
157
+ let currentVersion = 1 ;
163
158
let steps = spec ( ) . withGCEnabled ( false ) ;
164
159
165
160
steps = steps
166
161
. userListens ( query )
167
- . watchAcksFull ( query , version )
162
+ . watchAcksFull ( query , currentVersion )
168
163
. expectEvents ( query , { } ) ;
169
164
170
165
for ( let i = 1 ; i <= STEP_COUNT ; ++ i ) {
171
166
const docs = [ ] ;
172
167
173
168
for ( let j = 0 ; j < documentsPerStep ; ++ j ) {
174
- docs . push ( doc ( `collection/${ j } ` , ++ version , { v : version } ) ) ;
169
+ docs . push (
170
+ doc ( `collection/${ j } ` , ++ currentVersion , { v : currentVersion } )
171
+ ) ;
175
172
}
176
173
177
174
const changeType = i === 1 ? 'added' : 'modified' ;
178
175
179
176
steps = steps
180
177
. watchSends ( { affects : [ query ] } , ...docs )
181
- . watchSnapshots ( ++ version )
178
+ . watchSnapshots ( ++ currentVersion )
182
179
. expectEvents ( query , { [ changeType ] : docs } ) ;
183
180
}
184
181
@@ -187,8 +184,8 @@ describeSpec('Performance Tests:', ['benchmark'], () => {
187
184
188
185
specTest ( 'Watch has cached results' , [ ] , ( ) => {
189
186
const documentsPerStep = 100 ;
190
- let version = 1 ;
191
187
188
+ let currentVersion = 1 ;
192
189
let steps = spec ( ) . withGCEnabled ( false ) ;
193
190
194
191
for ( let i = 1 ; i <= STEP_COUNT ; ++ i ) {
@@ -197,18 +194,18 @@ describeSpec('Performance Tests:', ['benchmark'], () => {
197
194
198
195
const docs = [ ] ;
199
196
for ( let j = 0 ; j < documentsPerStep ; ++ j ) {
200
- docs . push ( doc ( `${ collPath } /${ j } ` , ++ version , { v : j } ) ) ;
197
+ docs . push ( doc ( `${ collPath } /${ j } ` , ++ currentVersion , { v : j } ) ) ;
201
198
}
202
199
203
200
steps = steps
204
201
. userListens ( query )
205
- . watchAcksFull ( query , ++ version , ...docs )
202
+ . watchAcksFull ( query , ++ currentVersion , ...docs )
206
203
. expectEvents ( query , { added : docs } )
207
204
. userUnlistens ( query )
208
205
. watchRemoves ( query )
209
- . userListens ( query , 'resume-token-' + version )
206
+ . userListens ( query , 'resume-token-' + currentVersion )
210
207
. expectEvents ( query , { added : docs , fromCache : true } )
211
- . watchAcksFull ( query , ++ version )
208
+ . watchAcksFull ( query , ++ currentVersion )
212
209
. expectEvents ( query , { } )
213
210
. userUnlistens ( query )
214
211
. watchRemoves ( query ) ;
0 commit comments