Skip to content

Commit 2f96ed5

Browse files
agarwal-navinanthony-murphy-agent
authored andcommitted
(compat) Fix incorrect usages of storage service at Runtime and Loader layer (microsoft#25722)
There are a couple of incorrect usages of the storage service at the Runtime and Loader layer after `IContainerStorageService` and `IRuntimeStorageService` were added by microsoft#25057. This PR fixes them. Also, removed a test that was ensuring `getSnapshotTree` cannot be accessed from data store context. With microsoft#25057, `getSnapshotTree` is not accesible from data store context's storage anymore so this test is not needed.
1 parent 53fc944 commit 2f96ed5

File tree

3 files changed

+7
-44
lines changed

3 files changed

+7
-44
lines changed

packages/loader/container-loader/src/container.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import type {
3232
ReadOnlyInfo,
3333
ILoader,
3434
ILoaderOptions,
35+
IContainerStorageService,
3536
} from "@fluidframework/container-definitions/internal";
3637
import { isFluidCodeDetails } from "@fluidframework/container-definitions/internal";
3738
import {
@@ -54,7 +55,6 @@ import {
5455
import {
5556
type IDocumentService,
5657
type IDocumentServiceFactory,
57-
type IDocumentStorageService,
5858
type IResolvedUrl,
5959
type ISnapshot,
6060
type IThrottlingWarning,
@@ -1887,7 +1887,7 @@ export class Container
18871887

18881888
private async initializeProtocolStateFromSnapshot(
18891889
attributes: IDocumentAttributes,
1890-
storage: IDocumentStorageService,
1890+
storage: IContainerStorageService,
18911891
snapshot: ISnapshotTree | undefined,
18921892
): Promise<void> {
18931893
const quorumSnapshot: IQuorumSnapshot = {

packages/runtime/container-runtime/src/test/containerRuntime.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
ContainerErrorTypes,
1919
type IContainerContext,
2020
type IBatchMessage,
21+
type IContainerStorageService,
2122
} from "@fluidframework/container-definitions/internal";
2223
import type { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
2324
import type {
@@ -58,7 +59,6 @@ import {
5859
type IEnvelope,
5960
type ITelemetryContext,
6061
type ISummarizeInternalResult,
61-
type IRuntimeStorageService,
6262
} from "@fluidframework/runtime-definitions/internal";
6363
import { defaultMinVersionForCollab } from "@fluidframework/runtime-utils/internal";
6464
import {
@@ -242,7 +242,7 @@ describe("Runtime", () => {
242242
const mockClientId = "mockClientId";
243243

244244
// Mock the storage layer so "submitSummary" works.
245-
const defaultMockStorage: Partial<IRuntimeStorageService> = {
245+
const defaultMockStorage: Partial<IContainerStorageService> = {
246246
uploadSummaryWithContext: async (summary: ISummaryTree, context: ISummaryContext) => {
247247
return "fakeHandle";
248248
},
@@ -251,7 +251,7 @@ describe("Runtime", () => {
251251
params: {
252252
settings?: Record<string, ConfigTypes>;
253253
logger?: ITelemetryBaseLogger;
254-
mockStorage?: Partial<IRuntimeStorageService>;
254+
mockStorage?: Partial<IContainerStorageService>;
255255
loadedFromVersion?: IVersion;
256256
baseSnapshot?: ISnapshotTree;
257257
connected?: boolean;
@@ -298,7 +298,7 @@ describe("Runtime", () => {
298298
},
299299
clientId,
300300
connected,
301-
storage: mockStorage as IRuntimeStorageService,
301+
storage: mockStorage as IContainerStorageService,
302302
baseSnapshot,
303303
} satisfies Partial<IContainerContext>;
304304

@@ -2119,7 +2119,7 @@ describe("Runtime", () => {
21192119
summaryRefSeq: 100,
21202120
summaryLogger: createChildLogger({}),
21212121
};
2122-
class MockStorageService implements Partial<IRuntimeStorageService> {
2122+
class MockStorageService implements Partial<IContainerStorageService> {
21232123
/**
21242124
* This always returns the same snapshot. Basically, when container runtime receives an ack for the
21252125
* deleted snapshot and tries to fetch the latest snapshot, return the latest snapshot.

packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -531,43 +531,6 @@ describeCompat(
531531
assert.strictEqual(sparseMatrix.id, sparseMatrixId, "Sparse matrix should exist!!");
532532
});
533533

534-
it("Storage in detached container", async () => {
535-
const { container } = await createDetachedContainerAndGetEntryPoint();
536-
537-
const snapshotTree = container.serialize();
538-
const defaultDataStore =
539-
await getContainerEntryPointBackCompat<TestFluidObject>(container);
540-
assert(
541-
defaultDataStore.context.storage !== undefined,
542-
"Storage should be present in detached data store",
543-
);
544-
let success1: boolean | undefined;
545-
await defaultDataStore.context.storage.getSnapshotTree(undefined).catch((err) => {
546-
success1 = false;
547-
});
548-
assert(
549-
success1 === false,
550-
"Snapshot fetch should not be allowed in detached data store",
551-
);
552-
553-
const container2: IContainer =
554-
await loader.rehydrateDetachedContainerFromSnapshot(snapshotTree);
555-
const defaultDataStore2 =
556-
await getContainerEntryPointBackCompat<TestFluidObject>(container2);
557-
assert(
558-
defaultDataStore2.context.storage !== undefined,
559-
"Storage should be present in rehydrated data store",
560-
);
561-
let success2: boolean | undefined;
562-
await defaultDataStore2.context.storage.getSnapshotTree(undefined).catch((err) => {
563-
success2 = false;
564-
});
565-
assert(
566-
success2 === false,
567-
"Snapshot fetch should not be allowed in rehydrated data store",
568-
);
569-
});
570-
571534
it("Change contents of dds, then rehydrate and then check summary", async () => {
572535
const { container } = await createDetachedContainerAndGetEntryPoint();
573536

0 commit comments

Comments
 (0)