Skip to content

Commit c7532f1

Browse files
committed
prepare docker build
1 parent 7e33448 commit c7532f1

File tree

5 files changed

+89
-21
lines changed

5 files changed

+89
-21
lines changed

.dockerignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.circleci/
2+
.dockerignore
3+
.git/
4+
.gitignore
5+
cleanup.js
6+
configureStyles.js
7+
copy.js
8+
favicon.ico
9+
frameworks/
10+
images/
11+
LICENSE
12+
node_modules/
13+
package-lock.json
14+
README.md
15+
results-ui/
16+
webdriver-ts/
17+
webdriver-ts-results/

Dockerfile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM centos:latest
2+
RUN echo "unsafe-perm = true" > /root/.npmrc
3+
RUN echo "{ \"allow_root\": true }" > /root/.bowerrc
4+
RUN curl -sL https://rpm.nodesource.com/setup_10.x | bash -
5+
RUN yum install -y nodejs gcc-c++ make git java
6+
RUN mkdir /server
7+
RUN mkdir /build
8+
RUN mkdir /src
9+
10+
COPY package.json /server
11+
WORKDIR /server
12+
RUN npm install
13+
14+
# Volume before chown changes owwner
15+
VOLUME /src
16+
VOLUME /build
17+
WORKDIR /build
18+
19+
RUN curl -sL https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm > /root/chrome.rpm
20+
RUN yum localinstall -y /root/chrome.rpm
21+
22+
# USER user
23+
24+
# RUN npm install
25+
EXPOSE 8080
26+
CMD ["/server/node_modules/.bin/http-server","-c-1","/build"]

package.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@
1010
"start": "http-server -c-1 .",
1111
"bench": "cd webdriver-ts && npm run selenium && npm run results",
1212
"selenium": "cd webdriver-ts && npm run selenium && npm run results",
13-
"check": "cd webdriver-ts && npm run selenium -- --count 1 --exitOnError true --fork false"
13+
"docker-build": "docker build -t js-framework-benchmark-centos -f Dockerfile .",
14+
"docker-start": "cross-env-shell docker run --rm -d -p 8080:8080 --name js-framework-benchmark --volume ${INIT_CWD}:/src --volume js-framework-benchmark:/build js-framework-benchmark-centos",
15+
"docker-stop": "docker stop js-framework-benchmark",
16+
"docker-sync": "docker exec -it js-framework-benchmark rsync -av --exclude /index.html --exclude dist --exclude package-lock.json --exclude node_modules --exclude .git --exclude webdriver-ts/results /src/ /build/",
17+
"docker-build-frameworks": "docker exec -it js-framework-benchmark npm install && docker exec -it js-framework-benchmark npm run build",
18+
"docker-rebuild": "npm run docker-sync && docker exec -it -w /build/webdriver-ts js-framework-benchmark npm run rebuild --headless",
19+
"docker-bench": "docker exec -it -w /build/webdriver-ts js-framework-benchmark node dist/benchmarkRunner.js --headless",
20+
"docker-results": "docker exec -it -w /build/webdriver-ts js-framework-benchmark npm run results",
21+
"docker-shell": "docker exec -it -w /build/webdriver-ts js-framework-benchmark /bin/bash",
22+
"docker-dev-webdriver": "npm run docker-sync && docker exec -it -w /build/webdriver-ts js-framework-benchmark npm run compile && docker exec -it -w /build/webdriver-ts js-framework-benchmark node dist/benchmarkRunner.js --headless"
1423
},
1524
"keywords": [
1625
"benchmark",
@@ -34,6 +43,7 @@
3443
"http-server": "^0.10.0",
3544
"lodash": "^4.15.0",
3645
"rimraf": "^2.6.2",
37-
"yargs": "^12.0.1"
46+
"yargs": "^12.0.1",
47+
"cross-env": "^5.2.0"
3848
}
3949
}

webdriver-ts/src/forkedBenchmarkRunner.ts

+30-15
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ async function runCPUBenchmark(framework: FrameworkData, benchmark: Benchmark, b
415415
await afterBenchmark(driver, benchmark, framework);
416416
await driver.executeScript("console.timeStamp('afterBenchmark')");
417417
} catch (e) {
418+
console.log(e);
418419
errors.push(await registerError(driver, framework, benchmark, e, ));
419420
throw e;
420421
}
@@ -473,6 +474,7 @@ async function runMemBenchmark(framework: FrameworkData, benchmark: Benchmark, b
473474
allResults.push(result);
474475
} catch (e) {
475476
errors.push(await registerError(driver, framework, benchmark, e, ));
477+
console.log(e);
476478
throw e;
477479
} finally {
478480
await driver.close();
@@ -494,6 +496,7 @@ async function runStartupBenchmark(framework: FrameworkData, benchmark: Benchmar
494496
try {
495497
results.push(await runLighthouse(framework, benchmarkOptions));
496498
} catch (error) {
499+
console.log(error);
497500
errors.push({imageFile: null, exception: error});
498501
throw error;
499502
}
@@ -523,24 +526,36 @@ export async function executeBenchmark(frameworks: FrameworkData[], keyed: boole
523526
return errorsAndWarnings;
524527
}
525528

529+
export async function benchmarkWithRetry(frameworks: FrameworkData[], keyed: boolean, frameworkName: string, benchmarkName: string, benchmarkOptions: BenchmarkOptions, retryCount: number): Promise<ErrorsAndWarning> {
530+
try {
531+
let errorsAndWarnings = await executeBenchmark(frameworks, keyed, frameworkName, benchmarkName, benchmarkOptions);
532+
if (config.LOG_DEBUG) console.log("benchmark finished - got errors promise", errorsAndWarnings);
533+
process.send(errorsAndWarnings);
534+
process.exit(0);
535+
return errorsAndWarnings;
536+
} catch (err) {
537+
console.log("error running benchmark", err);
538+
if (retryCount>1) {
539+
console.log("************* RETRY BENCHMARK *******************", retryCount);
540+
benchmarkWithRetry(frameworks, keyed, frameworkName, benchmarkName, benchmarkOptions, retryCount-1);
541+
} else {
542+
console.log("max retry reached");
543+
process.exit(1);
544+
}
545+
}
546+
}
547+
526548
process.on('message', (msg) => {
527549
if (config.LOG_DEBUG) console.log("child process got message", msg);
528550

529551
let {frameworks, keyed, frameworkName, benchmarkName, benchmarkOptions} : {frameworks: FrameworkData[], keyed: boolean, frameworkName: string, benchmarkName: string, benchmarkOptions: BenchmarkOptions} = msg;
530552
if (!benchmarkOptions.port) benchmarkOptions.port = config.PORT.toFixed();
531-
532-
try {
533-
let errorsPromise = executeBenchmark(frameworks, keyed, frameworkName, benchmarkName, benchmarkOptions);
534-
errorsPromise.then(errorsAndWarnings => {
535-
if (config.LOG_DEBUG) console.log("benchmark finished - got errors promise", errorsAndWarnings);
536-
process.send(errorsAndWarnings);
537-
process.exit(0);
538-
}).catch(err => {
539-
console.log("error running benchmark", err);
540-
process.exit(1);
541-
});
542-
} catch (err) {
543-
console.log("error running benchmark", err);
544-
process.exit(1);
553+
const MAX_RETRY = 3;
554+
try {
555+
benchmarkWithRetry(frameworks, keyed, frameworkName, benchmarkName, benchmarkOptions, MAX_RETRY)
556+
} catch (err) {
557+
console.log("direct error", err);
558+
process.exit(1);
559+
}
545560
}
546-
});
561+
);

webdriver-ts/src/rebuild.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ if (frameworks.length === 0) {
4141
if (frameworkInfos.length === 0) {
4242
throw "expected to find some version information for the framework";
4343
}
44-
console.log('npm run bench -- --count 1 --framework '+frameworkNames);
45-
exec('npm run bench -- --count 1 --framework '+frameworkNames, {
44+
console.log('npm run bench -- --headless --count 1 --framework '+frameworkNames);
45+
exec('npm run bench -- --headless --count 1 --framework '+frameworkNames, {
4646
stdio: 'inherit'
4747
});
48-
console.log('npm run isKeyed -- --framework '+frameworkNames);
49-
exec('npm run isKeyed -- --framework '+frameworkNames, {
48+
console.log('npm run isKeyed -- --headless --framework '+frameworkNames);
49+
exec('npm run isKeyed -- --headless --framework '+frameworkNames, {
5050
stdio: 'inherit'
5151
});
5252

0 commit comments

Comments
 (0)