@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.
Files changed (28) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/test-utils/general-utils.d.ts +13 -1
  3. package/dist/test-utils/general-utils.js +30 -1
  4. package/dist/test-utils/general-utils.js.map +1 -1
  5. package/dist/test-utils/stream_utils.js +2 -2
  6. package/dist/test-utils/stream_utils.js.map +1 -1
  7. package/dist/tests/register-compacting-tests.js +266 -257
  8. package/dist/tests/register-compacting-tests.js.map +1 -1
  9. package/dist/tests/register-data-storage-checkpoint-tests.js +36 -57
  10. package/dist/tests/register-data-storage-checkpoint-tests.js.map +1 -1
  11. package/dist/tests/register-data-storage-data-tests.js +839 -863
  12. package/dist/tests/register-data-storage-data-tests.js.map +1 -1
  13. package/dist/tests/register-data-storage-parameter-tests.js +228 -236
  14. package/dist/tests/register-data-storage-parameter-tests.js.map +1 -1
  15. package/dist/tests/register-parameter-compacting-tests.js +81 -89
  16. package/dist/tests/register-parameter-compacting-tests.js.map +1 -1
  17. package/dist/tests/register-sync-tests.js +468 -462
  18. package/dist/tests/register-sync-tests.js.map +1 -1
  19. package/package.json +3 -3
  20. package/src/test-utils/general-utils.ts +41 -2
  21. package/src/test-utils/stream_utils.ts +2 -2
  22. package/src/tests/register-compacting-tests.ts +279 -270
  23. package/src/tests/register-data-storage-checkpoint-tests.ts +36 -57
  24. package/src/tests/register-data-storage-data-tests.ts +673 -770
  25. package/src/tests/register-data-storage-parameter-tests.ts +245 -257
  26. package/src/tests/register-parameter-compacting-tests.ts +84 -92
  27. package/src/tests/register-sync-tests.ts +375 -391
  28. 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 result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
72
- await batch.markAllSnapshotDone('1/1');
73
- await batch.save({
74
- sourceTable: TEST_TABLE,
75
- tag: storage.SaveOperationTag.INSERT,
76
- after: {
77
- id: 't1'
78
- },
79
- afterReplicaId: test_utils.rid('t1')
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
- const checkpoint = result.flushed_op;
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 result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
174
- await batch.markAllSnapshotDone('1/1');
175
- await batch.save({
176
- sourceTable: TEST_TABLE,
177
- tag: storage.SaveOperationTag.INSERT,
178
- after: {
179
- id: 't1'
180
- },
181
- afterReplicaId: test_utils.rid('t1')
182
- });
183
- await batch.save({
184
- sourceTable: TEST_TABLE,
185
- tag: storage.SaveOperationTag.INSERT,
186
- after: {
187
- id: 't2'
188
- },
189
- afterReplicaId: test_utils.rid('t2')
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
- const checkpoint = result.flushed_op;
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 result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
283
- await batch.markAllSnapshotDone('1/1');
284
- await batch.save({
285
- sourceTable: TEST_TABLE,
286
- tag: storage.SaveOperationTag.INSERT,
287
- after: {
288
- id: 't1'
289
- },
290
- afterReplicaId: 't1'
291
- });
292
- await batch.save({
293
- sourceTable: TEST_TABLE,
294
- tag: storage.SaveOperationTag.INSERT,
295
- after: {
296
- id: 't2'
297
- },
298
- afterReplicaId: 't2'
299
- });
300
- await batch.save({
301
- sourceTable: TEST_TABLE,
302
- tag: storage.SaveOperationTag.DELETE,
303
- before: {
304
- id: 't1'
305
- },
306
- beforeReplicaId: 't1'
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
- const checkpoint1 = result.flushed_op;
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 checksumBefore = await bucketStorage.getChecksums(checkpoint1, [request]);
313
- const result2 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
314
- await batch.save({
315
- sourceTable: TEST_TABLE,
316
- tag: storage.SaveOperationTag.DELETE,
317
- before: {
318
- id: 't2'
319
- },
320
- beforeReplicaId: 't2'
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
- const checkpoint2 = result2.flushed_op;
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 result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
371
- await batch.markAllSnapshotDone('1/1');
372
- /**
373
- * Repeatedly create operations which fall into different buckets.
374
- * The bucket operations are purposely interleaved as the op_id increases.
375
- * A large amount of operations are created here.
376
- * The configured window of compacting operations is 100. This means the initial window will
377
- * contain operations from multiple buckets.
378
- */
379
- for (let count = 0; count < 100; count++) {
380
- await batch.save({
381
- sourceTable: TEST_TABLE,
382
- tag: storage.SaveOperationTag.INSERT,
383
- after: {
384
- id: 't1',
385
- b: 'b1',
386
- value: 'start'
387
- },
388
- afterReplicaId: test_utils.rid('t1')
389
- });
390
- await batch.save({
391
- sourceTable: TEST_TABLE,
392
- tag: storage.SaveOperationTag.UPDATE,
393
- after: {
394
- id: 't1',
395
- b: 'b1',
396
- value: 'intermediate'
397
- },
398
- afterReplicaId: test_utils.rid('t1')
399
- });
400
- await batch.save({
401
- sourceTable: TEST_TABLE,
402
- tag: storage.SaveOperationTag.INSERT,
403
- after: {
404
- id: 't2',
405
- b: 'b2',
406
- value: 'start'
407
- },
408
- afterReplicaId: test_utils.rid('t2')
409
- });
410
- await batch.save({
411
- sourceTable: TEST_TABLE,
412
- tag: storage.SaveOperationTag.UPDATE,
413
- after: {
414
- id: 't1',
415
- b: 'b1',
416
- value: 'final'
417
- },
418
- afterReplicaId: test_utils.rid('t1')
419
- });
420
- await batch.save({
421
- sourceTable: TEST_TABLE,
422
- tag: storage.SaveOperationTag.UPDATE,
423
- after: {
424
- id: 't2',
425
- b: 'b2',
426
- value: 'final'
427
- },
428
- afterReplicaId: test_utils.rid('t2')
429
- });
430
- await batch.commit('1/1');
431
- }
432
- });
433
- const checkpoint = result.flushed_op;
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.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
491
- await batch.markAllSnapshotDone('1/1');
492
- await batch.save({
493
- sourceTable: TEST_TABLE,
494
- tag: storage.SaveOperationTag.INSERT,
495
- after: {
496
- id: 't1'
497
- },
498
- afterReplicaId: 't1'
499
- });
500
- await batch.save({
501
- sourceTable: TEST_TABLE,
502
- tag: storage.SaveOperationTag.INSERT,
503
- after: {
504
- id: 't2'
505
- },
506
- afterReplicaId: 't2'
507
- });
508
- await batch.save({
509
- sourceTable: TEST_TABLE,
510
- tag: storage.SaveOperationTag.DELETE,
511
- before: {
512
- id: 't1'
513
- },
514
- beforeReplicaId: 't1'
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 result2 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
526
- await batch.save({
527
- sourceTable: TEST_TABLE,
528
- tag: storage.SaveOperationTag.DELETE,
529
- before: {
530
- id: 't2'
531
- },
532
- beforeReplicaId: 't2'
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
- const checkpoint2 = result2.flushed_op;
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 result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
569
- await batch.markAllSnapshotDone('1/1');
570
- await batch.save({
571
- sourceTable: TEST_TABLE,
572
- tag: storage.SaveOperationTag.INSERT,
573
- after: {
574
- id: 't1'
575
- },
576
- afterReplicaId: 't1'
577
- });
578
- await batch.save({
579
- sourceTable: TEST_TABLE,
580
- tag: storage.SaveOperationTag.UPDATE,
581
- after: {
582
- id: 't1'
583
- },
584
- afterReplicaId: 't1'
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(result.flushed_op, bucketRequests(syncRules, ['global[]']));
590
- const result2 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
591
- await batch.save({
592
- sourceTable: TEST_TABLE,
593
- tag: storage.SaveOperationTag.DELETE,
594
- before: {
595
- id: 't1'
596
- },
597
- beforeReplicaId: 't1'
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 = result2.flushed_op;
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 result1 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
641
- await batch.markAllSnapshotDone('1/1');
642
- await batch.save({
643
- sourceTable: TEST_TABLE,
644
- tag: storage.SaveOperationTag.INSERT,
645
- after: { id: 't1' },
646
- afterReplicaId: test_utils.rid('t1')
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
- const checkpoint1 = result1.flushed_op;
651
- const result2 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
652
- // This is flushed but not committed (does not advance the checkpoint)
653
- await batch.save({
654
- sourceTable: TEST_TABLE,
655
- tag: storage.SaveOperationTag.UPDATE,
656
- after: { id: 't1' },
657
- afterReplicaId: test_utils.rid('t1')
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
- const checkpoint2 = result2.flushed_op;
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.