Skip to content

Commit

Permalink
loadContainerPaused() test fix (microsoft#22173)
Browse files Browse the repository at this point in the history
**Issue:** `Throw if attempting to pause at a sequence number before the
latest summary` test was failing erratically. Passed for local server
but failed for odsp/frs etc services.

**Root Cause:** The test tries to check that the `loadContainerPaused()`
function should throw an error when we try to load from a seq number
which is lesser than the latest snapshot sequence number. This was
failing because the latest snapshot that the container refereed to was
an older one (the very first snapshot generated when a container is
created) because the`fetchSnapshot` races to retrieve the snapshot from
cache or network and in almost all cases, refers to the snapshot in
cache.

**Fix:** Now we are explicily providing the snapshot version number in
the `IRequestHeaders` so that the test refers to the latest snapshot
when performing comparisons.


[AB#8561](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/8561)
  • Loading branch information
pragya91 authored Aug 9, 2024
1 parent e632b39 commit 7a9c3c0
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/test/test-end-to-end-tests/src/test/loadModes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
createDocumentId,
createLoader,
createSummarizerFromFactory,
summarizeNow,
} from "@fluidframework/test-utils/internal";

const counterKey = "count";
Expand Down Expand Up @@ -143,7 +144,7 @@ describeCompat("LoadModes", "NoCompat", (getTestObjectProvider, apis: CompatApis
containerUrl: IResolvedUrl | undefined,
defaultFactory: IFluidDataStoreFactory,
headers?: IRequestHeader,
sequenceNumber?: number,
loadToSequenceNumber?: number,
): Promise<IContainer> {
const runtimeFactory = new ContainerRuntimeFactoryWithDefaultDataStore({
defaultFactory,
Expand All @@ -162,7 +163,7 @@ describeCompat("LoadModes", "NoCompat", (getTestObjectProvider, apis: CompatApis
url: await provider.driver.createContainerUrl(documentId, containerUrl),
headers,
},
sequenceNumber,
loadToSequenceNumber,
);
}

Expand Down Expand Up @@ -378,23 +379,20 @@ describeCompat("LoadModes", "NoCompat", (getTestObjectProvider, apis: CompatApis
dataObject1.increment();
}
await loaderContainerTracker.ensureSynchronized(container1);
const result = summarizer.summarizeOnDemand({ reason: "test" });
const submitResult = await result.receivedSummaryAckOrNack;
assert.ok(submitResult);
const result = await summarizeNow(summarizer);

// Try to pause at sequence number 1 (before snapshot)
const sequenceNumber = 1;
const headers: IRequestHeader = {
[LoaderHeader.loadMode]: {
opsBeforeReturn: "sequenceNumber",
},
// Force the container to load from the latest created summary instead of using the cached version. Latest snapshot is in cache is updated async so could cause test flakiness.
[LoaderHeader.version]: result.summaryVersion,
};
// Try to pause at sequence number 1 (before snapshot)
const loadUptoSeqNumber = 1;
await assert.rejects(
loadContainer(
container1.resolvedUrl,
testDataObjectFactory,
headers,
sequenceNumber,
loadUptoSeqNumber,
),
{
message:
Expand Down

0 comments on commit 7a9c3c0

Please sign in to comment.