Savepoint
This commit is contained in:
parent
7db1a3456b
commit
02c483950c
45 changed files with 5136 additions and 256 deletions
|
@ -1,5 +1,5 @@
|
|||
import { Router, json as jsonMiddleware } from "express";
|
||||
import { getSilencedTests } from "../database/queries/silenced_tests.js";
|
||||
import { getSilencedTests } from "../database/queries/alerting.js";
|
||||
const router = Router();
|
||||
|
||||
// Apply Middlewares
|
||||
|
@ -11,8 +11,8 @@ router.get("/silenced", (req, res) => {
|
|||
});
|
||||
|
||||
// Post Routes
|
||||
router.post("/silence", (req,res)=>{
|
||||
res.sendStatus(200);
|
||||
router.post("/silence", (req, res) => {
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { Router, json as jsonMiddleware } from "express";
|
||||
import { getTests } from "../database/queries/tests.js";
|
||||
import { getTests } from "../database/queries/catalog.js";
|
||||
const router = Router();
|
||||
|
||||
const maxSize = 1024 * 1024 * 100; // 100MB
|
||||
|
||||
// Apply Middlewares
|
||||
router.use(jsonMiddleware({limit: maxSize}));
|
||||
router.use(jsonMiddleware({ limit: maxSize }));
|
||||
|
||||
// Get Routes
|
||||
router.get("/tests", async (req, res) => {
|
||||
|
@ -14,7 +14,7 @@ router.get("/tests", async (req, res) => {
|
|||
});
|
||||
|
||||
// Post Routes
|
||||
router.post("/update", (req,res)=>{
|
||||
router.post("/update", (req, res) => {
|
||||
// Update All Tests
|
||||
res.sendStatus(200);
|
||||
});
|
|
@ -4,9 +4,9 @@ import jobs from "../core/JobManager.js";
|
|||
const router = Router();
|
||||
|
||||
router.get("/jobs", (req, res) => {
|
||||
const { clients } = jobs;
|
||||
const { clients } = jobs;
|
||||
const allJobs = [];
|
||||
for(var c of clients) allJobs.push(...c.jobs);
|
||||
for (var c of clients) allJobs.push(...c.jobs);
|
||||
res.json(allJobs);
|
||||
});
|
||||
export default router;
|
||||
|
|
37
lib/routes/mock-route.js
Normal file
37
lib/routes/mock-route.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { Router } from "express";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
const router = Router();
|
||||
|
||||
const catalog = "lib/routes/mocks/catalog.json";
|
||||
const alerting = "lib/routes/mocks/alerting.json";
|
||||
const results = "lib/routes/mocks/results.json";
|
||||
|
||||
const query = async (mock) => JSON.parse(readFileSync(mock));
|
||||
|
||||
// Queries
|
||||
router.get("/api/catalog/tests", (req, res) => {
|
||||
query(catalog).then((catalog) => {
|
||||
res.json(req.get("full") ? catalog["tests:full"] : catalog.tests);
|
||||
});
|
||||
});
|
||||
|
||||
router.get("/api/results/failing", async (req, res) => {
|
||||
query(results).then(async (results) => {
|
||||
if (req.get("count")) res.json({ failing: results.results.length });
|
||||
else if (!req.get("full")) res.json(results.results);
|
||||
else
|
||||
query(catalog).then((catalog) => {
|
||||
res.json(
|
||||
results.results.map((r) => ({
|
||||
...catalog["tests:full"].find((t) => t.name === r.name),
|
||||
...r,
|
||||
}))
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Mutations
|
||||
|
||||
export default router;
|
32
lib/routes/mocks/alerting.json
Normal file
32
lib/routes/mocks/alerting.json
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"silenced": [
|
||||
{
|
||||
"name": "Test1",
|
||||
"class": "TestClass1",
|
||||
"method": "TestMethod1",
|
||||
"regions": ["us"],
|
||||
"alerting": "MyUtcDate"
|
||||
},
|
||||
{
|
||||
"name": "Test2",
|
||||
"class": null,
|
||||
"method": "TestMethod1",
|
||||
"regions": [],
|
||||
"alerting": "MyUtcDate"
|
||||
},
|
||||
{
|
||||
"name": "*",
|
||||
"class": "*",
|
||||
"method": "TestMethod1",
|
||||
"regions": [],
|
||||
"alerting": "MyUtcDate"
|
||||
},
|
||||
{
|
||||
"name": "Test3",
|
||||
"class": "TestClass3",
|
||||
"method": "*",
|
||||
"regions": ["us", "au"],
|
||||
"alerting": "MyUtcDate"
|
||||
}
|
||||
]
|
||||
}
|
92
lib/routes/mocks/catalog.json
Normal file
92
lib/routes/mocks/catalog.json
Normal file
|
@ -0,0 +1,92 @@
|
|||
{
|
||||
"tests": [
|
||||
{
|
||||
"name": "Test 1",
|
||||
"class": "Test Class 1",
|
||||
"compound": false,
|
||||
"type": "api"
|
||||
},
|
||||
{
|
||||
"name": "Test 2",
|
||||
"class": "Test Class 2",
|
||||
"compound": false,
|
||||
"type": "ui"
|
||||
},
|
||||
{
|
||||
"name": "Test Primary",
|
||||
"class": "Test Class Primary",
|
||||
"compound": true,
|
||||
"type": "api"
|
||||
},
|
||||
{
|
||||
"name": "Test Secondary",
|
||||
"class": "Test Class Secondary",
|
||||
"compound": true,
|
||||
"type": "ui"
|
||||
}
|
||||
],
|
||||
"tests:full": [
|
||||
{
|
||||
"name": "Test1",
|
||||
"class": "TestClass1",
|
||||
"compound": false,
|
||||
"type": "api",
|
||||
"markers": ["Service1"],
|
||||
"ignored": false,
|
||||
"comment": "This Comment Is Part Of Test 1",
|
||||
"coverage": ["/api/test1", "/api/test2"],
|
||||
"env": ["prod", "ci"],
|
||||
"path": "tests/api/test1.js",
|
||||
"regions": ["us", "ca"],
|
||||
"origin": "Repo1",
|
||||
"cron": "1hour"
|
||||
},
|
||||
{
|
||||
"name": "Test2",
|
||||
"class": "TestClass2",
|
||||
"compound": false,
|
||||
"type": "ui",
|
||||
"markers": ["Service2"],
|
||||
"ignored": false,
|
||||
"comment": "Comment belonging to Test2",
|
||||
"coverage": ["Page1/FeatureA"],
|
||||
"env": ["prod"],
|
||||
"path": "tests/ui/test2.js",
|
||||
"regions": [],
|
||||
"origin": "Repo2",
|
||||
"cron": "30min"
|
||||
},
|
||||
{
|
||||
"name": "TestPrimary",
|
||||
"class": "TestClassPrimary",
|
||||
"compound": true,
|
||||
"type": "api",
|
||||
"markers": [
|
||||
"ServiceComplex",
|
||||
"compound_Repo2!TestClassSecondary#TestSecondary"
|
||||
],
|
||||
"ignored": false,
|
||||
"comment": "Comment belonging to Test Primary",
|
||||
"coverage": ["/api/compound"],
|
||||
"env": ["ci"],
|
||||
"path": "tests/api/primary.js",
|
||||
"regions": [],
|
||||
"origin": "Repo1",
|
||||
"cron": "2hour"
|
||||
},
|
||||
{
|
||||
"name": "TestSecondary",
|
||||
"class": "TestClassSecondary",
|
||||
"compound": true,
|
||||
"type": "ui",
|
||||
"markers": ["ServiceComplex"],
|
||||
"ignored": false,
|
||||
"coverage": ["PageComplex/FeatureA"],
|
||||
"env": ["ci"],
|
||||
"path": "tests/ui/secondary.js",
|
||||
"regions": [],
|
||||
"origin": "Repo2",
|
||||
"cron": "2hour"
|
||||
}
|
||||
]
|
||||
}
|
48
lib/routes/mocks/results.json
Normal file
48
lib/routes/mocks/results.json
Normal file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"results": [
|
||||
{
|
||||
"name": "Test1",
|
||||
"method": "Test1Method",
|
||||
"env": "prod",
|
||||
"timestamp": "2022-05-10T16:35:27.220Z",
|
||||
"retry": false,
|
||||
"failed": true,
|
||||
"failed_message": "Some failure message",
|
||||
"screenshot": "https://example.com",
|
||||
"weblog": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Test2",
|
||||
"method": "Test2Method",
|
||||
"env": "prod",
|
||||
"timestamp": "2022-05-10T16:35:31.682Z",
|
||||
"retry": false,
|
||||
"failed": true,
|
||||
"failed_message": "Some failure message 2",
|
||||
"screenshot": "https://example.com",
|
||||
"weblog": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Test1",
|
||||
"method": null,
|
||||
"env": "prod",
|
||||
"timestamp": "2022-05-10T16:35:33.810Z",
|
||||
"retry": false,
|
||||
"failed": false,
|
||||
"failed_message": null,
|
||||
"screenshot": "https://example.com",
|
||||
"weblog": "https://example.com"
|
||||
},
|
||||
{
|
||||
"name": "Test1",
|
||||
"method": null,
|
||||
"env": "ci",
|
||||
"timestamp": "2022-05-10T16:35:33.810Z",
|
||||
"retry": false,
|
||||
"failed": false,
|
||||
"failed_message": null,
|
||||
"screenshot": "https://example.com",
|
||||
"weblog": "https://example.com"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { Router, json as jsonMiddleware } from "express";
|
||||
import { getCurrentlyFailing } from "../database/queries/test_results.js";
|
||||
import { getCurrentlyFailing } from "../database/queries/results.js";
|
||||
const router = Router();
|
||||
|
||||
// Apply Middlewares
|
||||
|
@ -11,8 +11,8 @@ router.get("/failing", (req, res) => {
|
|||
});
|
||||
|
||||
// Post Routes
|
||||
router.post("/history", (req,res)=>{
|
||||
res.send([]);
|
||||
router.post("/history", (req, res) => {
|
||||
res.send([]);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue