@fluidframework/test-utils 0.54.2 → 0.56.0-49831

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.
@@ -109,21 +109,14 @@ class TestObjectProvider {
109
109
  *
110
110
  * @param packageEntries - list of code details and fluidEntryPoint pairs.
111
111
  */
112
- createLoader(packageEntries, options, detachedBlobStorage) {
112
+ createLoader(packageEntries, loaderProps) {
113
+ var _a, _b, _c;
113
114
  const multiSinkLogger = new telemetry_utils_1.MultiSinkLogger();
114
115
  multiSinkLogger.addLogger(this.logger);
115
- if ((options === null || options === void 0 ? void 0 : options.logger) !== undefined) {
116
- multiSinkLogger.addLogger(options.logger);
116
+ if ((loaderProps === null || loaderProps === void 0 ? void 0 : loaderProps.logger) !== undefined) {
117
+ multiSinkLogger.addLogger(loaderProps.logger);
117
118
  }
118
- const codeLoader = new localCodeLoader_1.LocalCodeLoader(packageEntries);
119
- const loader = new this.LoaderConstructor({
120
- urlResolver: this.urlResolver,
121
- documentServiceFactory: this.documentServiceFactory,
122
- codeLoader,
123
- logger: multiSinkLogger,
124
- options,
125
- detachedBlobStorage,
126
- });
119
+ const loader = new this.LoaderConstructor(Object.assign(Object.assign({}, loaderProps), { logger: multiSinkLogger, codeLoader: (_a = loaderProps === null || loaderProps === void 0 ? void 0 : loaderProps.codeLoader) !== null && _a !== void 0 ? _a : new localCodeLoader_1.LocalCodeLoader(packageEntries), urlResolver: (_b = loaderProps === null || loaderProps === void 0 ? void 0 : loaderProps.urlResolver) !== null && _b !== void 0 ? _b : this.urlResolver, documentServiceFactory: (_c = loaderProps === null || loaderProps === void 0 ? void 0 : loaderProps.documentServiceFactory) !== null && _c !== void 0 ? _c : this.documentServiceFactory }));
127
120
  this._loaderContainerTracker.add(loader);
128
121
  return loader;
129
122
  }
@@ -136,11 +129,11 @@ class TestObjectProvider {
136
129
  *
137
130
  * @param packageEntries - list of code details and fluidEntryPoint pairs.
138
131
  */
139
- async createContainer(entryPoint, options) {
132
+ async createContainer(entryPoint, loaderProps) {
140
133
  if (this._documentCreated) {
141
134
  throw new Error("Only one container/document can be created. To load the container/document use loadContainer");
142
135
  }
143
- const loader = this.createLoader([[defaultCodeDetails, entryPoint]], options);
136
+ const loader = this.createLoader([[defaultCodeDetails, entryPoint]], loaderProps);
144
137
  const container = await localLoader_1.createAndAttachContainer(defaultCodeDetails, loader, this.driver.createCreateNewRequest(this.documentId));
145
138
  this._documentCreated = true;
146
139
  // r11s driver will generate a new ID for the new container.
@@ -148,8 +141,8 @@ class TestObjectProvider {
148
141
  this._documentIdStrategy.update(container.resolvedUrl);
149
142
  return container;
150
143
  }
151
- async loadContainer(entryPoint, options, requestHeader) {
152
- const loader = this.createLoader([[defaultCodeDetails, entryPoint]], options);
144
+ async loadContainer(entryPoint, loaderProps, requestHeader) {
145
+ const loader = this.createLoader([[defaultCodeDetails, entryPoint]], loaderProps);
153
146
  return loader.resolve({ url: await this.driver.createContainerUrl(this.documentId), headers: requestHeader });
154
147
  }
155
148
  /**
@@ -157,8 +150,8 @@ class TestObjectProvider {
157
150
  * The version of the loader/containerRuntime/dataRuntime may vary based on compat config of the current run
158
151
  * @param testContainerConfig - optional configuring the test Container
159
152
  */
160
- makeTestLoader(testContainerConfig, detachedBlobStorage) {
161
- return this.createLoader([[defaultCodeDetails, this.createFluidEntryPoint(testContainerConfig)]], testContainerConfig === null || testContainerConfig === void 0 ? void 0 : testContainerConfig.loaderOptions, detachedBlobStorage);
153
+ makeTestLoader(testContainerConfig) {
154
+ return this.createLoader([[defaultCodeDetails, this.createFluidEntryPoint(testContainerConfig)]], testContainerConfig === null || testContainerConfig === void 0 ? void 0 : testContainerConfig.loaderProps);
162
155
  }
163
156
  /**
164
157
  * Make a container using a default document id and code details
@@ -1 +1 @@
1
- {"version":3,"file":"testObjectProvider.js","sourceRoot":"","sources":["../src/testObjectProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,uEAAwG;AAIxG,+DAAsE;AAEtE,+BA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D,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB,CAC1B,mBAA0C,EAC1C,aAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;QACxD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACnC,GAAG,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC;YAC1D,OAAO,EAAE,aAAa;SACzB,CAAC,CAAC;QACH,MAAM,yCAAsB,CAAC,SAAS,CAAC,CAAC;QACxC,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;QACrC,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAClC,CAAC;IAEM,KAAK,CAAC,kBAAkB;QAC3B,OAAO,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,EAAE,CAAC;IAC7D,CAAC;IAED,gBAAgB,CAAC,WAAqC;QAClD,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;CACJ;AAvMD,gDAuMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IContainer, IHostLoader, ILoaderOptions } from \"@fluidframework/container-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { IDetachedBlobStorage, Loader, waitContainerToCatchUp } from \"@fluidframework/container-loader\";\nimport { IContainerRuntimeOptions } from \"@fluidframework/container-runtime\";\nimport { IFluidCodeDetails, IRequestHeader } from \"@fluidframework/core-interfaces\";\nimport { IDocumentServiceFactory, IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { ensureFluidResolvedUrl } from \"@fluidframework/driver-utils\";\nimport { ITestDriver, TestDriverTypes } from \"@fluidframework/test-driver-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport { ChildLogger, MultiSinkLogger } from \"@fluidframework/telemetry-utils\";\nimport { LoaderContainerTracker } from \"./loaderContainerTracker\";\nimport { fluidEntryPoint, LocalCodeLoader } from \"./localCodeLoader\";\nimport { createAndAttachContainer } from \"./localLoader\";\nimport { ChannelFactoryRegistry } from \"./testFluidObject\";\n\nconst defaultCodeDetails: IFluidCodeDetails = {\n package: \"defaultTestPackage\",\n config: {},\n};\n\nexport interface IOpProcessingController {\n processIncoming(...containers: IContainer[]): Promise<void>;\n processOutgoing(...containers: IContainer[]): Promise<void>;\n pauseProcessing(...containers: IContainer[]): Promise<void>;\n resumeProcessing(...containers: IContainer[]): void;\n}\n\nexport interface ITestObjectProvider {\n createFluidEntryPoint: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint;\n createLoader(\n packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,\n options?: ITestLoaderOptions,\n detachedBlobStorage?: IDetachedBlobStorage,\n ): IHostLoader;\n createContainer(entryPoint: fluidEntryPoint, options?: ITestLoaderOptions): Promise<IContainer>;\n loadContainer(\n entryPoint: fluidEntryPoint,\n options?: ITestLoaderOptions,\n requestHeader?: IRequestHeader,\n ): Promise<IContainer>;\n\n /**\n * Used to create a test Container. The Loader/ContainerRuntime/DataRuntime might be different versioned.\n * In generateLocalCompatTest(), this Container and its runtime will be arbitrarily-versioned.\n */\n makeTestLoader(testContainerConfig?: ITestContainerConfig, detachedBlobStorage?: IDetachedBlobStorage): IHostLoader,\n makeTestContainer(testContainerConfig?: ITestContainerConfig): Promise<IContainer>,\n loadTestContainer(testContainerConfig?: ITestContainerConfig, requestHeader?: IRequestHeader): Promise<IContainer>,\n /**\n *\n * @param url - Resolved container URL\n */\n updateDocumentId(url: IResolvedUrl | undefined): void,\n\n logger: ITelemetryBaseLogger,\n documentServiceFactory: IDocumentServiceFactory,\n urlResolver: IUrlResolver,\n defaultCodeDetails: IFluidCodeDetails,\n opProcessingController: IOpProcessingController,\n\n ensureSynchronized(): Promise<void>;\n reset(): void,\n\n documentId: string,\n driver: ITestDriver;\n}\n\nexport enum DataObjectFactoryType {\n Primed, // default\n Test,\n}\n\nexport interface ITestContainerConfig {\n /** TestFluidDataObject instead of PrimedDataStore */\n fluidDataObjectType?: DataObjectFactoryType,\n\n /** An array of channel name and DDS factory pair to create on container creation time */\n registry?: ChannelFactoryRegistry,\n\n /** Container runtime options for the container instance */\n runtimeOptions?: IContainerRuntimeOptions,\n\n /** Loader options for the loader used to create containers */\n loaderOptions?: ITestLoaderOptions,\n}\n\n// new interface to help inject custom loggers to tests\nexport interface ITestLoaderOptions extends ILoaderOptions {\n logger?: ITelemetryBaseLogger;\n}\n\nexport const createDocumentId = (): string => uuid();\n\ninterface IDocumentIdStrategy {\n get(): string;\n update(resolvedUrl?: IResolvedUrl): void;\n reset(): void;\n}\n\n/**\n * Document ID is treated differently by test drivers. The key difference is in generating\n * a new container ID and accessing the container in multi-instance test cases.\n */\nfunction getDocumentIdStrategy(type?: TestDriverTypes): IDocumentIdStrategy {\n let documentId = createDocumentId();\n switch (type) {\n case \"odsp\":\n return {\n get: () => documentId,\n update: () => { }, // do not update the document ID in odsp test cases\n reset: () => documentId = createDocumentId(),\n };\n default:\n return {\n get: () => documentId,\n update: (resolvedUrl?: IResolvedUrl) => {\n // Extract the document ID from the resolved container's URL and reset the ID property\n ensureFluidResolvedUrl(resolvedUrl);\n documentId = resolvedUrl.id ?? documentId;\n },\n reset: () => documentId = createDocumentId(),\n };\n }\n}\n\n/**\n * Shared base class for test object provider. Contain code for loader and container creation and loading\n */\nexport class TestObjectProvider {\n private readonly _loaderContainerTracker = new LoaderContainerTracker();\n private _documentServiceFactory: IDocumentServiceFactory | undefined;\n private _urlResolver: IUrlResolver | undefined;\n private _logger: ITelemetryBaseLogger | undefined;\n private readonly _documentIdStrategy: IDocumentIdStrategy;\n // Since documentId doesn't change we can only create/make one container. Call the load functions instead.\n private _documentCreated = false;\n\n /**\n * Manage objects for loading and creating container, including the driver, loader, and OpProcessingController\n * @param createFluidEntryPoint - callback to create a fluidEntryPoint, with an optional set of channel name\n * and factory for TestFluidObject\n */\n constructor(\n public readonly LoaderConstructor: typeof Loader,\n public readonly driver: ITestDriver,\n public readonly createFluidEntryPoint: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint,\n ) {\n this._documentIdStrategy = getDocumentIdStrategy(driver.type);\n }\n\n get logger() {\n if (this._logger === undefined) {\n this._logger = ChildLogger.create(getTestLogger?.(), undefined,\n {\n all: {\n driverType: this.driver.type,\n driverEndpointName: this.driver.endpointName,\n driverTenantName: this.driver.tenantName,\n driverUserIndex: this.driver.userIndex,\n },\n });\n }\n return this._logger;\n }\n\n get documentServiceFactory() {\n if (!this._documentServiceFactory) {\n this._documentServiceFactory = this.driver.createDocumentServiceFactory();\n }\n return this._documentServiceFactory;\n }\n\n get urlResolver() {\n if (!this._urlResolver) {\n this._urlResolver = this.driver.createUrlResolver();\n }\n return this._urlResolver;\n }\n\n get documentId() {\n return this._documentIdStrategy.get();\n }\n\n get defaultCodeDetails() {\n return defaultCodeDetails;\n }\n\n get opProcessingController(): IOpProcessingController {\n return this._loaderContainerTracker;\n }\n\n /**\n * Create a loader. Containers created/loaded through this loader will be added to the OpProcessingController.\n *\n * Only the version of the loader will vary based on compat config. The version of\n * containerRuntime/dataRuntime used in fluidEntryPoint will be used as is from what is passed in.\n *\n * @param packageEntries - list of code details and fluidEntryPoint pairs.\n */\n public createLoader(\n packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,\n options?: ITestLoaderOptions,\n detachedBlobStorage?: IDetachedBlobStorage,\n ) {\n const multiSinkLogger = new MultiSinkLogger();\n multiSinkLogger.addLogger(this.logger);\n if (options?.logger !== undefined) {\n multiSinkLogger.addLogger(options.logger);\n }\n\n const codeLoader = new LocalCodeLoader(packageEntries);\n const loader = new this.LoaderConstructor({\n urlResolver: this.urlResolver,\n documentServiceFactory: this.documentServiceFactory,\n codeLoader,\n logger: multiSinkLogger,\n options,\n detachedBlobStorage,\n });\n this._loaderContainerTracker.add(loader);\n return loader;\n }\n\n /**\n * Create a container using a default document id and code details.\n * Container created is automatically added to the OpProcessingController to manage op flow\n *\n * Only the version of the loader will vary based on compat config. The version of\n * containerRuntime/dataRuntime used in fluidEntryPoint will be used as is from what is passed in.\n *\n * @param packageEntries - list of code details and fluidEntryPoint pairs.\n */\n public async createContainer(entryPoint: fluidEntryPoint, options?: ITestLoaderOptions) {\n if (this._documentCreated) {\n throw new Error(\n \"Only one container/document can be created. To load the container/document use loadContainer\");\n }\n const loader = this.createLoader([[defaultCodeDetails, entryPoint]], options);\n const container = await createAndAttachContainer(\n defaultCodeDetails,\n loader,\n this.driver.createCreateNewRequest(this.documentId),\n );\n this._documentCreated = true;\n // r11s driver will generate a new ID for the new container.\n // update the document ID with the actual ID of the attached container.\n this._documentIdStrategy.update(container.resolvedUrl);\n return container;\n }\n\n public async loadContainer(entryPoint: fluidEntryPoint, options?: ITestLoaderOptions,\n requestHeader?: IRequestHeader): Promise<IContainer> {\n const loader = this.createLoader([[defaultCodeDetails, entryPoint]], options);\n return loader.resolve({ url: await this.driver.createContainerUrl(this.documentId), headers: requestHeader });\n }\n\n /**\n * Make a test loader. Containers created/loaded through this loader will be added to the OpProcessingController.\n * The version of the loader/containerRuntime/dataRuntime may vary based on compat config of the current run\n * @param testContainerConfig - optional configuring the test Container\n */\n public makeTestLoader(testContainerConfig?: ITestContainerConfig, detachedBlobStorage?: IDetachedBlobStorage) {\n return this.createLoader(\n [[defaultCodeDetails, this.createFluidEntryPoint(testContainerConfig)]],\n testContainerConfig?.loaderOptions,\n detachedBlobStorage,\n );\n }\n\n /**\n * Make a container using a default document id and code details\n * Container loaded is automatically added to the OpProcessingController to manage op flow\n * @param testContainerConfig - optional configuring the test Container\n */\n public async makeTestContainer(testContainerConfig?: ITestContainerConfig): Promise<IContainer> {\n if (this._documentCreated) {\n throw new Error(\n \"Only one container/document can be created. To load the container/document use loadTestContainer\");\n }\n const loader = this.makeTestLoader(testContainerConfig);\n const container =\n await createAndAttachContainer(\n defaultCodeDetails,\n loader,\n this.driver.createCreateNewRequest(this.documentId));\n this._documentCreated = true;\n // r11s driver will generate a new ID for the new container.\n // update the document ID with the actual ID of the attached container.\n this._documentIdStrategy.update(container.resolvedUrl);\n return container;\n }\n\n /**\n * Load a container using a default document id and code details.\n * IContainer loaded is automatically added to the OpProcessingController to manage op flow\n * @param testContainerConfig - optional configuring the test Container\n * @param requestHeader - optional headers to be supplied to the loader\n */\n public async loadTestContainer(\n testContainerConfig?: ITestContainerConfig,\n requestHeader?: IRequestHeader,\n ): Promise<IContainer> {\n const loader = this.makeTestLoader(testContainerConfig);\n const container = await loader.resolve({\n url: await this.driver.createContainerUrl(this.documentId),\n headers: requestHeader,\n });\n await waitContainerToCatchUp(container);\n return container;\n }\n\n public reset() {\n this._loaderContainerTracker.reset();\n this._documentServiceFactory = undefined;\n this._urlResolver = undefined;\n this._documentIdStrategy.reset();\n this._logger = undefined;\n this._documentCreated = false;\n }\n\n public async ensureSynchronized() {\n return this._loaderContainerTracker.ensureSynchronized();\n }\n\n updateDocumentId(resolvedUrl: IResolvedUrl | undefined) {\n this._documentIdStrategy.update(resolvedUrl);\n }\n}\n"]}
1
+ {"version":3,"file":"testObjectProvider.js","sourceRoot":"","sources":["../src/testObjectProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,uEAAgG;AAIhG,+DAAsE;AAEtE,+BAAkC;AAClC,qEAA+E;AAC/E,qEAAkE;AAClE,uDAAqE;AACrE,+CAAyD;AAGzD,MAAM,kBAAkB,GAAsB;IAC1C,OAAO,EAAE,oBAAoB;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CAAC,iBAAiB,CAC1B,mBAA0C,EAC1C,aAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;QACxD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACnC,GAAG,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC;YAC1D,OAAO,EAAE,aAAa;SACzB,CAAC,CAAC;QACH,MAAM,yCAAsB,CAAC,SAAS,CAAC,CAAC;QACxC,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;QACrC,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAClC,CAAC;IAEM,KAAK,CAAC,kBAAkB;QAC3B,OAAO,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,EAAE,CAAC;IAC7D,CAAC;IAED,gBAAgB,CAAC,WAAqC;QAClD,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;CACJ;AArMD,gDAqMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IContainer, IHostLoader } from \"@fluidframework/container-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { ILoaderProps, Loader, waitContainerToCatchUp } from \"@fluidframework/container-loader\";\nimport { IContainerRuntimeOptions } from \"@fluidframework/container-runtime\";\nimport { IFluidCodeDetails, IRequestHeader } from \"@fluidframework/core-interfaces\";\nimport { IDocumentServiceFactory, IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { ensureFluidResolvedUrl } from \"@fluidframework/driver-utils\";\nimport { ITestDriver, TestDriverTypes } from \"@fluidframework/test-driver-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport { ChildLogger, MultiSinkLogger } from \"@fluidframework/telemetry-utils\";\nimport { LoaderContainerTracker } from \"./loaderContainerTracker\";\nimport { fluidEntryPoint, LocalCodeLoader } from \"./localCodeLoader\";\nimport { createAndAttachContainer } from \"./localLoader\";\nimport { ChannelFactoryRegistry } from \"./testFluidObject\";\n\nconst defaultCodeDetails: IFluidCodeDetails = {\n package: \"defaultTestPackage\",\n config: {},\n};\n\nexport interface IOpProcessingController {\n processIncoming(...containers: IContainer[]): Promise<void>;\n processOutgoing(...containers: IContainer[]): Promise<void>;\n pauseProcessing(...containers: IContainer[]): Promise<void>;\n resumeProcessing(...containers: IContainer[]): void;\n}\n\nexport interface ITestObjectProvider {\n createFluidEntryPoint: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint;\n createLoader(\n packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,\n loaderProps?: Partial<ILoaderProps>,\n ): IHostLoader;\n createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;\n loadContainer(\n entryPoint: fluidEntryPoint,\n loaderProps?: Partial<ILoaderProps>,\n requestHeader?: IRequestHeader,\n ): Promise<IContainer>;\n\n /**\n * Used to create a test Container. The Loader/ContainerRuntime/DataRuntime might be different versioned.\n * In generateLocalCompatTest(), this Container and its runtime will be arbitrarily-versioned.\n */\n makeTestLoader(testContainerConfig?: ITestContainerConfig): IHostLoader,\n makeTestContainer(testContainerConfig?: ITestContainerConfig): Promise<IContainer>,\n loadTestContainer(testContainerConfig?: ITestContainerConfig, requestHeader?: IRequestHeader): Promise<IContainer>,\n /**\n *\n * @param url - Resolved container URL\n */\n updateDocumentId(url: IResolvedUrl | undefined): void,\n\n logger: ITelemetryBaseLogger,\n documentServiceFactory: IDocumentServiceFactory,\n urlResolver: IUrlResolver,\n defaultCodeDetails: IFluidCodeDetails,\n opProcessingController: IOpProcessingController,\n\n ensureSynchronized(): Promise<void>;\n reset(): void,\n\n documentId: string,\n driver: ITestDriver;\n}\n\nexport enum DataObjectFactoryType {\n Primed, // default\n Test,\n}\n\nexport interface ITestContainerConfig {\n /** TestFluidDataObject instead of PrimedDataStore */\n fluidDataObjectType?: DataObjectFactoryType,\n\n /** An array of channel name and DDS factory pair to create on container creation time */\n registry?: ChannelFactoryRegistry,\n\n /** Container runtime options for the container instance */\n runtimeOptions?: IContainerRuntimeOptions,\n\n /** Loader options for the loader used to create containers */\n loaderProps?: Partial<ILoaderProps>,\n}\n\nexport const createDocumentId = (): string => uuid();\n\ninterface IDocumentIdStrategy {\n get(): string;\n update(resolvedUrl?: IResolvedUrl): void;\n reset(): void;\n}\n\n/**\n * Document ID is treated differently by test drivers. The key difference is in generating\n * a new container ID and accessing the container in multi-instance test cases.\n */\nfunction getDocumentIdStrategy(type?: TestDriverTypes): IDocumentIdStrategy {\n let documentId = createDocumentId();\n switch (type) {\n case \"odsp\":\n return {\n get: () => documentId,\n update: () => { }, // do not update the document ID in odsp test cases\n reset: () => documentId = createDocumentId(),\n };\n default:\n return {\n get: () => documentId,\n update: (resolvedUrl?: IResolvedUrl) => {\n // Extract the document ID from the resolved container's URL and reset the ID property\n ensureFluidResolvedUrl(resolvedUrl);\n documentId = resolvedUrl.id ?? documentId;\n },\n reset: () => documentId = createDocumentId(),\n };\n }\n}\n\n/**\n * Shared base class for test object provider. Contain code for loader and container creation and loading\n */\nexport class TestObjectProvider implements ITestObjectProvider {\n private readonly _loaderContainerTracker = new LoaderContainerTracker();\n private _documentServiceFactory: IDocumentServiceFactory | undefined;\n private _urlResolver: IUrlResolver | undefined;\n private _logger: ITelemetryBaseLogger | undefined;\n private readonly _documentIdStrategy: IDocumentIdStrategy;\n // Since documentId doesn't change we can only create/make one container. Call the load functions instead.\n private _documentCreated = false;\n\n /**\n * Manage objects for loading and creating container, including the driver, loader, and OpProcessingController\n * @param createFluidEntryPoint - callback to create a fluidEntryPoint, with an optional set of channel name\n * and factory for TestFluidObject\n */\n constructor(\n public readonly LoaderConstructor: typeof Loader,\n public readonly driver: ITestDriver,\n public readonly createFluidEntryPoint: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint,\n ) {\n this._documentIdStrategy = getDocumentIdStrategy(driver.type);\n }\n\n get logger() {\n if (this._logger === undefined) {\n this._logger = ChildLogger.create(getTestLogger?.(), undefined,\n {\n all: {\n driverType: this.driver.type,\n driverEndpointName: this.driver.endpointName,\n driverTenantName: this.driver.tenantName,\n driverUserIndex: this.driver.userIndex,\n },\n });\n }\n return this._logger;\n }\n\n get documentServiceFactory() {\n if (!this._documentServiceFactory) {\n this._documentServiceFactory = this.driver.createDocumentServiceFactory();\n }\n return this._documentServiceFactory;\n }\n\n get urlResolver() {\n if (!this._urlResolver) {\n this._urlResolver = this.driver.createUrlResolver();\n }\n return this._urlResolver;\n }\n\n get documentId() {\n return this._documentIdStrategy.get();\n }\n\n get defaultCodeDetails() {\n return defaultCodeDetails;\n }\n\n get opProcessingController(): IOpProcessingController {\n return this._loaderContainerTracker;\n }\n\n /**\n * Create a loader. Containers created/loaded through this loader will be added to the OpProcessingController.\n *\n * Only the version of the loader will vary based on compat config. The version of\n * containerRuntime/dataRuntime used in fluidEntryPoint will be used as is from what is passed in.\n *\n * @param packageEntries - list of code details and fluidEntryPoint pairs.\n */\n public createLoader(\n packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,\n loaderProps?: Partial<ILoaderProps>,\n ) {\n const multiSinkLogger = new MultiSinkLogger();\n multiSinkLogger.addLogger(this.logger);\n if (loaderProps?.logger !== undefined) {\n multiSinkLogger.addLogger(loaderProps.logger);\n }\n\n const loader = new this.LoaderConstructor({\n ... loaderProps,\n logger: multiSinkLogger,\n codeLoader: loaderProps?.codeLoader ?? new LocalCodeLoader(packageEntries),\n urlResolver: loaderProps?.urlResolver ?? this.urlResolver,\n documentServiceFactory: loaderProps?.documentServiceFactory ?? this.documentServiceFactory,\n });\n this._loaderContainerTracker.add(loader);\n return loader;\n }\n\n /**\n * Create a container using a default document id and code details.\n * Container created is automatically added to the OpProcessingController to manage op flow\n *\n * Only the version of the loader will vary based on compat config. The version of\n * containerRuntime/dataRuntime used in fluidEntryPoint will be used as is from what is passed in.\n *\n * @param packageEntries - list of code details and fluidEntryPoint pairs.\n */\n public async createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>) {\n if (this._documentCreated) {\n throw new Error(\n \"Only one container/document can be created. To load the container/document use loadContainer\");\n }\n const loader = this.createLoader([[defaultCodeDetails, entryPoint]], loaderProps);\n const container = await createAndAttachContainer(\n defaultCodeDetails,\n loader,\n this.driver.createCreateNewRequest(this.documentId),\n );\n this._documentCreated = true;\n // r11s driver will generate a new ID for the new container.\n // update the document ID with the actual ID of the attached container.\n this._documentIdStrategy.update(container.resolvedUrl);\n return container;\n }\n\n public async loadContainer(\n entryPoint: fluidEntryPoint,\n loaderProps?: Partial<ILoaderProps>,\n requestHeader?: IRequestHeader): Promise<IContainer> {\n const loader = this.createLoader([[defaultCodeDetails, entryPoint]], loaderProps);\n return loader.resolve({ url: await this.driver.createContainerUrl(this.documentId), headers: requestHeader });\n }\n\n /**\n * Make a test loader. Containers created/loaded through this loader will be added to the OpProcessingController.\n * The version of the loader/containerRuntime/dataRuntime may vary based on compat config of the current run\n * @param testContainerConfig - optional configuring the test Container\n */\n public makeTestLoader(testContainerConfig?: ITestContainerConfig) {\n return this.createLoader(\n [[defaultCodeDetails, this.createFluidEntryPoint(testContainerConfig)]],\n testContainerConfig?.loaderProps,\n );\n }\n\n /**\n * Make a container using a default document id and code details\n * Container loaded is automatically added to the OpProcessingController to manage op flow\n * @param testContainerConfig - optional configuring the test Container\n */\n public async makeTestContainer(testContainerConfig?: ITestContainerConfig): Promise<IContainer> {\n if (this._documentCreated) {\n throw new Error(\n \"Only one container/document can be created. To load the container/document use loadTestContainer\");\n }\n const loader = this.makeTestLoader(testContainerConfig);\n const container =\n await createAndAttachContainer(\n defaultCodeDetails,\n loader,\n this.driver.createCreateNewRequest(this.documentId));\n this._documentCreated = true;\n // r11s driver will generate a new ID for the new container.\n // update the document ID with the actual ID of the attached container.\n this._documentIdStrategy.update(container.resolvedUrl);\n return container;\n }\n\n /**\n * Load a container using a default document id and code details.\n * IContainer loaded is automatically added to the OpProcessingController to manage op flow\n * @param testContainerConfig - optional configuring the test Container\n * @param requestHeader - optional headers to be supplied to the loader\n */\n public async loadTestContainer(\n testContainerConfig?: ITestContainerConfig,\n requestHeader?: IRequestHeader,\n ): Promise<IContainer> {\n const loader = this.makeTestLoader(testContainerConfig);\n const container = await loader.resolve({\n url: await this.driver.createContainerUrl(this.documentId),\n headers: requestHeader,\n });\n await waitContainerToCatchUp(container);\n return container;\n }\n\n public reset() {\n this._loaderContainerTracker.reset();\n this._documentServiceFactory = undefined;\n this._urlResolver = undefined;\n this._documentIdStrategy.reset();\n this._logger = undefined;\n this._documentCreated = false;\n }\n\n public async ensureSynchronized() {\n return this._loaderContainerTracker.ensureSynchronized();\n }\n\n updateDocumentId(resolvedUrl: IResolvedUrl | undefined) {\n this._documentIdStrategy.update(resolvedUrl);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"timeoutUtils.d.ts","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE3C,MAAM,WAAW,gBAAgB;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,IAAI;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,C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,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,EAChG,cAAc,GAAE,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAM,GAC5D,OAAO,CAAC,CAAC,CAAC,CA0BZ"}
@@ -6,27 +6,29 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.timeoutPromise = exports.timeoutAwait = exports.defaultTimeoutDurationMs = void 0;
8
8
  exports.defaultTimeoutDurationMs = 250;
9
- // eslint-disable-next-line prefer-arrow/prefer-arrow-functions
10
9
  async function timeoutAwait(promise, timeoutOptions = {}) {
11
10
  return Promise.race([promise, timeoutPromise(() => { }, timeoutOptions)]);
12
11
  }
13
12
  exports.timeoutAwait = timeoutAwait;
14
13
  async function timeoutPromise(executor, timeoutOptions = {}) {
15
14
  var _a;
15
+ const timeout = timeoutOptions.durationMs !== undefined
16
+ && Number.isFinite(timeoutOptions.durationMs)
17
+ && timeoutOptions.durationMs > 0
18
+ ? timeoutOptions.durationMs : exports.defaultTimeoutDurationMs;
16
19
  // create the timeout error outside the async task, so it's callstack includes
17
20
  // the original call site, this makes it easier to debug
18
21
  const err = timeoutOptions.reject === false
19
22
  ? undefined
20
- : new Error((_a = timeoutOptions.errorMsg) !== null && _a !== void 0 ? _a : "Timeout");
21
- return new Promise((res, rej) => {
22
- var _a;
23
- const timeout = setTimeout(() => timeoutOptions.reject === false ? res(timeoutOptions.value) : rej(err), (_a = timeoutOptions.durationMs) !== null && _a !== void 0 ? _a : exports.defaultTimeoutDurationMs);
23
+ : new Error(`${(_a = timeoutOptions.errorMsg) !== null && _a !== void 0 ? _a : "Timed out"}(${timeout}ms)`);
24
+ return new Promise((resolve, reject) => {
25
+ const timer = setTimeout(() => timeoutOptions.reject === false ? resolve(timeoutOptions.value) : reject(err), timeout);
24
26
  executor((value) => {
25
- clearTimeout(timeout);
26
- res(value);
27
+ clearTimeout(timer);
28
+ resolve(value);
27
29
  }, (reason) => {
28
- clearTimeout(timeout);
29
- rej(reason);
30
+ clearTimeout(timer);
31
+ reject(reason);
30
32
  });
31
33
  });
32
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"timeoutUtils.js","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,wBAAwB,GAAG,GAAG,CAAC;AAa5C,+DAA+D;AACxD,KAAK,UAAU,YAAY,CAC9B,OAAuB,EACvB,iBAAyD,EAAE;IAE3D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAI,GAAE,EAAE,GAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC;AALD,oCAKC;AAEO,KAAK,UAAU,cAAc,CACjC,QAAgG,EAChG,iBAAyD,EAAE;;IAE3D,8EAA8E;IAC9E,wDAAwD;IACxD,MAAM,GAAG,GAAG,cAAc,CAAC,MAAM,KAAK,KAAK;QACvC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,IAAI,KAAK,OAAC,cAAc,CAAC,QAAQ,mCAAI,SAAS,CAAC,CAAC;IACtD,OAAO,IAAI,OAAO,CAAI,CAAC,GAAG,EAAC,GAAG,EAAC,EAAE;;QAC7B,MAAM,OAAO,GAAG,UAAU,CACtB,GAAE,EAAE,CAAA,cAAc,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,QAC1E,cAAc,CAAC,UAAU,mCAAI,gCAAwB,CAAC,CAAC;QAE3D,QAAQ,CACJ,CAAC,KAAK,EAAE,EAAE;YACN,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,GAAG,CAAC,KAAK,CAAC,CAAC;QACf,CAAC,EACD,CAAC,MAAM,EAAE,EAAE;YACP,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,GAAG,CAAC,MAAM,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC;AAxBA,wCAwBA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const defaultTimeoutDurationMs = 250;\n\n export interface TimeoutWithError{\n durationMs?: number;\n reject?: true;\n errorMsg?: string;\n }\n export interface TimeoutWithValue<T = void>{\n durationMs?: number;\n reject: false;\n value: T;\n }\n\n// eslint-disable-next-line prefer-arrow/prefer-arrow-functions\nexport async function timeoutAwait<T = void>(\n promise: PromiseLike<T>,\n timeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n) {\n return Promise.race([promise, timeoutPromise<T>(()=>{}, timeoutOptions)]);\n}\n\n export async function timeoutPromise<T = void>(\n executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void,\n timeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n // create the timeout error outside the async task, so it's callstack includes\n // the original call site, this makes it easier to debug\n const err = timeoutOptions.reject === false\n ? undefined\n : new Error(timeoutOptions.errorMsg ?? \"Timeout\");\n return new Promise<T>((res,rej)=>{\n const timeout = setTimeout(\n ()=>timeoutOptions.reject === false ? res(timeoutOptions.value) : rej(err),\n timeoutOptions.durationMs ?? defaultTimeoutDurationMs);\n\n executor(\n (value) => {\n clearTimeout(timeout);\n res(value);\n },\n (reason) => {\n clearTimeout(timeout);\n rej(reason);\n });\n });\n}\n"]}
1
+ {"version":3,"file":"timeoutUtils.js","sourceRoot":"","sources":["../src/timeoutUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,wBAAwB,GAAG,GAAG,CAAC;AAarC,KAAK,UAAU,YAAY,CAC9B,OAAuB,EACvB,iBAAyD,EAAE;IAE3D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAI,GAAG,EAAE,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC;AALD,oCAKC;AAEM,KAAK,UAAU,cAAc,CAChC,QAAgG,EAChG,iBAAyD,EAAE;;IAE3D,MAAM,OAAO,GACT,cAAc,CAAC,UAAU,KAAK,SAAS;WACpC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC;WAC1C,cAAc,CAAC,UAAU,GAAG,CAAC;QAC5B,CAAC,CAAE,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,gCAAwB,CAAC;IAChE,8EAA8E;IAC9E,wDAAwD;IACxD,MAAM,GAAG,GAAG,cAAc,CAAC,MAAM,KAAK,KAAK;QACvC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,MAAA,cAAc,CAAC,QAAQ,mCAAI,WAAW,IAAI,OAAO,KAAK,CAAC,CAAC;IAC3E,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAC,MAAM,EAAC,EAAE;QACpC,MAAM,KAAK,GAAG,UAAU,CACpB,GAAE,EAAE,CAAA,cAAc,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EACjF,OAAO,CAAC,CAAC;QAEb,QAAQ,CACJ,CAAC,KAAK,EAAE,EAAE;YACN,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC,EACD,CAAC,MAAM,EAAE,EAAE;YACP,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC;AA7BD,wCA6BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const defaultTimeoutDurationMs = 250;\n\nexport interface TimeoutWithError {\n durationMs?: number;\n reject?: true;\n errorMsg?: string;\n}\nexport interface TimeoutWithValue<T = void> {\n durationMs?: number;\n reject: false;\n value: T;\n}\n\nexport async function timeoutAwait<T = void>(\n promise: PromiseLike<T>,\n timeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n) {\n return Promise.race([promise, timeoutPromise<T>(() => { }, timeoutOptions)]);\n}\n\nexport async function timeoutPromise<T = void>(\n executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void,\n timeoutOptions: TimeoutWithError | TimeoutWithValue<T> = {},\n): Promise<T> {\n const timeout =\n timeoutOptions.durationMs !== undefined\n && Number.isFinite(timeoutOptions.durationMs)\n && timeoutOptions.durationMs > 0\n ? timeoutOptions.durationMs : defaultTimeoutDurationMs;\n // create the timeout error outside the async task, so it's callstack includes\n // the original call site, this makes it easier to debug\n const err = timeoutOptions.reject === false\n ? undefined\n : new Error(`${timeoutOptions.errorMsg ?? \"Timed out\"}(${timeout}ms)`);\n return new Promise<T>((resolve,reject)=>{\n const timer = setTimeout(\n ()=>timeoutOptions.reject === false ? resolve(timeoutOptions.value) : reject(err),\n timeout);\n\n executor(\n (value) => {\n clearTimeout(timer);\n resolve(value);\n },\n (reason) => {\n clearTimeout(timer);\n reject(reason);\n });\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/test-utils",
3
- "version": "0.54.2",
3
+ "version": "0.56.0-49831",
4
4
  "description": "Utilities for Fluid tests",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": "https://github.com/microsoft/FluidFramework",
@@ -21,7 +21,7 @@
21
21
  "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
22
22
  "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
23
23
  "eslint": "eslint --format stylish src",
24
- "eslint:fix": "eslint --format stylish src --fix",
24
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
25
25
  "lint": "npm run eslint",
26
26
  "lint:fix": "npm run eslint:fix",
27
27
  "tsc": "tsc",
@@ -49,51 +49,52 @@
49
49
  "temp-directory": "nyc/.nyc_output"
50
50
  },
51
51
  "dependencies": {
52
- "@fluidframework/aqueduct": "^0.54.2",
52
+ "@fluidframework/aqueduct": "0.56.0-49831",
53
53
  "@fluidframework/common-definitions": "^0.20.1",
54
54
  "@fluidframework/common-utils": "^0.32.1",
55
- "@fluidframework/container-definitions": "^0.44.0",
56
- "@fluidframework/container-loader": "^0.54.2",
57
- "@fluidframework/container-runtime": "^0.54.2",
58
- "@fluidframework/container-runtime-definitions": "^0.54.2",
59
- "@fluidframework/core-interfaces": "^0.41.0",
60
- "@fluidframework/datastore": "^0.54.2",
61
- "@fluidframework/datastore-definitions": "^0.54.2",
62
- "@fluidframework/driver-definitions": "^0.43.0",
63
- "@fluidframework/driver-utils": "^0.54.2",
64
- "@fluidframework/local-driver": "^0.54.2",
65
- "@fluidframework/map": "^0.54.2",
55
+ "@fluidframework/container-definitions": "^0.45.0-0",
56
+ "@fluidframework/container-loader": "0.56.0-49831",
57
+ "@fluidframework/container-runtime": "0.56.0-49831",
58
+ "@fluidframework/container-runtime-definitions": "0.56.0-49831",
59
+ "@fluidframework/core-interfaces": "^0.42.0-0",
60
+ "@fluidframework/datastore": "0.56.0-49831",
61
+ "@fluidframework/datastore-definitions": "0.56.0-49831",
62
+ "@fluidframework/driver-definitions": "^0.44.0-0",
63
+ "@fluidframework/driver-utils": "0.56.0-49831",
64
+ "@fluidframework/local-driver": "0.56.0-49831",
65
+ "@fluidframework/map": "0.56.0-49831",
66
66
  "@fluidframework/protocol-definitions": "^0.1026.0",
67
- "@fluidframework/request-handler": "^0.54.2",
68
- "@fluidframework/routerlicious-driver": "^0.54.2",
69
- "@fluidframework/runtime-definitions": "^0.54.2",
70
- "@fluidframework/runtime-utils": "^0.54.2",
71
- "@fluidframework/telemetry-utils": "^0.54.2",
72
- "@fluidframework/test-driver-definitions": "^0.54.2",
73
- "@fluidframework/test-runtime-utils": "^0.54.2",
67
+ "@fluidframework/request-handler": "0.56.0-49831",
68
+ "@fluidframework/routerlicious-driver": "0.56.0-49831",
69
+ "@fluidframework/runtime-definitions": "0.56.0-49831",
70
+ "@fluidframework/runtime-utils": "0.56.0-49831",
71
+ "@fluidframework/telemetry-utils": "0.56.0-49831",
72
+ "@fluidframework/test-driver-definitions": "0.56.0-49831",
73
+ "@fluidframework/test-runtime-utils": "0.56.0-49831",
74
74
  "debug": "^4.1.1",
75
75
  "uuid": "^8.3.1"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@fluidframework/build-common": "^0.23.0",
79
- "@fluidframework/eslint-config-fluid": "^0.24.0",
79
+ "@fluidframework/eslint-config-fluid": "^0.25.0",
80
80
  "@microsoft/api-extractor": "^7.16.1",
81
+ "@rushstack/eslint-config": "^2.5.1",
81
82
  "@types/diff": "^3.5.1",
82
83
  "@types/mocha": "^8.2.2",
83
84
  "@types/node": "^14.18.0",
84
85
  "@types/random-js": "^1.0.31",
85
- "@typescript-eslint/eslint-plugin": "~4.14.0",
86
- "@typescript-eslint/parser": "~4.14.0",
86
+ "@typescript-eslint/eslint-plugin": "~5.9.0",
87
+ "@typescript-eslint/parser": "~5.9.0",
87
88
  "concurrently": "^6.2.0",
88
89
  "copyfiles": "^2.1.0",
89
90
  "diff": "^3.5.0",
90
- "eslint": "~7.18.0",
91
+ "eslint": "~8.6.0",
92
+ "eslint-plugin-editorconfig": "~3.2.0",
91
93
  "eslint-plugin-eslint-comments": "~3.2.0",
92
- "eslint-plugin-import": "~2.22.1",
94
+ "eslint-plugin-import": "~2.25.4",
93
95
  "eslint-plugin-no-null": "~1.0.2",
94
- "eslint-plugin-prefer-arrow": "~1.2.2",
95
- "eslint-plugin-react": "~7.22.0",
96
- "eslint-plugin-unicorn": "~26.0.1",
96
+ "eslint-plugin-react": "~7.28.0",
97
+ "eslint-plugin-unicorn": "~40.0.0",
97
98
  "mocha": "^8.4.0",
98
99
  "nyc": "^15.0.0",
99
100
  "random-js": "^1.0.8",
@@ -47,11 +47,8 @@ export class LoaderContainerTracker implements IOpProcessingController {
47
47
  return container;
48
48
  };
49
49
  };
50
- // eslint-disable-next-line @typescript-eslint/unbound-method
51
50
  loader.resolve = patch(loader.resolve);
52
- // eslint-disable-next-line @typescript-eslint/unbound-method
53
51
  loader.createDetachedContainer = patch(loader.createDetachedContainer);
54
- // eslint-disable-next-line @typescript-eslint/unbound-method
55
52
  loader.rehydrateDetachedContainerFromSnapshot = patch(loader.rehydrateDetachedContainerFromSnapshot);
56
53
  }
57
54
 
@@ -126,7 +123,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
126
123
  }
127
124
 
128
125
  private trackLastProposal(container: IContainer) {
129
- container.getQuorum().on("addProposal", (proposal) => {
126
+ container.on("codeDetailsProposed", (value, proposal) => {
130
127
  if (proposal.sequenceNumber > this.lastProposalSeqNum) {
131
128
  this.lastProposalSeqNum = proposal.sequenceNumber;
132
129
  }
@@ -192,11 +189,11 @@ export class LoaderContainerTracker implements IOpProcessingController {
192
189
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
193
190
  debugWait(`Waiting container to be saved ${dirtyContainers.map((c) => this.containers.get(c)!.index)}`);
194
191
  waitingSequenceNumberSynchronized = false;
195
- await Promise.all(dirtyContainers.map(async (c) => new Promise((res) => c.once("saved", res))));
192
+ await Promise.all(dirtyContainers.map(async (c) => new Promise((resolve) => c.once("saved", resolve))));
196
193
  }
197
194
 
198
195
  // yield a turn to allow side effect of the ops we just processed execute before we check again
199
- await new Promise<void>((res) => { setTimeout(res, 0); });
196
+ await new Promise<void>((resolve) => { setTimeout(resolve, 0); });
200
197
  }
201
198
 
202
199
  // Pause all container that was resumed
@@ -299,7 +296,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
299
296
  const unconnectedClients =
300
297
  Array.from(this.containers.keys()).filter((c) => !c.closed && !(c as Container).connected);
301
298
  return Promise.all(pendingClients.map(async ([container, pendingClientId]) => {
302
- return new Promise<void>((res) => {
299
+ return new Promise<void>((resolve) => {
303
300
  const cleanup = () => {
304
301
  unconnectedClients.forEach((c) => c.off("connected", handler));
305
302
  container.getQuorum().off("removeMember", handler);
@@ -308,7 +305,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
308
305
  pendingClientId.delete(clientId);
309
306
  if (pendingClientId.size === 0) {
310
307
  cleanup();
311
- res();
308
+ resolve();
312
309
  }
313
310
  };
314
311
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -318,7 +315,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
318
315
  container.getQuorum().on("removeMember", handler);
319
316
  container.on("closed", () => {
320
317
  cleanup();
321
- res();
318
+ resolve();
322
319
  });
323
320
  });
324
321
  }));
@@ -329,12 +326,12 @@ export class LoaderContainerTracker implements IOpProcessingController {
329
326
  * @param containersToApply - the set of containers to wait for any inbound ops for
330
327
  */
331
328
  private async waitForAnyInboundOps(containersToApply: IContainer[]) {
332
- return new Promise<void>((res) => {
329
+ return new Promise<void>((resolve) => {
333
330
  const handler = () => {
334
331
  containersToApply.map((c) => {
335
332
  c.deltaManager.inbound.off("push", handler);
336
333
  });
337
- res();
334
+ resolve();
338
335
  };
339
336
  containersToApply.map((c) => {
340
337
  c.deltaManager.inbound.on("push", handler);
@@ -420,7 +417,7 @@ export class LoaderContainerTracker implements IOpProcessingController {
420
417
 
421
418
  while (resumed.some((queue) => !queue.idle)) {
422
419
  debugWait("Wait until queue is idle");
423
- await new Promise<void>((res) => { setTimeout(res, 0); });
420
+ await new Promise<void>((resolve) => { setTimeout(resolve, 0); });
424
421
  }
425
422
 
426
423
  // Make sure all the op that we sent out are acked first
@@ -10,8 +10,9 @@ import {
10
10
  IProvideRuntimeFactory,
11
11
  IFluidModule,
12
12
  } from "@fluidframework/container-definitions";
13
- import { IFluidCodeDetails, IProvideFluidCodeDetailsComparer } from "@fluidframework/core-interfaces";
14
- import { IProvideFluidDataStoreFactory, IProvideFluidDataStoreRegistry } from "@fluidframework/runtime-definitions";
13
+ import { IFluidCodeDetails, IProvideFluidCodeDetailsComparer, IRequest } from "@fluidframework/core-interfaces";
14
+ import { IContainerRuntimeBase, IProvideFluidDataStoreFactory,
15
+ IProvideFluidDataStoreRegistry } from "@fluidframework/runtime-definitions";
15
16
  import { createDataStoreFactory } from "@fluidframework/runtime-utils";
16
17
  import { IContainerRuntimeOptions } from "@fluidframework/container-runtime";
17
18
 
@@ -56,6 +57,8 @@ export class LocalCodeLoader implements ICodeLoader {
56
57
  } else {
57
58
  assert(maybeExport.IFluidDataStoreFactory !== undefined);
58
59
  const defaultFactory = createDataStoreFactory("default", maybeExport.IFluidDataStoreFactory);
60
+ const innerRequestHandler = async (request: IRequest, runtime: IContainerRuntimeBase) =>
61
+ runtime.IFluidHandleContext.resolveHandle(request);
59
62
  fluidModule = {
60
63
  fluidExport: {
61
64
  ... maybeExport,
@@ -64,7 +67,7 @@ export class LocalCodeLoader implements ICodeLoader {
64
67
  defaultFactory,
65
68
  [[defaultFactory.type, Promise.resolve(defaultFactory)]],
66
69
  undefined,
67
- undefined,
70
+ [innerRequestHandler],
68
71
  runtimeOptions,
69
72
  ),
70
73
  },
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/test-utils";
9
- export const pkgVersion = "0.54.2";
9
+ export const pkgVersion = "0.56.0-49831";
@@ -7,7 +7,9 @@ import { defaultRouteRequestHandler } from "@fluidframework/aqueduct";
7
7
  import { IContainerContext, IRuntime } from "@fluidframework/container-definitions";
8
8
  import { ContainerRuntime, IContainerRuntimeOptions } from "@fluidframework/container-runtime";
9
9
  import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
10
- import { innerRequestHandler, RuntimeRequestHandlerBuilder } from "@fluidframework/request-handler";
10
+ import {
11
+ buildRuntimeRequestHandler,
12
+ RuntimeRequestHandler } from "@fluidframework/request-handler";
11
13
  import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
12
14
  import { RuntimeFactoryHelper } from "@fluidframework/runtime-utils";
13
15
 
@@ -22,6 +24,7 @@ export const createTestContainerRuntimeFactory = (containerRuntimeCtor: typeof C
22
24
  public runtimeOptions: IContainerRuntimeOptions = {
23
25
  summaryOptions: { initialSummarizerDelayMs: 0 },
24
26
  },
27
+ public requestHandlers: RuntimeRequestHandler[] = [],
25
28
  ) {
26
29
  super();
27
30
  }
@@ -46,18 +49,16 @@ export const createTestContainerRuntimeFactory = (containerRuntimeCtor: typeof C
46
49
  context: IContainerContext,
47
50
  existing: boolean,
48
51
  ): Promise<IRuntime & IContainerRuntime> {
49
- const builder = new RuntimeRequestHandlerBuilder();
50
- builder.pushHandler(
51
- defaultRouteRequestHandler("default"),
52
- innerRequestHandler);
53
-
54
52
  const runtime: ContainerRuntime = await containerRuntimeCtor.load(
55
53
  context,
56
54
  [
57
55
  ["default", Promise.resolve(this.dataStoreFactory)],
58
56
  [this.type, Promise.resolve(this.dataStoreFactory)],
59
57
  ],
60
- async (req, rt) => builder.handleRequest(req, rt),
58
+ buildRuntimeRequestHandler(
59
+ defaultRouteRequestHandler("default"),
60
+ ...this.requestHandlers,
61
+ ),
61
62
  this.runtimeOptions,
62
63
  undefined, // containerScope
63
64
  existing,
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IContainer, IHostLoader, ILoaderOptions } from "@fluidframework/container-definitions";
6
+ import { IContainer, IHostLoader } from "@fluidframework/container-definitions";
7
7
  import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
8
- import { IDetachedBlobStorage, Loader, waitContainerToCatchUp } from "@fluidframework/container-loader";
8
+ import { ILoaderProps, Loader, waitContainerToCatchUp } from "@fluidframework/container-loader";
9
9
  import { IContainerRuntimeOptions } from "@fluidframework/container-runtime";
10
10
  import { IFluidCodeDetails, IRequestHeader } from "@fluidframework/core-interfaces";
11
11
  import { IDocumentServiceFactory, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
@@ -34,13 +34,12 @@ export interface ITestObjectProvider {
34
34
  createFluidEntryPoint: (testContainerConfig?: ITestContainerConfig) => fluidEntryPoint;
35
35
  createLoader(
36
36
  packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,
37
- options?: ITestLoaderOptions,
38
- detachedBlobStorage?: IDetachedBlobStorage,
37
+ loaderProps?: Partial<ILoaderProps>,
39
38
  ): IHostLoader;
40
- createContainer(entryPoint: fluidEntryPoint, options?: ITestLoaderOptions): Promise<IContainer>;
39
+ createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>): Promise<IContainer>;
41
40
  loadContainer(
42
41
  entryPoint: fluidEntryPoint,
43
- options?: ITestLoaderOptions,
42
+ loaderProps?: Partial<ILoaderProps>,
44
43
  requestHeader?: IRequestHeader,
45
44
  ): Promise<IContainer>;
46
45
 
@@ -48,7 +47,7 @@ export interface ITestObjectProvider {
48
47
  * Used to create a test Container. The Loader/ContainerRuntime/DataRuntime might be different versioned.
49
48
  * In generateLocalCompatTest(), this Container and its runtime will be arbitrarily-versioned.
50
49
  */
51
- makeTestLoader(testContainerConfig?: ITestContainerConfig, detachedBlobStorage?: IDetachedBlobStorage): IHostLoader,
50
+ makeTestLoader(testContainerConfig?: ITestContainerConfig): IHostLoader,
52
51
  makeTestContainer(testContainerConfig?: ITestContainerConfig): Promise<IContainer>,
53
52
  loadTestContainer(testContainerConfig?: ITestContainerConfig, requestHeader?: IRequestHeader): Promise<IContainer>,
54
53
  /**
@@ -86,12 +85,7 @@ export interface ITestContainerConfig {
86
85
  runtimeOptions?: IContainerRuntimeOptions,
87
86
 
88
87
  /** Loader options for the loader used to create containers */
89
- loaderOptions?: ITestLoaderOptions,
90
- }
91
-
92
- // new interface to help inject custom loggers to tests
93
- export interface ITestLoaderOptions extends ILoaderOptions {
94
- logger?: ITelemetryBaseLogger;
88
+ loaderProps?: Partial<ILoaderProps>,
95
89
  }
96
90
 
97
91
  export const createDocumentId = (): string => uuid();
@@ -131,7 +125,7 @@ function getDocumentIdStrategy(type?: TestDriverTypes): IDocumentIdStrategy {
131
125
  /**
132
126
  * Shared base class for test object provider. Contain code for loader and container creation and loading
133
127
  */
134
- export class TestObjectProvider {
128
+ export class TestObjectProvider implements ITestObjectProvider {
135
129
  private readonly _loaderContainerTracker = new LoaderContainerTracker();
136
130
  private _documentServiceFactory: IDocumentServiceFactory | undefined;
137
131
  private _urlResolver: IUrlResolver | undefined;
@@ -204,23 +198,20 @@ export class TestObjectProvider {
204
198
  */
205
199
  public createLoader(
206
200
  packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,
207
- options?: ITestLoaderOptions,
208
- detachedBlobStorage?: IDetachedBlobStorage,
201
+ loaderProps?: Partial<ILoaderProps>,
209
202
  ) {
210
203
  const multiSinkLogger = new MultiSinkLogger();
211
204
  multiSinkLogger.addLogger(this.logger);
212
- if (options?.logger !== undefined) {
213
- multiSinkLogger.addLogger(options.logger);
205
+ if (loaderProps?.logger !== undefined) {
206
+ multiSinkLogger.addLogger(loaderProps.logger);
214
207
  }
215
208
 
216
- const codeLoader = new LocalCodeLoader(packageEntries);
217
209
  const loader = new this.LoaderConstructor({
218
- urlResolver: this.urlResolver,
219
- documentServiceFactory: this.documentServiceFactory,
220
- codeLoader,
210
+ ... loaderProps,
221
211
  logger: multiSinkLogger,
222
- options,
223
- detachedBlobStorage,
212
+ codeLoader: loaderProps?.codeLoader ?? new LocalCodeLoader(packageEntries),
213
+ urlResolver: loaderProps?.urlResolver ?? this.urlResolver,
214
+ documentServiceFactory: loaderProps?.documentServiceFactory ?? this.documentServiceFactory,
224
215
  });
225
216
  this._loaderContainerTracker.add(loader);
226
217
  return loader;
@@ -235,12 +226,12 @@ export class TestObjectProvider {
235
226
  *
236
227
  * @param packageEntries - list of code details and fluidEntryPoint pairs.
237
228
  */
238
- public async createContainer(entryPoint: fluidEntryPoint, options?: ITestLoaderOptions) {
229
+ public async createContainer(entryPoint: fluidEntryPoint, loaderProps?: Partial<ILoaderProps>) {
239
230
  if (this._documentCreated) {
240
231
  throw new Error(
241
232
  "Only one container/document can be created. To load the container/document use loadContainer");
242
233
  }
243
- const loader = this.createLoader([[defaultCodeDetails, entryPoint]], options);
234
+ const loader = this.createLoader([[defaultCodeDetails, entryPoint]], loaderProps);
244
235
  const container = await createAndAttachContainer(
245
236
  defaultCodeDetails,
246
237
  loader,
@@ -253,9 +244,11 @@ export class TestObjectProvider {
253
244
  return container;
254
245
  }
255
246
 
256
- public async loadContainer(entryPoint: fluidEntryPoint, options?: ITestLoaderOptions,
247
+ public async loadContainer(
248
+ entryPoint: fluidEntryPoint,
249
+ loaderProps?: Partial<ILoaderProps>,
257
250
  requestHeader?: IRequestHeader): Promise<IContainer> {
258
- const loader = this.createLoader([[defaultCodeDetails, entryPoint]], options);
251
+ const loader = this.createLoader([[defaultCodeDetails, entryPoint]], loaderProps);
259
252
  return loader.resolve({ url: await this.driver.createContainerUrl(this.documentId), headers: requestHeader });
260
253
  }
261
254
 
@@ -264,11 +257,10 @@ export class TestObjectProvider {
264
257
  * The version of the loader/containerRuntime/dataRuntime may vary based on compat config of the current run
265
258
  * @param testContainerConfig - optional configuring the test Container
266
259
  */
267
- public makeTestLoader(testContainerConfig?: ITestContainerConfig, detachedBlobStorage?: IDetachedBlobStorage) {
260
+ public makeTestLoader(testContainerConfig?: ITestContainerConfig) {
268
261
  return this.createLoader(
269
262
  [[defaultCodeDetails, this.createFluidEntryPoint(testContainerConfig)]],
270
- testContainerConfig?.loaderOptions,
271
- detachedBlobStorage,
263
+ testContainerConfig?.loaderProps,
272
264
  );
273
265
  }
274
266