Skip to content

Commit

Permalink
test-fix(offline): Only run "applies stashed ops with no saved ops" t…
Browse files Browse the repository at this point in the history
…est against local server (#23383)

This test is covering sequence number gymnastics when loading from
serialized pending state and applying stashed ops. Server summary/op
implementations and potential race conditions are not interesting, and
only make the test run slow (4s on average for `waitForSummary`) if not
time out (the cause of the bug this fixes).

So, only run against local server.

This also brings back the assert removed in #22712, but ensuring that we
load from the summary (and don't end up with the original snapshot),
which ensures we actually get coverage of the code this is supposed to
test (see original PR adding the test, #17375)
  • Loading branch information
markfields authored Dec 21, 2024
1 parent 05f8561 commit b3e61f0
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions packages/test/test-end-to-end-tests/src/test/stashedOps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ const waitForSummary = async (
container,
testConfig,
);
await summarizeNow(summarizer);
const { summaryVersion } = await summarizeNow(summarizer);
summarizingContainer.close();
return summaryVersion;
};
// Introduced in 0.37
// REVIEW: enable compat testing
Expand Down Expand Up @@ -2025,14 +2026,21 @@ describeCompat("stashed ops", "NoCompat", (getTestObjectProvider, apis) => {
});

it("applies stashed ops with no saved ops", async function () {
// TODO: This test is consistently failing when ran against AFR. See ADO:7968
if (provider.driver.type === "routerlicious" && provider.driver.endpointName === "frs") {
// Waiting for summary takes many seconds and can timeout these tests on real services.
// That coverage isn't a marginal gain over local server testing, so only test against local server.
if (provider.driver.type !== "local") {
this.skip();
}
await waitForSummary(provider, container1, testContainerConfig);

// avoid our join op being saved
const headers: IRequestHeader = { [LoaderHeader.loadMode]: { deltaConnection: "none" } };
// We want to test the case where we stash ops based on the sequence number of the snapshot we load from
// So step 1 is to complete a summary so we can load from it.
const summaryVersion = await waitForSummary(provider, container1, testContainerConfig);

// avoid our join op being saved (so saved ops is empty and the map op below has the right ref seq)
const headers: IRequestHeader = {
[LoaderHeader.loadMode]: { deltaConnection: "none" },
[LoaderHeader.version]: summaryVersion,
};
const container: IContainerExperimental = await loader.resolve({ url, headers });
const dataStore = (await container.getEntryPoint()) as ITestFluidObject;
const map = await dataStore.getSharedObject<ISharedMap>(mapId);
Expand All @@ -2041,8 +2049,13 @@ describeCompat("stashed ops", "NoCompat", (getTestObjectProvider, apis) => {
const stashBlob = await container.closeAndGetPendingLocalState?.();
assert(stashBlob);
const pendingState = JSON.parse(stashBlob);

// make sure the container loaded from summary and we have no saved ops
assert.strictEqual(pendingState.savedOps.length, 0);
assert.strictEqual(pendingState.savedOps.length, 0, "Expected no saved ops");
assert(
pendingState.pendingRuntimeState.pending.pendingStates[0].referenceSequenceNumber > 0,
"Expected the pending state to have some ops with non-zero ref seq (should match the snapshot sequence number)",
);

// load container with pending ops, which should resend the op not sent by previous container
const container2 = await loader.resolve({ url }, stashBlob);
Expand Down

0 comments on commit b3e61f0

Please sign in to comment.