65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
const baseCommand = "node";
|
|
const suiteEntry = "tests/assets/suite/runner.js";
|
|
const pipelineMapping = [
|
|
{
|
|
id: 0,
|
|
pipeline: [{ name: "primary" }, { name: "secondary", delay: 5000 }],
|
|
},
|
|
];
|
|
|
|
const buildCommon = (jobRequest) => {
|
|
const { testName } = jobRequest;
|
|
if (!testName) throw Error("'testName' must be provided!");
|
|
const command = [baseCommand, suiteEntry, `test=${testName}`];
|
|
|
|
// Apply Common Flags
|
|
command.push("isRetry=false");
|
|
|
|
// Return new request
|
|
return { ...jobRequest, command };
|
|
};
|
|
|
|
const buildSingle = (jobReq) => jobReq;
|
|
|
|
const buildMarker = (jobReq) => {};
|
|
|
|
const buildProject = (jobReq) => {};
|
|
|
|
const pipelineMaxLife = (testName) => {
|
|
const pipelines = pipelineMapping
|
|
.filter((m) => m.pipeline.find((t) => t.name === testName))
|
|
.map((m) => m.pipeline);
|
|
return Math.max(pipelines.map((p) => p.length)) + 1;
|
|
};
|
|
|
|
const buildCompound = (jobReq, socketId) => {
|
|
const { testName, command } = jobReq;
|
|
const { pipeline } = jobReq;
|
|
if (pipeline) {
|
|
pipeline.dashboardSocketId = socketId;
|
|
const pipelineArg = Buffer.from(JSON.stringify(pipeline), "utf8").toString(
|
|
"base64"
|
|
);
|
|
command.push(`pipeline=${pipelineArg}`);
|
|
}
|
|
|
|
return { ...jobReq, command };
|
|
};
|
|
|
|
function nextCompound(previousTest) {}
|
|
|
|
export default function jobBuilder(jobRequest, id) {
|
|
const jobReq = buildCommon(jobRequest, id);
|
|
switch (jobRequest.type) {
|
|
case "single":
|
|
return buildSingle(jobReq);
|
|
case "marker":
|
|
return buildMarker(jobReq);
|
|
case "project":
|
|
return buildProject(jobReq);
|
|
case "compound":
|
|
return buildCompound(jobReq, id);
|
|
default:
|
|
throw Error("No Job Request Type Specified!");
|
|
}
|
|
}
|