Skip to content

Commit

Permalink
Make it possible to use the compare plugin in Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Jul 30, 2024
1 parent 602a2c5 commit 5dc949f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 5 additions & 3 deletions testrunner/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ location:
# containers, you need to set --s3.endpoint to something else than 127.0.0.1.
# On Mac you can use --s3.endpoint http://host.docker.internal:9000 and on Linux
# you can use your actual IP.
useDocker: true
useDocker: false

- name: "Emulated Mobile"
type: "emulatedMobile"
browsers: ["chrome"]
connectivity: ["native", "3g", "4g", "cable"]
useDocker: true
useDocker: false

# Here's an example of setting up a Android phone
#- name: "Android"
Expand Down Expand Up @@ -64,10 +64,12 @@ executable: "sitespeed.io"
# If you run sitespeed.io using Docker this is the container that is used.
# If you use the latest, make sure to docker pull the container once a day
# to get the latest version
# extraparameters will be passed omn to Docker, between docker run and the container name
# extraparameters will be passed on to Docker, between docker run and the container name
# baselineDddir is the directory that is mappedd where baseline data is stored
docker:
container: "sitespeedio/sitespeed.io:latest"
extraparameters: "--cap-add=NET_ADMIN"
#baselinedir: "$(pwd)"

# The number of jobs to keep in the queue
# Depending on how many jobs you run and how much memory
Expand Down
13 changes: 11 additions & 2 deletions testrunner/src/testrunners/docker-testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export default async function runJob(job) {
configFileName,
resultFileName,
(job.data.extras && job.data.extras.includes('--webpagereplay')) ||
job.data.config.webpagereplay
job.data.config.webpagereplay,
(job.data.extras && job.data.extras.includes('--compare.')) ||
job.data.config.compare
);

if (job.data.scripting) {
Expand Down Expand Up @@ -156,7 +158,8 @@ function setupDockerParameters(
workingDirectory,
configFileName,
resultFileName,
usingWebPageReplay
usingWebPageReplay,
usingBaseline
) {
const baseParameters = [
'run',
Expand All @@ -177,6 +180,12 @@ function setupDockerParameters(
if (usingWebPageReplay) {
baseParameters.splice(1, 0, '-e', 'REPLAY=true', '-e', 'LATENCY=100');
}

if (usingBaseline) {
const baselineDirectory = nconf.get('docker:baselinedir') || '"$(pwd)"';
baseParameters.splice(1, 0, '-v', `${baselineDirectory}:/baseline`);
}

return baseParameters;
}

Expand Down
3 changes: 2 additions & 1 deletion testrunner/src/validateconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ const loggingSchema = Joi.object({
// Docker schema
const dockerSchema = Joi.object({
container: Joi.string().optional(),
extraparameters: Joi.string().allow(null).optional()
extraparameters: Joi.string().allow(null).optional(),
baselinedir: Joi.string().allow(null).optional()
});

// Complete config schema
Expand Down

0 comments on commit 5dc949f

Please sign in to comment.