Updated things for compound testing
This commit is contained in:
parent
4e6732c09b
commit
5c3f865604
16 changed files with 160 additions and 56 deletions
|
@ -11,7 +11,7 @@ const reportingUrl = `${process.env.QUALITEER_URL}/api/dev/rabbit/TestResults`;
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const test = (args.find((v)=>v.includes("test=")) ?? "").replace("test=","");
|
const test = (args.find((v)=>v.includes("test=")) ?? "").replace("test=","");
|
||||||
const pipelineData = (args.find((v)=>v.includes("pipelineData=")) ?? "").replace("pipelineData=","");
|
const pipelineData = (args.find((v)=>v.includes("pipelineData=")) ?? "").replace("pipelineData=","");
|
||||||
const pipelineLife = parseInt((args.find((v)=>v.includes("pipelineLife=")) ?? "0").replace("pipelineLife=",""));
|
const pipelineTriggers = (args.find((v)=>v.includes("pipelineTriggers=")) ?? "").replace("pipelineTriggers=","");
|
||||||
const pipelineDashboardSocket = (args.find((v)=>v.includes("pipelineDashboardSocket=")) ?? "").replace("pipelineDashboardSocket=","") || undefined;
|
const pipelineDashboardSocket = (args.find((v)=>v.includes("pipelineDashboardSocket=")) ?? "").replace("pipelineDashboardSocket=","") || undefined;
|
||||||
|
|
||||||
const logNow = () => console.log(Date.now());
|
const logNow = () => console.log(Date.now());
|
||||||
|
@ -38,7 +38,7 @@ const runTests = () => {
|
||||||
liveIndicator();
|
liveIndicator();
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
const status = runTests();
|
const status = runTests();
|
||||||
const testResult = {...status, name:test, pipelineLife, pipelineDashboardSocket}
|
const testResult = {...status, name:test, pipelineTriggers: pipelineTriggers ? pipelineTriggers : undefined, pipelineDashboardSocket}
|
||||||
axios.post(reportingUrl, {testResult}).catch((e)=>{console.log(e.response.status)});
|
axios.post(reportingUrl, {testResult}).catch((e)=>{console.log(e.response.status)});
|
||||||
},endLiveCount * 1000);
|
},endLiveCount * 1000);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { INFO, OK, logInfo } from "../util/logging.js";
|
||||||
import expressApp from "./server.js";
|
import expressApp from "./server.js";
|
||||||
import applySockets from "../sockets/handler.js";
|
import applySockets from "../sockets/handler.js";
|
||||||
import jobManager from "./JobManager.js";
|
import jobManager from "./JobManager.js";
|
||||||
import rabbiteer from "../rabbit/rabbit-workers.js";
|
import getRabbiteer from "../rabbit/rabbit-workers.js";
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const title = "QLTR";
|
const title = "QLTR";
|
||||||
|
@ -27,7 +27,8 @@ export default class Qualiteer {
|
||||||
this.app = expressApp;
|
this.app = expressApp;
|
||||||
this.server = http.createServer(this.app);
|
this.server = http.createServer(this.app);
|
||||||
this.sockets = applySockets(this.server, this.jobs);
|
this.sockets = applySockets(this.server, this.jobs);
|
||||||
this.rabbiteer = rabbiteer;
|
this.app.set("socketio", this.sockets);
|
||||||
|
this.rabbiteer = getRabbiteer(this.sockets);
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
|
|
@ -34,8 +34,8 @@ const pipelineMaxLife = (testName) => {
|
||||||
|
|
||||||
const buildCompound = (jobReq, socketId) => {
|
const buildCompound = (jobReq, socketId) => {
|
||||||
const { testName, command } = jobReq;
|
const { testName, command } = jobReq;
|
||||||
const pipelineLife = jobReq.pipelineLife ?? pipelineMaxLife(testName);
|
const pipelineTriggers = jobReq.pipelineTriggers;
|
||||||
command.push(`pipelineLife=${pipelineLife}`);
|
if (pipelineTriggers) command.push(`pipelineTriggers=${pipelineTriggers}`);
|
||||||
command.push(`pipelineDashboardSocket=${socketId}`);
|
command.push(`pipelineDashboardSocket=${socketId}`);
|
||||||
return { ...jobReq, command };
|
return { ...jobReq, command };
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ const app = express();
|
||||||
// Special Routes
|
// Special Routes
|
||||||
app.all("/", (req, res) => res.redirect("/qualiteer"));
|
app.all("/", (req, res) => res.redirect("/qualiteer"));
|
||||||
if (process.env.MOCK_ROUTES === "true") app.use(mock);
|
if (process.env.MOCK_ROUTES === "true") app.use(mock);
|
||||||
if(process.env.USE_DEV_ROUTER === "true") app.use("/api/dev",dev);
|
if (process.env.USE_DEV_ROUTER === "true") app.use("/api/dev", dev);
|
||||||
|
|
||||||
// Middlewares
|
// Middlewares
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Rabbiteer from "rabbiteer";
|
import Rabbiteer from "rabbiteer";
|
||||||
import workers from "./workers/index.js";
|
import getWorkers from "./workers/index.js";
|
||||||
|
|
||||||
// Pull Environment Variables
|
// Pull Environment Variables
|
||||||
const { RABBIT_HOST: host, RABBIT_USER: user, RABBIT_PASS: pass } = process.env;
|
const { RABBIT_HOST: host, RABBIT_USER: user, RABBIT_PASS: pass } = process.env;
|
||||||
|
@ -11,4 +11,7 @@ const rabbitConfig = {
|
||||||
pass: pass ?? "rabbit",
|
pass: pass ?? "rabbit",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default new Rabbiteer(null, workers, { autoRabbit: rabbitConfig });
|
const getRabbiteer = (skio) =>
|
||||||
|
new Rabbiteer(null, getWorkers(skio), { autoRabbit: rabbitConfig });
|
||||||
|
|
||||||
|
export default getRabbiteer;
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
// Imports
|
// Imports
|
||||||
import { Worker } from "rabbiteer";
|
import { Worker } from "rabbiteer";
|
||||||
|
import evt from "../../sockets/events.js";
|
||||||
// Class
|
// Class
|
||||||
export default class TestResultsWorker extends Worker {
|
export default class TestResultsWorker extends Worker {
|
||||||
constructor() {
|
constructor(skio) {
|
||||||
super("TestResults");
|
super("TestResults");
|
||||||
|
this.skio = skio;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Example Test Result
|
/* Example Test Result
|
||||||
|
@ -22,6 +24,24 @@ export default class TestResultsWorker extends Worker {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
onMessage(testResult) {
|
onMessage(testResult) {
|
||||||
console.log(testResult);
|
const { pipelineData, pipelineTriggers, pipelineDelay } = testResult;
|
||||||
|
const pipelineTrigger = { pipelineData, pipelineTriggers, pipelineDelay };
|
||||||
|
// Alter to start next test
|
||||||
|
// TODO the delay should be autopopulated either by the suite, or filled in by the server
|
||||||
|
if (pipelineTriggers)
|
||||||
|
return this.pipelineTrigger(
|
||||||
|
pipelineTrigger,
|
||||||
|
testResult.pipelineDashboardSocket
|
||||||
|
);
|
||||||
|
this.pipelineClose(testResult.pipelineDashboardSocket);
|
||||||
|
}
|
||||||
|
|
||||||
|
pipelineTrigger(pipelineTrigger, socketId) {
|
||||||
|
pipelineTrigger.pipelineDelay = 1000 * 5;
|
||||||
|
this.skio.to(socketId).emit(evt.PPL_TRG, pipelineTrigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
pipelineClose(socketId) {
|
||||||
|
this.skio.to(socketId).emit(evt.PPL_CLS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
import TestResultsWorker from "./TestResultsWorker.js";
|
import TestResultsWorker from "./TestResultsWorker.js";
|
||||||
|
|
||||||
export default [new TestResultsWorker()];
|
const getWorkers = (skio) => [new TestResultsWorker(skio)];
|
||||||
|
export default getWorkers;
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import { Router, json as jsonMiddleware } from "express";
|
import { Router, json as jsonMiddleware } from "express";
|
||||||
import TestResultsWorker from "../rabbit/workers/TestResultsWorker.js";
|
import TestResultsWorker from "../rabbit/workers/TestResultsWorker.js";
|
||||||
|
|
||||||
const testResultsHandler = new TestResultsWorker();
|
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
router.use(jsonMiddleware());
|
router.use(jsonMiddleware());
|
||||||
router.post("/rabbit/TestResults", (req, res) => {
|
router.post("/rabbit/TestResults", (req, res) => {
|
||||||
const { testResult } = req.body;
|
const { testResult } = req.body;
|
||||||
testResultsHandler.onMessage(testResult);
|
var io = req.app.get("socketio");
|
||||||
|
new TestResultsWorker(io).onMessage(testResult);
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,11 @@ export default class Initiator {
|
||||||
this.onLog = options.onLog ?? ((d) => console.log(`job: ${d}`));
|
this.onLog = options.onLog ?? ((d) => console.log(`job: ${d}`));
|
||||||
this.onClose = options.onClose ?? (() => {});
|
this.onClose = options.onClose ?? (() => {});
|
||||||
this.onCreate = options.onCreate ?? ((id) => console.log(`job id: ${id}`));
|
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) {
|
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_LOG = "jl"; // Job Log Event
|
||||||
const JOB_CLS = "jc"; // Job Close Event
|
const JOB_CLS = "jc"; // Job Close Event
|
||||||
const JOB_CRT = "jcr"; // Job Create 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
|
const ERR = "e"; // Socket Error
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -9,5 +11,7 @@ export default {
|
||||||
JOB_LOG,
|
JOB_LOG,
|
||||||
JOB_CLS,
|
JOB_CLS,
|
||||||
JOB_CRT,
|
JOB_CRT,
|
||||||
|
PPL_TRG,
|
||||||
|
PPL_CLS,
|
||||||
ERR,
|
ERR,
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,6 +43,7 @@ const applySockets = (server, jobs, options) => {
|
||||||
io.on("connection", (socket) => socketConnect(io, socket, jobs));
|
io.on("connection", (socket) => socketConnect(io, socket, jobs));
|
||||||
io.of("/").adapter.on("leave-room", (room, id) => socketDrop(io, room, id));
|
io.of("/").adapter.on("leave-room", (room, id) => socketDrop(io, room, id));
|
||||||
return io;
|
return io;
|
||||||
|
cle;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default applySockets;
|
export default applySockets;
|
||||||
|
|
|
@ -3,11 +3,7 @@ import StoreContext from "./ctx/StoreContext.jsx";
|
||||||
import JobContext from "./ctx/JobContext.jsx";
|
import JobContext from "./ctx/JobContext.jsx";
|
||||||
import Navbar from "./Navbar.jsx";
|
import Navbar from "./Navbar.jsx";
|
||||||
|
|
||||||
import {
|
import { Routes, Route, Navigate } from "react-router-dom";
|
||||||
Routes,
|
|
||||||
Route,
|
|
||||||
Navigate,
|
|
||||||
} from "react-router-dom";
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Toolbar from "@mui/material/Toolbar";
|
import Toolbar from "@mui/material/Toolbar";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
|
|
@ -51,7 +51,7 @@ export default function Jobs() {
|
||||||
const handleClickOpen = () => setJobDialogOpen(true);
|
const handleClickOpen = () => setJobDialogOpen(true);
|
||||||
|
|
||||||
const [queued, setQueued] = useState([]);
|
const [queued, setQueued] = useState([]);
|
||||||
useEffect(() => { }, [jobState.jobs, location]);
|
useEffect(() => {}, [jobState.jobs, location]);
|
||||||
|
|
||||||
const handleClose = (confirmed) => () => {
|
const handleClose = (confirmed) => () => {
|
||||||
setJobDialogOpen(false);
|
setJobDialogOpen(false);
|
||||||
|
@ -61,11 +61,20 @@ export default function Jobs() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="jobs">
|
<div className="jobs">
|
||||||
{location.hash === "" && jobState.jobs.map((v, i) => (
|
{location.hash === "" &&
|
||||||
<a key={i} href={`/jobs#${v.name}`} style={{ textDecoration: 'none' }}><JobBox job={v} /></a>
|
jobState.jobs.map((v, i) => (
|
||||||
|
<a
|
||||||
|
key={i}
|
||||||
|
href={`/jobs#${v.name}`}
|
||||||
|
style={{ textDecoration: "none" }}
|
||||||
|
>
|
||||||
|
<JobBox job={v} />
|
||||||
|
</a>
|
||||||
))}
|
))}
|
||||||
{jobState.jobs.find((job)=>job.name===location.hash.slice(1)) && (
|
{jobState.jobs.find((job) => job.name === location.hash.slice(1)) && (
|
||||||
<JobView job={jobState.jobs.find((job)=>job.name===location.hash.slice(1))}/>
|
<JobView
|
||||||
|
job={jobState.jobs.find((job) => job.name === location.hash.slice(1))}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Dialog open={jobDialogOpen} onClose={handleClose()} fullScreen>
|
<Dialog open={jobDialogOpen} onClose={handleClose()} fullScreen>
|
||||||
|
|
|
@ -9,7 +9,14 @@ import Stack from "@mui/material/Stack";
|
||||||
export default function JobLogView(props) {
|
export default function JobLogView(props) {
|
||||||
const { log } = props;
|
const { log } = props;
|
||||||
|
|
||||||
const LoadingDot = () => (<Skeleton variant="circular" width={16} height={16} sx={{backgroundColor:"rgb(240,240,240)"}}/>)
|
const LoadingDot = () => (
|
||||||
|
<Skeleton
|
||||||
|
variant="circular"
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
sx={{ backgroundColor: "rgb(240,240,240)" }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
@ -21,7 +28,7 @@ export default function JobLogView(props) {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{log.map((l, i) => (
|
{log.map((l, i) => (
|
||||||
<Box className="line" key={i} sx={{margin: ".25rem 0px"}}>
|
<Box className="line" key={i} sx={{ margin: ".25rem 0px" }}>
|
||||||
<Typography
|
<Typography
|
||||||
variant="body2"
|
variant="body2"
|
||||||
component="div"
|
component="div"
|
||||||
|
@ -34,8 +41,8 @@ export default function JobLogView(props) {
|
||||||
margin: "0px 0.5rem",
|
margin: "0px 0.5rem",
|
||||||
color: "rgb(210,210,210)",
|
color: "rgb(210,210,210)",
|
||||||
|
|
||||||
justifyContent:"center",
|
justifyContent: "center",
|
||||||
minWidth:"2rem"
|
minWidth: "2rem",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{i + 1}
|
{i + 1}
|
||||||
|
@ -50,10 +57,10 @@ export default function JobLogView(props) {
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
<Stack direction="row" spacing={1} sx={{mt:".5rem", ml:"0.75rem"}}>
|
<Stack direction="row" spacing={1} sx={{ mt: ".5rem", ml: "0.75rem" }}>
|
||||||
<LoadingDot/>
|
<LoadingDot />
|
||||||
<LoadingDot/>
|
<LoadingDot />
|
||||||
<LoadingDot/>
|
<LoadingDot />
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,15 +15,11 @@ export default function JobView(props) {
|
||||||
const { job: initJob } = props;
|
const { job: initJob } = props;
|
||||||
const [job, setJob] = useState({ log: [initJob.name] });
|
const [job, setJob] = useState({ log: [initJob.name] });
|
||||||
|
|
||||||
function retryJob(){
|
function retryJob() {}
|
||||||
|
|
||||||
}
|
function downloadLog() {}
|
||||||
|
|
||||||
function downloadLog(){
|
function navigateToJobs() {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function navigateToJobs(){
|
|
||||||
navigate("/jobs");
|
navigate("/jobs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,12 +33,19 @@ export default function JobView(props) {
|
||||||
<Box>
|
<Box>
|
||||||
<AppBar
|
<AppBar
|
||||||
position="fixed"
|
position="fixed"
|
||||||
sx={{ backgroundColor: "rgba(0,0,0,0)", boxShadow: "none", color:"black" }}
|
sx={{
|
||||||
><Toolbar disableGutters />
|
backgroundColor: "rgba(0,0,0,0)",
|
||||||
<Box sx={{ flexGrow: 1, margin:"0 10px" }}>
|
boxShadow: "none",
|
||||||
|
color: "black",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Toolbar disableGutters />
|
||||||
|
<Box sx={{ flexGrow: 1, margin: "0 10px" }}>
|
||||||
<Toolbar disableGutters>
|
<Toolbar disableGutters>
|
||||||
<Button onClick={navigateToJobs}>Back</Button>
|
<Button onClick={navigateToJobs}>Back</Button>
|
||||||
<Typography variant="h6" sx={{ml:"auto", mr:"auto"}}>{initJob.name}</Typography>
|
<Typography variant="h6" sx={{ ml: "auto", mr: "auto" }}>
|
||||||
|
{initJob.name}
|
||||||
|
</Typography>
|
||||||
<Button onClick={downloadLog}>Log</Button>
|
<Button onClick={downloadLog}>Log</Button>
|
||||||
<Button onClick={retryJob}>Retry</Button>
|
<Button onClick={retryJob}>Retry</Button>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
|
|
|
@ -14,9 +14,10 @@ const primary = new Initiator(url);
|
||||||
const job = {
|
const job = {
|
||||||
type: "compound",
|
type: "compound",
|
||||||
testName: "primary",
|
testName: "primary",
|
||||||
pipelineLife: 1,
|
pipelineTriggers: "secondary",
|
||||||
name: "testing",
|
name: "testing",
|
||||||
image: "node",
|
image: "node",
|
||||||
};
|
};
|
||||||
await primary.newJob(job, null, () => console.log("Primary Job Concluded"));
|
await primary.newPipelineJob(job, null, () =>
|
||||||
|
console.log("Primary Job Concluded")
|
||||||
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue