@powersync/service-module-mongodb-storage 0.22.0 → 0.23.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 +69 -0
- package/dist/storage/MongoBucketStorage.d.ts +5 -1
- package/dist/storage/MongoBucketStorage.js +30 -6
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/implementation/MongoBucketBatch.d.ts +23 -10
- package/dist/storage/implementation/MongoBucketBatch.js +132 -88
- 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/MongoParsedSyncConfigSet.js +8 -2
- package/dist/storage/implementation/MongoParsedSyncConfigSet.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/db.js +1 -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 +136 -133
- package/dist/storage/implementation/v1/MongoBucketBatchV1.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/v3/MongoBucketBatchV3.d.ts +5 -1
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js +131 -148
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js.map +1 -1
- package/dist/storage/implementation/v3/MongoCompactorV3.d.ts +4 -3
- package/dist/storage/implementation/v3/MongoCompactorV3.js +19 -10
- package/dist/storage/implementation/v3/MongoCompactorV3.js.map +1 -1
- package/dist/storage/implementation/v3/compact-utils.d.ts +6 -3
- 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/utils/test-utils.d.ts +2 -1
- package/dist/utils/test-utils.js +4 -3
- package/dist/utils/test-utils.js.map +1 -1
- package/package.json +7 -7
- package/src/storage/MongoBucketStorage.ts +35 -7
- package/src/storage/implementation/MongoBucketBatch.ts +201 -110
- 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/MongoParsedSyncConfigSet.ts +19 -1
- package/src/storage/implementation/MongoSyncBucketStorage.ts +19 -0
- package/src/storage/implementation/MongoSyncRulesLock.ts +56 -3
- package/src/storage/implementation/db.ts +1 -0
- package/src/storage/implementation/models.ts +1 -0
- package/src/storage/implementation/v1/MongoBucketBatchV1.ts +150 -152
- package/src/storage/implementation/v1/MongoSyncBucketStorageV1.ts +1 -1
- package/src/storage/implementation/v3/MongoBucketBatchV3.ts +167 -194
- package/src/storage/implementation/v3/MongoCompactorV3.ts +25 -22
- package/src/storage/implementation/v3/compact-utils.ts +19 -8
- package/src/storage/implementation/v3/models.ts +1 -1
- package/src/utils/test-utils.ts +5 -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/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 +2 -1
- 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/source_table_config.test.ts +97 -0
- package/test/src/storage.test.ts +32 -33
- package/test/src/storage_compacting.test.ts +184 -21
- 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 +4 -4
- package/test/src/storage_s3_writing.test.ts +3 -3
- package/test/src/storage_sync.test.ts +54 -47
- 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 });
|
|
@@ -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
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { mongoTestStorageFactoryGenerator } from '@module/utils/test-utils.js';
|
|
2
|
+
import { updateSyncRulesFromConfig } from '@powersync/service-core';
|
|
3
|
+
import { test_utils } from '@powersync/service-core-tests';
|
|
4
|
+
import { PrecompiledSyncConfig, SqlSyncRules } from '@powersync/service-sync-rules';
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
|
+
import { env } from './env.js';
|
|
7
|
+
import { TEST_STORAGE_VERSIONS } from './util.js';
|
|
8
|
+
|
|
9
|
+
const STREAMS = /* yaml */ `
|
|
10
|
+
# sync config fixture.
|
|
11
|
+
config:
|
|
12
|
+
edition: 3
|
|
13
|
+
streams:
|
|
14
|
+
orders:
|
|
15
|
+
query: SELECT * FROM orders
|
|
16
|
+
`;
|
|
17
|
+
const CONFIGURED = /* yaml */ `
|
|
18
|
+
# sync config fixture.
|
|
19
|
+
config:
|
|
20
|
+
edition: 3
|
|
21
|
+
source_table_options:
|
|
22
|
+
orders:
|
|
23
|
+
mongodb_filter_expression: { $eq: ['$$doc.active', true] }
|
|
24
|
+
streams:
|
|
25
|
+
orders:
|
|
26
|
+
query: SELECT * FROM orders
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
function storageFactory() {
|
|
30
|
+
return mongoTestStorageFactoryGenerator({
|
|
31
|
+
url: env.MONGO_TEST_URL,
|
|
32
|
+
isCI: env.CI,
|
|
33
|
+
supportsMultipleSyncConfigs: true
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe.for(TEST_STORAGE_VERSIONS)('source-table config with storage v%i', (storageVersion) => {
|
|
38
|
+
test('preserves source-table options across closing storage and loading its compiled plan', async () => {
|
|
39
|
+
let expected;
|
|
40
|
+
{
|
|
41
|
+
await using factory = await storageFactory().factory();
|
|
42
|
+
const parsed = SqlSyncRules.fromYaml(CONFIGURED, test_utils.PARSE_OPTIONS);
|
|
43
|
+
expected = (parsed.config as PrecompiledSyncConfig).plan.sourceTableConfig;
|
|
44
|
+
await factory.updateSyncRules(updateSyncRulesFromConfig(parsed, { storageVersion }));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Reopen the same database without clearing it, as a service restart would.
|
|
48
|
+
await using reopened = await storageFactory().factory({ doNotClear: true });
|
|
49
|
+
const deploying = (await reopened.getDeployingSyncConfig())!;
|
|
50
|
+
expect(deploying.content.compiled_plan?.plan.version).toBe(3);
|
|
51
|
+
const parsed = deploying.content.parsed(test_utils.PARSE_OPTIONS);
|
|
52
|
+
expect((parsed.syncConfigs[0].config as PrecompiledSyncConfig).plan.sourceTableConfig).toEqual(expected);
|
|
53
|
+
expect(parsed.hydratedSyncConfig.sourceTableConfig).toEqual(expected);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('continues loading unfiltered plans without source options', async () => {
|
|
57
|
+
await using factory = await storageFactory().factory();
|
|
58
|
+
await factory.updateSyncRules(
|
|
59
|
+
updateSyncRulesFromConfig(SqlSyncRules.fromYaml(STREAMS, test_utils.PARSE_OPTIONS), {
|
|
60
|
+
storageVersion
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
const deploying = (await factory.getDeployingSyncConfig())!;
|
|
64
|
+
expect(deploying.content.compiled_plan?.plan.version).toBe(1);
|
|
65
|
+
expect(deploying.content.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig.sourceTableConfig).toEqual({});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('starts replacement processing when source-table options change', async () => {
|
|
69
|
+
await using factory = await storageFactory().factory();
|
|
70
|
+
const deploy = (yaml: string) =>
|
|
71
|
+
factory.updateSyncRules(
|
|
72
|
+
updateSyncRulesFromConfig(SqlSyncRules.fromYaml(yaml, test_utils.PARSE_OPTIONS), {
|
|
73
|
+
storageVersion
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
const first = await deploy(CONFIGURED);
|
|
77
|
+
{
|
|
78
|
+
// Activate the first config so compatibility is checked against data already being served.
|
|
79
|
+
const storage = await test_utils.getTestStorage(factory, first);
|
|
80
|
+
await using writer = await storage.createWriter(test_utils.BATCH_OPTIONS);
|
|
81
|
+
await writer.markAllSnapshotDone('1/1');
|
|
82
|
+
await writer.commit('1/1');
|
|
83
|
+
}
|
|
84
|
+
if (storageVersion >= 3) {
|
|
85
|
+
// SQL-only edits can share source data when the source-table options are identical.
|
|
86
|
+
const sameOptions = await deploy(CONFIGURED.replace('SELECT * FROM orders', 'SELECT id FROM orders'));
|
|
87
|
+
expect(sameOptions.replicationStreamId).toBe(first.replicationStreamId);
|
|
88
|
+
const storage = await test_utils.getTestStorage(factory, sameOptions);
|
|
89
|
+
await using writer = await storage.createWriter(test_utils.BATCH_OPTIONS);
|
|
90
|
+
await writer.markAllSnapshotDone('2/1');
|
|
91
|
+
await writer.commit('2/1');
|
|
92
|
+
}
|
|
93
|
+
const changed = await deploy(CONFIGURED.replace('true', 'false'));
|
|
94
|
+
expect(changed.replicationStreamId).not.toBe(first.replicationStreamId);
|
|
95
|
+
expect((await factory.getActiveSyncConfig())?.content.replicationStreamId).toBe(first.replicationStreamId);
|
|
96
|
+
});
|
|
97
|
+
});
|
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
|
+
}
|