@fluidframework/id-compressor 2.12.0 → 2.20.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/.eslintrc.cjs +1 -4
- package/CHANGELOG.md +8 -0
- package/dist/appendOnlySortedMap.d.ts +37 -16
- package/dist/appendOnlySortedMap.d.ts.map +1 -1
- package/dist/appendOnlySortedMap.js +39 -21
- package/dist/appendOnlySortedMap.js.map +1 -1
- package/dist/finalSpace.d.ts +2 -2
- package/dist/finalSpace.d.ts.map +1 -1
- package/dist/finalSpace.js +5 -5
- package/dist/finalSpace.js.map +1 -1
- package/dist/idCompressor.d.ts.map +1 -1
- package/dist/idCompressor.js +18 -15
- package/dist/idCompressor.js.map +1 -1
- package/dist/identifiers.d.ts +1 -1
- package/dist/identifiers.js +1 -1
- package/dist/identifiers.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sessions.js.map +1 -1
- package/dist/test/appendOnlySortedMap.perf.spec.js.map +1 -1
- package/dist/test/appendOnlySortedMap.spec.js.map +1 -1
- package/dist/test/idCompressor.perf.spec.js.map +1 -1
- package/dist/test/idCompressor.spec.js.map +1 -1
- package/dist/test/idCompressorTestUtilities.d.ts +39 -13
- package/dist/test/idCompressorTestUtilities.d.ts.map +1 -1
- package/dist/test/idCompressorTestUtilities.js +68 -59
- package/dist/test/idCompressorTestUtilities.js.map +1 -1
- package/dist/test/numericUuid.spec.js.map +1 -1
- package/dist/test/sessionSpaceNormalizer.spec.js.map +1 -1
- package/dist/test/snapshots/summary.spec.js.map +1 -1
- package/dist/test/testCommon.d.ts +5 -1
- package/dist/test/testCommon.d.ts.map +1 -1
- package/dist/test/testCommon.js +2 -0
- package/dist/test/testCommon.js.map +1 -1
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +11 -8
- package/dist/utilities.js.map +1 -1
- package/lib/appendOnlySortedMap.d.ts +37 -16
- package/lib/appendOnlySortedMap.d.ts.map +1 -1
- package/lib/appendOnlySortedMap.js +39 -21
- package/lib/appendOnlySortedMap.js.map +1 -1
- package/lib/finalSpace.d.ts +2 -2
- package/lib/finalSpace.d.ts.map +1 -1
- package/lib/finalSpace.js +5 -5
- package/lib/finalSpace.js.map +1 -1
- package/lib/idCompressor.d.ts.map +1 -1
- package/lib/idCompressor.js +18 -15
- package/lib/idCompressor.js.map +1 -1
- package/lib/identifiers.d.ts +1 -1
- package/lib/identifiers.js +1 -1
- package/lib/identifiers.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sessions.js.map +1 -1
- package/lib/test/appendOnlySortedMap.perf.spec.js.map +1 -1
- package/lib/test/appendOnlySortedMap.spec.js.map +1 -1
- package/lib/test/idCompressor.perf.spec.js.map +1 -1
- package/lib/test/idCompressor.spec.js.map +1 -1
- package/lib/test/idCompressorTestUtilities.d.ts +39 -13
- package/lib/test/idCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/idCompressorTestUtilities.js +43 -34
- package/lib/test/idCompressorTestUtilities.js.map +1 -1
- package/lib/test/numericUuid.spec.js.map +1 -1
- package/lib/test/sessionSpaceNormalizer.spec.js.map +1 -1
- package/lib/test/snapshots/summary.spec.js.map +1 -1
- package/lib/test/testCommon.d.ts +5 -1
- package/lib/test/testCommon.d.ts.map +1 -1
- package/lib/test/testCommon.js +2 -0
- package/lib/test/testCommon.js.map +1 -1
- package/lib/utilities.d.ts.map +1 -1
- package/lib/utilities.js +11 -8
- package/lib/utilities.js.map +1 -1
- package/package.json +9 -9
- package/src/appendOnlySortedMap.ts +39 -21
- package/src/finalSpace.ts +6 -6
- package/src/idCompressor.ts +22 -18
- package/src/identifiers.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/sessions.ts +2 -2
- package/src/test/idCompressorTestUtilities.ts +70 -41
- package/src/test/testCommon.ts +5 -1
- package/src/utilities.ts +12 -9
|
@@ -13,17 +13,23 @@ import { ReadonlyIdCompressor } from "./testCommon.js";
|
|
|
13
13
|
export interface ClosedMap<K, V> extends Omit<Map<K, V>, "delete" | "clear"> {
|
|
14
14
|
get(key: K): V;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Identifies a compressor in a network
|
|
18
|
+
*/
|
|
17
19
|
export declare enum Client {
|
|
18
20
|
Client1 = "Client1",
|
|
19
21
|
Client2 = "Client2",
|
|
20
22
|
Client3 = "Client3"
|
|
21
23
|
}
|
|
22
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Identifies categories of compressors
|
|
26
|
+
*/
|
|
23
27
|
export declare enum MetaClient {
|
|
24
28
|
All = "All"
|
|
25
29
|
}
|
|
26
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Identifies a compressor inside the network but outside the three specially tracked clients.
|
|
32
|
+
*/
|
|
27
33
|
export declare enum OutsideClient {
|
|
28
34
|
Remote = "Remote"
|
|
29
35
|
}
|
|
@@ -38,7 +44,9 @@ export declare const OriginatingClient: {
|
|
|
38
44
|
Client2: Client.Client2;
|
|
39
45
|
Client3: Client.Client3;
|
|
40
46
|
};
|
|
41
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Identifies a compressor to which to send an operation
|
|
49
|
+
*/
|
|
42
50
|
export type DestinationClient = Client | MetaClient;
|
|
43
51
|
export declare const DestinationClient: {
|
|
44
52
|
All: MetaClient.All;
|
|
@@ -69,7 +77,9 @@ export type ClientMap<T> = ClosedMap<Client, T>;
|
|
|
69
77
|
* An array of session ID strings corresponding to all non-local `Client` entries.
|
|
70
78
|
*/
|
|
71
79
|
export declare const sessionIds: ClientMap<SessionId>;
|
|
72
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Information about a generated ID in a network to be validated by tests
|
|
82
|
+
*/
|
|
73
83
|
export interface TestIdData {
|
|
74
84
|
readonly id: SessionSpaceCompressedId;
|
|
75
85
|
readonly originatingClient: OriginatingClient;
|
|
@@ -82,15 +92,25 @@ export interface TestIdData {
|
|
|
82
92
|
*/
|
|
83
93
|
export declare class IdCompressorTestNetwork {
|
|
84
94
|
readonly initialClusterSize: number;
|
|
85
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* The compressors used in this network
|
|
97
|
+
*/
|
|
86
98
|
private readonly compressors;
|
|
87
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* The log of operations seen by the server so far. Append-only.
|
|
101
|
+
*/
|
|
88
102
|
private readonly serverOperations;
|
|
89
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* An index into `serverOperations` for each client which represents how many operations have been delivered to that client
|
|
105
|
+
*/
|
|
90
106
|
private readonly clientProgress;
|
|
91
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* All ids (local and sequenced) that a client has created or received, in order.
|
|
109
|
+
*/
|
|
92
110
|
private readonly idLogs;
|
|
93
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* All ids that a client has received from the server, in order.
|
|
113
|
+
*/
|
|
94
114
|
private readonly sequencedIdLogs;
|
|
95
115
|
constructor(initialClusterSize?: number);
|
|
96
116
|
/**
|
|
@@ -209,11 +229,17 @@ interface FuzzTestState extends BaseFuzzTestState {
|
|
|
209
229
|
clusterSize: number;
|
|
210
230
|
}
|
|
211
231
|
export interface OperationGenerationConfig {
|
|
212
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* maximum cluster size of the network. Default: 25
|
|
234
|
+
*/
|
|
213
235
|
maxClusterSize?: number;
|
|
214
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* Number of ops between validation ops. Default: 200
|
|
238
|
+
*/
|
|
215
239
|
validateInterval?: number;
|
|
216
|
-
/**
|
|
240
|
+
/**
|
|
241
|
+
* Fraction of ID allocations that are from an outside client (not Client1/2/3).
|
|
242
|
+
*/
|
|
217
243
|
outsideAllocationFraction?: number;
|
|
218
244
|
}
|
|
219
245
|
export declare function makeOpGenerator(options: OperationGenerationConfig): Generator<Operation, FuzzTestState>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idCompressorTestUtilities.d.ts","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"idCompressorTestUtilities.d.ts","sourceRoot":"","sources":["../../src/test/idCompressorTestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,iBAAiB,EACjB,SAAS,EACT,QAAQ,EAOR,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAEtB,mBAAmB,EACnB,mCAAmC,EACnC,wCAAwC,EACxC,SAAS,EACT,wBAAwB,EAGxB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAEN,oBAAoB,EAMpB,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3E,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;CACf;AAED;;GAEG;AACH,oBAAY,MAAM;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;CACnB;AAED;;GAEG;AACH,oBAAY,UAAU;IACrB,GAAG,QAAQ;CACX;AAED;;GAEG;AACH,oBAAY,aAAa;IACxB,MAAM,WAAW;CACjB;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,aAAa,CAAC;AACvD,eAAO,MAAM,iBAAiB;;;;;CAAkC,CAAC;AAEjE;;GAEG;AAC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5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.createAlwaysFinalizedIdCompressor = exports.generateCompressedIds = exports.performFuzzActions = exports.makeOpGenerator = exports.mergeArrayMaps = exports.expectSerializes = exports.roundtrip = exports.IdCompressorTestNetwork = exports.sessionIds = exports.buildHugeCompressor = exports.CompressorFactory = exports.DestinationClient = exports.OriginatingClient = exports.OutsideClient = exports.MetaClient = exports.Client = void 0;
|
|
8
|
-
|
|
8
|
+
// eslint-disable-next-line import/no-nodejs-modules
|
|
9
|
+
const node_assert_1 = require("node:assert");
|
|
9
10
|
const stochastic_test_utils_1 = require("@fluid-private/stochastic-test-utils");
|
|
10
11
|
const idCompressor_js_1 = require("../idCompressor.js");
|
|
11
12
|
const index_js_1 = require("../index.js");
|
|
12
13
|
const sessionSpaceNormalizer_js_1 = require("../sessionSpaceNormalizer.js");
|
|
13
14
|
const utilities_js_1 = require("../utilities.js");
|
|
14
15
|
const testCommon_js_1 = require("./testCommon.js");
|
|
15
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Identifies a compressor in a network
|
|
18
|
+
*/
|
|
16
19
|
var Client;
|
|
17
20
|
(function (Client) {
|
|
18
21
|
Client["Client1"] = "Client1";
|
|
19
22
|
Client["Client2"] = "Client2";
|
|
20
23
|
Client["Client3"] = "Client3";
|
|
21
24
|
})(Client || (exports.Client = Client = {}));
|
|
22
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Identifies categories of compressors
|
|
27
|
+
*/
|
|
23
28
|
var MetaClient;
|
|
24
29
|
(function (MetaClient) {
|
|
25
30
|
MetaClient["All"] = "All";
|
|
26
31
|
})(MetaClient || (exports.MetaClient = MetaClient = {}));
|
|
27
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Identifies a compressor inside the network but outside the three specially tracked clients.
|
|
34
|
+
*/
|
|
28
35
|
var OutsideClient;
|
|
29
36
|
(function (OutsideClient) {
|
|
30
37
|
OutsideClient["Remote"] = "Remote";
|
|
@@ -103,7 +110,9 @@ exports.sessionIds = makeSessionIds();
|
|
|
103
110
|
class IdCompressorTestNetwork {
|
|
104
111
|
constructor(initialClusterSize = 5) {
|
|
105
112
|
this.initialClusterSize = initialClusterSize;
|
|
106
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* The log of operations seen by the server so far. Append-only.
|
|
115
|
+
*/
|
|
107
116
|
this.serverOperations = [];
|
|
108
117
|
const compressors = new Map();
|
|
109
118
|
const clientProgress = new Map();
|
|
@@ -209,13 +218,14 @@ class IdCompressorTestNetwork {
|
|
|
209
218
|
* Same contract as `allocateAndSendIds`, but the originating client will be a client with the supplied sessionId.
|
|
210
219
|
*/
|
|
211
220
|
allocateAndSendIdsFromRemoteClient(clientFrom, sessionIdFrom, numIds) {
|
|
212
|
-
(0,
|
|
221
|
+
(0, node_assert_1.strict)(numIds > 0, "Must allocate a non-zero number of IDs");
|
|
213
222
|
if (clientFrom === exports.OriginatingClient.Remote) {
|
|
214
223
|
const range = {
|
|
215
224
|
sessionId: sessionIdFrom,
|
|
216
225
|
ids: {
|
|
217
226
|
firstGenCount: 1,
|
|
218
227
|
count: numIds,
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
219
229
|
requestedClusterSize: this.getCompressor(Client.Client1)[
|
|
220
230
|
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
221
231
|
"nextRequestedClusterSize"],
|
|
@@ -230,7 +240,7 @@ class IdCompressorTestNetwork {
|
|
|
230
240
|
return opSpaceIds;
|
|
231
241
|
}
|
|
232
242
|
else {
|
|
233
|
-
(0,
|
|
243
|
+
(0, node_assert_1.strict)(sessionIdFrom === exports.sessionIds.get(clientFrom));
|
|
234
244
|
const compressor = this.compressors.get(clientFrom);
|
|
235
245
|
const sessionSpaceIds = generateCompressedIds(compressor, numIds);
|
|
236
246
|
for (let i = 0; i < numIds; i++) {
|
|
@@ -248,14 +258,14 @@ class IdCompressorTestNetwork {
|
|
|
248
258
|
deliverOperations(clientTakingDelivery, opsToDeliver) {
|
|
249
259
|
let opIndexBound;
|
|
250
260
|
if (clientTakingDelivery === exports.DestinationClient.All) {
|
|
251
|
-
(0,
|
|
261
|
+
(0, node_assert_1.strict)(opsToDeliver === undefined);
|
|
252
262
|
opIndexBound = this.serverOperations.length;
|
|
253
263
|
}
|
|
254
264
|
else {
|
|
255
265
|
opIndexBound =
|
|
256
|
-
opsToDeliver
|
|
257
|
-
? this.
|
|
258
|
-
: this.
|
|
266
|
+
opsToDeliver === undefined
|
|
267
|
+
? this.serverOperations.length
|
|
268
|
+
: this.clientProgress.get(clientTakingDelivery) + opsToDeliver;
|
|
259
269
|
}
|
|
260
270
|
for (const [clientTo, compressorTo] of this.getTargetCompressors(clientTakingDelivery)) {
|
|
261
271
|
for (let i = this.clientProgress.get(clientTo); i < opIndexBound; i++) {
|
|
@@ -294,7 +304,7 @@ class IdCompressorTestNetwork {
|
|
|
294
304
|
for (let g = genCount; g < genCount + count; g++) {
|
|
295
305
|
const local = (0, utilities_js_1.localIdFromGenCount)(g);
|
|
296
306
|
if (opSpaceIds) {
|
|
297
|
-
|
|
307
|
+
node_assert_1.strict.strictEqual(opSpaceIds[g - firstGenCount], local);
|
|
298
308
|
}
|
|
299
309
|
localIdsInCreationRange.add(local);
|
|
300
310
|
}
|
|
@@ -303,71 +313,72 @@ class IdCompressorTestNetwork {
|
|
|
303
313
|
return localIdsInCreationRange;
|
|
304
314
|
};
|
|
305
315
|
// Ensure creation ranges for clients we track contain the correct local ID ranges
|
|
306
|
-
|
|
316
|
+
for (const [range, opSpaceIds, clientFrom] of this.serverOperations) {
|
|
307
317
|
if (clientFrom !== exports.OriginatingClient.Remote) {
|
|
308
318
|
const localIdsInCreationRange = getLocalIdsInRange(range, opSpaceIds);
|
|
309
319
|
let localCount = 0;
|
|
310
|
-
|
|
320
|
+
for (const id of opSpaceIds) {
|
|
311
321
|
if ((0, testCommon_js_1.isLocalId)(id)) {
|
|
312
322
|
localCount++;
|
|
313
|
-
(0,
|
|
323
|
+
(0, node_assert_1.strict)(localIdsInCreationRange.has(id), "Local ID not in creation range");
|
|
314
324
|
}
|
|
315
|
-
}
|
|
316
|
-
|
|
325
|
+
}
|
|
326
|
+
node_assert_1.strict.strictEqual(localCount, localIdsInCreationRange.size, "Local ID count mismatch");
|
|
317
327
|
}
|
|
318
|
-
}
|
|
328
|
+
}
|
|
319
329
|
const undeliveredRanges = new Map();
|
|
320
|
-
this.clientProgress.
|
|
330
|
+
for (const [client, progress] of this.clientProgress.entries()) {
|
|
321
331
|
const ranges = this.serverOperations
|
|
322
332
|
.slice(progress)
|
|
323
333
|
.filter((op) => op[2] === client)
|
|
324
334
|
.map(([range]) => range);
|
|
325
335
|
undeliveredRanges.set(client, ranges);
|
|
326
|
-
}
|
|
327
|
-
undeliveredRanges.
|
|
336
|
+
}
|
|
337
|
+
for (const [client, ranges] of undeliveredRanges.entries()) {
|
|
328
338
|
const compressor = this.compressors.get(client);
|
|
329
339
|
let firstGenCount;
|
|
330
340
|
let totalCount = 0;
|
|
331
341
|
const unionedLocalRanges = new sessionSpaceNormalizer_js_1.SessionSpaceNormalizer();
|
|
332
|
-
|
|
333
|
-
(0,
|
|
342
|
+
for (const range of ranges) {
|
|
343
|
+
(0, node_assert_1.strict)(range.sessionId === compressor.localSessionId);
|
|
334
344
|
if (range.ids !== undefined) {
|
|
335
345
|
// initialize firstGenCount if not set
|
|
336
346
|
if (firstGenCount === undefined) {
|
|
337
347
|
firstGenCount = range.ids.firstGenCount;
|
|
338
348
|
}
|
|
339
349
|
totalCount += range.ids.count;
|
|
340
|
-
|
|
350
|
+
for (const [genCount, count] of range.ids.localIdRanges) {
|
|
341
351
|
unionedLocalRanges.addLocalRange(genCount, count);
|
|
342
|
-
}
|
|
352
|
+
}
|
|
343
353
|
}
|
|
344
|
-
}
|
|
354
|
+
}
|
|
345
355
|
const retakenRange = compressor.takeUnfinalizedCreationRange();
|
|
346
|
-
if (retakenRange.ids
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
retakenLocalIds.addLocalRange(genCount, count);
|
|
350
|
-
});
|
|
351
|
-
assert_1.strict.strictEqual(retakenLocalIds.equals(unionedLocalRanges), true, "Local ID ranges mismatch");
|
|
352
|
-
assert_1.strict.strictEqual(retakenRange.ids.count, totalCount, "Count mismatch");
|
|
353
|
-
assert_1.strict.strictEqual(retakenRange.ids.firstGenCount, firstGenCount, "Count mismatch");
|
|
356
|
+
if (retakenRange.ids === undefined) {
|
|
357
|
+
node_assert_1.strict.strictEqual(totalCount, 0);
|
|
358
|
+
node_assert_1.strict.strictEqual(unionedLocalRanges.idRanges.size, 0);
|
|
354
359
|
}
|
|
355
360
|
else {
|
|
356
|
-
|
|
357
|
-
|
|
361
|
+
const retakenLocalIds = new sessionSpaceNormalizer_js_1.SessionSpaceNormalizer();
|
|
362
|
+
for (const [genCount, count] of retakenRange.ids.localIdRanges) {
|
|
363
|
+
retakenLocalIds.addLocalRange(genCount, count);
|
|
364
|
+
}
|
|
365
|
+
node_assert_1.strict.strictEqual(retakenLocalIds.equals(unionedLocalRanges), true, "Local ID ranges mismatch");
|
|
366
|
+
node_assert_1.strict.strictEqual(retakenRange.ids.count, totalCount, "Count mismatch");
|
|
367
|
+
node_assert_1.strict.strictEqual(retakenRange.ids.firstGenCount, firstGenCount, "Count mismatch");
|
|
358
368
|
}
|
|
359
|
-
}
|
|
369
|
+
}
|
|
360
370
|
// First, ensure all clients each generated a unique ID for each of their own calls to generate.
|
|
361
371
|
for (const [compressor, ids] of sequencedLogs) {
|
|
362
372
|
const allUuids = new Set();
|
|
363
373
|
for (const idData of ids) {
|
|
364
374
|
const uuid = compressor.decompress(idData.id);
|
|
365
|
-
|
|
375
|
+
node_assert_1.strict.strictEqual(!allUuids.has(uuid), true, "Duplicate UUID generated.");
|
|
366
376
|
allUuids.add(uuid);
|
|
367
377
|
}
|
|
368
378
|
}
|
|
369
379
|
const maxLogLength = sequencedLogs
|
|
370
380
|
.map(([_, data]) => data.length)
|
|
381
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
371
382
|
.reduce((p, n) => Math.max(p, n));
|
|
372
383
|
function getNextLogWithEntryAt(logsIndex, entryIndex) {
|
|
373
384
|
for (let i = logsIndex; i < sequencedLogs.length; i++) {
|
|
@@ -407,51 +418,49 @@ class IdCompressorTestNetwork {
|
|
|
407
418
|
const sessionSpaceIdA = idDataA.id;
|
|
408
419
|
const idIndex = (0, testCommon_js_1.getOrCreate)(idIndicesAggregator, idDataA.sessionId, () => 0);
|
|
409
420
|
originatingSession ?? (originatingSession = idDataA.sessionId);
|
|
410
|
-
(0,
|
|
421
|
+
(0, node_assert_1.strict)(idDataA.sessionId === originatingSession, "Test infra gave wrong originating client to TestIdData");
|
|
411
422
|
// Only one client should have this ID as local in its session space, as only one client could have created this ID
|
|
412
423
|
if ((0, testCommon_js_1.isLocalId)(sessionSpaceIdA)) {
|
|
413
424
|
if (originatingSession !== exports.OriginatingClient.Remote) {
|
|
414
|
-
|
|
425
|
+
node_assert_1.strict.strictEqual(idDataA.sessionId, this.compressors.get(idDataA.originatingClient).localSessionId);
|
|
415
426
|
}
|
|
416
427
|
idCreatorCount++;
|
|
417
428
|
}
|
|
418
429
|
const uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);
|
|
419
|
-
|
|
420
|
-
|
|
430
|
+
node_assert_1.strict.strictEqual(uuidASessionSpace, (0, testCommon_js_1.incrementStableId)(idDataA.sessionId, idIndex));
|
|
431
|
+
node_assert_1.strict.strictEqual(compressorA.recompress(uuidASessionSpace), sessionSpaceIdA);
|
|
421
432
|
uuids.add(uuidASessionSpace);
|
|
422
433
|
const opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);
|
|
423
434
|
if (!(0, testCommon_js_1.isFinalId)(opSpaceIdA)) {
|
|
424
435
|
(0, testCommon_js_1.fail)("IDs should have been finalized.");
|
|
425
436
|
}
|
|
426
437
|
const reNormalizedIdA = compressorA.normalizeToSessionSpace(opSpaceIdA, compressorA.localSessionId);
|
|
427
|
-
|
|
438
|
+
node_assert_1.strict.strictEqual(reNormalizedIdA, sessionSpaceIdA);
|
|
428
439
|
finalIds.add(opSpaceIdA);
|
|
429
440
|
const uuidAOpSpace = compressorA.decompress(reNormalizedIdA);
|
|
430
|
-
|
|
441
|
+
node_assert_1.strict.strictEqual(uuidASessionSpace, uuidAOpSpace);
|
|
431
442
|
if (next !== undefined) {
|
|
432
443
|
const [compressorB, idDataB] = next;
|
|
433
444
|
const sessionSpaceIdB = idDataB.id;
|
|
434
445
|
const uuidBSessionSpace = compressorB.decompress(sessionSpaceIdB);
|
|
435
|
-
|
|
446
|
+
node_assert_1.strict.strictEqual(uuidASessionSpace, uuidBSessionSpace);
|
|
436
447
|
const opSpaceIdB = compressorB.normalizeToOpSpace(sessionSpaceIdB);
|
|
437
448
|
if (opSpaceIdA !== opSpaceIdB) {
|
|
438
449
|
compressorB.normalizeToOpSpace(sessionSpaceIdB);
|
|
439
450
|
compressorA.normalizeToOpSpace(sessionSpaceIdA);
|
|
440
451
|
}
|
|
441
|
-
|
|
452
|
+
node_assert_1.strict.strictEqual(opSpaceIdA, opSpaceIdB);
|
|
442
453
|
if (!(0, testCommon_js_1.isFinalId)(opSpaceIdB)) {
|
|
443
454
|
(0, testCommon_js_1.fail)("IDs should have been finalized.");
|
|
444
455
|
}
|
|
445
456
|
const uuidBOpSpace = compressorB.decompress(opSpaceIdB);
|
|
446
|
-
|
|
457
|
+
node_assert_1.strict.strictEqual(uuidAOpSpace, uuidBOpSpace);
|
|
447
458
|
}
|
|
448
459
|
}
|
|
449
|
-
(0,
|
|
450
|
-
|
|
451
|
-
(0,
|
|
452
|
-
idIndicesAggregator.set(originatingSession,
|
|
453
|
-
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
454
|
-
(idIndicesAggregator.get(originatingSession) ??
|
|
460
|
+
(0, node_assert_1.strict)(idCreatorCount <= 1, "Only one client can create an ID.");
|
|
461
|
+
node_assert_1.strict.strictEqual(uuids.size, finalIds.size);
|
|
462
|
+
(0, node_assert_1.strict)(originatingSession !== undefined, "Expected originating client to be defined");
|
|
463
|
+
idIndicesAggregator.set(originatingSession, (idIndicesAggregator.get(originatingSession) ??
|
|
455
464
|
(0, testCommon_js_1.fail)("Expected pre-existing index for originating client")) + 1);
|
|
456
465
|
}
|
|
457
466
|
for (const [compressor] of sequencedLogs) {
|
|
@@ -467,7 +476,7 @@ function changeCapacity(compressor, newClusterCapacity) {
|
|
|
467
476
|
function roundtrip(compressor, withSession) {
|
|
468
477
|
// preserve the capacity request as this property is normally private and resets
|
|
469
478
|
// to a default on construction (deserialization)
|
|
470
|
-
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
479
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-assignment
|
|
471
480
|
const capacity = compressor["nextRequestedClusterSize"];
|
|
472
481
|
if (withSession) {
|
|
473
482
|
const serialized = compressor.serialize(withSession);
|
|
@@ -496,7 +505,7 @@ function expectSerializes(compressor) {
|
|
|
496
505
|
else {
|
|
497
506
|
[serialized, deserialized] = roundtrip(compressor, false);
|
|
498
507
|
}
|
|
499
|
-
|
|
508
|
+
node_assert_1.strict.strictEqual(compressor.equals(deserialized, withSession), true);
|
|
500
509
|
return serialized;
|
|
501
510
|
}
|
|
502
511
|
return [
|
|
@@ -511,11 +520,11 @@ exports.expectSerializes = expectSerializes;
|
|
|
511
520
|
function mergeArrayMaps(to, from) {
|
|
512
521
|
for (const [key, value] of from.entries()) {
|
|
513
522
|
const entry = to.get(key);
|
|
514
|
-
if (entry
|
|
515
|
-
|
|
523
|
+
if (entry === undefined) {
|
|
524
|
+
to.set(key, [...value]);
|
|
516
525
|
}
|
|
517
526
|
else {
|
|
518
|
-
|
|
527
|
+
entry.push(...value);
|
|
519
528
|
}
|
|
520
529
|
}
|
|
521
530
|
return to;
|
|
@@ -531,7 +540,7 @@ function makeOpGenerator(options) {
|
|
|
531
540
|
...defaultOptions,
|
|
532
541
|
...options,
|
|
533
542
|
};
|
|
534
|
-
(0,
|
|
543
|
+
(0, node_assert_1.strict)(outsideAllocationFraction >= 0 && outsideAllocationFraction <= 1);
|
|
535
544
|
function allocateIdsGenerator({ activeClients, clusterSize, random, }) {
|
|
536
545
|
const client = random.pick(activeClients);
|
|
537
546
|
const maxIdsPerUsage = clusterSize * 2;
|