Skip to content

Commit

Permalink
Merge fa81614 into 1fa4268
Browse files Browse the repository at this point in the history
  • Loading branch information
surilindur committed May 2, 2024
2 parents 1fa4268 + fa81614 commit c9332ae
Show file tree
Hide file tree
Showing 16 changed files with 3,262 additions and 3,156 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/.husky/_
**/.idea/
**/node_modules/
**/coverage/
Expand Down
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

7 changes: 3 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run build && npm run lint && npm run test
yarn run build
yarn run lint
yarn run test
1 change: 0 additions & 1 deletion .yarnrc.yml

This file was deleted.

15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@
"scripts": {
"test-changed": "lerna run test --since HEAD",
"build-changed": "lerna run build --since HEAD",
"build": "npm run build:ts && npm run build:components",
"build": "yarn run build:ts && yarn run build:components",
"build:ts": "tsc",
"build:components": "componentsjs-generator packages/*",
"build-watch": "tsc --watch",
"publish": "yarn run build",
"publish-release": "lerna publish",
"publish-bare": "lerna exec -- npm publish --silent",
"publish-bare": "lerna exec -- yarn publish --silent",
"publish-canary": "yarn run build && lerna version prerelease --preid alpha.$(git rev-parse --short HEAD) --ignore-scripts --force-publish --no-push --no-git-tag-version --yes && git update-index --assume-unchanged $(git ls-files | tr '\\n' ' ') && lerna publish from-package --no-git-reset --pre-dist-tag next --force-publish --no-push --no-git-tag-version --yes && git update-index --no-assume-unchanged $(git ls-files | tr '\\n' ' ') && git checkout .",
"test": "jest --runInBand",
"test-ci": "jest --ci --maxWorkers=4 --coverage",
"lint": "eslint . --ext .ts --cache",
"clean": "rm -rf ./node_modules && rm -rf ./packages/*/node_modules",
"postinstall": "yarn run build && lerna run prepare",
"version": "manual-git-changelog onversion",
"prepare": "husky install",
"prepare": "husky",
"doc": "typedoc"
},
"devDependencies": {
Expand All @@ -71,7 +71,7 @@
"eslint-plugin-tsdoc": "^0.2.7",
"eslint-plugin-unused-imports": "^2.0.0",
"fs-extra": "^10.0.0",
"husky": "^8.0.0",
"husky": "^9.0.0",
"jest": "^29.0.0",
"jest-extended": "^4.0.0",
"lerna": "^6.0.0",
Expand All @@ -80,10 +80,5 @@
"ts-jest": "^29.0.0",
"typedoc": "^0.21.0",
"typescript": "^4.0.5"
},
"pre-commit": [
"build",
"lint",
"test"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class ExperimentHandlerSolidBench extends ExperimentHandler<ExperimentSol
configValidation: 'input/config-validation.json',
hadoopMemory: '4G',
dockerfileServer: 'input/dockerfiles/Dockerfile-server',

endpointUrl: 'http://localhost:3001/sparql',
serverPort: 3_000,
serverLogLevel: 'info',
Expand All @@ -36,11 +35,9 @@ export class ExperimentHandlerSolidBench extends ExperimentHandler<ExperimentSol
},
queryRunnerReplication: 3,
queryRunnerWarmupRounds: 1,
queryRunnerRecordTimestamps: true,
queryRunnerRecordHttpRequests: true,
queryRunnerUpQuery: `SELECT * WHERE { <http://solidbench-server:3000/pods/00000000000000000933/profile/card#me> a ?o } LIMIT 1`,
queryRunnerUrlParamsInit: {},
queryRunnerUrlParamsRun: {},
queryRunnerUrlParams: {},
queryRunnerEndpointAvailabilityCheckTimeout: 1_000,
queryRunnerRequestDelay: 0,
};
}

Expand Down
59 changes: 25 additions & 34 deletions packages/experiment-solidbench/lib/ExperimentSolidBench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Experiment, Hook, ITaskContext,
DockerResourceConstraints, ICleanTargets, DockerContainerHandler, DockerNetworkHandler } from 'jbr';
import { ProcessHandlerComposite, secureProcessHandler } from 'jbr';
import { Generator } from 'solidbench/lib/Generator';
import { readQueries, SparqlBenchmarkRunner, writeBenchmarkResults } from 'sparql-benchmark-runner';
import { QueryLoaderFile, SparqlBenchmarkRunner, ResultSerializerCsv } from 'sparql-benchmark-runner';

/**
* An experiment instance for the SolidBench social network benchmark.
Expand All @@ -27,13 +27,11 @@ export class ExperimentSolidBench implements Experiment {
public readonly serverBaseUrl: string;
public readonly serverResourceConstraints: DockerResourceConstraints;
public readonly endpointUrl: string;
public readonly queryRunnerEndpointAvailabilityCheckTimeout: number | undefined;
public readonly queryRunnerRequestDelay: number | undefined;
public readonly queryRunnerReplication: number;
public readonly queryRunnerWarmupRounds: number;
public readonly queryRunnerRecordTimestamps: boolean;
public readonly queryRunnerRecordHttpRequests: boolean;
public readonly queryRunnerUpQuery: string;
public readonly queryRunnerUrlParamsInit: Record<string, any>;
public readonly queryRunnerUrlParamsRun: Record<string, any>;
public readonly queryRunnerUrlParams: Record<string, any>;
public readonly queryTimeoutFallback: number | undefined;

/**
Expand All @@ -53,13 +51,11 @@ export class ExperimentSolidBench implements Experiment {
* @param serverBaseUrl
* @param serverResourceConstraints
* @param endpointUrl
* @param queryRunnerEndpointAvailabilityCheckTimeout
* @param queryRunnerRequestDelay
* @param queryRunnerReplication
* @param queryRunnerWarmupRounds
* @param queryRunnerRecordTimestamps
* @param queryRunnerRecordHttpRequests
* @param queryRunnerUpQuery
* @param queryRunnerUrlParamsInit - @range {json}
* @param queryRunnerUrlParamsRun - @range {json}
* @param queryRunnerUrlParams - @range {json}
* @param queryTimeoutFallback
*/
public constructor(
Expand All @@ -79,13 +75,11 @@ export class ExperimentSolidBench implements Experiment {
serverBaseUrl: string,
serverResourceConstraints: DockerResourceConstraints,
endpointUrl: string,
queryRunnerEndpointAvailabilityCheckTimeout: number | undefined,
queryRunnerRequestDelay: number | undefined,
queryRunnerReplication: number,
queryRunnerWarmupRounds: number,
queryRunnerRecordTimestamps: boolean,
queryRunnerRecordHttpRequests: boolean,
queryRunnerUpQuery: string,
queryRunnerUrlParamsInit: Record<string, any>,
queryRunnerUrlParamsRun: Record<string, any>,
queryRunnerUrlParams: Record<string, any>,
queryTimeoutFallback: number | undefined,
) {
this.scale = scale;
Expand All @@ -104,13 +98,11 @@ export class ExperimentSolidBench implements Experiment {
this.serverLogLevel = serverLogLevel;
this.serverBaseUrl = serverBaseUrl;
this.serverResourceConstraints = serverResourceConstraints;
this.queryRunnerEndpointAvailabilityCheckTimeout = queryRunnerEndpointAvailabilityCheckTimeout;
this.queryRunnerRequestDelay = queryRunnerRequestDelay;
this.queryRunnerReplication = queryRunnerReplication;
this.queryRunnerWarmupRounds = queryRunnerWarmupRounds;
this.queryRunnerRecordTimestamps = queryRunnerRecordTimestamps;
this.queryRunnerRecordHttpRequests = queryRunnerRecordHttpRequests;
this.queryRunnerUpQuery = queryRunnerUpQuery;
this.queryRunnerUrlParamsInit = queryRunnerUrlParamsInit;
this.queryRunnerUrlParamsRun = queryRunnerUrlParamsRun;
this.queryRunnerUrlParams = queryRunnerUrlParams;
this.queryTimeoutFallback = queryTimeoutFallback;
}

Expand Down Expand Up @@ -183,6 +175,13 @@ export class ExperimentSolidBench implements Experiment {
const network = networkHandler.network.id;
const endpointProcessHandler = await this.hookSparqlEndpoint.start(context, { docker: { network }});

// Setup query loader and result serializer
const queryLoader = new QueryLoaderFile({
path: Path.join(context.experimentPaths.generated, 'out-queries'),
extensions: [ '.sparql' ],
});
const resultSerializer = new ResultSerializerCsv();

const processHandler = new ProcessHandlerComposite([
serverHandler,
endpointProcessHandler,
Expand All @@ -194,14 +193,13 @@ export class ExperimentSolidBench implements Experiment {
let stopStats: () => void;
const results = await new SparqlBenchmarkRunner({
endpoint: this.endpointUrl,
querySets: await readQueries(Path.join(context.experimentPaths.generated, 'out-queries')),
querySets: await queryLoader.loadQueries(),
replication: this.queryRunnerReplication,
warmup: this.queryRunnerWarmupRounds,
timestampsRecording: this.queryRunnerRecordTimestamps,
logger: (message: string) => process.stderr.write(message),
upQuery: this.queryRunnerUpQuery,
additionalUrlParamsInit: new URLSearchParams(this.queryRunnerUrlParamsInit),
additionalUrlParamsRun: new URLSearchParams(this.queryRunnerUrlParamsRun),
additionalUrlParams: new URLSearchParams(this.queryRunnerUrlParams),
availabilityCheckTimeout: this.queryRunnerEndpointAvailabilityCheckTimeout,
requestDelay: this.queryRunnerRequestDelay,
timeout: this.queryTimeoutFallback,
}).run({
async onStart() {
Expand All @@ -224,14 +222,7 @@ export class ExperimentSolidBench implements Experiment {
await fs.mkdir(resultsOutput);
}
context.logger.info(`Writing results to ${resultsOutput}\n`);
await writeBenchmarkResults(
results,
Path.join(resultsOutput, 'query-times.csv'),
this.queryRunnerRecordTimestamps,
[
...this.queryRunnerRecordHttpRequests ? [ 'httpRequests' ] : [],
],
);
await resultSerializer.serialize(Path.join(resultsOutput, 'query-times.csv'), results);

// Close endpoint and server
await closeProcess();
Expand Down
2 changes: 1 addition & 1 deletion packages/experiment-solidbench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@
"@types/yargs": "^17.0.0",
"fs-extra": "^10.0.0",
"solidbench": "^1.6.1",
"sparql-benchmark-runner": "^2.9.4"
"sparql-benchmark-runner": "^3.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('ExperimentHandlerSolidBench', () => {
describe('getDefaultParams', () => {
it('returns a hash', () => {
expect(handler.getDefaultParams(experimentPaths)).toBeInstanceOf(Object);
expect(Object.entries(handler.getDefaultParams(experimentPaths)).length).toEqual(22);
expect(Object.entries(handler.getDefaultParams(experimentPaths)).length).toEqual(20);
});
});

Expand Down
64 changes: 15 additions & 49 deletions packages/experiment-solidbench/test/ExperimentSolidBench.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { Hook, ITaskContext,
DockerContainerHandler,
DockerResourceConstraints, ProcessHandler } from 'jbr';
import { StaticDockerResourceConstraints, createExperimentPaths } from 'jbr';
import { writeBenchmarkResults } from 'sparql-benchmark-runner';
import { TestLogger } from '../../jbr/test/TestLogger';
import { ExperimentSolidBench } from '../lib/ExperimentSolidBench';

Expand All @@ -16,15 +15,21 @@ jest.mock('solidbench/lib/Generator', () => ({
}));

let sparqlBenchmarkRun: any;
let queryLoaderLoadQueries: any;
let resultSerializerSerialize: any;
jest.mock('sparql-benchmark-runner', () => ({
SparqlBenchmarkRunner: jest.fn().mockImplementation((options: any) => {
options.logger('Test logger');
return {
run: sparqlBenchmarkRun,
};
}),
readQueries: jest.fn(),
writeBenchmarkResults: jest.fn(),
QueryLoaderFile: jest.fn().mockImplementation(() => ({
loadQueries: queryLoaderLoadQueries,
})),
ResultSerializerCsv: jest.fn().mockImplementation(() => ({
serialize: resultSerializerSerialize,
})),
}));

let files: Record<string, boolean | string> = {};
Expand Down Expand Up @@ -145,6 +150,8 @@ describe('ExperimentSolidBench', () => {
await onStart();
await onStop();
});
queryLoaderLoadQueries = jest.fn();
resultSerializerSerialize = jest.fn();
resourceConstraints = new StaticDockerResourceConstraints({}, {});
experiment = new ExperimentSolidBench(
'0.1',
Expand All @@ -163,12 +170,10 @@ describe('ExperimentSolidBench', () => {
'http://localhost:3000',
resourceConstraints,
'http://localhost:3001/sparql',
1_000,
0,
3,
1,
true,
true,
`SELECT * WHERE { <http://solidbench-server:3000/pods/00000000000000000933/profile/card#me> a ?o } LIMIT 1`,
{},
{},
600,
);
Expand Down Expand Up @@ -278,11 +283,10 @@ This can be configured using Node's --max_old_space_size option.`);
expect(endpointHandler.close).toHaveBeenCalled();
expect(serverHandlerStopCollectingStats).toHaveBeenCalled();
expect(endpointHandlerStopCollectingStats).toHaveBeenCalled();
expect(writeBenchmarkResults).toHaveBeenCalledWith(
undefined,
expect(resultSerializerSerialize).toHaveBeenCalledWith(
Path.normalize('CWD/output/query-times.csv'),
true,
[ 'httpRequests' ],
// eslint-disable-next-line unicorn/no-useless-undefined
undefined,
);

expect(dirsOut).toEqual({
Expand All @@ -291,44 +295,6 @@ This can be configured using Node's --max_old_space_size option.`);
});
});

it('should run the experiment without recording http requests', async() => {
experiment = new ExperimentSolidBench(
'0.1',
'input/config-enhancer.json',
'input/config-fragmenter.json',
'input/config-fragmenter-auxiliary.json',
'input/config-queries.json',
'input/config-server.json',
'input/config-validation-params.json',
'input/config-validation-config.json',
'4G',
'input/dockerfiles/Dockerfile-server',
hookSparqlEndpoint,
3_000,
'info',
'http://localhost:3000',
resourceConstraints,
'http://localhost:3001/sparql',
3,
1,
true,
false,
`SELECT * WHERE { <http://solidbench-server:3000/pods/00000000000000000933/profile/card#me> a ?o } LIMIT 1`,
{},
{},
600,
);

await experiment.run(context);

expect(writeBenchmarkResults).toHaveBeenCalledWith(
undefined,
Path.normalize('CWD/output/query-times.csv'),
true,
[],
);
});

it('should not create an output dir if it already exists', async() => {
files['CWD/output'] = true;
await experiment.run(context);
Expand Down
7 changes: 3 additions & 4 deletions packages/experiment-watdiv/lib/ExperimentHandlerWatDiv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ export class ExperimentHandlerWatDiv extends ExperimentHandler<ExperimentWatDiv>
datasetScale: 1,
queryCount: 5,
queryRecurrence: 1,

generateHdt: true,

endpointUrl: 'http://localhost:3001/sparql',
queryRunnerReplication: 3,
queryRunnerWarmupRounds: 1,
queryRunnerRecordTimestamps: true,
queryRunnerRecordHttpRequests: true,
queryRunnerUrlParamsInit: {},
queryRunnerUrlParamsRun: {},
queryRunnerUrlParams: {},
queryRunnerEndpointAvailabilityCheckTimeout: 1_000,
queryRunnerRequestDelay: 0,
};
}

Expand Down
Loading

0 comments on commit c9332ae

Please sign in to comment.