Skip to content

Commit

Permalink
Fix flaky test for r11s for attribution (microsoft#22607)
Browse files Browse the repository at this point in the history
## Description


[AB#13018](https://dev.azure.com/fluidframework/internal/_workitems/edit/13018)

[AB#13948](https://dev.azure.com/fluidframework/internal/_workitems/edit/13948)

1.) Fix Flaky test for "repopulates attribution association data using
the summary tree" for r11s-frs in which it was not loading from a
specific summary because the version was passed in wrongly.
2.) Skip "Can attribute content from multiple collaborators" for r11s,
since its timeout due to network calls taking more time and this test is
not related to r11s.

Co-authored-by: Jatin Garg <[email protected]>
  • Loading branch information
jatgarg and Jatin Garg authored Sep 24, 2024
1 parent fbda4c0 commit 2c9ff85
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ describeCompat("Attributor", "NoCompat", (getTestObjectProvider, apis) => {

const getTestConfig = (
enable: boolean = false,
summaryVersion?: string,
disableSummaries: boolean = true,
): ITestContainerConfig => ({
...testContainerConfig,
Expand All @@ -135,7 +134,6 @@ describeCompat("Attributor", "NoCompat", (getTestObjectProvider, apis) => {
track: enable,
policyFactory: createInsertOnlyAttributionPolicy,
},
[LoaderHeader.version]: summaryVersion,
} as any,
},
runtimeOptions: disableSummaries
Expand Down Expand Up @@ -170,8 +168,13 @@ describeCompat("Attributor", "NoCompat", (getTestObjectProvider, apis) => {
*/
itSkipsFailureOnSpecificDrivers(
"Can attribute content from multiple collaborators",
["tinylicious", "t9s", "r11s"],
async () => {
["tinylicious", "t9s"],
async function () {
// Skip tests for r11s drivers due to timeout issues because of certain network calls
// taking longer time and this test has nothing to do with r11s driver.
if (provider.driver.type === "r11s" || provider.driver.type === "routerlicious") {
this.skip();
}
const container1 = await provider.makeTestContainer(getTestConfig(true));
const sharedString1 = await sharedStringFromContainer(container1);
const container2 = await provider.loadTestContainer(getTestConfig(true));
Expand Down Expand Up @@ -208,75 +211,75 @@ describeCompat("Attributor", "NoCompat", (getTestObjectProvider, apis) => {
},
);

itSkipsFailureOnSpecificDrivers(
"attributes content created in a detached state",
["r11s"],
async () => {
const loader = provider.makeTestLoader(getTestConfig(true));
const defaultCodeDetails: IFluidCodeDetails = {
package: "defaultTestPackage",
config: {},
};
const container1 = await loader.createDetachedContainer(defaultCodeDetails);
const sharedString1 = await sharedStringFromContainer(container1);
it("attributes content created in a detached state", async function () {
// Skip tests for r11s drivers due to timeout issues because of certain network calls
// taking longer time and this test has nothing to do with r11s driver.
if (provider.driver.type === "r11s" || provider.driver.type === "routerlicious") {
this.skip();
}
const loader = provider.makeTestLoader(getTestConfig(true));
const defaultCodeDetails: IFluidCodeDetails = {
package: "defaultTestPackage",
config: {},
};
const container1 = await loader.createDetachedContainer(defaultCodeDetails);
const sharedString1 = await sharedStringFromContainer(container1);

const text = "client 1";
sharedString1.insertText(0, text);
await container1.attach(provider.driver.createCreateNewRequest("doc id"));
await provider.ensureSynchronized();
const text = "client 1";
sharedString1.insertText(0, text);
await container1.attach(provider.driver.createCreateNewRequest("doc id"));
await provider.ensureSynchronized();

const url = await container1.getAbsoluteUrl("");
assert(url !== undefined);
const loader2 = provider.makeTestLoader(getTestConfig(true));
const container2 = await loader2.resolve({ url });
const url = await container1.getAbsoluteUrl("");
assert(url !== undefined);
const loader2 = provider.makeTestLoader(getTestConfig(true));
const container2 = await loader2.resolve({ url });

const sharedString2 = await sharedStringFromContainer(container2);
sharedString2.insertText(0, "client 2, ");
const sharedString2 = await sharedStringFromContainer(container2);
sharedString2.insertText(0, "client 2, ");

await provider.ensureSynchronized();
assert.equal(sharedString1.getText(), "client 2, client 1");
await provider.ensureSynchronized();
assert.equal(sharedString1.getText(), "client 2, client 1");

assert(
container1.clientId !== undefined && container2.clientId !== undefined,
"Both containers should have client ids.",
);
const attributor = await getAttributorFromContainer(container1);
assertAttributionMatches(sharedString1, 3, attributor, {
user: container1.audience.getMember(container2.clientId)?.user,
});
assertAttributionMatches(sharedString1, 13, attributor, "detached");
assert(
container1.clientId !== undefined && container2.clientId !== undefined,
"Both containers should have client ids.",
);
const attributor = await getAttributorFromContainer(container1);
assertAttributionMatches(sharedString1, 3, attributor, {
user: container1.audience.getMember(container2.clientId)?.user,
});
assertAttributionMatches(sharedString1, 13, attributor, "detached");

const attributor2 = await getAttributorFromContainer(container2);
assertAttributionMatches(sharedString2, 3, attributor2, {
user: container1.audience.getMember(container2.clientId)?.user,
});
assertAttributionMatches(sharedString2, 13, attributor2, "detached");
},
);
const attributor2 = await getAttributorFromContainer(container2);
assertAttributionMatches(sharedString2, 3, attributor2, {
user: container1.audience.getMember(container2.clientId)?.user,
});
assertAttributionMatches(sharedString2, 13, attributor2, "detached");
});

it("repopulates attribution association data using the summary tree", async () => {
it("repopulates attribution association data using the summary tree", async function () {
const container1 = await provider.makeTestContainer(getTestConfig(true));
const sharedString1 = await sharedStringFromContainer(container1);
const attributor1 = await getAttributorFromContainer(container1);

const text = "client 1";
sharedString1.insertText(0, text);
// await container1.attach(provider.driver.createCreateNewRequest("doc id"));
await provider.ensureSynchronized();
sharedString1.insertText(0, "client 2, ");
await provider.ensureSynchronized();

const summarizer = await createSummarizer(
provider,
container1,
getTestConfig(true, undefined, false),
getTestConfig(true, false),
);
await provider.ensureSynchronized();
const summaryResult = await summarizeNow(summarizer.summarizer);

const container2 = await provider.loadTestContainer(
getTestConfig(true, summaryResult.summaryVersion),
);
const container2 = await provider.loadTestContainer(getTestConfig(true), {
[LoaderHeader.version]: summaryResult.summaryVersion,
});
const sharedString2 = await sharedStringFromContainer(container2);
const attributor2 = await getAttributorFromContainer(container2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ describeCompat("Attributor for SharedCell", "NoCompat", (getTestObjectProvider,
*/
itSkipsFailureOnSpecificDrivers(
"Can attribute content from multiple collaborators",
["tinylicious", "t9s", "r11s"],
async () => {
["tinylicious", "t9s"],
async function () {
// Skip tests for r11s drivers due to timeout issues because of certain network calls
// taking longer time and this test has nothing to do with r11s driver.
if (provider.driver.type === "r11s" || provider.driver.type === "routerlicious") {
this.skip();
}
const container1 = await provider.makeTestContainer(getTestConfig(true));
const sharedCell1 = await sharedCellFromContainer(container1);
const container2 = await provider.loadTestContainer(getTestConfig(true));
Expand Down Expand Up @@ -169,43 +174,44 @@ describeCompat("Attributor for SharedCell", "NoCompat", (getTestObjectProvider,
},
);

itSkipsFailureOnSpecificDrivers(
"attributes content created in a detached state",
["r11s"],
async () => {
const loader = provider.makeTestLoader(getTestConfig(true));
const defaultCodeDetails: IFluidCodeDetails = {
package: "defaultTestPackage",
config: {},
};
const container1 = await loader.createDetachedContainer(defaultCodeDetails);
const sharedCell1 = await sharedCellFromContainer(container1);

sharedCell1.set(1);
const attributor1 = await getAttributorFromContainer(container1);
assertAttributionMatches(sharedCell1, attributor1, "detached");

await container1.attach(provider.driver.createCreateNewRequest("doc id"));
await provider.ensureSynchronized();

const url = await container1.getAbsoluteUrl("");
assert(url !== undefined);
const loader2 = provider.makeTestLoader(getTestConfig());
const container2 = await loader2.resolve({ url });

const sharedCell2 = await sharedCellFromContainer(container2);
sharedCell2.set(2);

await provider.ensureSynchronized();

assert(
container1.clientId !== undefined && container2.clientId !== undefined,
"Both containers should have client ids.",
);

assertAttributionMatches(sharedCell1, attributor1, {
user: container1.audience.getMember(container2.clientId)?.user,
});
},
);
it("attributes content created in a detached state", async function () {
// Skip tests for r11s drivers due to timeout issues because of certain network calls
// taking longer time and this test has nothing to do with r11s driver.
if (provider.driver.type === "r11s" || provider.driver.type === "routerlicious") {
this.skip();
}
const loader = provider.makeTestLoader(getTestConfig(true));
const defaultCodeDetails: IFluidCodeDetails = {
package: "defaultTestPackage",
config: {},
};
const container1 = await loader.createDetachedContainer(defaultCodeDetails);
const sharedCell1 = await sharedCellFromContainer(container1);

sharedCell1.set(1);
const attributor1 = await getAttributorFromContainer(container1);
assertAttributionMatches(sharedCell1, attributor1, "detached");

await container1.attach(provider.driver.createCreateNewRequest("doc id"));
await provider.ensureSynchronized();

const url = await container1.getAbsoluteUrl("");
assert(url !== undefined);
const loader2 = provider.makeTestLoader(getTestConfig());
const container2 = await loader2.resolve({ url });

const sharedCell2 = await sharedCellFromContainer(container2);
sharedCell2.set(2);

await provider.ensureSynchronized();

assert(
container1.clientId !== undefined && container2.clientId !== undefined,
"Both containers should have client ids.",
);

assertAttributionMatches(sharedCell1, attributor1, {
user: container1.audience.getMember(container2.clientId)?.user,
});
});
});

0 comments on commit 2c9ff85

Please sign in to comment.