2022-07-07 21:45:38 +00:00
|
|
|
import axios from "axios";
|
|
|
|
import primary from "./primary.js";
|
2022-08-09 04:29:10 +00:00
|
|
|
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";
|
|
|
|
|
2022-07-07 21:45:38 +00:00
|
|
|
import single from "./single.js";
|
|
|
|
import failing from "./failing.js";
|
|
|
|
|
|
|
|
// Constants
|
2022-08-06 13:13:44 +00:00
|
|
|
const liveUpdateDelay = 100;
|
|
|
|
const endLiveCount = 20;
|
2022-07-07 21:45:38 +00:00
|
|
|
const reportingUrl = `${process.env.QUALITEER_URL}/api/dev/rabbit/TestResults`;
|
|
|
|
// Pull args
|
|
|
|
const args = process.argv.slice(2);
|
2022-07-12 22:07:44 +00:00
|
|
|
const test = (args.find((v) => v.includes("test=")) ?? "").replace("test=", "");
|
2022-08-09 04:29:10 +00:00
|
|
|
var pipeline = (args.find((v) => v.includes("pipeline=")) ?? "").replace(
|
|
|
|
"pipeline=",
|
|
|
|
""
|
|
|
|
);
|
|
|
|
if (pipeline)
|
|
|
|
pipeline = JSON.parse(Buffer.from(pipeline, "base64").toString("utf8"));
|
2022-07-07 21:45:38 +00:00
|
|
|
|
|
|
|
const logNow = () => console.log(Date.now());
|
|
|
|
const liveIndicator = () => {
|
2022-08-09 04:29:10 +00:00
|
|
|
for (var i = 0; i < endLiveCount; i++)
|
|
|
|
setTimeout(logNow, i * liveUpdateDelay);
|
2022-07-12 22:07:44 +00:00
|
|
|
};
|
2022-07-07 21:45:38 +00:00
|
|
|
|
|
|
|
const runTests = () => {
|
|
|
|
switch (test) {
|
|
|
|
case "primary":
|
|
|
|
return primary();
|
2022-08-09 04:29:10 +00:00
|
|
|
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);
|
2022-07-07 21:45:38 +00:00
|
|
|
case "single":
|
|
|
|
return single();
|
|
|
|
case "failing":
|
|
|
|
return failing();
|
|
|
|
default:
|
|
|
|
return single();
|
|
|
|
}
|
2022-07-12 22:07:44 +00:00
|
|
|
};
|
2022-07-07 21:45:38 +00:00
|
|
|
|
|
|
|
// Run
|
|
|
|
liveIndicator();
|
2022-07-12 22:07:44 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
const status = runTests();
|
2022-08-09 17:59:36 +00:00
|
|
|
if (pipeline) pipeline.testData = status.pipelineData;
|
2022-07-12 22:07:44 +00:00
|
|
|
const testResult = {
|
|
|
|
...status,
|
|
|
|
name: test,
|
2022-08-09 04:29:10 +00:00
|
|
|
pipeline,
|
2022-07-12 22:07:44 +00:00
|
|
|
};
|
2022-08-09 04:29:10 +00:00
|
|
|
axios
|
|
|
|
.post(reportingUrl, { testResult })
|
|
|
|
.catch((e) => {
|
|
|
|
console.log(e.response.status);
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
if (status.status === 1) process.exit(1);
|
|
|
|
});
|
2022-08-06 13:13:44 +00:00
|
|
|
}, endLiveCount * liveUpdateDelay);
|