@fluidframework/test-utils 2.0.0-rc.1.0.4 → 2.0.0-rc.2.0.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.
Files changed (151) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +4 -1
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +34 -0
  4. package/README.md +1 -1
  5. package/api-extractor-cjs.json +8 -0
  6. package/api-extractor-lint.json +1 -1
  7. package/api-extractor.json +1 -1
  8. package/api-report/test-utils.api.md +27 -9
  9. package/dist/DriverWrappers.d.ts +3 -0
  10. package/dist/DriverWrappers.d.ts.map +1 -1
  11. package/dist/DriverWrappers.js +3 -0
  12. package/dist/DriverWrappers.js.map +1 -1
  13. package/dist/TestConfigs.d.ts +14 -1
  14. package/dist/TestConfigs.d.ts.map +1 -1
  15. package/dist/TestConfigs.js +14 -3
  16. package/dist/TestConfigs.js.map +1 -1
  17. package/dist/TestSummaryUtils.d.ts +7 -2
  18. package/dist/TestSummaryUtils.d.ts.map +1 -1
  19. package/dist/TestSummaryUtils.js +39 -14
  20. package/dist/TestSummaryUtils.js.map +1 -1
  21. package/dist/containerUtils.d.ts +1 -1
  22. package/dist/containerUtils.d.ts.map +1 -1
  23. package/dist/containerUtils.js +2 -2
  24. package/dist/containerUtils.js.map +1 -1
  25. package/dist/debug.js +2 -2
  26. package/dist/debug.js.map +1 -1
  27. package/dist/index.d.ts +14 -14
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +44 -43
  30. package/dist/index.js.map +1 -1
  31. package/dist/loaderContainerTracker.d.ts +1 -1
  32. package/dist/loaderContainerTracker.d.ts.map +1 -1
  33. package/dist/loaderContainerTracker.js +11 -11
  34. package/dist/loaderContainerTracker.js.map +1 -1
  35. package/dist/localLoader.d.ts +1 -1
  36. package/dist/localLoader.d.ts.map +1 -1
  37. package/dist/localLoader.js +2 -2
  38. package/dist/localLoader.js.map +1 -1
  39. package/dist/package.json +3 -0
  40. package/dist/packageVersion.d.ts +1 -1
  41. package/dist/packageVersion.js +1 -1
  42. package/dist/packageVersion.js.map +1 -1
  43. package/dist/test-utils-alpha.d.ts +7 -3
  44. package/dist/test-utils-beta.d.ts +9 -3
  45. package/dist/test-utils-public.d.ts +9 -3
  46. package/dist/test-utils-untrimmed.d.ts +59 -14
  47. package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
  48. package/dist/testContainerRuntimeFactory.js +9 -2
  49. package/dist/testContainerRuntimeFactory.js.map +1 -1
  50. package/dist/testFluidObject.d.ts +1 -1
  51. package/dist/testFluidObject.d.ts.map +1 -1
  52. package/dist/testFluidObject.js.map +1 -1
  53. package/dist/testObjectProvider.d.ts +34 -11
  54. package/dist/testObjectProvider.d.ts.map +1 -1
  55. package/dist/testObjectProvider.js +71 -38
  56. package/dist/testObjectProvider.js.map +1 -1
  57. package/dist/timeoutUtils.d.ts.map +1 -1
  58. package/dist/timeoutUtils.js.map +1 -1
  59. package/dist/tsdoc-metadata.json +1 -1
  60. package/lib/DriverWrappers.d.ts +35 -0
  61. package/lib/DriverWrappers.d.ts.map +1 -0
  62. package/lib/DriverWrappers.js +54 -0
  63. package/lib/DriverWrappers.js.map +1 -0
  64. package/lib/TestConfigs.d.ts +23 -0
  65. package/lib/TestConfigs.d.ts.map +1 -0
  66. package/lib/TestConfigs.js +24 -0
  67. package/lib/TestConfigs.js.map +1 -0
  68. package/lib/TestSummaryUtils.d.ts +66 -0
  69. package/lib/TestSummaryUtils.d.ts.map +1 -0
  70. package/lib/TestSummaryUtils.js +153 -0
  71. package/lib/TestSummaryUtils.js.map +1 -0
  72. package/lib/containerUtils.d.ts +46 -0
  73. package/lib/containerUtils.d.ts.map +1 -0
  74. package/lib/containerUtils.js +79 -0
  75. package/lib/containerUtils.js.map +1 -0
  76. package/lib/debug.d.ts +7 -0
  77. package/lib/debug.d.ts.map +1 -0
  78. package/lib/debug.js +9 -0
  79. package/lib/debug.js.map +1 -0
  80. package/lib/index.d.ts +19 -0
  81. package/lib/index.d.ts.map +1 -0
  82. package/lib/index.js +18 -0
  83. package/lib/index.js.map +1 -0
  84. package/lib/interfaces.d.ts +25 -0
  85. package/lib/interfaces.d.ts.map +1 -0
  86. package/lib/interfaces.js +6 -0
  87. package/lib/interfaces.js.map +1 -0
  88. package/lib/loaderContainerTracker.d.ts +144 -0
  89. package/lib/loaderContainerTracker.d.ts.map +1 -0
  90. package/lib/loaderContainerTracker.js +631 -0
  91. package/lib/loaderContainerTracker.js.map +1 -0
  92. package/lib/localCodeLoader.d.ts +31 -0
  93. package/lib/localCodeLoader.d.ts.map +1 -0
  94. package/lib/localCodeLoader.js +73 -0
  95. package/lib/localCodeLoader.js.map +1 -0
  96. package/lib/localLoader.d.ts +26 -0
  97. package/lib/localLoader.d.ts.map +1 -0
  98. package/lib/localLoader.js +37 -0
  99. package/lib/localLoader.js.map +1 -0
  100. package/lib/packageVersion.d.ts +9 -0
  101. package/lib/packageVersion.d.ts.map +1 -0
  102. package/lib/packageVersion.js +9 -0
  103. package/lib/packageVersion.js.map +1 -0
  104. package/lib/retry.d.ts +18 -0
  105. package/lib/retry.d.ts.map +1 -0
  106. package/lib/retry.js +37 -0
  107. package/lib/retry.js.map +1 -0
  108. package/lib/test/timeoutUtils.spec.js +165 -0
  109. package/lib/test/timeoutUtils.spec.js.map +1 -0
  110. package/lib/test/types/validateTestUtilsPrevious.generated.js +90 -0
  111. package/lib/test/types/validateTestUtilsPrevious.generated.js.map +1 -0
  112. package/lib/test-utils-alpha.d.ts +309 -0
  113. package/lib/test-utils-beta.d.ts +208 -0
  114. package/lib/test-utils-public.d.ts +208 -0
  115. package/lib/test-utils-untrimmed.d.ts +1046 -0
  116. package/lib/testContainerRuntimeFactory.d.ts +46 -0
  117. package/lib/testContainerRuntimeFactory.d.ts.map +1 -0
  118. package/lib/testContainerRuntimeFactory.js +113 -0
  119. package/lib/testContainerRuntimeFactory.js.map +1 -0
  120. package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +23 -0
  121. package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -0
  122. package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js +28 -0
  123. package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -0
  124. package/lib/testFluidObject.d.ts +92 -0
  125. package/lib/testFluidObject.d.ts.map +1 -0
  126. package/lib/testFluidObject.js +159 -0
  127. package/lib/testFluidObject.js.map +1 -0
  128. package/lib/testObjectProvider.d.ts +435 -0
  129. package/lib/testObjectProvider.d.ts.map +1 -0
  130. package/lib/testObjectProvider.js +636 -0
  131. package/lib/testObjectProvider.js.map +1 -0
  132. package/lib/timeoutUtils.d.ts +60 -0
  133. package/lib/timeoutUtils.d.ts.map +1 -0
  134. package/lib/timeoutUtils.js +164 -0
  135. package/lib/timeoutUtils.js.map +1 -0
  136. package/package.json +105 -38
  137. package/src/DriverWrappers.ts +3 -0
  138. package/src/TestConfigs.ts +25 -3
  139. package/src/TestSummaryUtils.ts +36 -12
  140. package/src/containerUtils.ts +1 -1
  141. package/src/debug.ts +1 -1
  142. package/src/index.ts +19 -14
  143. package/src/loaderContainerTracker.ts +5 -5
  144. package/src/localLoader.ts +1 -1
  145. package/src/packageVersion.ts +1 -1
  146. package/src/testContainerRuntimeFactory.ts +12 -2
  147. package/src/testFluidObject.ts +1 -1
  148. package/src/testObjectProvider.ts +99 -34
  149. package/src/timeoutUtils.ts +1 -0
  150. package/tsconfig.cjs.json +7 -0
  151. package/tsconfig.json +3 -4
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IDocumentService, IDocumentServiceFactory, IDocumentStorageService, ISummaryContext } from "@fluidframework/driver-definitions";
6
+ import { ISummaryTree } from "@fluidframework/protocol-definitions";
7
+ /**
8
+ * @deprecated - unused
9
+ * Wraps the given IDocumentStorageService to override the `uploadSummaryWithContext` method. It calls the
10
+ * `uploadSummaryCb` whenever a summary is uploaded by the client. The summary context can be updated in the
11
+ * callback before it is uploaded to the server.
12
+ * @internal
13
+ */
14
+ export declare function wrapDocumentStorageService(innerDocStorageService: IDocumentStorageService, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentStorageService;
15
+ /**
16
+ * @deprecated - unused
17
+ * Wraps the given IDocumentService to override the `connectToStorage` method. The intent is to plumb the
18
+ * `uploadSummaryCb` to the IDocumentStorageService so that it is called whenever a summary is uploaded by
19
+ * the client.
20
+ * The document storage service that is created in `connectToStorage` is wrapped by calling `wrapDocumentStorageService`
21
+ * to pass in the `uploadSummaryCb`.
22
+ * @internal
23
+ */
24
+ export declare function wrapDocumentService(innerDocService: IDocumentService, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentService;
25
+ /**
26
+ * @deprecated - unused
27
+ * Wraps the given IDocumentServiceFactory to override the `createDocumentService` method. The intent is to plumb
28
+ * the `uploadSummaryCb` all the way to the IDocumentStorageService so that it is called whenever a summary is
29
+ * uploaded by the client.
30
+ * The document service that is created in `createDocumentService` is wrapped by calling `wrapDocumentService` to
31
+ * pass in the `uploadSummaryCb`.
32
+ * @internal
33
+ */
34
+ export declare function wrapDocumentServiceFactory(innerDocServiceFactory: IDocumentServiceFactory, uploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext): IDocumentServiceFactory;
35
+ //# sourceMappingURL=DriverWrappers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DriverWrappers.d.ts","sourceRoot":"","sources":["../src/DriverWrappers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EAEvB,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACzC,sBAAsB,EAAE,uBAAuB,EAC/C,eAAe,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,KAAK,eAAe,2BAWzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAClC,eAAe,EAAE,gBAAgB,EACjC,eAAe,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,KAAK,eAAe,oBAQzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACzC,sBAAsB,EAAE,uBAAuB,EAC/C,eAAe,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,KAAK,eAAe,2BAgBzF"}
@@ -0,0 +1,54 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * @deprecated - unused
7
+ * Wraps the given IDocumentStorageService to override the `uploadSummaryWithContext` method. It calls the
8
+ * `uploadSummaryCb` whenever a summary is uploaded by the client. The summary context can be updated in the
9
+ * callback before it is uploaded to the server.
10
+ * @internal
11
+ */
12
+ export function wrapDocumentStorageService(innerDocStorageService, uploadSummaryCb) {
13
+ const outerDocStorageService = Object.create(innerDocStorageService);
14
+ outerDocStorageService.uploadSummaryWithContext = async (summary, context) => {
15
+ const newContext = uploadSummaryCb(summary, context);
16
+ return innerDocStorageService.uploadSummaryWithContext(summary, newContext);
17
+ };
18
+ return outerDocStorageService;
19
+ }
20
+ /**
21
+ * @deprecated - unused
22
+ * Wraps the given IDocumentService to override the `connectToStorage` method. The intent is to plumb the
23
+ * `uploadSummaryCb` to the IDocumentStorageService so that it is called whenever a summary is uploaded by
24
+ * the client.
25
+ * The document storage service that is created in `connectToStorage` is wrapped by calling `wrapDocumentStorageService`
26
+ * to pass in the `uploadSummaryCb`.
27
+ * @internal
28
+ */
29
+ export function wrapDocumentService(innerDocService, uploadSummaryCb) {
30
+ const outerDocService = Object.create(innerDocService);
31
+ outerDocService.connectToStorage = async () => {
32
+ const storageService = await innerDocService.connectToStorage();
33
+ return wrapDocumentStorageService(storageService, uploadSummaryCb);
34
+ };
35
+ return outerDocService;
36
+ }
37
+ /**
38
+ * @deprecated - unused
39
+ * Wraps the given IDocumentServiceFactory to override the `createDocumentService` method. The intent is to plumb
40
+ * the `uploadSummaryCb` all the way to the IDocumentStorageService so that it is called whenever a summary is
41
+ * uploaded by the client.
42
+ * The document service that is created in `createDocumentService` is wrapped by calling `wrapDocumentService` to
43
+ * pass in the `uploadSummaryCb`.
44
+ * @internal
45
+ */
46
+ export function wrapDocumentServiceFactory(innerDocServiceFactory, uploadSummaryCb) {
47
+ const outerDocServiceFactory = Object.create(innerDocServiceFactory);
48
+ outerDocServiceFactory.createDocumentService = async (resolvedUrl, logger, clientIsSummarizer) => {
49
+ const documentService = await innerDocServiceFactory.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
50
+ return wrapDocumentService(documentService, uploadSummaryCb);
51
+ };
52
+ return outerDocServiceFactory;
53
+ }
54
+ //# sourceMappingURL=DriverWrappers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DriverWrappers.js","sourceRoot":"","sources":["../src/DriverWrappers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACzC,sBAA+C,EAC/C,eAAyF;IAEzF,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAA4B,CAAC;IAChG,sBAAsB,CAAC,wBAAwB,GAAG,KAAK,EACtD,OAAqB,EACrB,OAAwB,EACN,EAAE;QACpB,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrD,OAAO,sBAAsB,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC7E,CAAC,CAAC;IACF,OAAO,sBAAsB,CAAC;AAC/B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAClC,eAAiC,EACjC,eAAyF;IAEzF,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAqB,CAAC;IAC3E,eAAe,CAAC,gBAAgB,GAAG,KAAK,IAAsC,EAAE;QAC/E,MAAM,cAAc,GAAG,MAAM,eAAe,CAAC,gBAAgB,EAAE,CAAC;QAChE,OAAO,0BAA0B,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;IACpE,CAAC,CAAC;IACF,OAAO,eAAe,CAAC;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACzC,sBAA+C,EAC/C,eAAyF;IAEzF,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAA4B,CAAC;IAChG,sBAAsB,CAAC,qBAAqB,GAAG,KAAK,EACnD,WAAyB,EACzB,MAA6B,EAC7B,kBAA4B,EACA,EAAE;QAC9B,MAAM,eAAe,GAAG,MAAM,sBAAsB,CAAC,qBAAqB,CACzE,WAAW,EACX,MAAM,EACN,kBAAkB,CAClB,CAAC;QACF,OAAO,mBAAmB,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;IAC9D,CAAC,CAAC;IACF,OAAO,sBAAsB,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\n\n/**\n * @deprecated - unused\n * Wraps the given IDocumentStorageService to override the `uploadSummaryWithContext` method. It calls the\n * `uploadSummaryCb` whenever a summary is uploaded by the client. The summary context can be updated in the\n * callback before it is uploaded to the server.\n * @internal\n */\nexport function wrapDocumentStorageService(\n\tinnerDocStorageService: IDocumentStorageService,\n\tuploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext,\n) {\n\tconst outerDocStorageService = Object.create(innerDocStorageService) as IDocumentStorageService;\n\touterDocStorageService.uploadSummaryWithContext = async (\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> => {\n\t\tconst newContext = uploadSummaryCb(summary, context);\n\t\treturn innerDocStorageService.uploadSummaryWithContext(summary, newContext);\n\t};\n\treturn outerDocStorageService;\n}\n\n/**\n * @deprecated - unused\n * Wraps the given IDocumentService to override the `connectToStorage` method. The intent is to plumb the\n * `uploadSummaryCb` to the IDocumentStorageService so that it is called whenever a summary is uploaded by\n * the client.\n * The document storage service that is created in `connectToStorage` is wrapped by calling `wrapDocumentStorageService`\n * to pass in the `uploadSummaryCb`.\n * @internal\n */\nexport function wrapDocumentService(\n\tinnerDocService: IDocumentService,\n\tuploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext,\n) {\n\tconst outerDocService = Object.create(innerDocService) as IDocumentService;\n\touterDocService.connectToStorage = async (): Promise<IDocumentStorageService> => {\n\t\tconst storageService = await innerDocService.connectToStorage();\n\t\treturn wrapDocumentStorageService(storageService, uploadSummaryCb);\n\t};\n\treturn outerDocService;\n}\n\n/**\n * @deprecated - unused\n * Wraps the given IDocumentServiceFactory to override the `createDocumentService` method. The intent is to plumb\n * the `uploadSummaryCb` all the way to the IDocumentStorageService so that it is called whenever a summary is\n * uploaded by the client.\n * The document service that is created in `createDocumentService` is wrapped by calling `wrapDocumentService` to\n * pass in the `uploadSummaryCb`.\n * @internal\n */\nexport function wrapDocumentServiceFactory(\n\tinnerDocServiceFactory: IDocumentServiceFactory,\n\tuploadSummaryCb: (summaryTree: ISummaryTree, context: ISummaryContext) => ISummaryContext,\n) {\n\tconst outerDocServiceFactory = Object.create(innerDocServiceFactory) as IDocumentServiceFactory;\n\touterDocServiceFactory.createDocumentService = async (\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> => {\n\t\tconst documentService = await innerDocServiceFactory.createDocumentService(\n\t\t\tresolvedUrl,\n\t\t\tlogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t\treturn wrapDocumentService(documentService, uploadSummaryCb);\n\t};\n\treturn outerDocServiceFactory;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ConfigTypes, IConfigProviderBase } from "@fluidframework/core-interfaces";
6
+ /**
7
+ * Extension of IConfigProviderBase that supports setting a config value and clearing all
8
+ * config values for testing.
9
+ *
10
+ * @internal
11
+ */
12
+ export interface ITestConfigProvider extends IConfigProviderBase {
13
+ /** Set a config value */
14
+ set: (key: string, value: ConfigTypes) => void;
15
+ /** Clear all config values */
16
+ clear: () => void;
17
+ }
18
+ /**
19
+ * Creates a test config provider with the ability to set configs values and clear all config values.
20
+ * @internal
21
+ */
22
+ export declare const createTestConfigProvider: () => ITestConfigProvider;
23
+ //# sourceMappingURL=TestConfigs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestConfigs.d.ts","sourceRoot":"","sources":["../src/TestConfigs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC/D,yBAAyB;IACzB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC/C,8BAA8B;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,QAAO,mBAc3C,CAAC"}
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Creates a test config provider with the ability to set configs values and clear all config values.
7
+ * @internal
8
+ */
9
+ export const createTestConfigProvider = () => {
10
+ const settings = {};
11
+ return {
12
+ getRawConfig: (name) => settings[name],
13
+ set: (key, value) => {
14
+ settings[key] = value;
15
+ },
16
+ clear: () => {
17
+ Object.keys(settings).forEach((key) => {
18
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
19
+ delete settings[key];
20
+ });
21
+ },
22
+ };
23
+ };
24
+ //# sourceMappingURL=TestConfigs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestConfigs.js","sourceRoot":"","sources":["../src/TestConfigs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAwB,EAAE;IACjE,MAAM,QAAQ,GAAgC,EAAE,CAAC;IACjD,OAAO;QACN,YAAY,EAAE,CAAC,IAAY,EAAe,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC3D,GAAG,EAAE,CAAC,GAAW,EAAE,KAAkB,EAAE,EAAE;YACxC,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACvB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACX,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACrC,gEAAgE;gBAChE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ConfigTypes, IConfigProviderBase } from \"@fluidframework/core-interfaces\";\n\n/**\n * Extension of IConfigProviderBase that supports setting a config value and clearing all\n * config values for testing.\n *\n * @internal\n */\nexport interface ITestConfigProvider extends IConfigProviderBase {\n\t/** Set a config value */\n\tset: (key: string, value: ConfigTypes) => void;\n\t/** Clear all config values */\n\tclear: () => void;\n}\n\n/**\n * Creates a test config provider with the ability to set configs values and clear all config values.\n * @internal\n */\nexport const createTestConfigProvider = (): ITestConfigProvider => {\n\tconst settings: Record<string, ConfigTypes> = {};\n\treturn {\n\t\tgetRawConfig: (name: string): ConfigTypes => settings[name],\n\t\tset: (key: string, value: ConfigTypes) => {\n\t\t\tsettings[key] = value;\n\t\t},\n\t\tclear: () => {\n\t\t\tObject.keys(settings).forEach((key) => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete settings[key];\n\t\t\t});\n\t\t},\n\t};\n};\n"]}
@@ -0,0 +1,66 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct";
6
+ import { IContainer, IHostLoader } from "@fluidframework/container-definitions";
7
+ import { IOnDemandSummarizeOptions, ISummarizer } from "@fluidframework/container-runtime";
8
+ import { ITelemetryBaseLogger, IConfigProviderBase } from "@fluidframework/core-interfaces";
9
+ import { IFluidDataStoreFactory, NamedFluidDataStoreRegistryEntries } from "@fluidframework/runtime-definitions";
10
+ import { ISummaryTree } from "@fluidframework/protocol-definitions";
11
+ import { ITestContainerConfig, ITestObjectProvider } from "./testObjectProvider.js";
12
+ /** @internal */
13
+ export declare function createSummarizerCore(container: IContainer, loader: IHostLoader, summaryVersion?: string): Promise<{
14
+ container: IContainer;
15
+ summarizer: ISummarizer;
16
+ }>;
17
+ /**
18
+ * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's
19
+ * IContainer and ISummarizer.
20
+ * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
21
+ * @internal
22
+ */
23
+ export declare function createSummarizerFromFactory(provider: ITestObjectProvider, container: IContainer, dataStoreFactory: IFluidDataStoreFactory, summaryVersion?: string, containerRuntimeFactoryType?: typeof ContainerRuntimeFactoryWithDefaultDataStore, registryEntries?: NamedFluidDataStoreRegistryEntries, logger?: ITelemetryBaseLogger, configProvider?: IConfigProviderBase): Promise<{
24
+ container: IContainer;
25
+ summarizer: ISummarizer;
26
+ }>;
27
+ /**
28
+ * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.
29
+ * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
30
+ *
31
+ * Can pass in a test config provider to enable/disable features.
32
+ * @internal
33
+ */
34
+ export declare function createSummarizer(provider: ITestObjectProvider, container: IContainer, config?: ITestContainerConfig, summaryVersion?: string, logger?: ITelemetryBaseLogger): Promise<{
35
+ container: IContainer;
36
+ summarizer: ISummarizer;
37
+ }>;
38
+ /**
39
+ * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the
40
+ * submitted summary.
41
+ *
42
+ * @param summarizer - The ISummarizer to use to summarize on demand
43
+ * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.
44
+ * Defaults to the reason "end-to-end test".
45
+ * @internal
46
+ */
47
+ export declare function summarizeNow(summarizer: ISummarizer, inputs?: string | IOnDemandSummarizeOptions): Promise<SummaryInfo>;
48
+ /**
49
+ * Summary information containing the summary tree, summary version, and summary sequence number.
50
+ * @internal
51
+ */
52
+ export interface SummaryInfo {
53
+ /**
54
+ * The summary tree generated
55
+ */
56
+ summaryTree: ISummaryTree;
57
+ /**
58
+ * Handle of the completed summary
59
+ */
60
+ summaryVersion: string;
61
+ /**
62
+ * Reference sequence number of the current summary generation
63
+ */
64
+ summaryRefSeq: number;
65
+ }
66
+ //# sourceMappingURL=TestSummaryUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestSummaryUtils.d.ts","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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;AACH,wBAAsB,YAAY,CACjC,UAAU,EAAE,WAAW,EACvB,MAAM,GAAE,MAAM,GAAG,yBAA6C,GAC5D,OAAO,CAAC,WAAW,CAAC,CAmCtB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,WAAW,EAAE,YAAY,CAAC;IAC1B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,153 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct";
6
+ import { assert } from "@fluidframework/core-utils";
7
+ import { LoaderHeader } from "@fluidframework/container-definitions";
8
+ import { DriverHeader } from "@fluidframework/driver-definitions";
9
+ import { createTestConfigProvider } from "./TestConfigs.js";
10
+ import { waitForContainerConnection } from "./containerUtils.js";
11
+ import { timeoutAwait } from "./timeoutUtils.js";
12
+ import { createContainerRuntimeFactoryWithDefaultDataStore } from "./testContainerRuntimeFactoryWithDefaultDataStore.js";
13
+ const summarizerClientType = "summarizer";
14
+ /**
15
+ * This function should ONLY be used for back compat purposes
16
+ * LTS versions of the Loader/Container will not have the "getEntryPoint" method, so we need to fallback to "request"
17
+ * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0
18
+ * @internal
19
+ */
20
+ async function getSummarizerBackCompat(container) {
21
+ if (container.getEntryPoint !== undefined) {
22
+ const entryPoint = await container.getEntryPoint();
23
+ // Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running
24
+ // cross version compat testing scenarios, if we create with 1.X container and load with 2.X then the
25
+ // function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined
26
+ // since the container's runtime will be on version 1.X, which does not have an entry point defined.
27
+ if (entryPoint !== undefined) {
28
+ return entryPoint;
29
+ }
30
+ }
31
+ const response = await container.request({ url: "_summarizer" });
32
+ assert(response.status === 200, "requesting '/' should return default data object");
33
+ return response.value;
34
+ }
35
+ /** @internal */
36
+ export async function createSummarizerCore(container, loader, summaryVersion) {
37
+ const absoluteUrl = await container.getAbsoluteUrl("");
38
+ if (absoluteUrl === undefined) {
39
+ throw new Error("URL could not be resolved");
40
+ }
41
+ const request = {
42
+ headers: {
43
+ [LoaderHeader.cache]: false,
44
+ [LoaderHeader.clientDetails]: {
45
+ capabilities: { interactive: false },
46
+ type: summarizerClientType,
47
+ },
48
+ [DriverHeader.summarizingClient]: true,
49
+ [LoaderHeader.version]: summaryVersion,
50
+ },
51
+ url: absoluteUrl,
52
+ };
53
+ const summarizerContainer = await loader.resolve(request);
54
+ await waitForContainerConnection(summarizerContainer);
55
+ // Old loaders will not have getEntryPoint API on the container. So, use getSummarizerBackCompat which
56
+ // will use request pattern to get the summarizer in these old loaders.
57
+ const fluidObject = await getSummarizerBackCompat(summarizerContainer);
58
+ if (fluidObject.ISummarizer === undefined) {
59
+ throw new Error("Fluid object does not implement ISummarizer");
60
+ }
61
+ return {
62
+ container: summarizerContainer,
63
+ summarizer: fluidObject.ISummarizer,
64
+ };
65
+ }
66
+ const defaultSummaryOptions = {
67
+ summaryConfigOverrides: {
68
+ state: "disableHeuristics",
69
+ maxAckWaitTime: 20000,
70
+ maxOpsSinceLastSummary: 7000,
71
+ initialSummarizerDelayMs: 0,
72
+ },
73
+ };
74
+ /**
75
+ * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's
76
+ * IContainer and ISummarizer.
77
+ * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
78
+ * @internal
79
+ */
80
+ export async function createSummarizerFromFactory(provider, container, dataStoreFactory, summaryVersion, containerRuntimeFactoryType = ContainerRuntimeFactoryWithDefaultDataStore, registryEntries, logger, configProvider = createTestConfigProvider()) {
81
+ const runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(containerRuntimeFactoryType, {
82
+ defaultFactory: dataStoreFactory,
83
+ registryEntries: registryEntries ?? [
84
+ [dataStoreFactory.type, Promise.resolve(dataStoreFactory)],
85
+ ],
86
+ runtimeOptions: { summaryOptions: defaultSummaryOptions },
87
+ });
88
+ const loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {
89
+ configProvider,
90
+ logger,
91
+ });
92
+ return createSummarizerCore(container, loader, summaryVersion);
93
+ }
94
+ /**
95
+ * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.
96
+ * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.
97
+ *
98
+ * Can pass in a test config provider to enable/disable features.
99
+ * @internal
100
+ */
101
+ export async function createSummarizer(provider, container, config, summaryVersion, logger) {
102
+ const testContainerConfig = {
103
+ ...config,
104
+ runtimeOptions: {
105
+ ...config?.runtimeOptions,
106
+ summaryOptions: config?.runtimeOptions?.summaryOptions ?? defaultSummaryOptions,
107
+ },
108
+ loaderProps: {
109
+ ...config?.loaderProps,
110
+ configProvider: config?.loaderProps?.configProvider ?? createTestConfigProvider(),
111
+ logger,
112
+ },
113
+ };
114
+ const loader = provider.makeTestLoader(testContainerConfig);
115
+ return createSummarizerCore(container, loader, summaryVersion);
116
+ }
117
+ /**
118
+ * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the
119
+ * submitted summary.
120
+ *
121
+ * @param summarizer - The ISummarizer to use to summarize on demand
122
+ * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.
123
+ * Defaults to the reason "end-to-end test".
124
+ * @internal
125
+ */
126
+ export async function summarizeNow(summarizer, inputs = "end-to-end test") {
127
+ const options = typeof inputs === "string" ? { reason: inputs } : inputs;
128
+ const result = summarizer.summarizeOnDemand(options);
129
+ const submitResult = await timeoutAwait(result.summarySubmitted);
130
+ if (!submitResult.success) {
131
+ if (typeof submitResult.error !== "string") {
132
+ submitResult.error.data = submitResult.data;
133
+ }
134
+ throw submitResult.error;
135
+ }
136
+ assert(submitResult.data.stage === "submit", "on-demand summary submitted data stage should be submit");
137
+ assert(submitResult.data.summaryTree !== undefined, "summary tree should exist");
138
+ const broadcastResult = await timeoutAwait(result.summaryOpBroadcasted);
139
+ if (!broadcastResult.success) {
140
+ throw broadcastResult.error;
141
+ }
142
+ const ackNackResult = await timeoutAwait(result.receivedSummaryAckOrNack);
143
+ if (!ackNackResult.success) {
144
+ throw ackNackResult.error;
145
+ }
146
+ await new Promise((resolve) => process.nextTick(resolve));
147
+ return {
148
+ summaryTree: submitResult.data.summaryTree,
149
+ summaryVersion: ackNackResult.data.summaryAckOp.contents.handle,
150
+ summaryRefSeq: submitResult.data.referenceSequenceNumber,
151
+ };
152
+ }
153
+ //# sourceMappingURL=TestSummaryUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestSummaryUtils.js","sourceRoot":"","sources":["../src/TestSummaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2CAA2C,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAA2B,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAY9F,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAOlE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,iDAAiD,EAAE,MAAM,sDAAsD,CAAC;AAEzH,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C;;;;;GAKG;AACH,KAAK,UAAU,uBAAuB,CAAC,SAAqB;IAC3D,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE;QAC1C,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACnD,0GAA0G;QAC1G,qGAAqG;QACrG,gHAAgH;QAChH,oGAAoG;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aAAa,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC1E,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;QAC3B,MAAM,aAAa,CAAC,KAAK,CAAC;KAC1B;IAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAE1D,OAAO;QACN,WAAW,EAAE,YAAY,CAAC,IAAI,CAAC,WAAW;QAC1C,cAAc,EAAE,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM;QAC/D,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,uBAAuB;KACxD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"@fluidframework/aqueduct\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IContainer, IHostLoader, LoaderHeader } from \"@fluidframework/container-definitions\";\nimport {\n\tIOnDemandSummarizeOptions,\n\tISummarizer,\n\tISummaryRuntimeOptions,\n} from \"@fluidframework/container-runtime\";\nimport {\n\tITelemetryBaseLogger,\n\tIRequest,\n\tIConfigProviderBase,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITestContainerConfig, ITestObjectProvider } from \"./testObjectProvider.js\";\nimport { createTestConfigProvider } from \"./TestConfigs.js\";\nimport { waitForContainerConnection } from \"./containerUtils.js\";\nimport { timeoutAwait } from \"./timeoutUtils.js\";\nimport { createContainerRuntimeFactoryWithDefaultDataStore } from \"./testContainerRuntimeFactoryWithDefaultDataStore.js\";\n\nconst summarizerClientType = \"summarizer\";\n\n/**\n * This function should ONLY be used for back compat purposes\n * LTS versions of the Loader/Container will not have the \"getEntryPoint\" method, so we need to fallback to \"request\"\n * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0\n * @internal\n */\nasync function getSummarizerBackCompat(container: IContainer): Promise<ISummarizer> {\n\tif (container.getEntryPoint !== undefined) {\n\t\tconst entryPoint = await container.getEntryPoint();\n\t\t// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running\n\t\t// cross version compat testing scenarios, if we create with 1.X container and load with 2.X then the\n\t\t// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined\n\t\t// since the container's runtime will be on version 1.X, which does not have an entry point defined.\n\t\tif (entryPoint !== undefined) {\n\t\t\treturn entryPoint as ISummarizer;\n\t\t}\n\t}\n\tconst response: IResponse = await (container as any).request({ url: \"_summarizer\" });\n\tassert(response.status === 200, \"requesting '/' should return default data object\");\n\treturn response.value as ISummarizer;\n}\n\n/** @internal */\nexport async function createSummarizerCore(\n\tcontainer: IContainer,\n\tloader: IHostLoader,\n\tsummaryVersion?: string,\n) {\n\tconst absoluteUrl = await container.getAbsoluteUrl(\"\");\n\tif (absoluteUrl === undefined) {\n\t\tthrow new Error(\"URL could not be resolved\");\n\t}\n\n\tconst request: IRequest = {\n\t\theaders: {\n\t\t\t[LoaderHeader.cache]: false,\n\t\t\t[LoaderHeader.clientDetails]: {\n\t\t\t\tcapabilities: { interactive: false },\n\t\t\t\ttype: summarizerClientType,\n\t\t\t},\n\t\t\t[DriverHeader.summarizingClient]: true,\n\t\t\t[LoaderHeader.version]: summaryVersion,\n\t\t},\n\t\turl: absoluteUrl,\n\t};\n\tconst summarizerContainer = await loader.resolve(request);\n\tawait waitForContainerConnection(summarizerContainer);\n\n\t// Old loaders will not have getEntryPoint API on the container. So, use getSummarizerBackCompat which\n\t// will use request pattern to get the summarizer in these old loaders.\n\tconst fluidObject = await getSummarizerBackCompat(summarizerContainer);\n\tif (fluidObject.ISummarizer === undefined) {\n\t\tthrow new Error(\"Fluid object does not implement ISummarizer\");\n\t}\n\n\treturn {\n\t\tcontainer: summarizerContainer,\n\t\tsummarizer: fluidObject.ISummarizer,\n\t};\n}\n\nconst defaultSummaryOptions: ISummaryRuntimeOptions = {\n\tsummaryConfigOverrides: {\n\t\tstate: \"disableHeuristics\",\n\t\tmaxAckWaitTime: 20000, // Some of the AFR tests take a long time to ack.\n\t\tmaxOpsSinceLastSummary: 7000,\n\t\tinitialSummarizerDelayMs: 0,\n\t},\n};\n\n/**\n * Creates a summarizer client from the given container and data store factory, and returns the summarizer client's\n * IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n * @internal\n */\nexport async function createSummarizerFromFactory(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tdataStoreFactory: IFluidDataStoreFactory,\n\tsummaryVersion?: string,\n\tcontainerRuntimeFactoryType = ContainerRuntimeFactoryWithDefaultDataStore,\n\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\tlogger?: ITelemetryBaseLogger,\n\tconfigProvider: IConfigProviderBase = createTestConfigProvider(),\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(\n\t\tcontainerRuntimeFactoryType,\n\t\t{\n\t\t\tdefaultFactory: dataStoreFactory,\n\t\t\tregistryEntries: registryEntries ?? [\n\t\t\t\t[dataStoreFactory.type, Promise.resolve(dataStoreFactory)],\n\t\t\t],\n\t\t\truntimeOptions: { summaryOptions: defaultSummaryOptions },\n\t\t},\n\t);\n\n\tconst loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {\n\t\tconfigProvider,\n\t\tlogger,\n\t});\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Creates a summarizer client from the given container and returns the summarizer client's IContainer and ISummarizer.\n * The ISummarizer can be used to generate on-demand summaries. The IContainer can be used to fetch data stores, etc.\n *\n * Can pass in a test config provider to enable/disable features.\n * @internal\n */\nexport async function createSummarizer(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\tconfig?: ITestContainerConfig,\n\tsummaryVersion?: string,\n\tlogger?: ITelemetryBaseLogger,\n): Promise<{ container: IContainer; summarizer: ISummarizer }> {\n\tconst testContainerConfig: ITestContainerConfig = {\n\t\t...config,\n\t\truntimeOptions: {\n\t\t\t...config?.runtimeOptions,\n\t\t\tsummaryOptions: config?.runtimeOptions?.summaryOptions ?? defaultSummaryOptions,\n\t\t},\n\t\tloaderProps: {\n\t\t\t...config?.loaderProps,\n\t\t\tconfigProvider: config?.loaderProps?.configProvider ?? createTestConfigProvider(),\n\t\t\tlogger,\n\t\t},\n\t};\n\tconst loader = provider.makeTestLoader(testContainerConfig);\n\treturn createSummarizerCore(container, loader, summaryVersion);\n}\n\n/**\n * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the\n * submitted summary.\n *\n * @param summarizer - The ISummarizer to use to summarize on demand\n * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.\n * Defaults to the reason \"end-to-end test\".\n * @internal\n */\nexport async function summarizeNow(\n\tsummarizer: ISummarizer,\n\tinputs: string | IOnDemandSummarizeOptions = \"end-to-end test\",\n): Promise<SummaryInfo> {\n\tconst options: IOnDemandSummarizeOptions =\n\t\ttypeof inputs === \"string\" ? { reason: inputs } : inputs;\n\tconst result = summarizer.summarizeOnDemand(options);\n\n\tconst submitResult = await timeoutAwait(result.summarySubmitted);\n\tif (!submitResult.success) {\n\t\tif (typeof submitResult.error !== \"string\") {\n\t\t\tsubmitResult.error.data = submitResult.data;\n\t\t}\n\t\tthrow submitResult.error;\n\t}\n\tassert(\n\t\tsubmitResult.data.stage === \"submit\",\n\t\t\"on-demand summary submitted data stage should be submit\",\n\t);\n\tassert(submitResult.data.summaryTree !== undefined, \"summary tree should exist\");\n\n\tconst broadcastResult = await timeoutAwait(result.summaryOpBroadcasted);\n\tif (!broadcastResult.success) {\n\t\tthrow broadcastResult.error;\n\t}\n\n\tconst ackNackResult = await timeoutAwait(result.receivedSummaryAckOrNack);\n\tif (!ackNackResult.success) {\n\t\tthrow ackNackResult.error;\n\t}\n\n\tawait new Promise((resolve) => process.nextTick(resolve));\n\n\treturn {\n\t\tsummaryTree: submitResult.data.summaryTree,\n\t\tsummaryVersion: ackNackResult.data.summaryAckOp.contents.handle,\n\t\tsummaryRefSeq: submitResult.data.referenceSequenceNumber,\n\t};\n}\n\n/**\n * Summary information containing the summary tree, summary version, and summary sequence number.\n * @internal\n */\nexport interface SummaryInfo {\n\t/**\n\t * The summary tree generated\n\t */\n\tsummaryTree: ISummaryTree;\n\t/**\n\t * Handle of the completed summary\n\t */\n\tsummaryVersion: string;\n\t/**\n\t * Reference sequence number of the current summary generation\n\t */\n\tsummaryRefSeq: number;\n}\n"]}
@@ -0,0 +1,46 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IContainer } from "@fluidframework/container-definitions";
6
+ import { IDataStore } from "@fluidframework/runtime-definitions";
7
+ import { TimeoutWithError } from "./timeoutUtils.js";
8
+ /**
9
+ * Utility function to wait for the specified Container to be in Connected state.
10
+ * If the Container is already connected, the Promise returns immediately; otherwise it resolves when the Container emits
11
+ * its 'connected' event.
12
+ * If failOnContainerClose === true, the returned Promise will be rejected if the container emits a 'closed' event
13
+ * before a 'connected' event.
14
+ * @param container - The container to wait for.
15
+ * @param failOnContainerClose - If true, the returned Promise will be rejected if the container emits a 'closed' event
16
+ * before a 'connected' event.
17
+ * Defaults to true.
18
+ * @param timeoutOptions - Options related to the behavior of the timeout.
19
+ * If provided, the returned Promise will reject if the container hasn't emitted relevant events in timeoutOptions.durationMs.
20
+ * If not provided, the Promise will wait indefinitely for the Container to emit its 'connected' (or 'closed', if
21
+ * failOnContainerClose === true) event.
22
+ *
23
+ * @returns A Promise that either:
24
+ * - Resolves when the specified container emits a 'connected' event (or immediately if the Container is already connected).
25
+ * - Rejects if failOnContainerClose === true and the container emits a 'closed' event before a 'connected' event.
26
+ * - Rejects after timeoutOptions.durationMs if timeoutOptions !== undefined and the container does not emit relevant
27
+ * events, within that timeframe.
28
+ * @internal
29
+ */
30
+ export declare function waitForContainerConnection(container: IContainer, failOnContainerClose?: boolean, timeoutOptions?: TimeoutWithError): Promise<void>;
31
+ /**
32
+ * This function should ONLY be used for back compat purposes
33
+ * LTS versions of the Loader/Container will not have the "getEntryPoint" method, so we need to fallback to "request"
34
+ * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0
35
+ * @internal
36
+ */
37
+ export declare function getContainerEntryPointBackCompat<T>(container: IContainer): Promise<T>;
38
+ /**
39
+ * This function should ONLY be used for back compat purposes
40
+ * Older supported versions of IDataStore do not have the "entryPoint" property, so we need to fallback to "request"
41
+ * This function can be removed once back-compat support for IDataStore moves to 2.0.0-internal.7.0.0
42
+ *
43
+ * @internal
44
+ */
45
+ export declare function getDataStoreEntryPointBackCompat<T>(dataStore: IDataStore): Promise<T>;
46
+ //# sourceMappingURL=containerUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containerUtils.d.ts","sourceRoot":"","sources":["../src/containerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAInE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAmC,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,0BAA0B,CAC/C,SAAS,EAAE,UAAU,EACrB,oBAAoB,GAAE,OAAc,EACpC,cAAc,CAAC,EAAE,gBAAgB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;;GAKG;AACH,wBAAsB,gCAAgC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAc3F;AAED;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAO3F"}
@@ -0,0 +1,79 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ConnectionState } from "@fluidframework/container-loader";
6
+ import { assert } from "@fluidframework/core-utils";
7
+ import { timeoutPromise } from "./timeoutUtils.js";
8
+ /**
9
+ * Utility function to wait for the specified Container to be in Connected state.
10
+ * If the Container is already connected, the Promise returns immediately; otherwise it resolves when the Container emits
11
+ * its 'connected' event.
12
+ * If failOnContainerClose === true, the returned Promise will be rejected if the container emits a 'closed' event
13
+ * before a 'connected' event.
14
+ * @param container - The container to wait for.
15
+ * @param failOnContainerClose - If true, the returned Promise will be rejected if the container emits a 'closed' event
16
+ * before a 'connected' event.
17
+ * Defaults to true.
18
+ * @param timeoutOptions - Options related to the behavior of the timeout.
19
+ * If provided, the returned Promise will reject if the container hasn't emitted relevant events in timeoutOptions.durationMs.
20
+ * If not provided, the Promise will wait indefinitely for the Container to emit its 'connected' (or 'closed', if
21
+ * failOnContainerClose === true) event.
22
+ *
23
+ * @returns A Promise that either:
24
+ * - Resolves when the specified container emits a 'connected' event (or immediately if the Container is already connected).
25
+ * - Rejects if failOnContainerClose === true and the container emits a 'closed' event before a 'connected' event.
26
+ * - Rejects after timeoutOptions.durationMs if timeoutOptions !== undefined and the container does not emit relevant
27
+ * events, within that timeframe.
28
+ * @internal
29
+ */
30
+ export async function waitForContainerConnection(container, failOnContainerClose = true, timeoutOptions) {
31
+ if (container.connectionState !== ConnectionState.Connected) {
32
+ const executor = (resolve, reject) => {
33
+ container.once("connected", () => resolve());
34
+ if (failOnContainerClose) {
35
+ container.once("closed", (error) => reject(error));
36
+ }
37
+ };
38
+ return timeoutOptions === undefined
39
+ ? new Promise(executor)
40
+ : timeoutPromise(executor, timeoutOptions);
41
+ }
42
+ }
43
+ /**
44
+ * This function should ONLY be used for back compat purposes
45
+ * LTS versions of the Loader/Container will not have the "getEntryPoint" method, so we need to fallback to "request"
46
+ * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0
47
+ * @internal
48
+ */
49
+ export async function getContainerEntryPointBackCompat(container) {
50
+ if (container.getEntryPoint !== undefined) {
51
+ const entryPoint = await container.getEntryPoint();
52
+ // Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running
53
+ // cross version compat testing scenarios, if we create with 1.X container and load with 2.X then the
54
+ // function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined
55
+ // since the container's runtime will be on version 1.X, which does not have an entry point defined.
56
+ if (entryPoint !== undefined) {
57
+ return entryPoint;
58
+ }
59
+ }
60
+ const response = await container.request({ url: "/" });
61
+ assert(response.status === 200, "requesting '/' should return default data object");
62
+ return response.value;
63
+ }
64
+ /**
65
+ * This function should ONLY be used for back compat purposes
66
+ * Older supported versions of IDataStore do not have the "entryPoint" property, so we need to fallback to "request"
67
+ * This function can be removed once back-compat support for IDataStore moves to 2.0.0-internal.7.0.0
68
+ *
69
+ * @internal
70
+ */
71
+ export async function getDataStoreEntryPointBackCompat(dataStore) {
72
+ if (dataStore.entryPoint !== undefined) {
73
+ return dataStore.entryPoint.get();
74
+ }
75
+ const response = await dataStore.request({ url: "" });
76
+ assert(response.status === 200, "empty request should return data object");
77
+ return response.value;
78
+ }
79
+ //# sourceMappingURL=containerUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containerUtils.js","sourceRoot":"","sources":["../src/containerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAmB,cAAc,EAAoB,MAAM,mBAAmB,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,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AC,UAAU,KAAK,SAAS,EAAE;QACvC,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,EAAgB,CAAC;KAChD;IACD,MAAM,QAAQ,GAAc,MAAO,SAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1E,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,yCAAyC,CAAC,CAAC;IAC3E,OAAO,QAAQ,CAAC,KAAU,CAAC;AAC5B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IContainer } from \"@fluidframework/container-definitions\";\nimport { ConnectionState } from \"@fluidframework/container-loader\";\nimport { IResponse } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDataStore } from \"@fluidframework/runtime-definitions\";\nimport { PromiseExecutor, timeoutPromise, TimeoutWithError } from \"./timeoutUtils.js\";\n\n/**\n * Utility function to wait for the specified Container to be in Connected state.\n * If the Container is already connected, the Promise returns immediately; otherwise it resolves when the Container emits\n * its 'connected' event.\n * If failOnContainerClose === true, the returned Promise will be rejected if the container emits a 'closed' event\n * before a 'connected' event.\n * @param container - The container to wait for.\n * @param failOnContainerClose - If true, the returned Promise will be rejected if the container emits a 'closed' event\n * before a 'connected' event.\n * Defaults to true.\n * @param timeoutOptions - Options related to the behavior of the timeout.\n * If provided, the returned Promise will reject if the container hasn't emitted relevant events in timeoutOptions.durationMs.\n * If not provided, the Promise will wait indefinitely for the Container to emit its 'connected' (or 'closed', if\n * failOnContainerClose === true) event.\n *\n * @returns A Promise that either:\n * - Resolves when the specified container emits a 'connected' event (or immediately if the Container is already connected).\n * - Rejects if failOnContainerClose === true and the container emits a 'closed' event before a 'connected' event.\n * - Rejects after timeoutOptions.durationMs if timeoutOptions !== undefined and the container does not emit relevant\n * events, within that timeframe.\n * @internal\n */\nexport async function waitForContainerConnection(\n\tcontainer: IContainer,\n\tfailOnContainerClose: boolean = true,\n\ttimeoutOptions?: TimeoutWithError,\n): Promise<void> {\n\tif (container.connectionState !== ConnectionState.Connected) {\n\t\tconst executor: PromiseExecutor = (resolve, reject) => {\n\t\t\tcontainer.once(\"connected\", () => resolve());\n\t\t\tif (failOnContainerClose) {\n\t\t\t\tcontainer.once(\"closed\", (error) => reject(error));\n\t\t\t}\n\t\t};\n\n\t\treturn timeoutOptions === undefined\n\t\t\t? new Promise(executor)\n\t\t\t: timeoutPromise(executor, timeoutOptions);\n\t}\n}\n\n/**\n * This function should ONLY be used for back compat purposes\n * LTS versions of the Loader/Container will not have the \"getEntryPoint\" method, so we need to fallback to \"request\"\n * This function can be removed once LTS version of Loader moves to 2.0.0-internal.7.0.0\n * @internal\n */\nexport async function getContainerEntryPointBackCompat<T>(container: IContainer): Promise<T> {\n\tif (container.getEntryPoint !== undefined) {\n\t\tconst entryPoint = await container.getEntryPoint();\n\t\t// Note: We need to also check if the result of `getEntryPoint()` is defined. This is because when running\n\t\t// cross version compat testing scenarios, if we create with 1.X container and load with 2.X then the\n\t\t// function container.getEntryPoint will be defined for the 2.X container. However, it will not return undefined\n\t\t// since the container's runtime will be on version 1.X, which does not have an entry point defined.\n\t\tif (entryPoint !== undefined) {\n\t\t\treturn entryPoint as T;\n\t\t}\n\t}\n\tconst response: IResponse = await (container as any).request({ url: \"/\" });\n\tassert(response.status === 200, \"requesting '/' should return default data object\");\n\treturn response.value as T;\n}\n\n/**\n * This function should ONLY be used for back compat purposes\n * Older supported versions of IDataStore do not have the \"entryPoint\" property, so we need to fallback to \"request\"\n * This function can be removed once back-compat support for IDataStore moves to 2.0.0-internal.7.0.0\n *\n * @internal\n */\nexport async function getDataStoreEntryPointBackCompat<T>(dataStore: IDataStore): Promise<T> {\n\tif (dataStore.entryPoint !== undefined) {\n\t\treturn dataStore.entryPoint.get() as Promise<T>;\n\t}\n\tconst response: IResponse = await (dataStore as any).request({ url: \"\" });\n\tassert(response.status === 200, \"empty request should return data object\");\n\treturn response.value as T;\n}\n"]}
package/lib/debug.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import registerDebug from "debug";
6
+ export declare const debug: registerDebug.Debugger;
7
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,aAAa,MAAM,OAAO,CAAC;AAGlC,eAAO,MAAM,KAAK,wBAAoC,CAAC"}
package/lib/debug.js ADDED
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import registerDebug from "debug";
6
+ import { pkgName, pkgVersion } from "./packageVersion.js";
7
+ export const debug = registerDebug("fluid:test-utils");
8
+ debug(`Package: ${pkgName} - Version: ${pkgVersion}`);
9
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,aAAa,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;AACvD,KAAK,CAAC,YAAY,OAAO,eAAe,UAAU,EAAE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport registerDebug from \"debug\";\nimport { pkgName, pkgVersion } from \"./packageVersion.js\";\n\nexport const debug = registerDebug(\"fluid:test-utils\");\ndebug(`Package: ${pkgName} - Version: ${pkgVersion}`);\n"]}
package/lib/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { wrapDocumentService, wrapDocumentServiceFactory, wrapDocumentStorageService, } from "./DriverWrappers.js";
6
+ export { IProvideTestFluidObject, ITestFluidObject } from "./interfaces.js";
7
+ export { LoaderContainerTracker } from "./loaderContainerTracker.js";
8
+ export { fluidEntryPoint, LocalCodeLoader, SupportedExportInterfaces } from "./localCodeLoader.js";
9
+ export { createAndAttachContainer, createLoader } from "./localLoader.js";
10
+ export { retryWithEventualValue } from "./retry.js";
11
+ export { createTestConfigProvider, ITestConfigProvider } from "./TestConfigs.js";
12
+ export { createTestContainerRuntimeFactory, TestContainerRuntimeFactory, } from "./testContainerRuntimeFactory.js";
13
+ export { ChannelFactoryRegistry, TestFluidObject, TestFluidObjectFactory, } from "./testFluidObject.js";
14
+ export { createDocumentId, DataObjectFactoryType, EventAndErrorTrackingLogger, getUnexpectedLogErrorException, IDocumentIdStrategy, IOpProcessingController, ITestContainerConfig, ITestObjectProvider, TestObjectProvider, TestObjectProviderWithVersionedLoad, } from "./testObjectProvider.js";
15
+ export { createSummarizer, createSummarizerCore, createSummarizerFromFactory, summarizeNow, SummaryInfo, } from "./TestSummaryUtils.js";
16
+ export { defaultTimeoutDurationMs, timeoutAwait, timeoutPromise, TimeoutWithError, TimeoutWithValue, } from "./timeoutUtils.js";
17
+ export { waitForContainerConnection, getContainerEntryPointBackCompat, getDataStoreEntryPointBackCompat, } from "./containerUtils.js";
18
+ export { createContainerRuntimeFactoryWithDefaultDataStore } from "./testContainerRuntimeFactoryWithDefaultDataStore.js";
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,GAC1B,MAAM,qBAAqB,CAAC;AAC7B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