Skip to content

Commit

Permalink
Merge tree: add sidedness to obliterate ops in conflict farm tests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaffiro authored Oct 9, 2024
1 parent 6c06bbd commit 809a1e7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/dds/merge-tree/src/test/client.conflictFarm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,30 @@ function runConflictFarmTests(opts: IConflictFarmConfig, extraSeed?: number): vo
config: { ...opts, applyOpDuringGeneration: true },
},
{
name: "with obliterate",
name: "obliterate with number endpoints",
config: {
...opts,
operations: [...opts.operations, obliterateRange],
},
},
// TODO: AB#15630
// {
// name: "obliterate with sided endpoints",
// config: {
// ...opts,
// operations: [...opts.operations, obliterateRange, obliterateRangeSided],
// },
// },
])
it(`${name}: ConflictFarm_${minLength}`, async () => {
const random = makeRandom(0xdeadbeef, 0xfeedbed, minLength, extraSeed ?? 0);

const clients: TestClient[] = [new TestClient({ mergeTreeEnableObliterate: true })];
const clients: TestClient[] = [
new TestClient({
mergeTreeEnableObliterate: true,
mergeTreeEnableSidedObliterate: true,
}),
];
for (const [i, c] of clients.entries()) c.startOrUpdateCollaboration(clientNames[i]);

let seq = 0;
Expand Down
27 changes: 27 additions & 0 deletions packages/dds/merge-tree/src/test/mergeTreeOperationRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/in
import { walkAllChildSegments } from "../mergeTreeNodeWalk.js";
import { ISegment, SegmentGroup, toMoveInfo, toRemovalInfo } from "../mergeTreeNodes.js";
import { IMergeTreeOp, MergeTreeDeltaType, ReferenceType } from "../ops.js";
import { Side } from "../sequencePlace.js";
import { TextSegment } from "../textSegment.js";

import { _dirname } from "./dirname.cjs";
Expand All @@ -39,6 +40,32 @@ export const obliterateRange: TestOperation = (
opEnd: number,
) => client.obliterateRangeLocal(opStart, opEnd);

export const obliterateRangeSided: TestOperation = (
client: TestClient,
opStart: number,
opEnd: number,
random: IRandom,
) => {
let startSide: Side;
let endSide: Side;

const oblEnd = random.integer(opStart, client.getLength() - 1);
// TODO: to create zero length obliterate ops, change '<=' to '<'.
// Doing so may cause different failures than those without zero length.
// AB#19930
if (oblEnd - opStart <= 1) {
startSide = Side.Before;
endSide = Side.After;
} else {
startSide = random.pick([Side.Before, Side.After]);
endSide = random.pick([Side.Before, Side.After]);
}

const start = { pos: opStart, side: startSide };
const end = { pos: oblEnd, side: endSide };
return client.obliterateRangeLocal(start, end);
};

export const annotateRange: TestOperation = (
client: TestClient,
opStart: number,
Expand Down

0 comments on commit 809a1e7

Please sign in to comment.