@powersync/service-core-tests 0.15.4 → 0.16.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 +53 -0
- package/dist/test-utils/AbstractStreamTestContext.d.ts +51 -0
- package/dist/test-utils/AbstractStreamTestContext.js +143 -0
- package/dist/test-utils/AbstractStreamTestContext.js.map +1 -0
- package/dist/test-utils/StorageDataHelpers.d.ts +8 -0
- package/dist/test-utils/StorageDataHelpers.js +33 -0
- package/dist/test-utils/StorageDataHelpers.js.map +1 -0
- package/dist/test-utils/general-utils.d.ts +3 -8
- package/dist/test-utils/general-utils.js +28 -26
- package/dist/test-utils/general-utils.js.map +1 -1
- package/dist/test-utils/test-utils-index.d.ts +2 -0
- package/dist/test-utils/test-utils-index.js +2 -0
- package/dist/test-utils/test-utils-index.js.map +1 -1
- package/dist/tests/register-data-storage-data-tests.js +3 -3
- package/dist/tests/register-data-storage-data-tests.js.map +1 -1
- package/dist/tests/register-data-storage-parameter-tests.js +436 -65
- package/dist/tests/register-data-storage-parameter-tests.js.map +1 -1
- package/dist/tests/register-parameter-compacting-tests.js +8 -8
- package/dist/tests/register-parameter-compacting-tests.js.map +1 -1
- package/dist/tests/util.d.ts +1 -2
- package/dist/tests/util.js +8 -5
- package/dist/tests/util.js.map +1 -1
- package/package.json +7 -6
- package/src/test-utils/AbstractStreamTestContext.ts +179 -0
- package/src/test-utils/StorageDataHelpers.ts +44 -0
- package/src/test-utils/general-utils.ts +31 -31
- package/src/test-utils/test-utils-index.ts +2 -0
- package/src/tests/register-data-storage-data-tests.ts +3 -3
- package/src/tests/register-data-storage-parameter-tests.ts +519 -67
- package/src/tests/register-parameter-compacting-tests.ts +8 -8
- package/src/tests/util.ts +12 -9
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @powersync/service-core-tests
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e2bf1ad: [Internal] rework resolveTables to handle multiple SourceTables.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [17fd96b]
|
|
12
|
+
- Updated dependencies [6e2a57e]
|
|
13
|
+
- Updated dependencies [ec6df9f]
|
|
14
|
+
- Updated dependencies [99d33d5]
|
|
15
|
+
- Updated dependencies [cae92ce]
|
|
16
|
+
- Updated dependencies [5ac5345]
|
|
17
|
+
- Updated dependencies [15cb880]
|
|
18
|
+
- Updated dependencies [f2f5086]
|
|
19
|
+
- Updated dependencies [5b1b215]
|
|
20
|
+
- Updated dependencies [e2bf1ad]
|
|
21
|
+
- Updated dependencies [92cc83b]
|
|
22
|
+
- Updated dependencies [0aab0f9]
|
|
23
|
+
- Updated dependencies [15e2466]
|
|
24
|
+
- Updated dependencies [ebeaa3b]
|
|
25
|
+
- Updated dependencies [b116857]
|
|
26
|
+
- Updated dependencies [a94b6c3]
|
|
27
|
+
- @powersync/service-core@1.22.0
|
|
28
|
+
- @powersync/service-sync-rules@0.37.0
|
|
29
|
+
- @powersync/lib-services-framework@0.9.5
|
|
30
|
+
|
|
31
|
+
## 0.15.5
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- cdb8993: Add `config.storage_version` configuration option.
|
|
36
|
+
- 040fffd: Improve consistency of logs and error messages
|
|
37
|
+
- Updated dependencies [f20f318]
|
|
38
|
+
- Updated dependencies [9add445]
|
|
39
|
+
- Updated dependencies [17503d1]
|
|
40
|
+
- Updated dependencies [ad9ea06]
|
|
41
|
+
- Updated dependencies [01c29c3]
|
|
42
|
+
- Updated dependencies [8afe719]
|
|
43
|
+
- Updated dependencies [b8f0195]
|
|
44
|
+
- Updated dependencies [cdb8993]
|
|
45
|
+
- Updated dependencies [7c7b525]
|
|
46
|
+
- Updated dependencies [824e229]
|
|
47
|
+
- Updated dependencies [6304a21]
|
|
48
|
+
- Updated dependencies [040fffd]
|
|
49
|
+
- Updated dependencies [9e474d3]
|
|
50
|
+
- Updated dependencies [423822c]
|
|
51
|
+
- Updated dependencies [2b19fc3]
|
|
52
|
+
- @powersync/service-core@1.21.0
|
|
53
|
+
- @powersync/service-sync-rules@0.36.0
|
|
54
|
+
- @powersync/service-jsonbig@0.17.13
|
|
55
|
+
|
|
3
56
|
## 0.15.4
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BucketStorageFactory, InternalOpId, storage, SyncRulesBucketStorage } from '@powersync/service-core';
|
|
2
|
+
export declare abstract class AbstractStreamTestContext implements AsyncDisposable {
|
|
3
|
+
protected abortController: AbortController;
|
|
4
|
+
protected syncRulesContent?: storage.PersistedSyncRulesContent;
|
|
5
|
+
storage?: SyncRulesBucketStorage;
|
|
6
|
+
protected settledReplicationPromise?: Promise<PromiseSettledResult<void>>;
|
|
7
|
+
abstract get factory(): BucketStorageFactory;
|
|
8
|
+
protected abstract get storageVersion(): number;
|
|
9
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
10
|
+
protected abstract _dispose(): Promise<void>;
|
|
11
|
+
dispose(): Promise<void>;
|
|
12
|
+
updateSyncRules(content: string): Promise<storage.SyncRulesBucketStorage>;
|
|
13
|
+
loadNextSyncRules(): Promise<storage.SyncRulesBucketStorage>;
|
|
14
|
+
loadActiveSyncRules(): Promise<storage.SyncRulesBucketStorage>;
|
|
15
|
+
private getSyncRulesContent;
|
|
16
|
+
/**
|
|
17
|
+
* Replicate a snapshot, start streaming, and wait for a consistent checkpoint.
|
|
18
|
+
*/
|
|
19
|
+
initializeReplication(): Promise<void>;
|
|
20
|
+
protected abstract triggerReplication(): Promise<void>;
|
|
21
|
+
protected abstract waitForInitialSnapshot(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Replicate the initial snapshot, and start streaming.
|
|
24
|
+
*/
|
|
25
|
+
replicateSnapshot(): Promise<void>;
|
|
26
|
+
abstract getClientCheckpoint(options?: {
|
|
27
|
+
timeout?: number;
|
|
28
|
+
}): Promise<bigint>;
|
|
29
|
+
getCheckpoint(options?: {
|
|
30
|
+
timeout?: number;
|
|
31
|
+
}): Promise<bigint>;
|
|
32
|
+
getBucketsDataBatch(buckets: Record<string, InternalOpId>, options?: {
|
|
33
|
+
timeout?: number;
|
|
34
|
+
}): Promise<storage.SyncBucketDataChunk[]>;
|
|
35
|
+
/**
|
|
36
|
+
* This waits for a client checkpoint.
|
|
37
|
+
*/
|
|
38
|
+
getBucketData(bucket: string, start?: InternalOpId | string | undefined, options?: {
|
|
39
|
+
timeout?: number;
|
|
40
|
+
}): Promise<import("@powersync/service-core").OplogEntry<import("@powersync/service-core").StoredOplogData>[]>;
|
|
41
|
+
getChecksums(buckets: string[], options?: {
|
|
42
|
+
timeout?: number;
|
|
43
|
+
}): Promise<Map<any, any>>;
|
|
44
|
+
getChecksum(bucket: string, options?: {
|
|
45
|
+
timeout?: number;
|
|
46
|
+
}): Promise<any>;
|
|
47
|
+
/**
|
|
48
|
+
* This does not wait for a client checkpoint.
|
|
49
|
+
*/
|
|
50
|
+
getCurrentBucketData(bucket: string, start?: InternalOpId | string | undefined): Promise<import("@powersync/service-core").OplogEntry<import("@powersync/service-core").StoredOplogData>[]>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { ReplicationAbortedError } from '@powersync/lib-services-framework';
|
|
2
|
+
import { settledPromise, unsettledPromise, updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
3
|
+
import { StorageDataHelpers } from './StorageDataHelpers.js';
|
|
4
|
+
import { bucketRequest } from './general-utils.js';
|
|
5
|
+
import { fromAsync } from './stream_utils.js';
|
|
6
|
+
export class AbstractStreamTestContext {
|
|
7
|
+
abortController = new AbortController();
|
|
8
|
+
syncRulesContent;
|
|
9
|
+
storage;
|
|
10
|
+
settledReplicationPromise;
|
|
11
|
+
async [Symbol.asyncDispose]() {
|
|
12
|
+
await this.dispose();
|
|
13
|
+
}
|
|
14
|
+
async dispose() {
|
|
15
|
+
this.abortController.abort();
|
|
16
|
+
try {
|
|
17
|
+
await this.settledReplicationPromise;
|
|
18
|
+
await this._dispose();
|
|
19
|
+
await this.factory?.[Symbol.asyncDispose]();
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
// Throwing here may result in SuppressedError. The underlying errors often don't show up
|
|
23
|
+
// in the test output, so we log it here.
|
|
24
|
+
// If we could get vitest to log SuppressedError.error and SuppressedError.suppressed, we
|
|
25
|
+
// could remove this.
|
|
26
|
+
console.error('Error during ConvexStreamTestContext dispose', e);
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async updateSyncRules(content) {
|
|
31
|
+
const syncRules = await this.factory.updateSyncRules(updateSyncRulesFromYaml(content, { validate: true, storageVersion: this.storageVersion }));
|
|
32
|
+
this.syncRulesContent = syncRules;
|
|
33
|
+
this.storage = this.factory.getInstance(syncRules);
|
|
34
|
+
return this.storage;
|
|
35
|
+
}
|
|
36
|
+
async loadNextSyncRules() {
|
|
37
|
+
const syncRules = await this.factory.getNextSyncRulesContent();
|
|
38
|
+
if (syncRules == null) {
|
|
39
|
+
throw new Error(`Next sync rules not available`);
|
|
40
|
+
}
|
|
41
|
+
this.syncRulesContent = syncRules;
|
|
42
|
+
this.storage = this.factory.getInstance(syncRules);
|
|
43
|
+
return this.storage;
|
|
44
|
+
}
|
|
45
|
+
async loadActiveSyncRules() {
|
|
46
|
+
const syncRules = await this.factory.getActiveSyncRulesContent();
|
|
47
|
+
if (syncRules == null) {
|
|
48
|
+
throw new Error(`Active sync rules not available`);
|
|
49
|
+
}
|
|
50
|
+
this.syncRulesContent = syncRules;
|
|
51
|
+
this.storage = this.factory.getInstance(syncRules);
|
|
52
|
+
return this.storage;
|
|
53
|
+
}
|
|
54
|
+
getSyncRulesContent() {
|
|
55
|
+
if (this.syncRulesContent == null) {
|
|
56
|
+
throw new Error('Sync rules not configured - call updateSyncRules() first');
|
|
57
|
+
}
|
|
58
|
+
return this.syncRulesContent;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Replicate a snapshot, start streaming, and wait for a consistent checkpoint.
|
|
62
|
+
*/
|
|
63
|
+
async initializeReplication() {
|
|
64
|
+
await this.replicateSnapshot();
|
|
65
|
+
// Make sure we're up to date
|
|
66
|
+
await this.getCheckpoint();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Replicate the initial snapshot, and start streaming.
|
|
70
|
+
*/
|
|
71
|
+
async replicateSnapshot() {
|
|
72
|
+
// Use a settledPromise to avoid unhandled rejections
|
|
73
|
+
this.settledReplicationPromise = settledPromise(this.triggerReplication());
|
|
74
|
+
try {
|
|
75
|
+
await Promise.race([unsettledPromise(this.settledReplicationPromise), this.waitForInitialSnapshot()]);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
if (e instanceof ReplicationAbortedError && e.cause != null) {
|
|
79
|
+
// Edge case for tests: replicate() can throw an error, but we'd receive the ReplicationAbortedError from
|
|
80
|
+
// waitForInitialSnapshot() first. In that case, prioritize the cause, e.g. MissingReplicationSlotError.
|
|
81
|
+
// This is not a concern for production use, since we only use waitForInitialSnapshot() in tests.
|
|
82
|
+
throw e.cause;
|
|
83
|
+
}
|
|
84
|
+
throw e;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async getCheckpoint(options) {
|
|
88
|
+
let checkpoint = await Promise.race([
|
|
89
|
+
this.getClientCheckpoint(options),
|
|
90
|
+
unsettledPromise(this.settledReplicationPromise)
|
|
91
|
+
]);
|
|
92
|
+
if (checkpoint == null) {
|
|
93
|
+
// This indicates an issue with the test setup - replicationPromise completed instead
|
|
94
|
+
// of getClientCheckpoint()
|
|
95
|
+
throw new Error('Test failure - replicationPromise completed');
|
|
96
|
+
}
|
|
97
|
+
return checkpoint;
|
|
98
|
+
}
|
|
99
|
+
async getBucketsDataBatch(buckets, options) {
|
|
100
|
+
const helpers = new StorageDataHelpers(this.storage, this.getSyncRulesContent());
|
|
101
|
+
const checkpoint = await this.getCheckpoint(options);
|
|
102
|
+
return helpers.getBucketsDataBatch(buckets, checkpoint);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* This waits for a client checkpoint.
|
|
106
|
+
*/
|
|
107
|
+
async getBucketData(bucket, start, options) {
|
|
108
|
+
const helpers = new StorageDataHelpers(this.storage, this.getSyncRulesContent());
|
|
109
|
+
const checkpoint = await this.getCheckpoint(options);
|
|
110
|
+
return helpers.getBucketData(bucket, checkpoint, start);
|
|
111
|
+
}
|
|
112
|
+
async getChecksums(buckets, options) {
|
|
113
|
+
const checkpoint = await this.getCheckpoint(options);
|
|
114
|
+
const syncRules = this.getSyncRulesContent();
|
|
115
|
+
const versionedBuckets = buckets.map((bucket) => bucketRequest(syncRules, bucket, 0n));
|
|
116
|
+
const checksums = await this.storage.getChecksums(checkpoint, versionedBuckets);
|
|
117
|
+
const unversioned = new Map();
|
|
118
|
+
for (let i = 0; i < buckets.length; i++) {
|
|
119
|
+
unversioned.set(buckets[i], checksums.get(versionedBuckets[i].bucket));
|
|
120
|
+
}
|
|
121
|
+
return unversioned;
|
|
122
|
+
}
|
|
123
|
+
async getChecksum(bucket, options) {
|
|
124
|
+
const checksums = await this.getChecksums([bucket], options);
|
|
125
|
+
return checksums.get(bucket);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* This does not wait for a client checkpoint.
|
|
129
|
+
*/
|
|
130
|
+
async getCurrentBucketData(bucket, start) {
|
|
131
|
+
start ??= 0n;
|
|
132
|
+
if (typeof start == 'string') {
|
|
133
|
+
start = BigInt(start);
|
|
134
|
+
}
|
|
135
|
+
const syncRules = this.getSyncRulesContent();
|
|
136
|
+
const { checkpoint } = await this.storage.getCheckpoint();
|
|
137
|
+
const map = [bucketRequest(syncRules, bucket, start)];
|
|
138
|
+
const batch = this.storage.getBucketDataBatch(checkpoint, map);
|
|
139
|
+
const batches = await fromAsync(batch);
|
|
140
|
+
return batches[0]?.chunkData.data ?? [];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=AbstractStreamTestContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractStreamTestContext.js","sourceRoot":"","sources":["../../src/test-utils/AbstractStreamTestContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAGL,cAAc,EAGd,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,OAAgB,yBAAyB;IACnC,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,gBAAgB,CAAqC;IACxD,OAAO,CAA0B;IAC9B,yBAAyB,CAAuC;IAK1E,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAID,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,yBAAyB,CAAC;YACrC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,yFAAyF;YACzF,yCAAyC;YACzC,yFAAyF;YACzF,qBAAqB;YACrB,OAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,CAAC,CAAC,C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C;YACxC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAE,CAAC,CAAC;QAC1E,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,OAA8B;QAC9D,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CAAC,MAAc,EAAE,KAAyC;QAClF,KAAK,KAAK,EAAE,CAAC;QACb,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC7C,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,CAAC,OAAQ,CAAC,aAAa,EAAE,CAAC;QAC3D,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QACtD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAQ,CAAC,kBAAkB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;QACvC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InternalOpId, OplogEntry, PersistedSyncRules, PersistedSyncRulesContent, SyncRulesBucketStorage } from '@powersync/service-core';
|
|
2
|
+
export declare class StorageDataHelpers {
|
|
3
|
+
storage: SyncRulesBucketStorage;
|
|
4
|
+
syncRules: PersistedSyncRulesContent | PersistedSyncRules;
|
|
5
|
+
constructor(storage: SyncRulesBucketStorage, syncRules: PersistedSyncRulesContent | PersistedSyncRules);
|
|
6
|
+
getBucketData(bucket: string, checkpoint: InternalOpId, start?: InternalOpId | string | undefined): Promise<OplogEntry<import("@powersync/service-core").StoredOplogData>[]>;
|
|
7
|
+
getBucketsDataBatch(buckets: Record<string, InternalOpId>, checkpoint: InternalOpId): Promise<import("@powersync/service-core").SyncBucketDataChunk[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { bucketRequest } from './general-utils.js';
|
|
2
|
+
import { fromAsync } from './stream_utils.js';
|
|
3
|
+
export class StorageDataHelpers {
|
|
4
|
+
storage;
|
|
5
|
+
syncRules;
|
|
6
|
+
constructor(storage, syncRules) {
|
|
7
|
+
this.storage = storage;
|
|
8
|
+
this.syncRules = syncRules;
|
|
9
|
+
}
|
|
10
|
+
async getBucketData(bucket, checkpoint, start) {
|
|
11
|
+
start ??= 0n;
|
|
12
|
+
if (typeof start == 'string') {
|
|
13
|
+
start = BigInt(start);
|
|
14
|
+
}
|
|
15
|
+
let map = [bucketRequest(this.syncRules, bucket, start)];
|
|
16
|
+
let data = [];
|
|
17
|
+
while (true) {
|
|
18
|
+
const batch = this.storage.getBucketDataBatch(checkpoint, map);
|
|
19
|
+
const batches = await fromAsync(batch);
|
|
20
|
+
data = data.concat(batches[0]?.chunkData.data ?? []);
|
|
21
|
+
if (batches.length == 0 || !batches[0].chunkData.has_more) {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
map = [bucketRequest(this.syncRules, bucket, BigInt(batches[0].chunkData.next_after))];
|
|
25
|
+
}
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
async getBucketsDataBatch(buckets, checkpoint) {
|
|
29
|
+
const map = Object.entries(buckets).map(([bucket, start]) => bucketRequest(this.syncRules, bucket, start));
|
|
30
|
+
return fromAsync(this.storage.getBucketDataBatch(checkpoint, map));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=StorageDataHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageDataHelpers.js","sourceRoot":"","sources":["../../src/test-utils/StorageDataHelpers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,OAAO,kBAAkB;IAC7B,OAAO,CAAyB;IAChC,SAAS,CAAiD;IAE1D,YAAY,OAA+B,EAAE,SAAyD;QACpG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAc,EAAE,UAAwB,EAAE,KAAyC;QACrG,KAAK,KAAK,EAAE,CAAC;QACb,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;QACD,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QACzD,IAAI,IAAI,GAAiB,EAAE,CAAC;QAC5B,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,IAAI,CAAC,OAAQ,CAAC,kBAAkB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;YAEhE,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;YACvC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YACrD,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;gBAC3D,MAAM;YACR,CAAC;YACD,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,OAAqC,EAAE,UAAwB;QACvF,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAC3G,OAAO,SAAS,CAAC,IAAI,CAAC,OAAQ,CAAC,kBAAkB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;CACF"}
|
|
@@ -4,15 +4,10 @@ import * as bson from 'bson';
|
|
|
4
4
|
export declare const ZERO_LSN = "0/0";
|
|
5
5
|
export declare const PARSE_OPTIONS: storage.ParseSyncRulesOptions;
|
|
6
6
|
export declare const BATCH_OPTIONS: storage.CreateWriterOptions;
|
|
7
|
-
export declare function makeTestTable(name: string, replicaIdColumns?: string[] | undefined, options?: {
|
|
8
|
-
tableIdStrings: boolean;
|
|
9
|
-
}): storage.SourceTable;
|
|
10
7
|
/**
|
|
11
|
-
* With
|
|
12
|
-
*
|
|
13
|
-
* This prepares for it.
|
|
8
|
+
* With newer storage versions, we need actual test tables, resolved via the writer.
|
|
14
9
|
*/
|
|
15
|
-
export declare function resolveTestTable(
|
|
10
|
+
export declare function resolveTestTable(writer: storage.BucketStorageBatch, name: string, replicaIdColumns: string[] | undefined, options: {
|
|
16
11
|
tableIdStrings: boolean;
|
|
17
12
|
}, idIndex?: number): Promise<storage.SourceTable>;
|
|
18
13
|
export declare function getBatchData(batch: utils.SyncBucketData[] | storage.SyncBucketDataChunk[] | storage.SyncBucketDataChunk): {
|
|
@@ -22,7 +17,7 @@ export declare function getBatchData(batch: utils.SyncBucketData[] | storage.Syn
|
|
|
22
17
|
checksum: number | bigint;
|
|
23
18
|
}[];
|
|
24
19
|
/**
|
|
25
|
-
* Bucket names no longer purely depend on the sync
|
|
20
|
+
* Bucket names no longer purely depend on the sync config.
|
|
26
21
|
* This converts a bucket name like "global[]" into the actual bucket name, for use in tests.
|
|
27
22
|
*/
|
|
28
23
|
export declare function bucketRequest(syncRules: storage.PersistedSyncRulesContent | storage.PersistedSyncRules, bucket: string, start?: InternalOpId | string | number): BucketDataRequest;
|
|
@@ -10,39 +10,41 @@ export const BATCH_OPTIONS = {
|
|
|
10
10
|
zeroLSN: ZERO_LSN,
|
|
11
11
|
storeCurrentData: true
|
|
12
12
|
};
|
|
13
|
-
export function makeTestTable(name, replicaIdColumns, options) {
|
|
14
|
-
const relId = utils.hashData('table', name, (replicaIdColumns ?? ['id']).join(','));
|
|
15
|
-
const id = options?.tableIdStrings == false ? new bson.ObjectId('6544e3899293153fa7b38331') : '6544e3899293153fa7b38331';
|
|
16
|
-
return new storage.SourceTable({
|
|
17
|
-
id: id,
|
|
18
|
-
connectionTag: storage.SourceTable.DEFAULT_TAG,
|
|
19
|
-
objectId: relId,
|
|
20
|
-
schema: 'public',
|
|
21
|
-
name: name,
|
|
22
|
-
replicaIdColumns: (replicaIdColumns ?? ['id']).map((column) => ({ name: column, type: 'VARCHAR', typeId: 25 })),
|
|
23
|
-
snapshotComplete: true
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
13
|
/**
|
|
27
|
-
* With
|
|
28
|
-
*
|
|
29
|
-
* This prepares for it.
|
|
14
|
+
* With newer storage versions, we need actual test tables, resolved via the writer.
|
|
30
15
|
*/
|
|
31
|
-
export async function resolveTestTable(
|
|
16
|
+
export async function resolveTestTable(writer, name, replicaIdColumns, options, idIndex = 1) {
|
|
17
|
+
void idIndex;
|
|
18
|
+
void options;
|
|
32
19
|
const relId = utils.hashData('table', name, (replicaIdColumns ?? ['id']).join(','));
|
|
33
|
-
//
|
|
34
|
-
//
|
|
20
|
+
// Semi-hardcoded id for tests, to get consistent output.
|
|
21
|
+
// If the same test uses multiple tables, pass idIndex to get different ids.
|
|
35
22
|
const idString = '6544e3899293153fa7b383' + (30 + idIndex).toString().padStart(2, '0');
|
|
36
23
|
const id = options.tableIdStrings == false ? new bson.ObjectId(idString) : idString;
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
let didGenerateId = false;
|
|
25
|
+
const source = {
|
|
39
26
|
connectionTag: storage.SourceTable.DEFAULT_TAG,
|
|
40
27
|
objectId: relId,
|
|
41
28
|
schema: 'public',
|
|
42
29
|
name: name,
|
|
43
|
-
replicaIdColumns: (replicaIdColumns ?? ['id']).map((column) => ({ name: column, type: 'VARCHAR', typeId: 25 }))
|
|
44
|
-
|
|
30
|
+
replicaIdColumns: (replicaIdColumns ?? ['id']).map((column) => ({ name: column, type: 'VARCHAR', typeId: 25 }))
|
|
31
|
+
};
|
|
32
|
+
const resolved = await writer.resolveTables({
|
|
33
|
+
connection_id: 1,
|
|
34
|
+
source,
|
|
35
|
+
idGenerator: () => {
|
|
36
|
+
if (didGenerateId) {
|
|
37
|
+
throw new Error('idGenerator called multiple times - not supported in tests');
|
|
38
|
+
}
|
|
39
|
+
didGenerateId = true;
|
|
40
|
+
return id;
|
|
41
|
+
}
|
|
45
42
|
});
|
|
43
|
+
const table = resolved.tables[0];
|
|
44
|
+
if (table == null) {
|
|
45
|
+
throw new Error(`Failed to resolve test table ${source.schema}.${source.name}`);
|
|
46
|
+
}
|
|
47
|
+
return table;
|
|
46
48
|
}
|
|
47
49
|
export function getBatchData(batch) {
|
|
48
50
|
const first = getFirst(batch);
|
|
@@ -59,10 +61,10 @@ export function getBatchData(batch) {
|
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
function isParsedSyncRules(syncRules) {
|
|
62
|
-
return syncRules.
|
|
64
|
+
return syncRules.syncConfigWithErrors !== undefined;
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
65
|
-
* Bucket names no longer purely depend on the sync
|
|
67
|
+
* Bucket names no longer purely depend on the sync config.
|
|
66
68
|
* This converts a bucket name like "global[]" into the actual bucket name, for use in tests.
|
|
67
69
|
*/
|
|
68
70
|
export function bucketRequest(syncRules, bucket, start) {
|
|
@@ -71,7 +73,7 @@ export function bucketRequest(syncRules, bucket, start) {
|
|
|
71
73
|
const parameterStart = bucket.indexOf('[');
|
|
72
74
|
const definitionName = bucket.substring(0, parameterStart);
|
|
73
75
|
const parameters = bucket.substring(parameterStart);
|
|
74
|
-
const source = parsed.
|
|
76
|
+
const source = parsed.syncConfigWithErrors.config.bucketDataSources.find((b) => b.uniqueName === definitionName);
|
|
75
77
|
if (source == null) {
|
|
76
78
|
throw new Error(`Failed to find global bucket ${bucket}`);
|
|
77
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general-utils.js","sourceRoot":"","sources":["../../src/test-utils/general-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,EAAqB,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAE9B,MAAM,CAAC,MAAM,aAAa,GAAkC;IAC1D,aAAa,EAAE,QAAQ;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAgC;IACxD,GAAG,aAAa;IAChB,OAAO,EAAE,QAAQ;IACjB,gBAAgB,EAAE,IAAI;CACvB,CAAC;AAEF,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"general-utils.js","sourceRoot":"","sources":["../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6B,GAAM;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export * from './AbstractStreamTestContext.js';
|
|
1
2
|
export * from './bucket-validation.js';
|
|
2
3
|
export * from './general-utils.js';
|
|
3
4
|
export * from './MetricsHelper.js';
|
|
5
|
+
export * from './StorageDataHelpers.js';
|
|
4
6
|
export * from './stream_utils.js';
|
|
5
7
|
//# sourceMappingURL=test-utils-index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils-index.js","sourceRoot":"","sources":["../../src/test-utils/test-utils-index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"test-utils-index.js","sourceRoot":"","sources":["../../src/test-utils/test-utils-index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
|
@@ -669,7 +669,7 @@ bucket_definitions:
|
|
|
669
669
|
}));
|
|
670
670
|
const bucketStorage = factory.getInstance(syncRules);
|
|
671
671
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
672
|
-
const sourceTable = test_utils.
|
|
672
|
+
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id', 'description'], config);
|
|
673
673
|
// Pre-setup
|
|
674
674
|
await writer.markAllSnapshotDone('1/1');
|
|
675
675
|
await writer.save({
|
|
@@ -765,7 +765,7 @@ bucket_definitions:
|
|
|
765
765
|
}));
|
|
766
766
|
const bucketStorage = factory.getInstance(syncRules);
|
|
767
767
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
768
|
-
const sourceTable = test_utils.
|
|
768
|
+
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id', 'description'], config);
|
|
769
769
|
// Pre-setup
|
|
770
770
|
await writer.markAllSnapshotDone('1/1');
|
|
771
771
|
await writer.save({
|
|
@@ -1411,7 +1411,7 @@ streams:
|
|
|
1411
1411
|
invalid:
|
|
1412
1412
|
query: UPDATE test SET foo = 'bar' RETURNING *
|
|
1413
1413
|
`));
|
|
1414
|
-
const { errors } = deployed.parsed({ defaultSchema: 'ignored' }).
|
|
1414
|
+
const { errors } = deployed.parsed({ defaultSchema: 'ignored' }).syncConfigWithErrors;
|
|
1415
1415
|
expect(errors).toHaveLength(1);
|
|
1416
1416
|
expect(errors[0].message).toStrictEqual('Expected a SELECT statement');
|
|
1417
1417
|
expect(errors[0].location).toStrictEqual({
|