@powersync/service-core-tests 0.15.0 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/test-utils/general-utils.d.ts +13 -1
- package/dist/test-utils/general-utils.js +30 -1
- package/dist/test-utils/general-utils.js.map +1 -1
- package/dist/test-utils/stream_utils.js +2 -2
- package/dist/test-utils/stream_utils.js.map +1 -1
- package/dist/tests/register-compacting-tests.js +266 -257
- package/dist/tests/register-compacting-tests.js.map +1 -1
- package/dist/tests/register-data-storage-checkpoint-tests.js +36 -57
- package/dist/tests/register-data-storage-checkpoint-tests.js.map +1 -1
- package/dist/tests/register-data-storage-data-tests.js +839 -863
- package/dist/tests/register-data-storage-data-tests.js.map +1 -1
- package/dist/tests/register-data-storage-parameter-tests.js +228 -236
- package/dist/tests/register-data-storage-parameter-tests.js.map +1 -1
- package/dist/tests/register-parameter-compacting-tests.js +81 -89
- package/dist/tests/register-parameter-compacting-tests.js.map +1 -1
- package/dist/tests/register-sync-tests.js +468 -462
- package/dist/tests/register-sync-tests.js.map +1 -1
- package/package.json +3 -3
- package/src/test-utils/general-utils.ts +41 -2
- package/src/test-utils/stream_utils.ts +2 -2
- package/src/tests/register-compacting-tests.ts +279 -270
- package/src/tests/register-data-storage-checkpoint-tests.ts +36 -57
- package/src/tests/register-data-storage-data-tests.ts +673 -770
- package/src/tests/register-data-storage-parameter-tests.ts +245 -257
- package/src/tests/register-parameter-compacting-tests.ts +84 -92
- package/src/tests/register-sync-tests.ts +375 -391
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -6,7 +6,6 @@ import { bucketRequestMap, bucketRequests } from './util.js';
|
|
|
6
6
|
|
|
7
7
|
export function registerCompactTests(config: storage.TestStorageConfig) {
|
|
8
8
|
const generateStorageFactory = config.factory;
|
|
9
|
-
const TEST_TABLE = test_utils.makeTestTable('test', ['id'], config);
|
|
10
9
|
|
|
11
10
|
test('compacting (1)', async () => {
|
|
12
11
|
await using factory = await generateStorageFactory();
|
|
@@ -19,39 +18,40 @@ bucket_definitions:
|
|
|
19
18
|
);
|
|
20
19
|
const bucketStorage = factory.getInstance(syncRules);
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await batch.save({
|
|
34
|
-
sourceTable: TEST_TABLE,
|
|
35
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
36
|
-
after: {
|
|
37
|
-
id: 't2'
|
|
38
|
-
},
|
|
39
|
-
afterReplicaId: test_utils.rid('t2')
|
|
40
|
-
});
|
|
21
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
22
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
23
|
+
await writer.markAllSnapshotDone('1/1');
|
|
24
|
+
await writer.save({
|
|
25
|
+
sourceTable: testTable,
|
|
26
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
27
|
+
after: {
|
|
28
|
+
id: 't1'
|
|
29
|
+
},
|
|
30
|
+
afterReplicaId: test_utils.rid('t1')
|
|
31
|
+
});
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
await writer.save({
|
|
34
|
+
sourceTable: testTable,
|
|
35
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
36
|
+
after: {
|
|
37
|
+
id: 't2'
|
|
38
|
+
},
|
|
39
|
+
afterReplicaId: test_utils.rid('t2')
|
|
40
|
+
});
|
|
50
41
|
|
|
51
|
-
|
|
42
|
+
await writer.save({
|
|
43
|
+
sourceTable: testTable,
|
|
44
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
45
|
+
after: {
|
|
46
|
+
id: 't2'
|
|
47
|
+
},
|
|
48
|
+
afterReplicaId: test_utils.rid('t2')
|
|
52
49
|
});
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
await writer.commit('1/1');
|
|
52
|
+
await writer.flush();
|
|
53
|
+
|
|
54
|
+
const checkpoint = writer.last_flushed_op!;
|
|
55
55
|
|
|
56
56
|
const request = bucketRequest(syncRules, 'global[]');
|
|
57
57
|
|
|
@@ -125,48 +125,49 @@ bucket_definitions:
|
|
|
125
125
|
);
|
|
126
126
|
const bucketStorage = factory.getInstance(syncRules);
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
await batch.save({
|
|
140
|
-
sourceTable: TEST_TABLE,
|
|
141
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
142
|
-
after: {
|
|
143
|
-
id: 't2'
|
|
144
|
-
},
|
|
145
|
-
afterReplicaId: test_utils.rid('t2')
|
|
146
|
-
});
|
|
128
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
129
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
130
|
+
await writer.markAllSnapshotDone('1/1');
|
|
131
|
+
await writer.save({
|
|
132
|
+
sourceTable: testTable,
|
|
133
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
134
|
+
after: {
|
|
135
|
+
id: 't1'
|
|
136
|
+
},
|
|
137
|
+
afterReplicaId: test_utils.rid('t1')
|
|
138
|
+
});
|
|
147
139
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
140
|
+
await writer.save({
|
|
141
|
+
sourceTable: testTable,
|
|
142
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
143
|
+
after: {
|
|
144
|
+
id: 't2'
|
|
145
|
+
},
|
|
146
|
+
afterReplicaId: test_utils.rid('t2')
|
|
147
|
+
});
|
|
156
148
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
149
|
+
await writer.save({
|
|
150
|
+
sourceTable: testTable,
|
|
151
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
152
|
+
before: {
|
|
153
|
+
id: 't1'
|
|
154
|
+
},
|
|
155
|
+
beforeReplicaId: test_utils.rid('t1')
|
|
156
|
+
});
|
|
165
157
|
|
|
166
|
-
|
|
158
|
+
await writer.save({
|
|
159
|
+
sourceTable: testTable,
|
|
160
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
161
|
+
after: {
|
|
162
|
+
id: 't2'
|
|
163
|
+
},
|
|
164
|
+
afterReplicaId: test_utils.rid('t2')
|
|
167
165
|
});
|
|
168
166
|
|
|
169
|
-
|
|
167
|
+
await writer.commit('1/1');
|
|
168
|
+
await writer.flush();
|
|
169
|
+
|
|
170
|
+
const checkpoint = writer.last_flushed_op!;
|
|
170
171
|
const request = bucketRequest(syncRules, 'global[]');
|
|
171
172
|
|
|
172
173
|
const batchBefore = await test_utils.oneFromAsync(bucketStorage.getBucketDataBatch(checkpoint, [request]));
|
|
@@ -240,54 +241,54 @@ bucket_definitions:
|
|
|
240
241
|
);
|
|
241
242
|
const bucketStorage = factory.getInstance(syncRules);
|
|
242
243
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
await batch.save({
|
|
255
|
-
sourceTable: TEST_TABLE,
|
|
256
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
257
|
-
after: {
|
|
258
|
-
id: 't2'
|
|
259
|
-
},
|
|
260
|
-
afterReplicaId: 't2'
|
|
261
|
-
});
|
|
244
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
245
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
246
|
+
await writer.markAllSnapshotDone('1/1');
|
|
247
|
+
await writer.save({
|
|
248
|
+
sourceTable: testTable,
|
|
249
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
250
|
+
after: {
|
|
251
|
+
id: 't1'
|
|
252
|
+
},
|
|
253
|
+
afterReplicaId: 't1'
|
|
254
|
+
});
|
|
262
255
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
256
|
+
await writer.save({
|
|
257
|
+
sourceTable: testTable,
|
|
258
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
259
|
+
after: {
|
|
260
|
+
id: 't2'
|
|
261
|
+
},
|
|
262
|
+
afterReplicaId: 't2'
|
|
263
|
+
});
|
|
271
264
|
|
|
272
|
-
|
|
265
|
+
await writer.save({
|
|
266
|
+
sourceTable: testTable,
|
|
267
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
268
|
+
before: {
|
|
269
|
+
id: 't1'
|
|
270
|
+
},
|
|
271
|
+
beforeReplicaId: 't1'
|
|
273
272
|
});
|
|
274
273
|
|
|
275
|
-
|
|
274
|
+
await writer.commit('1/1');
|
|
275
|
+
await writer.flush();
|
|
276
|
+
|
|
277
|
+
const checkpoint1 = writer.last_flushed_op!;
|
|
276
278
|
const request = bucketRequest(syncRules, 'global[]');
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
beforeReplicaId: 't2'
|
|
287
|
-
});
|
|
288
|
-
await batch.commit('2/1');
|
|
279
|
+
await using writer2 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
280
|
+
const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
|
|
281
|
+
await writer2.save({
|
|
282
|
+
sourceTable: testTable2,
|
|
283
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
284
|
+
before: {
|
|
285
|
+
id: 't2'
|
|
286
|
+
},
|
|
287
|
+
beforeReplicaId: 't2'
|
|
289
288
|
});
|
|
290
|
-
|
|
289
|
+
await writer2.commit('2/1');
|
|
290
|
+
await writer2.flush();
|
|
291
|
+
const checkpoint2 = writer2.last_flushed_op!;
|
|
291
292
|
|
|
292
293
|
await bucketStorage.compact({
|
|
293
294
|
clearBatchLimit: 2,
|
|
@@ -328,76 +329,78 @@ bucket_definitions:
|
|
|
328
329
|
);
|
|
329
330
|
const bucketStorage = factory.getInstance(syncRules);
|
|
330
331
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}
|
|
332
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
333
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
334
|
+
await writer.markAllSnapshotDone('1/1');
|
|
335
|
+
/**
|
|
336
|
+
* Repeatedly create operations which fall into different buckets.
|
|
337
|
+
* The bucket operations are purposely interleaved as the op_id increases.
|
|
338
|
+
* A large amount of operations are created here.
|
|
339
|
+
* The configured window of compacting operations is 100. This means the initial window will
|
|
340
|
+
* contain operations from multiple buckets.
|
|
341
|
+
*/
|
|
342
|
+
for (let count = 0; count < 100; count++) {
|
|
343
|
+
await writer.save({
|
|
344
|
+
sourceTable: testTable,
|
|
345
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
346
|
+
after: {
|
|
347
|
+
id: 't1',
|
|
348
|
+
b: 'b1',
|
|
349
|
+
value: 'start'
|
|
350
|
+
},
|
|
351
|
+
afterReplicaId: test_utils.rid('t1')
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
await writer.save({
|
|
355
|
+
sourceTable: testTable,
|
|
356
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
357
|
+
after: {
|
|
358
|
+
id: 't1',
|
|
359
|
+
b: 'b1',
|
|
360
|
+
value: 'intermediate'
|
|
361
|
+
},
|
|
362
|
+
afterReplicaId: test_utils.rid('t1')
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
await writer.save({
|
|
366
|
+
sourceTable: testTable,
|
|
367
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
368
|
+
after: {
|
|
369
|
+
id: 't2',
|
|
370
|
+
b: 'b2',
|
|
371
|
+
value: 'start'
|
|
372
|
+
},
|
|
373
|
+
afterReplicaId: test_utils.rid('t2')
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
await writer.save({
|
|
377
|
+
sourceTable: testTable,
|
|
378
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
379
|
+
after: {
|
|
380
|
+
id: 't1',
|
|
381
|
+
b: 'b1',
|
|
382
|
+
value: 'final'
|
|
383
|
+
},
|
|
384
|
+
afterReplicaId: test_utils.rid('t1')
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
await writer.save({
|
|
388
|
+
sourceTable: testTable,
|
|
389
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
390
|
+
after: {
|
|
391
|
+
id: 't2',
|
|
392
|
+
b: 'b2',
|
|
393
|
+
value: 'final'
|
|
394
|
+
},
|
|
395
|
+
afterReplicaId: test_utils.rid('t2')
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
await writer.commit('1/1');
|
|
399
|
+
}
|
|
399
400
|
|
|
400
|
-
|
|
401
|
+
await writer.flush();
|
|
402
|
+
|
|
403
|
+
const checkpoint = writer.last_flushed_op!;
|
|
401
404
|
|
|
402
405
|
await bucketStorage.compact({
|
|
403
406
|
clearBatchLimit: 100,
|
|
@@ -456,38 +459,39 @@ bucket_definitions:
|
|
|
456
459
|
);
|
|
457
460
|
const bucketStorage = factory.getInstance(syncRules);
|
|
458
461
|
|
|
459
|
-
await bucketStorage.
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
await batch.save({
|
|
471
|
-
sourceTable: TEST_TABLE,
|
|
472
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
473
|
-
after: {
|
|
474
|
-
id: 't2'
|
|
475
|
-
},
|
|
476
|
-
afterReplicaId: 't2'
|
|
477
|
-
});
|
|
462
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
463
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
464
|
+
await writer.markAllSnapshotDone('1/1');
|
|
465
|
+
await writer.save({
|
|
466
|
+
sourceTable: testTable,
|
|
467
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
468
|
+
after: {
|
|
469
|
+
id: 't1'
|
|
470
|
+
},
|
|
471
|
+
afterReplicaId: 't1'
|
|
472
|
+
});
|
|
478
473
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
474
|
+
await writer.save({
|
|
475
|
+
sourceTable: testTable,
|
|
476
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
477
|
+
after: {
|
|
478
|
+
id: 't2'
|
|
479
|
+
},
|
|
480
|
+
afterReplicaId: 't2'
|
|
481
|
+
});
|
|
487
482
|
|
|
488
|
-
|
|
483
|
+
await writer.save({
|
|
484
|
+
sourceTable: testTable,
|
|
485
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
486
|
+
before: {
|
|
487
|
+
id: 't1'
|
|
488
|
+
},
|
|
489
|
+
beforeReplicaId: 't1'
|
|
489
490
|
});
|
|
490
491
|
|
|
492
|
+
await writer.commit('1/1');
|
|
493
|
+
await writer.flush();
|
|
494
|
+
|
|
491
495
|
await bucketStorage.compact({
|
|
492
496
|
clearBatchLimit: 2,
|
|
493
497
|
moveBatchLimit: 1,
|
|
@@ -496,18 +500,19 @@ bucket_definitions:
|
|
|
496
500
|
minChangeRatio: 0
|
|
497
501
|
});
|
|
498
502
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
await batch.commit('2/1');
|
|
503
|
+
await using writer2 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
504
|
+
const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
|
|
505
|
+
await writer2.save({
|
|
506
|
+
sourceTable: testTable2,
|
|
507
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
508
|
+
before: {
|
|
509
|
+
id: 't2'
|
|
510
|
+
},
|
|
511
|
+
beforeReplicaId: 't2'
|
|
509
512
|
});
|
|
510
|
-
|
|
513
|
+
await writer2.commit('2/1');
|
|
514
|
+
await writer2.flush();
|
|
515
|
+
const checkpoint2 = writer2.last_flushed_op!;
|
|
511
516
|
const request = bucketRequest(syncRules, 'global[]');
|
|
512
517
|
await bucketStorage.clearChecksumCache();
|
|
513
518
|
const checksumAfter = await bucketStorage.getChecksums(checkpoint2, [request]);
|
|
@@ -532,42 +537,44 @@ bucket_definitions:
|
|
|
532
537
|
);
|
|
533
538
|
const bucketStorage = factory.getInstance(syncRules);
|
|
534
539
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
await batch.save({
|
|
547
|
-
sourceTable: TEST_TABLE,
|
|
548
|
-
tag: storage.SaveOperationTag.UPDATE,
|
|
549
|
-
after: {
|
|
550
|
-
id: 't1'
|
|
551
|
-
},
|
|
552
|
-
afterReplicaId: 't1'
|
|
553
|
-
});
|
|
540
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
541
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
542
|
+
await writer.markAllSnapshotDone('1/1');
|
|
543
|
+
await writer.save({
|
|
544
|
+
sourceTable: testTable,
|
|
545
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
546
|
+
after: {
|
|
547
|
+
id: 't1'
|
|
548
|
+
},
|
|
549
|
+
afterReplicaId: 't1'
|
|
550
|
+
});
|
|
554
551
|
|
|
555
|
-
|
|
552
|
+
await writer.save({
|
|
553
|
+
sourceTable: testTable,
|
|
554
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
555
|
+
after: {
|
|
556
|
+
id: 't1'
|
|
557
|
+
},
|
|
558
|
+
afterReplicaId: 't1'
|
|
556
559
|
});
|
|
557
560
|
|
|
561
|
+
await writer.commit('1/1');
|
|
562
|
+
await writer.flush();
|
|
563
|
+
|
|
558
564
|
// Get checksums here just to populate the cache
|
|
559
|
-
await bucketStorage.getChecksums(
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
await batch.commit('2/1');
|
|
565
|
+
await bucketStorage.getChecksums(writer.last_flushed_op!, bucketRequests(syncRules, ['global[]']));
|
|
566
|
+
await using writer2 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
567
|
+
const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
|
|
568
|
+
await writer2.save({
|
|
569
|
+
sourceTable: testTable2,
|
|
570
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
571
|
+
before: {
|
|
572
|
+
id: 't1'
|
|
573
|
+
},
|
|
574
|
+
beforeReplicaId: 't1'
|
|
570
575
|
});
|
|
576
|
+
await writer2.commit('2/1');
|
|
577
|
+
await writer2.flush();
|
|
571
578
|
|
|
572
579
|
await bucketStorage.compact({
|
|
573
580
|
clearBatchLimit: 20,
|
|
@@ -577,7 +584,7 @@ bucket_definitions:
|
|
|
577
584
|
minChangeRatio: 0
|
|
578
585
|
});
|
|
579
586
|
|
|
580
|
-
const checkpoint2 =
|
|
587
|
+
const checkpoint2 = writer2.last_flushed_op!;
|
|
581
588
|
const request = bucketRequest(syncRules, 'global[]');
|
|
582
589
|
// Check that the checksum was correctly updated with the clear operation after having a cached checksum
|
|
583
590
|
const checksumAfter = await bucketStorage.getChecksums(checkpoint2, [request]);
|
|
@@ -601,29 +608,31 @@ bucket_definitions:
|
|
|
601
608
|
);
|
|
602
609
|
const bucketStorage = factory.getInstance(syncRules);
|
|
603
610
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
await batch.commit('1/1');
|
|
611
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
612
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
613
|
+
await writer.markAllSnapshotDone('1/1');
|
|
614
|
+
await writer.save({
|
|
615
|
+
sourceTable: testTable,
|
|
616
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
617
|
+
after: { id: 't1' },
|
|
618
|
+
afterReplicaId: test_utils.rid('t1')
|
|
613
619
|
});
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
620
|
+
await writer.commit('1/1');
|
|
621
|
+
await writer.flush();
|
|
622
|
+
|
|
623
|
+
const checkpoint1 = writer.last_flushed_op!;
|
|
624
|
+
|
|
625
|
+
await using writer2 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
626
|
+
const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
|
|
627
|
+
// This is flushed but not committed (does not advance the checkpoint)
|
|
628
|
+
await writer2.save({
|
|
629
|
+
sourceTable: testTable2,
|
|
630
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
631
|
+
after: { id: 't1' },
|
|
632
|
+
afterReplicaId: test_utils.rid('t1')
|
|
625
633
|
});
|
|
626
|
-
|
|
634
|
+
await writer2.flush();
|
|
635
|
+
const checkpoint2 = writer2.last_flushed_op!;
|
|
627
636
|
|
|
628
637
|
const checkpointBeforeCompact = await bucketStorage.getCheckpoint();
|
|
629
638
|
expect(checkpointBeforeCompact.checkpoint).toEqual(checkpoint1);
|