From 87caafe36f640924f98fa50ce5c504640c8bf186 Mon Sep 17 00:00:00 2001 From: Dunemask Date: Sun, 23 Oct 2022 21:55:30 -0400 Subject: [PATCH] Pipeline Trigger Dialog --- dev/other.js | 5 - dev/query.js | 18 ---- dev/runner/JobDisplay.jsx | 14 --- dev/runner/JobView.jsx | 49 ---------- dev/views/TestCtx.jsx | 54 ----------- dev/views/TestSimple.jsx | 38 -------- .../jobs/pipeline/PipelineTriggerDialog.jsx | 13 ++- tests/api.js | 24 ----- tests/assets/suite/failing.js | 4 - tests/assets/suite/primary.js | 4 - tests/assets/suite/runner.js | 94 ------------------- tests/assets/suite/secondary1.js | 7 -- tests/assets/suite/secondary2.js | 7 -- tests/assets/suite/single-alt.js | 4 - tests/assets/suite/single.js | 4 - tests/assets/suite/tertiary1.js | 4 - tests/assets/suite/tertiary2.js | 4 - tests/assets/suite/tertiary3.js | 4 - tests/index.js | 39 -------- 19 files changed, 8 insertions(+), 382 deletions(-) delete mode 100644 dev/other.js delete mode 100644 dev/query.js delete mode 100644 dev/runner/JobDisplay.jsx delete mode 100644 dev/runner/JobView.jsx delete mode 100644 dev/views/TestCtx.jsx delete mode 100644 dev/views/TestSimple.jsx delete mode 100644 tests/api.js delete mode 100644 tests/assets/suite/failing.js delete mode 100644 tests/assets/suite/primary.js delete mode 100644 tests/assets/suite/runner.js delete mode 100644 tests/assets/suite/secondary1.js delete mode 100644 tests/assets/suite/secondary2.js delete mode 100644 tests/assets/suite/single-alt.js delete mode 100644 tests/assets/suite/single.js delete mode 100644 tests/assets/suite/tertiary1.js delete mode 100644 tests/assets/suite/tertiary2.js delete mode 100644 tests/assets/suite/tertiary3.js delete mode 100644 tests/index.js diff --git a/dev/other.js b/dev/other.js deleted file mode 100644 index 938a54e..0000000 --- a/dev/other.js +++ /dev/null @@ -1,5 +0,0 @@ -const cap = 10; - -const logNow = () => console.log(Date.now()); - -for (var i = 0; i < cap; i++) setTimeout(logNow, i * 1000); diff --git a/dev/query.js b/dev/query.js deleted file mode 100644 index a61a873..0000000 --- a/dev/query.js +++ /dev/null @@ -1,18 +0,0 @@ -import { - insertQuery, - selectWhereAnyQuery, - updateWhereAnyQuery, -} from "../lib/database/pg-query.js"; -import { readFileSync } from "fs"; -var data = JSON.parse(readFileSync("lib/routes/mocks/results.json")); - -var table = "test_results"; -var queries = data.results.map((r) => insertQuery(table, r)); -queries.forEach((q) => console.log(q + ";")); - -console.log(); - -table = "test_catalog"; -data = JSON.parse(readFileSync("lib/routes/mocks/catalog.json")); -queries = data["tests:full"].map((r) => insertQuery(table, r)); -queries.forEach((q) => console.log(q + ";")); diff --git a/dev/runner/JobDisplay.jsx b/dev/runner/JobDisplay.jsx deleted file mode 100644 index 34d7bab..0000000 --- a/dev/runner/JobDisplay.jsx +++ /dev/null @@ -1,14 +0,0 @@ -function jobDisplay({ props }) { - return ( -
-

Job ID: {props.job.id}

-

Log:

- {props.job.log.map((l, i) => ( -
- {l} -
-
- ))} -
- ); -} diff --git a/dev/runner/JobView.jsx b/dev/runner/JobView.jsx deleted file mode 100644 index 22183dc..0000000 --- a/dev/runner/JobView.jsx +++ /dev/null @@ -1,49 +0,0 @@ -import { useContext } from "react"; -import { Initiator } from "qualiteer/web-clients"; -import JobContext, { ACTIONS as jobActions } from "../../ctx/JobContext.jsx"; - -const cmd = `node other.js`; -export default function Test() { - const { state: jobState, dispatch: jobDispatch } = useContext(JobContext); - - function onLog(d) { - const job = jobState.jobs[0]; - job.log.push(d); - jobDispatch({ type: jobActions.UPDATE, jobId: jobState.jobs[0].id, job }); - console.log(d); - console.log(jobState); - } - - async function startJob() { - console.log("Wanting to start"); - const url = "https://Qualiteer.elijahparker3.repl.co"; - // Create an initiator and make a job request - const primary = new Initiator(url); - const jobRequest = { command: cmd }; - - const job = await primary.newJob(jobRequest, onLog, () => - console.log("Primary Job Concluded") - ); - jobDispatch({ type: jobActions.CREATE, job: { ...job, log: [] } }); - - console.log("Started"); - } - - return ( -
-

vv Info vv

- - {jobState.jobs.map((j) => - j.log.map((l, i) => ( -
- {l} -
-
- )) - )} -
- ); - - /* - }*/ -} diff --git a/dev/views/TestCtx.jsx b/dev/views/TestCtx.jsx deleted file mode 100644 index d8cacb3..0000000 --- a/dev/views/TestCtx.jsx +++ /dev/null @@ -1,54 +0,0 @@ -import { useContext } from "react"; -import { Initiator } from "qualiteer/web-clients"; -import JobContext from "../ctx/JobContext.jsx"; - -const cmd = `node other.js`; -export default function Test() { - const { - state: jobState, - dispatch: jobDispatch, - jobUpdate, - jobCreate, - } = useContext(JobContext); - - function onLog(d) { - const job = jobState.jobs[0]; - job.log.push(d); - jobUpdate(job.id, job); - console.log(d); - console.log(jobState); - } - - async function startJob() { - console.log("Wanting to start"); - const url = "https://Qualiteer.elijahparker3.repl.co"; - // Create an initiator and make a job request - const primary = new Initiator(url); - const jobRequest = { command: cmd }; - - const job = await primary.newJob(jobRequest, onLog, () => - console.log("Primary Job Concluded") - ); - jobCreate(job); - - console.log("Started"); - } - - return ( -
-

vv Info vv

- - {jobState.jobs.map((j) => - j.log.map((l, i) => ( -
- {l} -
-
- )) - )} -
- ); - - /* - }*/ -} diff --git a/dev/views/TestSimple.jsx b/dev/views/TestSimple.jsx deleted file mode 100644 index 213f35c..0000000 --- a/dev/views/TestSimple.jsx +++ /dev/null @@ -1,38 +0,0 @@ -import { useState } from "react"; -import { Initiator } from "qualiteer/web-clients"; - -const cmd = `node other.js`; -export default function Test() { - const [job, setJob] = useState({ log: ["INTRO"] }); - - function onLog(d) { - const j = { ...job }; - j.log.push(d); - setJob(j); - } - - async function startJob() { - console.log("Wanting to start"); - const url = "https://Qualiteer.elijahparker3.repl.co"; - // Create an initiator and make a job request - const primary = new Initiator(url); - const job = { command: cmd }; - await primary.newJob(job, onLog, () => - console.log("Primary Job Concluded") - ); - console.log("Started"); - } - - return ( -
-

vv Info vv

- - {job.log.map((l, i) => ( -
- {l} -
-
- ))} -
- ); -} diff --git a/src/views/jobs/pipeline/PipelineTriggerDialog.jsx b/src/views/jobs/pipeline/PipelineTriggerDialog.jsx index 553880a..0181d9f 100644 --- a/src/views/jobs/pipeline/PipelineTriggerDialog.jsx +++ b/src/views/jobs/pipeline/PipelineTriggerDialog.jsx @@ -11,6 +11,7 @@ import Dialog from "@mui/material/Dialog"; import Typography from "@mui/material/Typography"; import TextField from "@mui/material/TextField"; import Toolbar from "@mui/material/Toolbar"; +import ContentPasteIcon from "@mui/icons-material/ContentPaste"; export function usePipelineTriggerDialog(isOpen = false) { const [open, setOpen] = useState(isOpen); @@ -75,11 +76,13 @@ export default function PipelineTriggerDialog(props) { {trigger.testName} - + {trigger.jobReq && ( + + )} diff --git a/tests/api.js b/tests/api.js deleted file mode 100644 index 5322615..0000000 --- a/tests/api.js +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env node -import "dotenv/config"; // Load Envars -import Qualiteer from "qualiteer"; -import axios from "axios"; - -// Start server -const qltr = new Qualiteer(); -await qltr.start(); - -const url = process.env.QUALITEER_EXECUTOR_URL; - -const mappingsUrl = "/api/catalog/pipeline-mappings"; -const resultsUrl = "/api/results/failing"; - -const get = (...args) => axios.get(`${url}${args[0]}`, args[1]); - -const mappings = await get(resultsUrl, {}).catch((e) => console.log(e)); -console.log(mappings.data); -/*var res = await get(resultsUrl); -console.log(res.data); - -res = await get(resultsUrl, { headers: { count: true } }); - -console.log(res.data);*/ diff --git a/tests/assets/suite/failing.js b/tests/assets/suite/failing.js deleted file mode 100644 index af51872..0000000 --- a/tests/assets/suite/failing.js +++ /dev/null @@ -1,4 +0,0 @@ -export default function failingTest() { - console.log("This came from a failing test!"); - return { status: 1, message: "This test always fails :(" }; -} diff --git a/tests/assets/suite/primary.js b/tests/assets/suite/primary.js deleted file mode 100644 index aa33eb0..0000000 --- a/tests/assets/suite/primary.js +++ /dev/null @@ -1,4 +0,0 @@ -export default function primaryTest() { - console.log("This came from a primary test!"); - return { status: 0, pipelineData: "SomeData" }; -} diff --git a/tests/assets/suite/runner.js b/tests/assets/suite/runner.js deleted file mode 100644 index cd8b718..0000000 --- a/tests/assets/suite/runner.js +++ /dev/null @@ -1,94 +0,0 @@ -import axios from "axios"; -import Rabbiteer from "rabbiteer"; -import primary from "./primary.js"; -import secondary1 from "./secondary1.js"; -import secondary2 from "./secondary2.js"; - -import tertiary1 from "./tertiary1.js"; -import tertiary2 from "./tertiary2.js"; -import tertiary3 from "./tertiary3.js"; - -import single from "./single.js"; -import singleAlt from "./single-alt.js"; -import failing from "./failing.js"; - -// Constants -const liveUpdateDelay = 100; -const endLiveCount = 200; -const reportingUrl = `${process.env.QUALITEER_EXECUTOR_URL}/api/dev/rabbit/TestResults`; -// Pull args -const args = process.argv.slice(2); -const test = (args.find((v) => v.includes("test=")) ?? "").replace("test=", ""); -const isTriage = (args.find((v) => v.includes("isTriage=")) ?? "").replace( - "isTriage=", - "" -); -var pipeline = (args.find((v) => v.includes("pipeline=")) ?? "").replace( - "pipeline=", - "" -); -if (pipeline) - pipeline = JSON.parse(Buffer.from(pipeline, "base64").toString("utf8")); - -const logNow = () => console.log(Date.now()); -const liveIndicator = () => { - for (var i = 0; i < endLiveCount; i++) - setTimeout(logNow, i * liveUpdateDelay); -}; - -const runTests = () => { - switch (test) { - case "primary": - return primary(); - case "secondary1": - return secondary1(pipeline.testData); - case "secondary2": - return secondary2(pipeline.testData); - case "tertiary1": - return tertiary1(pipeline.testData); - case "tertiary2": - return tertiary2(pipeline.testData); - case "tertiary3": - return tertiary3(pipeline.testData); - case "single": - return single(); - case "single-alt": - return singleAlt(); - case "failing": - return failing(); - default: - return single(); - } -}; - -// Run -liveIndicator(); -setTimeout(async () => { - const status = runTests(); - if (pipeline) pipeline.testData = status.pipelineData; - const testResult = { - ...status, - failed: status.status !== 0, - name: test, - pipeline, - triage: isTriage === "true", - }; - - /*const rbt = new Rabbiteer(null, [], { - autoRabbit: { user: "guest", pass: "guest" }, - }); - await rbt.connect(); - const data = JSON.stringify(testResult); - await rbt.publishMessageWithTimeout("TestResults", data); - rbt.disconnect(); - if (status.status === 1) process.exit(1);*/ - - axios - .post(reportingUrl, { testResult }) - .catch((e) => { - console.log(e.response.status); - }) - .then(() => { - if (status.status === 1) process.exit(1); - }); -}, endLiveCount * liveUpdateDelay); diff --git a/tests/assets/suite/secondary1.js b/tests/assets/suite/secondary1.js deleted file mode 100644 index d8b4d04..0000000 --- a/tests/assets/suite/secondary1.js +++ /dev/null @@ -1,7 +0,0 @@ -export default function secondaryTest(pipelineData) { - console.log("This came from a secondary1 test!"); - return { - status: +(pipelineData !== "SomeData"), - pipelineData: "SomeOtherData", - }; -} diff --git a/tests/assets/suite/secondary2.js b/tests/assets/suite/secondary2.js deleted file mode 100644 index a95bde9..0000000 --- a/tests/assets/suite/secondary2.js +++ /dev/null @@ -1,7 +0,0 @@ -export default function secondaryTest(pipelineData) { - console.log("This came from a secondary2 test!"); - return { - status: +(pipelineData !== "SomeData"), - pipelineData: "SomeOtherOtherData", - }; -} diff --git a/tests/assets/suite/single-alt.js b/tests/assets/suite/single-alt.js deleted file mode 100644 index 639fba3..0000000 --- a/tests/assets/suite/single-alt.js +++ /dev/null @@ -1,4 +0,0 @@ -export default function singleAltTest() { - console.log("This came from a single test!"); - return { status: 0 }; -} diff --git a/tests/assets/suite/single.js b/tests/assets/suite/single.js deleted file mode 100644 index 2680727..0000000 --- a/tests/assets/suite/single.js +++ /dev/null @@ -1,4 +0,0 @@ -export default function singleTest() { - console.log("This came from a single test!"); - return { status: 0 }; -} diff --git a/tests/assets/suite/tertiary1.js b/tests/assets/suite/tertiary1.js deleted file mode 100644 index 654c3fb..0000000 --- a/tests/assets/suite/tertiary1.js +++ /dev/null @@ -1,4 +0,0 @@ -export default function secondaryTest(pipelineData) { - console.log("This came from a tertiary1!"); - return { status: +(pipelineData !== "SomeOtherData") }; -} diff --git a/tests/assets/suite/tertiary2.js b/tests/assets/suite/tertiary2.js deleted file mode 100644 index 63f5108..0000000 --- a/tests/assets/suite/tertiary2.js +++ /dev/null @@ -1,4 +0,0 @@ -export default function secondaryTest(pipelineData) { - console.log("This came from a tertiary2!"); - return { status: +(pipelineData !== "SomeOtherData") }; -} diff --git a/tests/assets/suite/tertiary3.js b/tests/assets/suite/tertiary3.js deleted file mode 100644 index b2bbc55..0000000 --- a/tests/assets/suite/tertiary3.js +++ /dev/null @@ -1,4 +0,0 @@ -export default function secondaryTest(pipelineData) { - console.log("This came from a tertiary3!"); - return { status: +(pipelineData !== "SomeOtherOtherData") }; -} diff --git a/tests/index.js b/tests/index.js deleted file mode 100644 index ae14de0..0000000 --- a/tests/index.js +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env node -import "dotenv/config"; // Load Envars -import Qualiteer from "qualiteer"; -import { Initiator, Executor } from "qualiteer/clients"; - -// Start server -const qltr = new Qualiteer(); -await qltr.start(); - -const url = process.env.QUALITEER_EXECUTOR_URL; - -// Create an initiator and make a job request -const primary = new Initiator(url); -const job = { - pipeline: { - __test: "primary", - triggers: { - secondary1: { - __testDelay: 1000, - tertiary1: {}, - tertiary2: { - __testDelay: 8000, - }, - }, - secondary2: { - __testDelay: 20000, - tertiary3: { - __testDelay: 3000, - }, - }, - }, - }, - name: "testing", - image: "node", -}; - -const launchJob = () => - primary.newPipelineJob(job, null, () => console.log("Primary Job Concluded")); -launchJob();