|
| 1 | +/*! |
| 2 | + * Copyright (c) Microsoft Corporation and contributors. All rights reserved. |
| 3 | + * Licensed under the MIT License. |
| 4 | + */ |
| 5 | + |
| 6 | +import { |
| 7 | + describeCompat, |
| 8 | + TestDataObjectType, |
| 9 | + type ITestDataObject, |
| 10 | +} from "@fluid-private/test-version-utils"; |
| 11 | +import { type IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal"; |
| 12 | +import type { IContainerRuntimeBase } from "@fluidframework/runtime-definitions/internal"; |
| 13 | +import { MockLogger } from "@fluidframework/telemetry-utils/internal"; |
| 14 | +import { |
| 15 | + type ITestObjectProvider, |
| 16 | + createSummarizer, |
| 17 | + createTestConfigProvider, |
| 18 | + summarizeNow, |
| 19 | +} from "@fluidframework/test-utils/internal"; |
| 20 | + |
| 21 | +import { TestSnapshotCache } from "../../testSnapshotCache.js"; |
| 22 | + |
| 23 | +describeCompat("Odsp Network calls", "NoCompat", (getTestObjectProvider) => { |
| 24 | + // Allow us to control summaries |
| 25 | + const runtimeOptions: IContainerRuntimeOptions = { |
| 26 | + summaryOptions: { |
| 27 | + summaryConfigOverrides: { |
| 28 | + state: "disabled", |
| 29 | + }, |
| 30 | + }, |
| 31 | + }; |
| 32 | + const configProvider = createTestConfigProvider({ |
| 33 | + "Fluid.Container.UseLoadingGroupIdForSnapshotFetch2": true, |
| 34 | + "Fluid.Container.enableOfflineLoad": true, |
| 35 | + }); |
| 36 | + |
| 37 | + let provider: ITestObjectProvider; |
| 38 | + const testSnapshotCache = new TestSnapshotCache(); |
| 39 | + |
| 40 | + beforeEach("setup", async function () { |
| 41 | + provider = getTestObjectProvider({ persistedCache: testSnapshotCache }); |
| 42 | + if (provider.driver.type !== "odsp") { |
| 43 | + this.skip(); |
| 44 | + } |
| 45 | + }); |
| 46 | + |
| 47 | + const loadingGroupId = "loadingGroupId"; |
| 48 | + const createDataObjectsWithGroupIds = async ( |
| 49 | + mainObject: ITestDataObject, |
| 50 | + containerRuntime: IContainerRuntimeBase, |
| 51 | + ) => { |
| 52 | + const dataStoreA = await containerRuntime.createDataStore( |
| 53 | + TestDataObjectType, |
| 54 | + loadingGroupId, |
| 55 | + ); |
| 56 | + const dataStoreB = await containerRuntime.createDataStore( |
| 57 | + TestDataObjectType, |
| 58 | + loadingGroupId, |
| 59 | + ); |
| 60 | + |
| 61 | + mainObject._root.set("dataObjectA", dataStoreA.entryPoint); |
| 62 | + mainObject._root.set("dataObjectB", dataStoreB.entryPoint); |
| 63 | + }; |
| 64 | + |
| 65 | + it.skip("Should not make odsp network calls", async () => { |
| 66 | + const container = await provider.makeTestContainer({ |
| 67 | + runtimeOptions, |
| 68 | + loaderProps: { configProvider }, |
| 69 | + }); |
| 70 | + const mainObject = (await container.getEntryPoint()) as ITestDataObject; |
| 71 | + const containerRuntime = mainObject._context.containerRuntime; |
| 72 | + |
| 73 | + // Testing all apis for creating a data store with a loadingGroupId |
| 74 | + await createDataObjectsWithGroupIds(mainObject, containerRuntime); |
| 75 | + const { summarizer } = await createSummarizer(provider, container, { |
| 76 | + loaderProps: { configProvider }, |
| 77 | + }); |
| 78 | + await provider.ensureSynchronized(); |
| 79 | + await summarizeNow(summarizer); |
| 80 | + |
| 81 | + testSnapshotCache.clearCache(); |
| 82 | + const logger = new MockLogger(); |
| 83 | + await provider.loadTestContainer({ |
| 84 | + loaderProps: { configProvider, logger }, |
| 85 | + }); |
| 86 | + if (provider.driver.type === "odsp") { |
| 87 | + logger.assertMatchNone( |
| 88 | + [ |
| 89 | + { |
| 90 | + eventName: "fluid:telemetry:OdspDriver:readDataBlob_end", |
| 91 | + }, |
| 92 | + ], |
| 93 | + "Should not have any odps network calls", |
| 94 | + ); |
| 95 | + } |
| 96 | + }); |
| 97 | +}); |
0 commit comments