@powersync/service-core-tests 0.15.0 → 0.15.1
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 +21 -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
|
@@ -57,7 +57,6 @@ import { bucketRequest } from '../test-utils/test-utils-index.js';
|
|
|
57
57
|
import { bucketRequestMap, bucketRequests } from './util.js';
|
|
58
58
|
export function registerCompactTests(config) {
|
|
59
59
|
const generateStorageFactory = config.factory;
|
|
60
|
-
const TEST_TABLE = test_utils.makeTestTable('test', ['id'], config);
|
|
61
60
|
test('compacting (1)', async () => {
|
|
62
61
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
63
62
|
try {
|
|
@@ -68,35 +67,36 @@ bucket_definitions:
|
|
|
68
67
|
data: [select * from test]
|
|
69
68
|
`));
|
|
70
69
|
const bucketStorage = factory.getInstance(syncRules);
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
await batch.save({
|
|
82
|
-
sourceTable: TEST_TABLE,
|
|
83
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
84
|
-
after: {
|
|
85
|
-
id: 't2'
|
|
86
|
-
},
|
|
87
|
-
afterReplicaId: test_utils.rid('t2')
|
|
88
|
-
});
|
|
89
|
-
await batch.save({
|
|
90
|
-
sourceTable: TEST_TABLE,
|
|
91
|
-
tag: storage.SaveOperationTag.UPDATE,
|
|
92
|
-
after: {
|
|
93
|
-
id: 't2'
|
|
94
|
-
},
|
|
95
|
-
afterReplicaId: test_utils.rid('t2')
|
|
96
|
-
});
|
|
97
|
-
await batch.commit('1/1');
|
|
70
|
+
const writer = __addDisposableResource(env_1, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
71
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
72
|
+
await writer.markAllSnapshotDone('1/1');
|
|
73
|
+
await writer.save({
|
|
74
|
+
sourceTable: testTable,
|
|
75
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
76
|
+
after: {
|
|
77
|
+
id: 't1'
|
|
78
|
+
},
|
|
79
|
+
afterReplicaId: test_utils.rid('t1')
|
|
98
80
|
});
|
|
99
|
-
|
|
81
|
+
await writer.save({
|
|
82
|
+
sourceTable: testTable,
|
|
83
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
84
|
+
after: {
|
|
85
|
+
id: 't2'
|
|
86
|
+
},
|
|
87
|
+
afterReplicaId: test_utils.rid('t2')
|
|
88
|
+
});
|
|
89
|
+
await writer.save({
|
|
90
|
+
sourceTable: testTable,
|
|
91
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
92
|
+
after: {
|
|
93
|
+
id: 't2'
|
|
94
|
+
},
|
|
95
|
+
afterReplicaId: test_utils.rid('t2')
|
|
96
|
+
});
|
|
97
|
+
await writer.commit('1/1');
|
|
98
|
+
await writer.flush();
|
|
99
|
+
const checkpoint = writer.last_flushed_op;
|
|
100
100
|
const request = bucketRequest(syncRules, 'global[]');
|
|
101
101
|
const batchBefore = await test_utils.oneFromAsync(bucketStorage.getBucketDataBatch(checkpoint, [request]));
|
|
102
102
|
const dataBefore = batchBefore.chunkData.data;
|
|
@@ -170,43 +170,44 @@ bucket_definitions:
|
|
|
170
170
|
data: [select * from test]
|
|
171
171
|
`));
|
|
172
172
|
const bucketStorage = factory.getInstance(syncRules);
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
await batch.save({
|
|
192
|
-
sourceTable: TEST_TABLE,
|
|
193
|
-
tag: storage.SaveOperationTag.DELETE,
|
|
194
|
-
before: {
|
|
195
|
-
id: 't1'
|
|
196
|
-
},
|
|
197
|
-
beforeReplicaId: test_utils.rid('t1')
|
|
198
|
-
});
|
|
199
|
-
await batch.save({
|
|
200
|
-
sourceTable: TEST_TABLE,
|
|
201
|
-
tag: storage.SaveOperationTag.UPDATE,
|
|
202
|
-
after: {
|
|
203
|
-
id: 't2'
|
|
204
|
-
},
|
|
205
|
-
afterReplicaId: test_utils.rid('t2')
|
|
206
|
-
});
|
|
207
|
-
await batch.commit('1/1');
|
|
173
|
+
const writer = __addDisposableResource(env_2, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
174
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
175
|
+
await writer.markAllSnapshotDone('1/1');
|
|
176
|
+
await writer.save({
|
|
177
|
+
sourceTable: testTable,
|
|
178
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
179
|
+
after: {
|
|
180
|
+
id: 't1'
|
|
181
|
+
},
|
|
182
|
+
afterReplicaId: test_utils.rid('t1')
|
|
183
|
+
});
|
|
184
|
+
await writer.save({
|
|
185
|
+
sourceTable: testTable,
|
|
186
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
187
|
+
after: {
|
|
188
|
+
id: 't2'
|
|
189
|
+
},
|
|
190
|
+
afterReplicaId: test_utils.rid('t2')
|
|
208
191
|
});
|
|
209
|
-
|
|
192
|
+
await writer.save({
|
|
193
|
+
sourceTable: testTable,
|
|
194
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
195
|
+
before: {
|
|
196
|
+
id: 't1'
|
|
197
|
+
},
|
|
198
|
+
beforeReplicaId: test_utils.rid('t1')
|
|
199
|
+
});
|
|
200
|
+
await writer.save({
|
|
201
|
+
sourceTable: testTable,
|
|
202
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
203
|
+
after: {
|
|
204
|
+
id: 't2'
|
|
205
|
+
},
|
|
206
|
+
afterReplicaId: test_utils.rid('t2')
|
|
207
|
+
});
|
|
208
|
+
await writer.commit('1/1');
|
|
209
|
+
await writer.flush();
|
|
210
|
+
const checkpoint = writer.last_flushed_op;
|
|
210
211
|
const request = bucketRequest(syncRules, 'global[]');
|
|
211
212
|
const batchBefore = await test_utils.oneFromAsync(bucketStorage.getBucketDataBatch(checkpoint, [request]));
|
|
212
213
|
const dataBefore = batchBefore.chunkData.data;
|
|
@@ -279,49 +280,50 @@ bucket_definitions:
|
|
|
279
280
|
data: [select * from test]
|
|
280
281
|
`));
|
|
281
282
|
const bucketStorage = factory.getInstance(syncRules);
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
await batch.commit('1/1');
|
|
283
|
+
const writer = __addDisposableResource(env_3, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
284
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
285
|
+
await writer.markAllSnapshotDone('1/1');
|
|
286
|
+
await writer.save({
|
|
287
|
+
sourceTable: testTable,
|
|
288
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
289
|
+
after: {
|
|
290
|
+
id: 't1'
|
|
291
|
+
},
|
|
292
|
+
afterReplicaId: 't1'
|
|
293
|
+
});
|
|
294
|
+
await writer.save({
|
|
295
|
+
sourceTable: testTable,
|
|
296
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
297
|
+
after: {
|
|
298
|
+
id: 't2'
|
|
299
|
+
},
|
|
300
|
+
afterReplicaId: 't2'
|
|
301
|
+
});
|
|
302
|
+
await writer.save({
|
|
303
|
+
sourceTable: testTable,
|
|
304
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
305
|
+
before: {
|
|
306
|
+
id: 't1'
|
|
307
|
+
},
|
|
308
|
+
beforeReplicaId: 't1'
|
|
309
309
|
});
|
|
310
|
-
|
|
310
|
+
await writer.commit('1/1');
|
|
311
|
+
await writer.flush();
|
|
312
|
+
const checkpoint1 = writer.last_flushed_op;
|
|
311
313
|
const request = bucketRequest(syncRules, 'global[]');
|
|
312
|
-
const
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
});
|
|
322
|
-
await batch.commit('2/1');
|
|
314
|
+
const writer2 = __addDisposableResource(env_3, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
315
|
+
const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
|
|
316
|
+
await writer2.save({
|
|
317
|
+
sourceTable: testTable2,
|
|
318
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
319
|
+
before: {
|
|
320
|
+
id: 't2'
|
|
321
|
+
},
|
|
322
|
+
beforeReplicaId: 't2'
|
|
323
323
|
});
|
|
324
|
-
|
|
324
|
+
await writer2.commit('2/1');
|
|
325
|
+
await writer2.flush();
|
|
326
|
+
const checkpoint2 = writer2.last_flushed_op;
|
|
325
327
|
await bucketStorage.compact({
|
|
326
328
|
clearBatchLimit: 2,
|
|
327
329
|
moveBatchLimit: 1,
|
|
@@ -367,70 +369,71 @@ bucket_definitions:
|
|
|
367
369
|
data:
|
|
368
370
|
- select * from test where b = bucket.b`));
|
|
369
371
|
const bucketStorage = factory.getInstance(syncRules);
|
|
370
|
-
const
|
|
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
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
|
|
372
|
+
const writer = __addDisposableResource(env_4, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
373
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
374
|
+
await writer.markAllSnapshotDone('1/1');
|
|
375
|
+
/**
|
|
376
|
+
* Repeatedly create operations which fall into different buckets.
|
|
377
|
+
* The bucket operations are purposely interleaved as the op_id increases.
|
|
378
|
+
* A large amount of operations are created here.
|
|
379
|
+
* The configured window of compacting operations is 100. This means the initial window will
|
|
380
|
+
* contain operations from multiple buckets.
|
|
381
|
+
*/
|
|
382
|
+
for (let count = 0; count < 100; count++) {
|
|
383
|
+
await writer.save({
|
|
384
|
+
sourceTable: testTable,
|
|
385
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
386
|
+
after: {
|
|
387
|
+
id: 't1',
|
|
388
|
+
b: 'b1',
|
|
389
|
+
value: 'start'
|
|
390
|
+
},
|
|
391
|
+
afterReplicaId: test_utils.rid('t1')
|
|
392
|
+
});
|
|
393
|
+
await writer.save({
|
|
394
|
+
sourceTable: testTable,
|
|
395
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
396
|
+
after: {
|
|
397
|
+
id: 't1',
|
|
398
|
+
b: 'b1',
|
|
399
|
+
value: 'intermediate'
|
|
400
|
+
},
|
|
401
|
+
afterReplicaId: test_utils.rid('t1')
|
|
402
|
+
});
|
|
403
|
+
await writer.save({
|
|
404
|
+
sourceTable: testTable,
|
|
405
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
406
|
+
after: {
|
|
407
|
+
id: 't2',
|
|
408
|
+
b: 'b2',
|
|
409
|
+
value: 'start'
|
|
410
|
+
},
|
|
411
|
+
afterReplicaId: test_utils.rid('t2')
|
|
412
|
+
});
|
|
413
|
+
await writer.save({
|
|
414
|
+
sourceTable: testTable,
|
|
415
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
416
|
+
after: {
|
|
417
|
+
id: 't1',
|
|
418
|
+
b: 'b1',
|
|
419
|
+
value: 'final'
|
|
420
|
+
},
|
|
421
|
+
afterReplicaId: test_utils.rid('t1')
|
|
422
|
+
});
|
|
423
|
+
await writer.save({
|
|
424
|
+
sourceTable: testTable,
|
|
425
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
426
|
+
after: {
|
|
427
|
+
id: 't2',
|
|
428
|
+
b: 'b2',
|
|
429
|
+
value: 'final'
|
|
430
|
+
},
|
|
431
|
+
afterReplicaId: test_utils.rid('t2')
|
|
432
|
+
});
|
|
433
|
+
await writer.commit('1/1');
|
|
434
|
+
}
|
|
435
|
+
await writer.flush();
|
|
436
|
+
const checkpoint = writer.last_flushed_op;
|
|
434
437
|
await bucketStorage.compact({
|
|
435
438
|
clearBatchLimit: 100,
|
|
436
439
|
moveBatchLimit: 100,
|
|
@@ -487,34 +490,35 @@ bucket_definitions:
|
|
|
487
490
|
data: [select * from test]
|
|
488
491
|
`));
|
|
489
492
|
const bucketStorage = factory.getInstance(syncRules);
|
|
490
|
-
await bucketStorage.
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
await batch.commit('1/1');
|
|
493
|
+
const writer = __addDisposableResource(env_5, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
494
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
495
|
+
await writer.markAllSnapshotDone('1/1');
|
|
496
|
+
await writer.save({
|
|
497
|
+
sourceTable: testTable,
|
|
498
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
499
|
+
after: {
|
|
500
|
+
id: 't1'
|
|
501
|
+
},
|
|
502
|
+
afterReplicaId: 't1'
|
|
503
|
+
});
|
|
504
|
+
await writer.save({
|
|
505
|
+
sourceTable: testTable,
|
|
506
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
507
|
+
after: {
|
|
508
|
+
id: 't2'
|
|
509
|
+
},
|
|
510
|
+
afterReplicaId: 't2'
|
|
511
|
+
});
|
|
512
|
+
await writer.save({
|
|
513
|
+
sourceTable: testTable,
|
|
514
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
515
|
+
before: {
|
|
516
|
+
id: 't1'
|
|
517
|
+
},
|
|
518
|
+
beforeReplicaId: 't1'
|
|
517
519
|
});
|
|
520
|
+
await writer.commit('1/1');
|
|
521
|
+
await writer.flush();
|
|
518
522
|
await bucketStorage.compact({
|
|
519
523
|
clearBatchLimit: 2,
|
|
520
524
|
moveBatchLimit: 1,
|
|
@@ -522,18 +526,19 @@ bucket_definitions:
|
|
|
522
526
|
minBucketChanges: 1,
|
|
523
527
|
minChangeRatio: 0
|
|
524
528
|
});
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
await batch.commit('2/1');
|
|
529
|
+
const writer2 = __addDisposableResource(env_5, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
530
|
+
const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
|
|
531
|
+
await writer2.save({
|
|
532
|
+
sourceTable: testTable2,
|
|
533
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
534
|
+
before: {
|
|
535
|
+
id: 't2'
|
|
536
|
+
},
|
|
537
|
+
beforeReplicaId: 't2'
|
|
535
538
|
});
|
|
536
|
-
|
|
539
|
+
await writer2.commit('2/1');
|
|
540
|
+
await writer2.flush();
|
|
541
|
+
const checkpoint2 = writer2.last_flushed_op;
|
|
537
542
|
const request = bucketRequest(syncRules, 'global[]');
|
|
538
543
|
await bucketStorage.clearChecksumCache();
|
|
539
544
|
const checksumAfter = await bucketStorage.getChecksums(checkpoint2, [request]);
|
|
@@ -565,39 +570,41 @@ bucket_definitions:
|
|
|
565
570
|
data: [select * from test]
|
|
566
571
|
`));
|
|
567
572
|
const bucketStorage = factory.getInstance(syncRules);
|
|
568
|
-
const
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
await batch.commit('1/1');
|
|
573
|
+
const writer = __addDisposableResource(env_6, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
574
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
575
|
+
await writer.markAllSnapshotDone('1/1');
|
|
576
|
+
await writer.save({
|
|
577
|
+
sourceTable: testTable,
|
|
578
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
579
|
+
after: {
|
|
580
|
+
id: 't1'
|
|
581
|
+
},
|
|
582
|
+
afterReplicaId: 't1'
|
|
583
|
+
});
|
|
584
|
+
await writer.save({
|
|
585
|
+
sourceTable: testTable,
|
|
586
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
587
|
+
after: {
|
|
588
|
+
id: 't1'
|
|
589
|
+
},
|
|
590
|
+
afterReplicaId: 't1'
|
|
587
591
|
});
|
|
592
|
+
await writer.commit('1/1');
|
|
593
|
+
await writer.flush();
|
|
588
594
|
// Get checksums here just to populate the cache
|
|
589
|
-
await bucketStorage.getChecksums(
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
await batch.commit('2/1');
|
|
595
|
+
await bucketStorage.getChecksums(writer.last_flushed_op, bucketRequests(syncRules, ['global[]']));
|
|
596
|
+
const writer2 = __addDisposableResource(env_6, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
597
|
+
const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
|
|
598
|
+
await writer2.save({
|
|
599
|
+
sourceTable: testTable2,
|
|
600
|
+
tag: storage.SaveOperationTag.DELETE,
|
|
601
|
+
before: {
|
|
602
|
+
id: 't1'
|
|
603
|
+
},
|
|
604
|
+
beforeReplicaId: 't1'
|
|
600
605
|
});
|
|
606
|
+
await writer2.commit('2/1');
|
|
607
|
+
await writer2.flush();
|
|
601
608
|
await bucketStorage.compact({
|
|
602
609
|
clearBatchLimit: 20,
|
|
603
610
|
moveBatchLimit: 10,
|
|
@@ -605,7 +612,7 @@ bucket_definitions:
|
|
|
605
612
|
minBucketChanges: 1,
|
|
606
613
|
minChangeRatio: 0
|
|
607
614
|
});
|
|
608
|
-
const checkpoint2 =
|
|
615
|
+
const checkpoint2 = writer2.last_flushed_op;
|
|
609
616
|
const request = bucketRequest(syncRules, 'global[]');
|
|
610
617
|
// Check that the checksum was correctly updated with the clear operation after having a cached checksum
|
|
611
618
|
const checksumAfter = await bucketStorage.getChecksums(checkpoint2, [request]);
|
|
@@ -637,27 +644,29 @@ bucket_definitions:
|
|
|
637
644
|
data: [select * from test]
|
|
638
645
|
`));
|
|
639
646
|
const bucketStorage = factory.getInstance(syncRules);
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
await batch.commit('1/1');
|
|
647
|
+
const writer = __addDisposableResource(env_7, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
648
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
649
|
+
await writer.markAllSnapshotDone('1/1');
|
|
650
|
+
await writer.save({
|
|
651
|
+
sourceTable: testTable,
|
|
652
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
653
|
+
after: { id: 't1' },
|
|
654
|
+
afterReplicaId: test_utils.rid('t1')
|
|
649
655
|
});
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
656
|
+
await writer.commit('1/1');
|
|
657
|
+
await writer.flush();
|
|
658
|
+
const checkpoint1 = writer.last_flushed_op;
|
|
659
|
+
const writer2 = __addDisposableResource(env_7, await bucketStorage.createWriter(test_utils.BATCH_OPTIONS), true);
|
|
660
|
+
const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
|
|
661
|
+
// This is flushed but not committed (does not advance the checkpoint)
|
|
662
|
+
await writer2.save({
|
|
663
|
+
sourceTable: testTable2,
|
|
664
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
665
|
+
after: { id: 't1' },
|
|
666
|
+
afterReplicaId: test_utils.rid('t1')
|
|
659
667
|
});
|
|
660
|
-
|
|
668
|
+
await writer2.flush();
|
|
669
|
+
const checkpoint2 = writer2.last_flushed_op;
|
|
661
670
|
const checkpointBeforeCompact = await bucketStorage.getCheckpoint();
|
|
662
671
|
expect(checkpointBeforeCompact.checkpoint).toEqual(checkpoint1);
|
|
663
672
|
// With default options, Postgres compaction should use the active checkpoint.
|