@powersync/service-module-mongodb-storage 0.21.0 → 0.23.0
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 +43 -0
- package/dist/storage/MongoBucketStorage.d.ts +10 -1
- package/dist/storage/MongoBucketStorage.js +37 -7
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/implementation/MongoBucketBatch.d.ts +24 -10
- package/dist/storage/implementation/MongoBucketBatch.js +134 -89
- package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
- package/dist/storage/implementation/MongoCompactor.d.ts +2 -0
- package/dist/storage/implementation/MongoCompactor.js.map +1 -1
- package/dist/storage/implementation/MongoIdSequence.d.ts +10 -1
- package/dist/storage/implementation/MongoIdSequence.js +14 -1
- package/dist/storage/implementation/MongoIdSequence.js.map +1 -1
- package/dist/storage/implementation/MongoOpIdAllocator.d.ts +27 -0
- package/dist/storage/implementation/MongoOpIdAllocator.js +97 -0
- package/dist/storage/implementation/MongoOpIdAllocator.js.map +1 -0
- package/dist/storage/implementation/MongoStorageProvider.js +4 -2
- package/dist/storage/implementation/MongoStorageProvider.js.map +1 -1
- package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +5 -0
- package/dist/storage/implementation/MongoSyncBucketStorage.js +17 -0
- package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/implementation/MongoSyncRulesLock.d.ts +26 -2
- package/dist/storage/implementation/MongoSyncRulesLock.js +38 -1
- package/dist/storage/implementation/MongoSyncRulesLock.js.map +1 -1
- package/dist/storage/implementation/MongoWriteBatch.d.ts +49 -0
- package/dist/storage/implementation/MongoWriteBatch.js +149 -0
- package/dist/storage/implementation/MongoWriteBatch.js.map +1 -0
- package/dist/storage/implementation/MongoWriteCheckpointAPI.js +2 -2
- package/dist/storage/implementation/MongoWriteCheckpointAPI.js.map +1 -1
- package/dist/storage/implementation/common/PersistedBatch.d.ts +5 -4
- package/dist/storage/implementation/common/PersistedBatch.js +6 -4
- package/dist/storage/implementation/common/PersistedBatch.js.map +1 -1
- package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.d.ts +3 -0
- package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js +3 -0
- package/dist/storage/implementation/common/VersionedPowerSyncMongoBase.js.map +1 -1
- package/dist/storage/implementation/db.d.ts +5 -0
- package/dist/storage/implementation/db.js +14 -0
- package/dist/storage/implementation/db.js.map +1 -1
- package/dist/storage/implementation/v1/MongoBucketBatchV1.d.ts +5 -0
- package/dist/storage/implementation/v1/MongoBucketBatchV1.js +149 -139
- package/dist/storage/implementation/v1/MongoBucketBatchV1.js.map +1 -1
- package/dist/storage/implementation/v1/MongoCompactorV1.d.ts +2 -1
- package/dist/storage/implementation/v1/MongoCompactorV1.js +23 -17
- package/dist/storage/implementation/v1/MongoCompactorV1.js.map +1 -1
- package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js +1 -1
- package/dist/storage/implementation/v1/MongoSyncBucketStorageV1.js.map +1 -1
- package/dist/storage/implementation/v1/PersistedBatchV1.d.ts +7 -5
- package/dist/storage/implementation/v1/PersistedBatchV1.js +22 -28
- package/dist/storage/implementation/v1/PersistedBatchV1.js.map +1 -1
- package/dist/storage/implementation/v3/MongoBucketBatchV3.d.ts +6 -1
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js +148 -162
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js.map +1 -1
- package/dist/storage/implementation/v3/MongoCompactorV3.d.ts +10 -4
- package/dist/storage/implementation/v3/MongoCompactorV3.js +175 -76
- package/dist/storage/implementation/v3/MongoCompactorV3.js.map +1 -1
- package/dist/storage/implementation/v3/PersistedBatchV3.d.ts +12 -8
- package/dist/storage/implementation/v3/PersistedBatchV3.js +25 -32
- package/dist/storage/implementation/v3/PersistedBatchV3.js.map +1 -1
- package/dist/storage/implementation/v3/compact-utils.d.ts +3 -2
- package/dist/storage/implementation/v3/compact-utils.js +12 -5
- package/dist/storage/implementation/v3/compact-utils.js.map +1 -1
- package/dist/storage/implementation/v3/models.d.ts +1 -1
- package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.js +8 -1
- package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.js.map +1 -1
- package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.d.ts +3 -3
- package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.js +7 -9
- package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.js.map +1 -1
- package/dist/storage/implementation/v3/object-storage/ObjectStorageUsage.d.ts +3 -2
- package/dist/storage/implementation/v3/object-storage/ObjectStorageUsage.js +4 -7
- package/dist/storage/implementation/v3/object-storage/ObjectStorageUsage.js.map +1 -1
- package/dist/storage/implementation/v3/object-storage/S3ObjectStorage.js +21 -3
- package/dist/storage/implementation/v3/object-storage/S3ObjectStorage.js.map +1 -1
- package/dist/types/types.d.ts +5 -0
- package/dist/types/types.js +12 -0
- package/dist/types/types.js.map +1 -1
- package/dist/utils/test-utils.d.ts +2 -1
- package/dist/utils/test-utils.js +5 -3
- package/dist/utils/test-utils.js.map +1 -1
- package/package.json +7 -7
- package/src/storage/MongoBucketStorage.ts +47 -8
- package/src/storage/implementation/MongoBucketBatch.ts +205 -111
- package/src/storage/implementation/MongoCompactor.ts +2 -0
- package/src/storage/implementation/MongoIdSequence.ts +21 -1
- package/src/storage/implementation/MongoOpIdAllocator.ts +105 -0
- package/src/storage/implementation/MongoStorageProvider.ts +12 -2
- package/src/storage/implementation/MongoSyncBucketStorage.ts +19 -0
- package/src/storage/implementation/MongoSyncRulesLock.ts +56 -3
- package/src/storage/implementation/MongoWriteBatch.ts +172 -0
- package/src/storage/implementation/MongoWriteCheckpointAPI.ts +4 -2
- package/src/storage/implementation/common/PersistedBatch.ts +12 -8
- package/src/storage/implementation/common/VersionedPowerSyncMongoBase.ts +4 -0
- package/src/storage/implementation/db.ts +15 -0
- package/src/storage/implementation/models.ts +1 -0
- package/src/storage/implementation/v1/MongoBucketBatchV1.ts +167 -160
- package/src/storage/implementation/v1/MongoCompactorV1.ts +29 -26
- package/src/storage/implementation/v1/MongoSyncBucketStorageV1.ts +1 -1
- package/src/storage/implementation/v1/PersistedBatchV1.ts +25 -30
- package/src/storage/implementation/v3/MongoBucketBatchV3.ts +217 -242
- package/src/storage/implementation/v3/MongoCompactorV3.ts +284 -108
- package/src/storage/implementation/v3/PersistedBatchV3.ts +36 -36
- package/src/storage/implementation/v3/compact-utils.ts +16 -7
- package/src/storage/implementation/v3/models.ts +1 -1
- package/src/storage/implementation/v3/object-storage/BucketDataObjectStorage.ts +8 -1
- package/src/storage/implementation/v3/object-storage/ObjectStorageLifecycle.ts +11 -10
- package/src/storage/implementation/v3/object-storage/ObjectStorageUsage.ts +8 -9
- package/src/storage/implementation/v3/object-storage/S3ObjectStorage.ts +23 -3
- package/src/types/types.ts +18 -0
- package/src/utils/test-utils.ts +6 -3
- package/test/src/__snapshots__/storage.test.ts.snap +102 -2
- package/test/src/__snapshots__/storage_compacting.test.ts.snap +2 -2
- package/test/src/__snapshots__/storage_sync.test.ts.snap +12 -12
- package/test/src/chunk_compaction_config.test.ts +38 -0
- package/test/src/cleanup-stopped-sync-configs.test.ts +19 -13
- package/test/src/compact-utils.test.ts +33 -8
- package/test/src/concurrent_writers.test.ts +599 -0
- package/test/src/helpers/concurrentWriter.mjs +29 -0
- package/test/src/helpers/s3TestFactory.ts +12 -12
- package/test/src/object_storage_usage.test.ts +18 -5
- package/test/src/parameter_compacting_v1.test.ts +2 -2
- package/test/src/parameter_compacting_v3.test.ts +2 -2
- package/test/src/parameter_compaction_fence.test.ts +3 -3
- package/test/src/storage.test.ts +32 -33
- package/test/src/storage_compacting.test.ts +402 -24
- package/test/src/storage_object_storage_inline_threshold.test.ts +3 -3
- package/test/src/storage_s3_checksums.test.ts +4 -4
- package/test/src/storage_s3_compaction_lifecycle.test.ts +8 -8
- package/test/src/storage_s3_reading.test.ts +51 -5
- package/test/src/storage_s3_writing.test.ts +3 -3
- package/test/src/storage_sync.test.ts +52 -46
- package/test/src/storeCurrentData.test.ts +5 -5
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -8,6 +8,7 @@ import { VersionedPowerSyncMongoV3 } from '@module/storage/implementation/v3/Ver
|
|
|
8
8
|
import * as lib_mongo from '@powersync/lib-service-mongodb';
|
|
9
9
|
import { mongo } from '@powersync/lib-service-mongodb';
|
|
10
10
|
import { updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
11
|
+
import { getTestStorage } from '@powersync/service-core-tests';
|
|
11
12
|
import { BucketDefinitionId } from '@powersync/service-sync-rules';
|
|
12
13
|
import { describe, expect, test } from 'vitest';
|
|
13
14
|
import { INITIALIZED_MONGO_STORAGE_FACTORY } from './util.js';
|
|
@@ -33,7 +34,7 @@ type UsageEntry = {
|
|
|
33
34
|
async function withUsageContext<T>(callback: (context: UsageContext) => Promise<T>): Promise<T> {
|
|
34
35
|
await using factory = await INITIALIZED_MONGO_STORAGE_FACTORY.factory();
|
|
35
36
|
const syncRules = await factory.updateSyncRules(updateSyncRulesFromYaml(SYNC_RULES_YAML, { storageVersion: 3 }));
|
|
36
|
-
const bucketStorage = factory
|
|
37
|
+
const bucketStorage = (await getTestStorage(factory, syncRules)) as MongoSyncBucketStorage;
|
|
37
38
|
const db = bucketStorage.db as VersionedPowerSyncMongoV3;
|
|
38
39
|
const definitionId = syncRules.syncConfigContent[0].mapping.allBucketDefinitionIds()[0];
|
|
39
40
|
return callback({ db, bucketStorage, definitionId });
|
|
@@ -123,14 +124,18 @@ describe('ObjectStorageUsage', () => {
|
|
|
123
124
|
await expect(
|
|
124
125
|
withTransaction(db, async (session) => {
|
|
125
126
|
await bucketData.insertOne(document, { session });
|
|
126
|
-
|
|
127
|
+
const writes = db.createWriteBatch(session, { ordered: false });
|
|
128
|
+
usage.applyDelta(definitionId, 123n, writes);
|
|
129
|
+
await writes.execute();
|
|
127
130
|
throw new Error('abort this attempt');
|
|
128
131
|
})
|
|
129
132
|
).rejects.toThrow('abort this attempt');
|
|
130
133
|
|
|
131
134
|
await withTransaction(db, async (session) => {
|
|
132
135
|
await bucketData.insertOne(document, { session });
|
|
133
|
-
|
|
136
|
+
const writes = db.createWriteBatch(session, { ordered: false });
|
|
137
|
+
usage.applyDelta(definitionId, 123n, writes);
|
|
138
|
+
await writes.execute();
|
|
134
139
|
});
|
|
135
140
|
|
|
136
141
|
expect(await bucketData.countDocuments({ storage_ref: { $exists: true } })).toBe(1);
|
|
@@ -182,7 +187,11 @@ describe('ObjectStorageUsage', () => {
|
|
|
182
187
|
const writerId = 'reused-writer';
|
|
183
188
|
const usage = new ObjectStorageUsage(db, replicationStreamId, writerId);
|
|
184
189
|
|
|
185
|
-
await withTransaction(db, (session) =>
|
|
190
|
+
await withTransaction(db, async (session) => {
|
|
191
|
+
const writes = db.createWriteBatch(session, { ordered: false });
|
|
192
|
+
usage.applyDelta(definitionId, 10n, writes);
|
|
193
|
+
await writes.execute();
|
|
194
|
+
});
|
|
186
195
|
await db.objectStorageUsage.updateOne(
|
|
187
196
|
{ _id: { g: replicationStreamId, w: writerId } },
|
|
188
197
|
{ $set: { updated_at: new Date(0) } }
|
|
@@ -191,7 +200,11 @@ describe('ObjectStorageUsage', () => {
|
|
|
191
200
|
|
|
192
201
|
// The folder committed first and deleted the writer shard. The writer's
|
|
193
202
|
// next transaction must recreate it through the upsert.
|
|
194
|
-
await withTransaction(db, (session) =>
|
|
203
|
+
await withTransaction(db, async (session) => {
|
|
204
|
+
const writes = db.createWriteBatch(session, { ordered: false });
|
|
205
|
+
usage.applyDelta(definitionId, 4n, writes);
|
|
206
|
+
await writes.execute();
|
|
207
|
+
});
|
|
195
208
|
expect((await readUsageEntries(db, replicationStreamId))[0].active_bytes).toBe(14n);
|
|
196
209
|
|
|
197
210
|
await db.objectStorageUsage.updateOne(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { storage, updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
2
|
-
import { test_utils } from '@powersync/service-core-tests';
|
|
2
|
+
import { getTestStorage, test_utils } from '@powersync/service-core-tests';
|
|
3
3
|
import * as bson from 'bson';
|
|
4
4
|
import { describe, expect, test } from 'vitest';
|
|
5
5
|
import type { SyncRuleDocumentV1 } from '../../src/storage/implementation/v1/models.js';
|
|
@@ -20,7 +20,7 @@ async function createActiveStorage() {
|
|
|
20
20
|
const syncRules = await factory.updateSyncRules(
|
|
21
21
|
updateSyncRulesFromYaml(PARAMETER_RULES, { storageVersion: storage.STORAGE_VERSION_2 })
|
|
22
22
|
);
|
|
23
|
-
const processingStorage = factory
|
|
23
|
+
const processingStorage = await getTestStorage(factory, syncRules);
|
|
24
24
|
await using writer = await processingStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
25
25
|
await writer.markAllSnapshotDone('1/1');
|
|
26
26
|
await writer.commit('1/1');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { storage, updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
2
|
-
import { test_utils } from '@powersync/service-core-tests';
|
|
2
|
+
import { getTestStorage, test_utils } from '@powersync/service-core-tests';
|
|
3
3
|
import * as bson from 'bson';
|
|
4
4
|
import { describe, expect, test } from 'vitest';
|
|
5
5
|
import { MongoParameterCompactorV3 } from '../../src/storage/implementation/v3/MongoParameterCompactorV3.js';
|
|
@@ -31,7 +31,7 @@ async function createActiveStorage(rules = PARAMETER_RULES) {
|
|
|
31
31
|
const syncRules = await factory.updateSyncRules(
|
|
32
32
|
updateSyncRulesFromYaml(rules, { storageVersion: storage.STORAGE_VERSION_3 })
|
|
33
33
|
);
|
|
34
|
-
const processingStorage = factory
|
|
34
|
+
const processingStorage = await getTestStorage(factory, syncRules);
|
|
35
35
|
await using writer = await processingStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
36
36
|
await writer.markAllSnapshotDone('1/1');
|
|
37
37
|
await writer.commit('1/1');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mongo } from '@powersync/lib-service-mongodb';
|
|
2
2
|
import { InternalOpId, storage, updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
3
|
-
import { test_utils } from '@powersync/service-core-tests';
|
|
3
|
+
import { getTestStorage, test_utils } from '@powersync/service-core-tests';
|
|
4
4
|
import { describe, expect, test } from 'vitest';
|
|
5
5
|
import type { VersionedPowerSyncMongo } from '../../src/storage/implementation/db.js';
|
|
6
6
|
import type { SyncRuleDocumentBase } from '../../src/storage/implementation/models.js';
|
|
@@ -83,7 +83,7 @@ describe('parameter compaction invalidation fence', () => {
|
|
|
83
83
|
*/
|
|
84
84
|
async function replicateParameterHistory(factory: storage.BucketStorageFactory) {
|
|
85
85
|
const syncRules = await factory.updateSyncRules(updateSyncRulesFromYaml(PARAMETER_RULES, { storageVersion }));
|
|
86
|
-
const processingStorage = factory
|
|
86
|
+
const processingStorage = await getTestStorage(factory, syncRules);
|
|
87
87
|
const writer = await processingStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
88
88
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], INITIALIZED_MONGO_STORAGE_FACTORY);
|
|
89
89
|
|
|
@@ -196,7 +196,7 @@ describe('parameter compaction invalidation fence', () => {
|
|
|
196
196
|
// which is the only record of t2's lookup.
|
|
197
197
|
//
|
|
198
198
|
// A separate storage instance is used to get a cold checkpoint-changes cache.
|
|
199
|
-
const coldStorage = (factory as MongoBucketStorage
|
|
199
|
+
const coldStorage = await getTestStorage(factory as MongoBucketStorage, replicationStream);
|
|
200
200
|
const atSnapshot = await coldStorage.getCheckpointChanges({
|
|
201
201
|
lastCheckpoint: checkpoint1,
|
|
202
202
|
nextCheckpoint: checkpoint3
|
package/test/src/storage.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mongoTestStorageFactoryGenerator } from '@module/utils/test-utils.js';
|
|
2
2
|
import { mongo } from '@powersync/lib-service-mongodb';
|
|
3
3
|
import { storage, updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
4
|
-
import { compactActive, register, test_utils } from '@powersync/service-core-tests';
|
|
4
|
+
import { compactActive, getTestStorage, register, test_utils } from '@powersync/service-core-tests';
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
import { MongoSyncBucketStorage } from '../../src/storage/implementation/createMongoSyncBucketStorage.js';
|
|
7
7
|
import { VersionedPowerSyncMongoV3 } from '../../src/storage/implementation/v3/VersionedPowerSyncMongoV3.js';
|
|
@@ -35,7 +35,7 @@ bucket_definitions:
|
|
|
35
35
|
{ storageVersion }
|
|
36
36
|
)
|
|
37
37
|
);
|
|
38
|
-
const bucketStorage = factory
|
|
38
|
+
const bucketStorage = await getTestStorage(factory, syncRules);
|
|
39
39
|
|
|
40
40
|
// user1 has no existing row, so this covers updateMany with upsert.
|
|
41
41
|
// The initial request stores checkpoint id 42 at source head 5/0.
|
|
@@ -144,7 +144,8 @@ bucket_definitions:
|
|
|
144
144
|
user_id: 'custom1',
|
|
145
145
|
checkpoint: 52n
|
|
146
146
|
});
|
|
147
|
-
|
|
147
|
+
// A custom-checkpoint-only commit uses the combined final flush path too.
|
|
148
|
+
await writer.commit('8/1');
|
|
148
149
|
const customGenerated = await factory.db.custom_write_checkpoints.findOne({ user_id: 'custom1' });
|
|
149
150
|
expect(customGenerated).not.toBeNull();
|
|
150
151
|
expect(customGenerated?.checkpoint_requested_at).toBeUndefined();
|
|
@@ -179,7 +180,7 @@ event_definitions:
|
|
|
179
180
|
{ storageVersion }
|
|
180
181
|
)
|
|
181
182
|
);
|
|
182
|
-
const bucketStorage = factory
|
|
183
|
+
const bucketStorage = await getTestStorage(factory, syncRules);
|
|
183
184
|
const db = bucketStorage.db as VersionedPowerSyncMongoV3;
|
|
184
185
|
const activeSyncConfig = bucketStorage.getParsedSyncRules({ defaultSchema: 'public' });
|
|
185
186
|
const eventA = activeSyncConfig.eventDescriptors.find((event) => event.name == 'checkpoint_a')!;
|
|
@@ -228,7 +229,7 @@ event_definitions:
|
|
|
228
229
|
|
|
229
230
|
writer.addCustomWriteCheckpoint({ user_id: 'user1', checkpoint: 5n, event_id: eventAId });
|
|
230
231
|
writer.addCustomWriteCheckpoint({ user_id: 'user1', checkpoint: 8n, event_id: eventBId });
|
|
231
|
-
|
|
232
|
+
// Collections must be prepared before the combined flush/checkpoint transaction.
|
|
232
233
|
await writer.keepalive('5/0');
|
|
233
234
|
|
|
234
235
|
const eventACollection = db.customCheckpointRequests({
|
|
@@ -296,7 +297,7 @@ event_definitions:
|
|
|
296
297
|
// A fresh storage instance has an empty initialization cache, just like
|
|
297
298
|
// one created after a service restart. Recreating the existing indexes
|
|
298
299
|
// must be idempotent before another checkpoint is written.
|
|
299
|
-
const freshBucketStorage = factory
|
|
300
|
+
const freshBucketStorage = await getTestStorage(factory, syncRules);
|
|
300
301
|
await using freshWriter = await freshBucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
301
302
|
freshWriter.addCustomWriteCheckpoint({
|
|
302
303
|
user_id: 'after-restart',
|
|
@@ -336,7 +337,7 @@ event_definitions:
|
|
|
336
337
|
updateSyncRulesFromYaml(syncConfigYaml("kind = 'write'", false), { storageVersion })
|
|
337
338
|
);
|
|
338
339
|
const firstEventId = first.syncConfigContent[0].mapping.eventDefinitionIdByName('write_checkpoints');
|
|
339
|
-
const firstStorage = factory
|
|
340
|
+
const firstStorage = await getTestStorage(factory, first);
|
|
340
341
|
await using firstWriter = await firstStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
341
342
|
firstWriter.addCustomWriteCheckpoint({ user_id: 'user1', checkpoint: 5n, event_id: firstEventId });
|
|
342
343
|
await firstWriter.markAllSnapshotDone('1/1');
|
|
@@ -348,7 +349,9 @@ event_definitions:
|
|
|
348
349
|
const unchangedEventId = unchanged.syncConfigContent[1].mapping.eventDefinitionIdByName('write_checkpoints');
|
|
349
350
|
expect(unchangedEventId).toBe(firstEventId);
|
|
350
351
|
|
|
351
|
-
await using unchangedWriter = await
|
|
352
|
+
await using unchangedWriter = await (
|
|
353
|
+
await getTestStorage(factory, unchanged)
|
|
354
|
+
).createWriter(test_utils.BATCH_OPTIONS);
|
|
352
355
|
await unchangedWriter.markAllSnapshotDone('2/1');
|
|
353
356
|
await unchangedWriter.commit('2/1');
|
|
354
357
|
|
|
@@ -369,7 +372,9 @@ event_definitions:
|
|
|
369
372
|
const changedEventId = changed.syncConfigContent[1].mapping.eventDefinitionIdByName('write_checkpoints');
|
|
370
373
|
expect(changedEventId).not.toBe(unchangedEventId);
|
|
371
374
|
|
|
372
|
-
await using changedWriter = await
|
|
375
|
+
await using changedWriter = await (
|
|
376
|
+
await getTestStorage(factory, changed)
|
|
377
|
+
).createWriter(test_utils.BATCH_OPTIONS);
|
|
373
378
|
changedWriter.addCustomWriteCheckpoint({ user_id: 'user1', checkpoint: 9n, event_id: changedEventId });
|
|
374
379
|
await changedWriter.flush();
|
|
375
380
|
|
|
@@ -415,7 +420,7 @@ bucket_definitions:
|
|
|
415
420
|
{ storageVersion }
|
|
416
421
|
)
|
|
417
422
|
);
|
|
418
|
-
const bucketStorage = factory
|
|
423
|
+
const bucketStorage = await getTestStorage(factory, syncRules);
|
|
419
424
|
|
|
420
425
|
// Replicate an extremely rare possibility where there are multiple records
|
|
421
426
|
await factory.db.write_checkpoints.insertMany([
|
|
@@ -486,26 +491,20 @@ bucket_definitions:
|
|
|
486
491
|
|
|
487
492
|
describe('Sync Bucket Validation', register.registerBucketValidationTests);
|
|
488
493
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
checksumOptions: {
|
|
507
|
-
bucketBatchLimit: 1,
|
|
508
|
-
operationBatchLimit: 100
|
|
509
|
-
}
|
|
510
|
-
})
|
|
511
|
-
));
|
|
494
|
+
for (const storageVersion of TEST_STORAGE_VERSIONS) {
|
|
495
|
+
for (const [name, checksumOptions] of [
|
|
496
|
+
['split operations', { bucketBatchLimit: 100, operationBatchLimit: 1 }],
|
|
497
|
+
['split buckets', { bucketBatchLimit: 1, operationBatchLimit: 100 }]
|
|
498
|
+
] as const) {
|
|
499
|
+
describe(`Mongo Sync Bucket Storage - ${name} - v${storageVersion}`, () =>
|
|
500
|
+
register.registerDataStorageDataTests({
|
|
501
|
+
...mongoTestStorageFactoryGenerator({
|
|
502
|
+
url: env.MONGO_TEST_URL,
|
|
503
|
+
isCI: env.CI,
|
|
504
|
+
checksumOptions
|
|
505
|
+
}),
|
|
506
|
+
storageVersion,
|
|
507
|
+
compressedBucketStorage: storageVersion >= 3
|
|
508
|
+
}));
|
|
509
|
+
}
|
|
510
|
+
}
|