Skip to content

Commit

Permalink
Make removeOnComplete and removeOnFail configurable (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Jun 26, 2024
1 parent 5d19120 commit d2bd6b1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
7 changes: 7 additions & 0 deletions testrunner/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ executable: "sitespeed.io"
docker:
container: "sitespeedio/sitespeed.io:latest"
extraparameters: "--cap-add=NET_ADMIN"

# The number of jobs to keep in the queue
# Depending on how many jobs you run and how much memory
# you have on your Redis/KeyDb instance you can tune this
queue:
removeOnComplete: 200
removeOnFail: 200
8 changes: 6 additions & 2 deletions testrunner/src/testrunners/docker-testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export default async function runJob(job) {
const dockerLogger = log.getLogger(
`sitespeedio.dockertestrunner.process.${job.id}`
);
// The number of objects to keep in the queue before removal
const removeOnComplete = nconf.get('queue:removeOnComplete') || 200;
const removeOnFail = nconf.get('queue:removeOnFail') || 200;

let workingDirectory;
try {
logger.info(`Start with job ${job.id}`);
Expand Down Expand Up @@ -103,8 +107,8 @@ export default async function runJob(job) {
runTime
},
{
removeOnComplete: 200,
removeOnFail: 200
removeOnComplete,
removeOnFail
}
);

Expand Down
9 changes: 7 additions & 2 deletions testrunner/src/testrunners/testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const { join } = path;
export default async function runJob(job) {
const logger = log.getLogger(`sitespeedio.testrunner.${job.id}`);
let workingDirectory;

// The number of objects to keep in the queue before removal
const removeOnComplete = nconf.get('queue:removeOnComplete') || 200;
const removeOnFail = nconf.get('queue:removeOnFail') || 200;

// Make sure we vatch everything that can go wrong
try {
logger.info('Start job');
Expand Down Expand Up @@ -50,8 +55,8 @@ export default async function runJob(job) {
runTime
},
{
removeOnComplete: 200,
removeOnFail: 200
removeOnComplete,
removeOnFail
}
);
if (testResult.exitCode > 0) {
Expand Down
8 changes: 7 additions & 1 deletion testrunner/src/validateconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const locationSchema = Joi.object({
setup: setupSchema.required()
});

const queueSchema = Joi.object({
removeOnComplete: Joi.number().allow(null).optional(),
removeOnFail: Joi.number().allow(null).optional()
});

// Redis schema
const redisSchema = Joi.object({
port: Joi.number().allow(null),
Expand Down Expand Up @@ -60,7 +65,8 @@ const configSchema = Joi.object({
sitespeedioConfigFile: Joi.string().optional(),
workingDirectory: Joi.string().optional(),
executable: Joi.string().required(),
docker: dockerSchema.required()
docker: dockerSchema.required(),
queue: queueSchema.optional()
});

export function validate(config) {
Expand Down

0 comments on commit d2bd6b1

Please sign in to comment.