@fluidframework/test-utils 2.74.0-370705 → 2.80.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 +8 -0
- package/dist/TestSummaryUtils.d.ts.map +1 -1
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/loaderContainerTracker.d.ts.map +1 -1
- package/dist/loaderContainerTracker.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactory.js.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/dist/testFluidObject.d.ts +3 -3
- package/dist/testFluidObject.d.ts.map +1 -1
- package/dist/testFluidObject.js.map +1 -1
- package/dist/testFluidObjectInternal.d.ts +1 -1
- package/dist/testFluidObjectInternal.d.ts.map +1 -1
- package/dist/testFluidObjectInternal.js.map +1 -1
- package/dist/testObjectProvider.d.ts.map +1 -1
- package/dist/testObjectProvider.js.map +1 -1
- package/dist/timeoutUtils.js.map +1 -1
- package/eslint.config.mts +18 -0
- package/lib/TestSummaryUtils.d.ts.map +1 -1
- package/lib/TestSummaryUtils.js.map +1 -1
- package/lib/loaderContainerTracker.d.ts.map +1 -1
- package/lib/loaderContainerTracker.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/testContainerRuntimeFactory.d.ts.map +1 -1
- package/lib/testContainerRuntimeFactory.js.map +1 -1
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/lib/testFluidObject.d.ts +3 -3
- package/lib/testFluidObject.d.ts.map +1 -1
- package/lib/testFluidObject.js.map +1 -1
- package/lib/testFluidObjectInternal.d.ts +1 -1
- package/lib/testFluidObjectInternal.d.ts.map +1 -1
- package/lib/testFluidObjectInternal.js.map +1 -1
- package/lib/testObjectProvider.d.ts.map +1 -1
- package/lib/testObjectProvider.js.map +1 -1
- package/lib/timeoutUtils.js.map +1 -1
- package/package.json +32 -31
- package/src/TestSummaryUtils.ts +4 -1
- package/src/loaderContainerTracker.ts +33 -26
- package/src/packageVersion.ts +1 -1
- package/src/testContainerRuntimeFactory.ts +6 -2
- package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +1 -1
- package/src/testFluidObject.ts +5 -5
- package/src/testFluidObjectInternal.ts +3 -3
- package/src/testObjectProvider.ts +36 -33
- package/src/timeoutUtils.ts +9 -9
|
@@ -61,7 +61,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
61
61
|
* Add a loader to start to track any container created from them
|
|
62
62
|
* @param loader - loader to start tracking any container created.
|
|
63
63
|
*/
|
|
64
|
-
public add<LoaderType extends IHostLoader>(loader: LoaderType) {
|
|
64
|
+
public add<LoaderType extends IHostLoader>(loader: LoaderType): void {
|
|
65
65
|
// TODO: Expose Loader API to able to intercept container creation (See issue #5114)
|
|
66
66
|
const patch = <T, C extends IContainer>(fn: (...args) => Promise<C>) => {
|
|
67
67
|
const boundFn = fn.bind(loader);
|
|
@@ -85,7 +85,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
85
85
|
*
|
|
86
86
|
* @param container - container to add
|
|
87
87
|
*/
|
|
88
|
-
public addContainer(container: IContainer) {
|
|
88
|
+
public addContainer(container: IContainer): void {
|
|
89
89
|
// don't add container that is already tracked
|
|
90
90
|
if (this.containers.has(container)) {
|
|
91
91
|
return;
|
|
@@ -144,7 +144,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
144
144
|
* @param container - the container to track
|
|
145
145
|
* @param record - the record to update the trailing op information
|
|
146
146
|
*/
|
|
147
|
-
private trackTrailingNoOps(container: IContainer, record: ContainerRecord) {
|
|
147
|
+
private trackTrailingNoOps(container: IContainer, record: ContainerRecord): void {
|
|
148
148
|
const deltaManagerFull = toIDeltaManagerFull(container.deltaManager);
|
|
149
149
|
deltaManagerFull.outbound.on("op", (messages) => {
|
|
150
150
|
for (const msg of messages) {
|
|
@@ -184,7 +184,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
private trackLastProposal(container: IContainer) {
|
|
187
|
+
private trackLastProposal(container: IContainer): void {
|
|
188
188
|
container.on("codeDetailsProposed", (value, proposal) => {
|
|
189
189
|
if (proposal.sequenceNumber > this.lastProposalSeqNum) {
|
|
190
190
|
this.lastProposalSeqNum = proposal.sequenceNumber;
|
|
@@ -195,7 +195,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
195
195
|
/**
|
|
196
196
|
* Reset the tracker, closing all containers and stop tracking them.
|
|
197
197
|
*/
|
|
198
|
-
public reset() {
|
|
198
|
+
public reset(): void {
|
|
199
199
|
this.lastProposalSeqNum = 0;
|
|
200
200
|
for (const container of this.containers.keys()) {
|
|
201
201
|
container.close();
|
|
@@ -305,7 +305,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
305
305
|
*
|
|
306
306
|
* @param containersToApply - the set of containers to check
|
|
307
307
|
*/
|
|
308
|
-
private getPendingClients(containersToApply: IContainer[]) {
|
|
308
|
+
private getPendingClients(containersToApply: IContainer[]): [IContainer, Set<string>][] {
|
|
309
309
|
// All the clientId we track should be a superset of the quorum, otherwise, we are missing
|
|
310
310
|
// leave messages
|
|
311
311
|
const openedDocuments = Array.from(this.containers.keys()).filter((c) => !c.closed);
|
|
@@ -338,7 +338,9 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
338
338
|
*
|
|
339
339
|
* @param containersToApply - the set of containers to check
|
|
340
340
|
*/
|
|
341
|
-
private needSequenceNumberSynchronize(
|
|
341
|
+
private needSequenceNumberSynchronize(
|
|
342
|
+
containersToApply: NonEmptyArray<IContainer>,
|
|
343
|
+
): { reason: string; message: string } | undefined {
|
|
342
344
|
// If there is a pending proposal, wait for it to be accepted
|
|
343
345
|
const minSeqNum = containersToApply[0].deltaManager.minimumSequenceNumber;
|
|
344
346
|
if (minSeqNum < this.lastProposalSeqNum) {
|
|
@@ -405,7 +407,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
405
407
|
return undefined;
|
|
406
408
|
}
|
|
407
409
|
|
|
408
|
-
private containerIndexStrings(containers: IContainer[]) {
|
|
410
|
+
private containerIndexStrings(containers: IContainer[]): number[] {
|
|
409
411
|
return containers.map(
|
|
410
412
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
411
413
|
(c) => this.containers.get(c)!.index,
|
|
@@ -420,18 +422,20 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
420
422
|
*
|
|
421
423
|
* @param containersToApply - the set of containers to wait for any inbound ops for
|
|
422
424
|
*/
|
|
423
|
-
private async waitForPendingClients(
|
|
425
|
+
private async waitForPendingClients(
|
|
426
|
+
pendingClients: [IContainer, Set<string>][],
|
|
427
|
+
): Promise<void[]> {
|
|
424
428
|
const unconnectedClients = Array.from(this.containers.keys()).filter(
|
|
425
429
|
(c) => !c.closed && c.connectionState !== ConnectionState.Connected,
|
|
426
430
|
);
|
|
427
431
|
return Promise.all(
|
|
428
432
|
pendingClients.map(async ([container, pendingClientId]) => {
|
|
429
433
|
return new Promise<void>((resolve) => {
|
|
430
|
-
const cleanup = () => {
|
|
434
|
+
const cleanup = (): void => {
|
|
431
435
|
unconnectedClients.forEach((c) => c.off("connected", handler));
|
|
432
436
|
container.getQuorum().off("removeMember", handler);
|
|
433
437
|
};
|
|
434
|
-
const handler = (clientId: string) => {
|
|
438
|
+
const handler = (clientId: string): void => {
|
|
435
439
|
pendingClientId.delete(clientId);
|
|
436
440
|
if (pendingClientId.size === 0) {
|
|
437
441
|
cleanup();
|
|
@@ -458,9 +462,9 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
458
462
|
* Utility to wait for any inbound ops from a set of containers
|
|
459
463
|
* @param containersToApply - the set of containers to wait for any inbound ops for
|
|
460
464
|
*/
|
|
461
|
-
private async waitForAnyInboundOps(containersToApply: IContainer[]) {
|
|
465
|
+
private async waitForAnyInboundOps(containersToApply: IContainer[]): Promise<void> {
|
|
462
466
|
return new Promise<void>((resolve) => {
|
|
463
|
-
const handler = () => {
|
|
467
|
+
const handler = (): void => {
|
|
464
468
|
containersToApply.map((c) => {
|
|
465
469
|
toIDeltaManagerFull(c.deltaManager).inbound.off("push", handler);
|
|
466
470
|
});
|
|
@@ -475,7 +479,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
475
479
|
/**
|
|
476
480
|
* Resume all queue activities on all paused tracked containers and return them
|
|
477
481
|
*/
|
|
478
|
-
public resumeProcessing(...containers: IContainer[]) {
|
|
482
|
+
public resumeProcessing(...containers: IContainer[]): IContainer[] {
|
|
479
483
|
const resumed: IContainer[] = [];
|
|
480
484
|
const containersToApply = this.getContainers(containers);
|
|
481
485
|
for (const container of containersToApply) {
|
|
@@ -505,7 +509,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
505
509
|
* avoid missing join messages or change the sequence of event when switching from read to
|
|
506
510
|
* write mode.
|
|
507
511
|
*/
|
|
508
|
-
public async pauseProcessing(...containers: IContainer[]) {
|
|
512
|
+
public async pauseProcessing(...containers: IContainer[]): Promise<void> {
|
|
509
513
|
const waitP: Promise<void>[] = [];
|
|
510
514
|
const containersToApply = this.getContainers(containers);
|
|
511
515
|
for (const container of containersToApply) {
|
|
@@ -529,7 +533,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
529
533
|
* @param container - the container to pause
|
|
530
534
|
* @param record - the record for the container
|
|
531
535
|
*/
|
|
532
|
-
private async pauseContainer(container: IContainer, record: ContainerRecord) {
|
|
536
|
+
private async pauseContainer(container: IContainer, record: ContainerRecord): Promise<void> {
|
|
533
537
|
debugWait(`${record.index}: pausing container`);
|
|
534
538
|
const deltaManagerFull = toIDeltaManagerFull(container.deltaManager);
|
|
535
539
|
assert(!deltaManagerFull.outbound.paused, "Container should not be paused yet");
|
|
@@ -593,7 +597,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
593
597
|
*
|
|
594
598
|
* Pausing will switch the container to write mode. See `pauseProcessing`
|
|
595
599
|
*/
|
|
596
|
-
public async processIncoming(...containers: IContainer[]) {
|
|
600
|
+
public async processIncoming(...containers: IContainer[]): Promise<void> {
|
|
597
601
|
return this.processQueue(
|
|
598
602
|
containers,
|
|
599
603
|
(container) => toIDeltaManagerFull(container.deltaManager).inbound,
|
|
@@ -607,7 +611,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
607
611
|
*
|
|
608
612
|
* Pausing will switch the container to write mode. See `pauseProcessing`
|
|
609
613
|
*/
|
|
610
|
-
public async processOutgoing(...containers: IContainer[]) {
|
|
614
|
+
public async processOutgoing(...containers: IContainer[]): Promise<void> {
|
|
611
615
|
return this.processQueue(
|
|
612
616
|
containers,
|
|
613
617
|
(container) => toIDeltaManagerFull(container.deltaManager).outbound,
|
|
@@ -620,7 +624,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
620
624
|
private async processQueue<U>(
|
|
621
625
|
containers: IContainer[],
|
|
622
626
|
getQueue: (container: IContainer) => IDeltaQueue<U>,
|
|
623
|
-
) {
|
|
627
|
+
): Promise<void> {
|
|
624
628
|
await this.pauseProcessing(...containers);
|
|
625
629
|
const resumed: IDeltaQueue<U>[] = [];
|
|
626
630
|
|
|
@@ -672,15 +676,18 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
672
676
|
* @param container - the container to setup
|
|
673
677
|
* @param inflightTracker - a map to track the clientSequenceNumber per container it expect to get ops back
|
|
674
678
|
*/
|
|
675
|
-
private setupInOutTracker(
|
|
676
|
-
|
|
679
|
+
private setupInOutTracker(
|
|
680
|
+
container: IContainer,
|
|
681
|
+
inflightTracker: Map<IContainer, number>,
|
|
682
|
+
): () => void {
|
|
683
|
+
const outHandler = (messages: IDocumentMessage[]): void => {
|
|
677
684
|
for (const message of messages) {
|
|
678
685
|
if (!canBeCoalescedByService(message)) {
|
|
679
686
|
inflightTracker.set(container, message.clientSequenceNumber);
|
|
680
687
|
}
|
|
681
688
|
}
|
|
682
689
|
};
|
|
683
|
-
const inHandler = (message: ISequencedDocumentMessage) => {
|
|
690
|
+
const inHandler = (message: ISequencedDocumentMessage): void => {
|
|
684
691
|
if (
|
|
685
692
|
!canBeCoalescedByService(message) &&
|
|
686
693
|
message.clientId === container.clientId &&
|
|
@@ -694,7 +701,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
694
701
|
deltaManagerFull.outbound.on("op", outHandler);
|
|
695
702
|
deltaManagerFull.inbound.on("push", inHandler);
|
|
696
703
|
|
|
697
|
-
return () => {
|
|
704
|
+
return (): void => {
|
|
698
705
|
deltaManagerFull.outbound.off("op", outHandler);
|
|
699
706
|
deltaManagerFull.inbound.off("push", inHandler);
|
|
700
707
|
};
|
|
@@ -703,9 +710,9 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
703
710
|
/**
|
|
704
711
|
* Setup debug traces for connection and ops
|
|
705
712
|
*/
|
|
706
|
-
private setupTrace(container: IContainer, index: number) {
|
|
713
|
+
private setupTrace(container: IContainer, index: number): void {
|
|
707
714
|
if (debugOp.enabled) {
|
|
708
|
-
const getContentsString = (type: string, msgContents: any) => {
|
|
715
|
+
const getContentsString = (type: string, msgContents: any): string => {
|
|
709
716
|
try {
|
|
710
717
|
if (type !== MessageType.Operation) {
|
|
711
718
|
if (typeof msgContents === "string") {
|
|
@@ -779,7 +786,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
|
|
|
779
786
|
* @param containers - The container to filter to. If the array is empty, it means don't filter and return
|
|
780
787
|
* all open containers.
|
|
781
788
|
*/
|
|
782
|
-
private getContainers(containers: IContainer[]) {
|
|
789
|
+
private getContainers(containers: IContainer[]): IContainer[] {
|
|
783
790
|
const containersToApply =
|
|
784
791
|
containers.length === 0 ? Array.from(this.containers.keys()) : containers;
|
|
785
792
|
return containersToApply.filter((container) => !container.closed);
|
package/src/packageVersion.ts
CHANGED
|
@@ -68,6 +68,7 @@ interface backCompat_ContainerRuntime {
|
|
|
68
68
|
*/
|
|
69
69
|
export const createTestContainerRuntimeFactory = (
|
|
70
70
|
containerRuntimeCtor: typeof ContainerRuntime,
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Returning anonymous class type
|
|
71
72
|
) => {
|
|
72
73
|
return class extends RuntimeFactoryHelper {
|
|
73
74
|
constructor(
|
|
@@ -144,14 +145,17 @@ export const createTestContainerRuntimeFactory = (
|
|
|
144
145
|
existing,
|
|
145
146
|
);
|
|
146
147
|
}
|
|
147
|
-
const provideEntryPoint = async (runtime: IContainerRuntime) => {
|
|
148
|
+
const provideEntryPoint = async (runtime: IContainerRuntime): Promise<FluidObject> => {
|
|
148
149
|
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
149
150
|
if (entryPoint === undefined) {
|
|
150
151
|
throw new Error("default dataStore must exist");
|
|
151
152
|
}
|
|
152
153
|
return entryPoint.get();
|
|
153
154
|
};
|
|
154
|
-
const getDefaultObject = async (
|
|
155
|
+
const getDefaultObject = async (
|
|
156
|
+
request: IRequest,
|
|
157
|
+
runtime: IContainerRuntime,
|
|
158
|
+
): Promise<IResponse | undefined> => {
|
|
155
159
|
const parser = RequestParser.create(request);
|
|
156
160
|
if (parser.pathParts.length === 0) {
|
|
157
161
|
// This cast is safe as loadContainerRuntime is called below
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
NamedFluidDataStoreRegistryEntries,
|
|
15
15
|
} from "@fluidframework/runtime-definitions/internal";
|
|
16
16
|
|
|
17
|
-
const getDefaultFluidObject = async (runtime: IContainerRuntime) => {
|
|
17
|
+
const getDefaultFluidObject = async (runtime: IContainerRuntime): Promise<FluidObject> => {
|
|
18
18
|
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
19
19
|
if (entryPoint === undefined) {
|
|
20
20
|
throw new Error("default dataStore must exist");
|
package/src/testFluidObject.ts
CHANGED
|
@@ -41,11 +41,11 @@ import { ITestFluidObject } from "./interfaces.js";
|
|
|
41
41
|
* @internal
|
|
42
42
|
*/
|
|
43
43
|
export class TestFluidObject implements ITestFluidObject {
|
|
44
|
-
public get ITestFluidObject() {
|
|
44
|
+
public get ITestFluidObject(): ITestFluidObject {
|
|
45
45
|
return this;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
public get IFluidLoadable() {
|
|
48
|
+
public get IFluidLoadable(): IFluidLoadable {
|
|
49
49
|
return this;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -101,8 +101,8 @@ export class TestFluidObject implements ITestFluidObject {
|
|
|
101
101
|
: create404Response(request);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
public async initialize(existing: boolean) {
|
|
105
|
-
const doInitialization = async () => {
|
|
104
|
+
public async initialize(existing: boolean): Promise<void> {
|
|
105
|
+
const doInitialization = async (): Promise<void> => {
|
|
106
106
|
if (!existing) {
|
|
107
107
|
this.root = SharedMap.create(this.runtime, "root");
|
|
108
108
|
|
|
@@ -176,7 +176,7 @@ export type TestDataObjectKind = new (
|
|
|
176
176
|
* @internal
|
|
177
177
|
*/
|
|
178
178
|
export class TestFluidObjectFactory implements IFluidDataStoreFactory {
|
|
179
|
-
public get IFluidDataStoreFactory() {
|
|
179
|
+
public get IFluidDataStoreFactory(): IFluidDataStoreFactory {
|
|
180
180
|
return this;
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -35,7 +35,7 @@ import type {
|
|
|
35
35
|
* @internal
|
|
36
36
|
*/
|
|
37
37
|
export class TestFluidObjectInternal implements IFluidLoadable {
|
|
38
|
-
public get IFluidLoadable() {
|
|
38
|
+
public get IFluidLoadable(): IFluidLoadable {
|
|
39
39
|
return this;
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -94,8 +94,8 @@ export class TestFluidObjectInternal implements IFluidLoadable {
|
|
|
94
94
|
: create404Response(request);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
public async initialize(existing: boolean) {
|
|
98
|
-
const doInitialization = async () => {
|
|
97
|
+
public async initialize(existing: boolean): Promise<void> {
|
|
98
|
+
const doInitialization = async (): Promise<void> => {
|
|
99
99
|
if (!existing) {
|
|
100
100
|
for (const [key, sharedObjectFactory] of this.initialSharedObjectsFactories) {
|
|
101
101
|
const channel = this.runtime.createChannel(key, sharedObjectFactory.type);
|
|
@@ -365,7 +365,7 @@ export class EventAndErrorTrackingLogger
|
|
|
365
365
|
private readonly expectedEvents: { index: number; event: ITelemetryGenericEventExt }[] = [];
|
|
366
366
|
private readonly unexpectedErrors: ITelemetryBaseEvent[] = [];
|
|
367
367
|
|
|
368
|
-
public registerExpectedEvent(...orderedExpectedEvents: ITelemetryGenericEventExt[]) {
|
|
368
|
+
public registerExpectedEvent(...orderedExpectedEvents: ITelemetryGenericEventExt[]): void {
|
|
369
369
|
if (this.expectedEvents.length !== 0) {
|
|
370
370
|
// we don't have to error here. just no reason not to. given the events must be
|
|
371
371
|
// ordered it could be tricky to figure out problems around multiple registrations.
|
|
@@ -419,7 +419,10 @@ export class EventAndErrorTrackingLogger
|
|
|
419
419
|
this.baseLogger?.send(event);
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
public reportAndClearTrackedEvents() {
|
|
422
|
+
public reportAndClearTrackedEvents(): {
|
|
423
|
+
expectedNotFound: { index: number; event: ITelemetryGenericEventExt }[];
|
|
424
|
+
unexpectedErrors: ITelemetryBaseEvent[];
|
|
425
|
+
} {
|
|
423
426
|
const expectedNotFound = this.expectedEvents.splice(0, this.expectedEvents.length);
|
|
424
427
|
const unexpectedErrors = this.unexpectedErrors.splice(0, this.unexpectedErrors.length);
|
|
425
428
|
return {
|
|
@@ -490,7 +493,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
490
493
|
return this._logger;
|
|
491
494
|
}
|
|
492
495
|
|
|
493
|
-
public get tracker() {
|
|
496
|
+
public get tracker(): EventAndErrorTrackingLogger {
|
|
494
497
|
void this.logger;
|
|
495
498
|
assert(this._tracker !== undefined, "should be initialized");
|
|
496
499
|
return this._tracker;
|
|
@@ -499,7 +502,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
499
502
|
/**
|
|
500
503
|
* {@inheritDoc ITestObjectProvider.documentServiceFactory}
|
|
501
504
|
*/
|
|
502
|
-
public get documentServiceFactory() {
|
|
505
|
+
public get documentServiceFactory(): IDocumentServiceFactory {
|
|
503
506
|
if (!this._documentServiceFactory) {
|
|
504
507
|
this._documentServiceFactory = this.driver.createDocumentServiceFactory();
|
|
505
508
|
}
|
|
@@ -509,7 +512,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
509
512
|
/**
|
|
510
513
|
* {@inheritDoc ITestObjectProvider.urlResolver}
|
|
511
514
|
*/
|
|
512
|
-
public get urlResolver() {
|
|
515
|
+
public get urlResolver(): IUrlResolver {
|
|
513
516
|
if (!this._urlResolver) {
|
|
514
517
|
this._urlResolver = this.driver.createUrlResolver();
|
|
515
518
|
}
|
|
@@ -519,14 +522,14 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
519
522
|
/**
|
|
520
523
|
* {@inheritDoc ITestObjectProvider.documentId}
|
|
521
524
|
*/
|
|
522
|
-
public get documentId() {
|
|
525
|
+
public get documentId(): string {
|
|
523
526
|
return this._documentIdStrategy.get();
|
|
524
527
|
}
|
|
525
528
|
|
|
526
529
|
/**
|
|
527
530
|
* {@inheritDoc ITestObjectProvider.defaultCodeDetails}
|
|
528
531
|
*/
|
|
529
|
-
public get defaultCodeDetails() {
|
|
532
|
+
public get defaultCodeDetails(): IFluidCodeDetails {
|
|
530
533
|
return defaultCodeDetails;
|
|
531
534
|
}
|
|
532
535
|
|
|
@@ -543,7 +546,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
543
546
|
public createLoader(
|
|
544
547
|
packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,
|
|
545
548
|
loaderProps?: Partial<ILoaderProps>,
|
|
546
|
-
) {
|
|
549
|
+
): Loader {
|
|
547
550
|
const logger = createMultiSinkLogger({
|
|
548
551
|
loggers: [this.logger, loaderProps?.logger],
|
|
549
552
|
});
|
|
@@ -566,7 +569,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
566
569
|
public async createContainer(
|
|
567
570
|
entryPoint: fluidEntryPoint,
|
|
568
571
|
loaderProps?: Partial<ILoaderProps>,
|
|
569
|
-
) {
|
|
572
|
+
): Promise<IContainer> {
|
|
570
573
|
if (this._documentCreated) {
|
|
571
574
|
throw new Error(
|
|
572
575
|
"Only one container/document can be created. To load the container/document use loadContainer",
|
|
@@ -632,7 +635,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
632
635
|
loader: ILoader,
|
|
633
636
|
headers?: IRequestHeader,
|
|
634
637
|
pendingLocalState?: string,
|
|
635
|
-
) {
|
|
638
|
+
): Promise<IContainer> {
|
|
636
639
|
return loader.resolve(
|
|
637
640
|
{
|
|
638
641
|
url: await this.driver.createContainerUrl(this.documentId),
|
|
@@ -645,7 +648,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
645
648
|
/**
|
|
646
649
|
* {@inheritDoc ITestObjectProvider.makeTestLoader}
|
|
647
650
|
*/
|
|
648
|
-
public makeTestLoader(testContainerConfig?: ITestContainerConfig) {
|
|
651
|
+
public makeTestLoader(testContainerConfig?: ITestContainerConfig): Loader {
|
|
649
652
|
return this.createLoader(
|
|
650
653
|
[[defaultCodeDetails, this.createFluidEntryPoint(testContainerConfig)]],
|
|
651
654
|
testContainerConfig?.loaderProps,
|
|
@@ -695,7 +698,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
695
698
|
/**
|
|
696
699
|
* {@inheritDoc ITestObjectProvider.reset}
|
|
697
700
|
*/
|
|
698
|
-
public reset() {
|
|
701
|
+
public reset(): void {
|
|
699
702
|
this._loaderContainerTracker.reset();
|
|
700
703
|
this._documentServiceFactory = undefined;
|
|
701
704
|
this._urlResolver = undefined;
|
|
@@ -716,7 +719,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
716
719
|
return this._loaderContainerTracker.ensureSynchronized(...containers);
|
|
717
720
|
}
|
|
718
721
|
|
|
719
|
-
private async waitContainerToCatchUp(container: IContainer) {
|
|
722
|
+
private async waitContainerToCatchUp(container: IContainer): Promise<boolean> {
|
|
720
723
|
// The original waitContainerToCatchUp() from container loader uses either Container.resume()
|
|
721
724
|
// or Container.connect() as part of its implementation. However, resume() was deprecated
|
|
722
725
|
// and eventually replaced with connect(). To avoid issues during LTS compatibility testing
|
|
@@ -731,7 +734,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
731
734
|
/**
|
|
732
735
|
* {@inheritDoc ITestObjectProvider.updateDocumentId}
|
|
733
736
|
*/
|
|
734
|
-
public updateDocumentId(resolvedUrl: IResolvedUrl | undefined) {
|
|
737
|
+
public updateDocumentId(resolvedUrl: IResolvedUrl | undefined): void {
|
|
735
738
|
this._documentIdStrategy.update(resolvedUrl);
|
|
736
739
|
this.logger.send({
|
|
737
740
|
category: "generic",
|
|
@@ -743,7 +746,7 @@ export class TestObjectProvider implements ITestObjectProvider {
|
|
|
743
746
|
/**
|
|
744
747
|
* {@inheritDoc ITestObjectProvider.resetLoaderContainerTracker}
|
|
745
748
|
*/
|
|
746
|
-
public resetLoaderContainerTracker(syncSummarizerClients: boolean = false) {
|
|
749
|
+
public resetLoaderContainerTracker(syncSummarizerClients: boolean = false): void {
|
|
747
750
|
this._loaderContainerTracker.reset();
|
|
748
751
|
this._loaderContainerTracker = new LoaderContainerTracker(syncSummarizerClients);
|
|
749
752
|
}
|
|
@@ -795,7 +798,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
795
798
|
/**
|
|
796
799
|
* {@inheritDoc ITestObjectProvider.logger}
|
|
797
800
|
*/
|
|
798
|
-
public get logger() {
|
|
801
|
+
public get logger(): ITelemetryBaseLogger {
|
|
799
802
|
if (this._logger === undefined) {
|
|
800
803
|
this._tracker = new EventAndErrorTrackingLogger(getTestLogger?.());
|
|
801
804
|
this._logger = createChildLogger({
|
|
@@ -806,7 +809,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
806
809
|
return this._logger;
|
|
807
810
|
}
|
|
808
811
|
|
|
809
|
-
public get tracker() {
|
|
812
|
+
public get tracker(): EventAndErrorTrackingLogger {
|
|
810
813
|
void this.logger;
|
|
811
814
|
assert(this._tracker !== undefined, "should be initialized");
|
|
812
815
|
return this._tracker;
|
|
@@ -815,7 +818,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
815
818
|
/**
|
|
816
819
|
* {@inheritDoc ITestObjectProvider.documentServiceFactory}
|
|
817
820
|
*/
|
|
818
|
-
public get documentServiceFactory() {
|
|
821
|
+
public get documentServiceFactory(): IDocumentServiceFactory {
|
|
819
822
|
if (!this._documentServiceFactory) {
|
|
820
823
|
this._documentServiceFactory = this.driverForCreating.createDocumentServiceFactory();
|
|
821
824
|
}
|
|
@@ -825,7 +828,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
825
828
|
/**
|
|
826
829
|
* {@inheritDoc ITestObjectProvider.urlResolver}
|
|
827
830
|
*/
|
|
828
|
-
public get urlResolver() {
|
|
831
|
+
public get urlResolver(): IUrlResolver {
|
|
829
832
|
if (!this._urlResolver) {
|
|
830
833
|
this._urlResolver = this.driverForCreating.createUrlResolver();
|
|
831
834
|
}
|
|
@@ -835,14 +838,14 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
835
838
|
/**
|
|
836
839
|
* {@inheritDoc ITestObjectProvider.documentId}
|
|
837
840
|
*/
|
|
838
|
-
public get documentId() {
|
|
841
|
+
public get documentId(): string {
|
|
839
842
|
return this._documentIdStrategy.get();
|
|
840
843
|
}
|
|
841
844
|
|
|
842
845
|
/**
|
|
843
846
|
* {@inheritDoc ITestObjectProvider.defaultCodeDetails}
|
|
844
847
|
*/
|
|
845
|
-
public get defaultCodeDetails() {
|
|
848
|
+
public get defaultCodeDetails(): IFluidCodeDetails {
|
|
846
849
|
return defaultCodeDetails;
|
|
847
850
|
}
|
|
848
851
|
|
|
@@ -874,7 +877,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
874
877
|
private createLoaderForCreating(
|
|
875
878
|
packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,
|
|
876
879
|
loaderProps?: Partial<ILoaderProps>,
|
|
877
|
-
) {
|
|
880
|
+
): Loader {
|
|
878
881
|
const logger = createMultiSinkLogger({
|
|
879
882
|
loggers: [this.logger, loaderProps?.logger],
|
|
880
883
|
});
|
|
@@ -895,7 +898,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
895
898
|
private createLoaderForLoading(
|
|
896
899
|
packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,
|
|
897
900
|
loaderProps?: Partial<ILoaderProps>,
|
|
898
|
-
) {
|
|
901
|
+
): Loader {
|
|
899
902
|
const logger = createMultiSinkLogger({
|
|
900
903
|
loggers: [this.logger, loaderProps?.logger],
|
|
901
904
|
});
|
|
@@ -920,7 +923,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
920
923
|
packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,
|
|
921
924
|
loaderProps?: Partial<ILoaderProps>,
|
|
922
925
|
forceUseCreateVersion = false,
|
|
923
|
-
) {
|
|
926
|
+
): Loader {
|
|
924
927
|
const useCreateVersion = forceUseCreateVersion === true || this.useCreateApi;
|
|
925
928
|
if (this.useCreateApi) {
|
|
926
929
|
// After we create the first loader, we can set this.useCreateApi to false.
|
|
@@ -938,7 +941,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
938
941
|
public async createContainer(
|
|
939
942
|
entryPoint: fluidEntryPoint,
|
|
940
943
|
loaderProps?: Partial<ILoaderProps>,
|
|
941
|
-
) {
|
|
944
|
+
): Promise<IContainer> {
|
|
942
945
|
if (this._documentCreated) {
|
|
943
946
|
throw new Error(
|
|
944
947
|
"Only one container/document can be created. To load the container/document use loadContainer",
|
|
@@ -1006,7 +1009,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
1006
1009
|
headers?: IRequestHeader,
|
|
1007
1010
|
driver?: ITestDriver,
|
|
1008
1011
|
pendingLocalState?: string,
|
|
1009
|
-
) {
|
|
1012
|
+
): Promise<IContainer> {
|
|
1010
1013
|
return loader.resolve(
|
|
1011
1014
|
{
|
|
1012
1015
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -1020,7 +1023,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
1020
1023
|
/**
|
|
1021
1024
|
* {@inheritDoc ITestObjectProvider.makeTestLoader}
|
|
1022
1025
|
*/
|
|
1023
|
-
public makeTestLoader(testContainerConfig?: ITestContainerConfig) {
|
|
1026
|
+
public makeTestLoader(testContainerConfig?: ITestContainerConfig): Loader {
|
|
1024
1027
|
return this.createLoader(
|
|
1025
1028
|
[[defaultCodeDetails, this.createFluidEntryPoint(testContainerConfig)]],
|
|
1026
1029
|
testContainerConfig?.loaderProps,
|
|
@@ -1080,7 +1083,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
1080
1083
|
/**
|
|
1081
1084
|
* {@inheritDoc ITestObjectProvider.reset}
|
|
1082
1085
|
*/
|
|
1083
|
-
public reset() {
|
|
1086
|
+
public reset(): void {
|
|
1084
1087
|
this.useCreateApi = true;
|
|
1085
1088
|
this._loaderContainerTracker.reset();
|
|
1086
1089
|
this._logger = undefined;
|
|
@@ -1102,7 +1105,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
1102
1105
|
return this._loaderContainerTracker.ensureSynchronized(...containers);
|
|
1103
1106
|
}
|
|
1104
1107
|
|
|
1105
|
-
private async waitContainerToCatchUp(container: IContainer) {
|
|
1108
|
+
private async waitContainerToCatchUp(container: IContainer): Promise<boolean> {
|
|
1106
1109
|
// The original waitContainerToCatchUp() from container loader uses either Container.resume()
|
|
1107
1110
|
// or Container.connect() as part of its implementation. However, resume() was deprecated
|
|
1108
1111
|
// and eventually replaced with connect(). To avoid issues during LTS compatibility testing
|
|
@@ -1117,7 +1120,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
1117
1120
|
/**
|
|
1118
1121
|
* {@inheritDoc ITestObjectProvider.updateDocumentId}
|
|
1119
1122
|
*/
|
|
1120
|
-
public updateDocumentId(resolvedUrl: IResolvedUrl | undefined) {
|
|
1123
|
+
public updateDocumentId(resolvedUrl: IResolvedUrl | undefined): void {
|
|
1121
1124
|
this._documentIdStrategy.update(resolvedUrl);
|
|
1122
1125
|
this.logger.send({
|
|
1123
1126
|
category: "generic",
|
|
@@ -1129,7 +1132,7 @@ export class TestObjectProviderWithVersionedLoad implements ITestObjectProvider
|
|
|
1129
1132
|
/**
|
|
1130
1133
|
* {@inheritDoc ITestObjectProvider.resetLoaderContainerTracker}
|
|
1131
1134
|
*/
|
|
1132
|
-
public resetLoaderContainerTracker(syncSummarizerClients: boolean = false) {
|
|
1135
|
+
public resetLoaderContainerTracker(syncSummarizerClients: boolean = false): void {
|
|
1133
1136
|
this._loaderContainerTracker.reset();
|
|
1134
1137
|
this._loaderContainerTracker = new LoaderContainerTracker(syncSummarizerClients);
|
|
1135
1138
|
}
|
|
@@ -1169,7 +1172,7 @@ const primaryEventProps = ({
|
|
|
1169
1172
|
eventName,
|
|
1170
1173
|
error,
|
|
1171
1174
|
errorType,
|
|
1172
|
-
}: ITelemetryBaseEvent) => ({
|
|
1175
|
+
}: ITelemetryBaseEvent): Partial<ITelemetryBaseEvent> => ({
|
|
1173
1176
|
category,
|
|
1174
1177
|
eventName,
|
|
1175
1178
|
error,
|
|
@@ -1183,7 +1186,7 @@ const primaryEventProps = ({
|
|
|
1183
1186
|
export function getUnexpectedLogErrorException(
|
|
1184
1187
|
logger: IEventAndErrorTrackingLogger | undefined,
|
|
1185
1188
|
prefix?: string,
|
|
1186
|
-
) {
|
|
1189
|
+
): Error | undefined {
|
|
1187
1190
|
if (logger === undefined) {
|
|
1188
1191
|
return;
|
|
1189
1192
|
}
|
package/src/timeoutUtils.ts
CHANGED
|
@@ -19,31 +19,31 @@ class TestTimeout {
|
|
|
19
19
|
private deferred: Deferred<void> = new Deferred<void>();
|
|
20
20
|
|
|
21
21
|
private static instance: TestTimeout = new TestTimeout();
|
|
22
|
-
public static updateOnYield(runnable: Mocha.Runnable) {
|
|
22
|
+
public static updateOnYield(runnable: Mocha.Runnable): void {
|
|
23
23
|
TestTimeout.instance.clearTimer();
|
|
24
24
|
TestTimeout.instance.resetTimer(runnable);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
public static reset() {
|
|
27
|
+
public static reset(): void {
|
|
28
28
|
TestTimeout.instance.clearTimer();
|
|
29
29
|
TestTimeout.instance = new TestTimeout();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
public static getInstance() {
|
|
32
|
+
public static getInstance(): TestTimeout {
|
|
33
33
|
return TestTimeout.instance;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
public async getPromise() {
|
|
36
|
+
public async getPromise(): Promise<void> {
|
|
37
37
|
return this.deferred.promise;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
public getTimeout() {
|
|
40
|
+
public getTimeout(): number | undefined {
|
|
41
41
|
return this.timeout;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
private constructor() {}
|
|
45
45
|
|
|
46
|
-
private resetTimer(runnable: Mocha.Runnable) {
|
|
46
|
+
private resetTimer(runnable: Mocha.Runnable): void {
|
|
47
47
|
assert(!this.timer, "clearTimer should have been called before reset");
|
|
48
48
|
assert(!this.deferred.isCompleted, "can't reset a completed TestTimeout");
|
|
49
49
|
|
|
@@ -61,7 +61,7 @@ class TestTimeout {
|
|
|
61
61
|
this.deferred.reject(this);
|
|
62
62
|
}, this.timeout);
|
|
63
63
|
}
|
|
64
|
-
private clearTimer() {
|
|
64
|
+
private clearTimer(): void {
|
|
65
65
|
if (this.timer) {
|
|
66
66
|
this.deferred = new Deferred();
|
|
67
67
|
clearTimeout(this.timer);
|
|
@@ -220,14 +220,14 @@ async function getTimeoutPromise<T = void>(
|
|
|
220
220
|
) => void,
|
|
221
221
|
timeoutOptions: TimeoutWithError | TimeoutWithValue<T>,
|
|
222
222
|
err: Error | undefined,
|
|
223
|
-
) {
|
|
223
|
+
): Promise<T> {
|
|
224
224
|
const timeout = timeoutOptions.durationMs ?? 0;
|
|
225
225
|
if (timeout <= 0 || !Number.isFinite(timeout)) {
|
|
226
226
|
return new Promise(executor);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
return new Promise<T>((resolve, reject) => {
|
|
230
|
-
const timeoutRejections = () => {
|
|
230
|
+
const timeoutRejections = (): void => {
|
|
231
231
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
232
232
|
const errorObject = err!;
|
|
233
233
|
errorObject.message = `${errorObject.message} (${timeout}ms)`;
|