Skip to content

Commit

Permalink
Add stress test for testing new fluid binary wire format (#9391)
Browse files Browse the repository at this point in the history
  • Loading branch information
jatgarg authored Mar 30, 2022
1 parent b84ea27 commit f3e2823
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 14 deletions.
18 changes: 9 additions & 9 deletions packages/drivers/odsp-driver/src/compactSnapshotParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
assertNumberInstance,
getAndValidateNodeProps,
NodeCore,
NodeTypes,
TreeBuilder,
} from "./zipItDataRepresentationUtils";

Expand All @@ -28,7 +29,8 @@ interface ISnapshotSection {
* Recreates blobs section of the tree.
* @param node - tree node to read blob section from
*/
function readBlobSection(node: NodeCore) {
function readBlobSection(node: NodeTypes) {
assertNodeCoreInstance(node, "TreeBlobs should be of type NodeCore");
const blobs: Map<string, ArrayBuffer> = new Map();
for (let count = 0; count < node.length; ++count) {
const blob = node.getNode(count);
Expand All @@ -44,7 +46,8 @@ function readBlobSection(node: NodeCore) {
* Recreates ops section of the tree.
* @param node - tree node to read ops section from
*/
function readOpsSection(node: NodeCore) {
function readOpsSection(node: NodeTypes) {
assertNodeCoreInstance(node, "Deltas should be of type NodeCore");
const ops: ISequencedDocumentMessage[] = [];
const records = getAndValidateNodeProps(node, ["firstSequenceNumber", "deltas"]);
assertNumberInstance(records.firstSequenceNumber, "Seq number should be a number");
Expand Down Expand Up @@ -93,7 +96,8 @@ function readTreeSection(node: NodeCore) {
* Recreates snapshot tree out of tree representation.
* @param node - tree node to de-serialize from
*/
function readSnapshotSection(node: NodeCore): ISnapshotSection {
function readSnapshotSection(node: NodeTypes): ISnapshotSection {
assertNodeCoreInstance(node, "Snapshot should be of type NodeCore");
const records = getAndValidateNodeProps(node,
["id", "sequenceNumber", "treeNodes"]);

Expand All @@ -120,7 +124,7 @@ export function parseCompactSnapshotResponse(buffer: ReadBuffer): ISnapshotConte
const root = builder.getNode(0);

const records = getAndValidateNodeProps(root,
["mrv", "cv", "snapshot", "blobs", "deltas"]);
["mrv", "cv", "snapshot", "blobs", "deltas"], false);

assertBlobCoreInstance(records.mrv, "minReadVersion should be of BlobCore type");
assertBlobCoreInstance(records.cv, "createVersion should be of BlobCore type");
Expand All @@ -129,13 +133,9 @@ export function parseCompactSnapshotResponse(buffer: ReadBuffer): ISnapshotConte
assert(records.cv.toString() >= snapshotMinReadVersion,
0x210 /* "Snapshot should be created with minReadVersion or above" */);

assertNodeCoreInstance(records.snapshot, "Snapshot should be of type NodeCore");
assertNodeCoreInstance(records.blobs, "TreeBlobs should be of type NodeCore");
assertNodeCoreInstance(records.deltas, "Deltas should be of type NodeCore");

return {
...readSnapshotSection(records.snapshot),
blobs: readBlobSection(records.blobs),
ops: readOpsSection(records.deltas),
ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [],
};
}
2 changes: 1 addition & 1 deletion packages/test/test-drivers/src/odspDriverApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const generateOdspHostStoragePolicy = (seed: number) => {
sessionOptions: [undefined, ...generatePairwiseOptions(odspSessionOptions, seed)],
enableRedeemFallback: booleanCases,
cacheCreateNewSummary: booleanCases,
fetchBinarySnapshotFormat: [false],
fetchBinarySnapshotFormat: [undefined],
isolateSocketCache: [true],
enableShareLinkWithCreate: [false],
};
Expand Down
12 changes: 12 additions & 0 deletions packages/test/test-service-load/src/optionsMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
numberCases,
} from "@fluidframework/test-pairwise-generator";
import { ILoaderOptions } from "@fluidframework/container-loader";
import { ConfigTypes } from "@fluidframework/telemetry-utils";

const loaderOptionsMatrix: OptionsMatrix<ILoaderOptions> = {
cache: booleanCases,
Expand Down Expand Up @@ -87,3 +88,14 @@ export function generateRuntimeOptions(
{...overrides, gcOptions: undefined, summaryOptions: undefined}),
seed);
}

export function generateConfigurations(
seed: number, overrides: OptionsMatrix<Record<string,ConfigTypes>> | undefined,
): Record<string,ConfigTypes>[] {
if (overrides === undefined) {
return [{}];
}
return generatePairwiseOptions<Record<string, ConfigTypes>>(
overrides,
seed);
}
9 changes: 8 additions & 1 deletion packages/test/test-service-load/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ITelemetryLogger } from "@fluidframework/common-definitions";
import { ILoadTest, IRunConfig } from "./loadTestDataStore";
import { createCodeLoader, createTestDriver, getProfile, loggerP, safeExit } from "./utils";
import { FaultInjectionDocumentServiceFactory } from "./faultInjectionDriver";
import { generateLoaderOptions, generateRuntimeOptions } from "./optionsMatrix";
import { generateConfigurations, generateLoaderOptions, generateRuntimeOptions } from "./optionsMatrix";

function printStatus(runConfig: IRunConfig, message: string) {
if (runConfig.verbose) {
Expand Down Expand Up @@ -139,6 +139,8 @@ async function runnerProcess(
const containerOptions = generateRuntimeOptions(
seed, runConfig.testConfig?.optionOverrides?.[driver]?.container);

const configurations = generateConfigurations(
seed, runConfig.testConfig?.optionOverrides?.[driver]?.configurations);
const testDriver: ITestDriver = await createTestDriver(driver, seed, runConfig.runId);
const baseLogger = await loggerP;
const logger = ChildLogger.create(baseLogger, undefined,
Expand Down Expand Up @@ -180,6 +182,11 @@ async function runnerProcess(
codeLoader: createCodeLoader(containerOptions[runConfig.runId % containerOptions.length]),
logger,
options: loaderOptions[runConfig.runId % containerOptions.length],
configProvider: {
getRawConfig(name) {
return configurations[runConfig.runId % configurations.length][name];
},
},
});

const container: IContainer = await loader.resolve({ url, headers });
Expand Down
6 changes: 4 additions & 2 deletions packages/test/test-service-load/src/testConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { ILoaderOptions } from "@fluidframework/container-definitions";
import { IContainerRuntimeOptions } from "@fluidframework/container-runtime";
import { ConfigTypes } from "@fluidframework/telemetry-utils";
import { TestDriverTypes } from "@fluidframework/test-driver-definitions";
import { OptionsMatrix } from "@fluidframework/test-pairwise-generator";

Expand Down Expand Up @@ -43,6 +44,7 @@ export interface ILoadTestConfig {
}

export interface OptionOverride{
loader?: Partial<OptionsMatrix<ILoaderOptions>>,
container?: Partial<OptionsMatrix<IContainerRuntimeOptions>>
loader?: Partial<OptionsMatrix<ILoaderOptions>>;
container?: Partial<OptionsMatrix<IContainerRuntimeOptions>>;
configurations?: OptionsMatrix<Record<string, ConfigTypes>>;
}
11 changes: 10 additions & 1 deletion packages/test/test-service-load/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ITelemetryBufferedLogger, ITestDriver, TestDriverTypes } from "@fluidfr
import { createFluidTestDriver, generateOdspHostStoragePolicy, OdspTestDriver } from "@fluidframework/test-drivers";
import { LocalCodeLoader } from "@fluidframework/test-utils";
import { createFluidExport, ILoadTest } from "./loadTestDataStore";
import { generateLoaderOptions, generateRuntimeOptions } from "./optionsMatrix";
import { generateConfigurations, generateLoaderOptions, generateRuntimeOptions } from "./optionsMatrix";
import { pkgName, pkgVersion } from "./packageVersion";
import { ILoadTestConfig, ITestConfig } from "./testConfigFile";

Expand Down Expand Up @@ -126,6 +126,10 @@ export async function initialize(testDriver: ITestDriver, seed: number, testConf
const containerOptions = random.pick(
randEng,
generateRuntimeOptions(seed, testConfig.optionOverrides?.[testDriver.type]?.container));
const configurations = random.pick(
randEng,
generateConfigurations(seed, testConfig?.optionOverrides?.[testDriver.type]?.configurations));

// Construct the loader
const loader = new Loader({
urlResolver: testDriver.createUrlResolver(),
Expand All @@ -140,6 +144,11 @@ export async function initialize(testDriver: ITestDriver, seed: number, testConf
}),
options: loaderOptions,
detachedBlobStorage: new MockDetachedBlobStorage(),
configProvider: {
getRawConfig(name) {
return configurations[name];
},
},
});

const container: IContainer = await loader.createDetachedContainer(codeDetails);
Expand Down
14 changes: 14 additions & 0 deletions packages/test/test-service-load/testConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@
"totalBlobCount": 300,
"blobSize": 10240,
"detachedBlobCount": 10
},
"binarySnapshotFormat": {
"opRatePerMin": 60,
"progressIntervalMs": 5000,
"numClients": 4,
"totalSendCount": 150,
"readWriteCycleMs": 10000,
"optionOverrides":{
"odsp":{
"configurations":{
"Fluid.Driver.Odsp.binaryFormatSnapshot": [true]
}
}
}
}
}
}

0 comments on commit f3e2823

Please sign in to comment.