Updated things for compound testing
This commit is contained in:
parent
4e6732c09b
commit
5c3f865604
16 changed files with 160 additions and 56 deletions
|
@ -12,6 +12,11 @@ export default class Initiator {
|
|||
this.onLog = options.onLog ?? ((d) => console.log(`job: ${d}`));
|
||||
this.onClose = options.onClose ?? (() => {});
|
||||
this.onCreate = options.onCreate ?? ((id) => console.log(`job id: ${id}`));
|
||||
this.onPipelineClose =
|
||||
options.onPipelineClose ??
|
||||
(() => {
|
||||
console.log("job pipeline closed");
|
||||
});
|
||||
}
|
||||
|
||||
async newJob(jobRequest, onLog, onClose, onCreate) {
|
||||
|
@ -31,4 +36,58 @@ export default class Initiator {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
async newPipelineJob(
|
||||
jobRequest,
|
||||
onLog,
|
||||
onClose,
|
||||
onCreate,
|
||||
onPipelineTrigger,
|
||||
onPipelineClose
|
||||
) {
|
||||
const mgr = new Manager(this.url, {
|
||||
query: { mode: this.mode, job: JSON.stringify(jobRequest) },
|
||||
});
|
||||
onLog = onLog ?? this.onLog.bind(this);
|
||||
onClose = onClose ?? this.onClose.bind(this);
|
||||
onCreate = onCreate ?? this.onCreate.bind(this);
|
||||
onPipelineTrigger =
|
||||
onPipelineTrigger ??
|
||||
((trigger) => {
|
||||
console.log("job trg:", trigger);
|
||||
const testName = trigger.pipelineTriggers;
|
||||
const pipelineData = trigger.pipelineData;
|
||||
const pipelineTriggers = trigger.newPipelineTriggers;
|
||||
const jobReq = {
|
||||
...jobRequest,
|
||||
testName,
|
||||
pipelineData,
|
||||
pipelineTriggers,
|
||||
};
|
||||
setTimeout(
|
||||
() =>
|
||||
this.newPipelineJob(
|
||||
jobReq,
|
||||
onLog,
|
||||
onClose,
|
||||
onCreate,
|
||||
onPipelineTrigger,
|
||||
onPipelineClose
|
||||
),
|
||||
trigger.pipelineDelay
|
||||
);
|
||||
});
|
||||
onPipelineClose = onPipelineClose ?? this.onPipelineClose.bind(this);
|
||||
const sk = mgr.socket("/");
|
||||
sk.on(events.JOB_LOG, onLog);
|
||||
sk.on(events.JOB_CLS, onClose);
|
||||
sk.on(events.PPL_TRG, onPipelineTrigger);
|
||||
sk.on(events.PPL_CLS, onPipelineClose);
|
||||
return new Promise((res) =>
|
||||
sk.on(events.JOB_CRT, function onJobCreate(id) {
|
||||
onCreate(id);
|
||||
res({ ...jobRequest, id });
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ const JOB_REP = "jr"; // Job Report Event
|
|||
const JOB_LOG = "jl"; // Job Log Event
|
||||
const JOB_CLS = "jc"; // Job Close Event
|
||||
const JOB_CRT = "jcr"; // Job Create Event
|
||||
const PPL_TRG = "plr"; // Pipeline Trigger Event
|
||||
const PPL_CLS = "plc"; // Pipeline Close Event
|
||||
const ERR = "e"; // Socket Error
|
||||
|
||||
export default {
|
||||
|
@ -9,5 +11,7 @@ export default {
|
|||
JOB_LOG,
|
||||
JOB_CLS,
|
||||
JOB_CRT,
|
||||
PPL_TRG,
|
||||
PPL_CLS,
|
||||
ERR,
|
||||
};
|
||||
|
|
|
@ -43,6 +43,7 @@ const applySockets = (server, jobs, options) => {
|
|||
io.on("connection", (socket) => socketConnect(io, socket, jobs));
|
||||
io.of("/").adapter.on("leave-room", (room, id) => socketDrop(io, room, id));
|
||||
return io;
|
||||
cle;
|
||||
};
|
||||
|
||||
export default applySockets;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue