qualiteer/lib/server/rabbit/workers/TestResultsWorker.js

65 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-05-05 12:35:47 +00:00
// Imports
2022-05-05 20:30:24 +00:00
import { Worker } from "rabbiteer";
2022-10-08 17:47:46 +00:00
import { VERB } from "../../util/logging.js";
import { getPipelineMappings } from "../../database/queries/catalog.js";
2022-10-08 17:47:46 +00:00
import { insertTestResult } from "../../database/queries/results.js";
2022-10-15 11:47:47 +00:00
import evt from "../../../common/sockets/events.js";
import { asTree, asBranches, as1d } from "../../../../src/util/pipelines.js";
2022-05-05 12:35:47 +00:00
// Class
2022-05-05 20:30:24 +00:00
export default class TestResultsWorker extends Worker {
2022-07-12 02:44:44 +00:00
constructor(skio) {
2022-05-05 12:35:47 +00:00
super("TestResults");
2022-07-12 02:44:44 +00:00
this.skio = skio;
2022-05-05 12:35:47 +00:00
}
/* Example Test Result
{
testName: SomeTest,
testClass: SomeClass,
testMethod: SomeMethod,
testType: API/UI,
testTimestamp: 123893024,
origin: TestSuite,
failed: true,
failedMessage: Some Failure,
screenshotUrl: https://screenshot”,
expectedScreenshotUrl: https://expected”
consoleLogUrl: https://consolelog”
}
*/
2022-10-08 17:47:46 +00:00
async onMessage(testResult) {
const { pipeline, autoPipeline } = testResult;
2022-10-08 17:47:46 +00:00
await this.handleReporting(testResult);
if(autoPipeline) return this.autoPipeline(testResult);
2022-07-12 02:44:44 +00:00
// Alter to start next test
// TODO the delay should be autopopulated either by the suite, or filled in by the server
2022-08-09 04:29:10 +00:00
if (pipeline) return this.pipelineTrigger(pipeline);
2022-07-12 02:44:44 +00:00
}
2022-08-09 04:29:10 +00:00
pipelineTrigger(pipeline) {
const { dashboardSocketId: dsi } = pipeline;
this.skio.to(dsi).emit(evt.PPL_TRG, pipeline);
2022-07-12 02:44:44 +00:00
}
2022-10-08 17:47:46 +00:00
async autoPipeline(testResult){
const {name} = testResult;
console.log(testResult);
const mappings = await getPipelineMappings();
const primaries = mappings.filter((m) =>
m.find((t) => t.name === name)
);
const pipelineTree = asTree(primaries);
const pipelineReq = pipelineTree[name];
delete pipelineReq.__testDelay;
for(var k of Object.keys(pipelineReq)){
console.log("Would auto start: ", k);
}
}
2022-10-08 17:47:46 +00:00
handleReporting(result) {
VERB("TestResults", result.name);
insertTestResult(result);
}
2022-05-05 12:35:47 +00:00
}