Updated Tables

This commit is contained in:
Dunemask 2022-05-08 01:36:22 +00:00
parent 1b650070d7
commit 7db1a3456b
13 changed files with 192 additions and 9 deletions

32
ROADMAP.md Normal file
View file

@ -0,0 +1,32 @@
# Roadmap
### The end goal of this application is to provide a powerful application able to process and handle all of the your realtime QA data needs
## v0.0.1
- [x] Initial Skeleton
- [x] Frontend Drafts
- [ ] Frontend Core
- [ ] Frontend Pages
## v0.0.2
- [ ] Database Queries (Req PG)
- [ ] Database Tables (Req PG)
- [ ] Backend Routes (Req Database)
- [ ] Crons
## v0.0.3
- [ ] Rabbitmq Consumers (Req Database)
- [ ] Alerting
- [ ] Silencing
## v0.0.4
- [ ] Auth
## v0.0.5
- [ ] Docker config
- [ ] Gitlab Integration
- [ ] Garden config
## v0.0.6
- [ ] Internal Tests
- [ ] Self Test Suite

View file

@ -1,9 +1,11 @@
import { v4 } from "uuid"; import { v4 } from "uuid";
import applyJob from "./kubernetes.js"; import applyJob from "./kubernetes.js";
export default class JobManager { const maxJobs = process.env.MAX_JOBS ? parseInt(process.env.MAX_JOBS) : 3;
constructor(clientMaxJobs) {
this.clientMaxJobs = clientMaxJobs; class JobManager {
constructor() {
this.clientMaxJobs = maxJobs;
this.clients = {}; this.clients = {};
} }
@ -53,3 +55,5 @@ export default class JobManager {
); );
} }
} }
export default new JobManager();

View file

@ -6,7 +6,7 @@ import { INFO, OK, logInfo } from "../util/logging.js";
// Import Core Modules // Import Core Modules
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 rabbiteer from "../rabbit/rabbit-workers.js";
// Constants // Constants
@ -17,12 +17,12 @@ const port = process.env.QUALITEER_DEV_PORT ?? 52000;
export default class Qualiteer { export default class Qualiteer {
constructor(options = {}) { constructor(options = {}) {
for (var k in options) this[k] = options[k]; for (var k in options) this[k] = options[k];
this.jobs = new JobManager(options.maxClientJobs ?? 3); this.jobs = jobManager;
this.port = options.port ?? port; this.port = options.port ?? port;
} }
async _preinitialize() { async _preinitialize() {
logInfo(fig.textSync(title, "Cosmike")); logInfo(fig.textSync(title, "Cyberlarge"));
INFO("INIT", "Initializing..."); INFO("INIT", "Initializing...");
this.app = expressApp; this.app = expressApp;
this.server = http.createServer(this.app); this.server = http.createServer(this.app);

View file

@ -3,6 +3,10 @@ import express from "express";
// Routes // Routes
import results from "../routes/results-route.js"; import results from "../routes/results-route.js";
import alerting from "../routes/alerting-route.js";
import react from "../routes/react-route.js";
import tests from "../routes/tests-route.js";
import jobs from "../routes/jobs-route.js";
const app = express(); const app = express();
app.all("/", (req, res) => res.redirect("/qualiteer")); app.all("/", (req, res) => res.redirect("/qualiteer"));
@ -10,6 +14,10 @@ app.all("/", (req, res) => res.redirect("/qualiteer"));
// Middlewares // Middlewares
// Routes // Routes
app.use(react); // Static Build Route
app.use("/api/results", results); app.use("/api/results", results);
app.use("/api/alerting", alerting);
app.use("/api/tests", tests);
app.use("/api/jobs", jobs);
export default app; export default app;

42
lib/database/TABLES.md Normal file
View file

@ -0,0 +1,42 @@
CREATE SEQUENCE test_results_id_seq;
CREATE TABLE test_results (
id bigint NOT NULL DEFAULT nextval('test_results_seq') PRIMARY KEY,
test_name varchar(255) DEFAULT NULL,
test_class varchar(255) DEFAULT NULL,
test_method varchar(255) DEFAULT NULL,
test_path varchar(255) DEFAULT NULL,
test_type varchar(32) DEFAULT NULL,
test_timestamp timestamptz NOT NULL DEFAULT now(),
test_retry BOOLEAN DEFAULT FALSE,
origin varchar(255) DEFAULT NULL,
failed BOOLEAN DEFAULT FALSE,
failed_message varchar(2047) DEFAULT NULL,
screenshot_url varchar(255) DEFAULT NULL,
weblog_url varchar(255) DEFAULT NULL,
);
ALTER SEQUENCE test_results_id_seq OWNED BY test_results.id;
# Tables
PG Database Tables Mapped Out
## ```test_results```
| id | test_name | test_class | test_method | test_path | test_type | test_timestamp | test_retry | origin | failed | failed_message | screenshot_url | weblog_url |
| int | string | string | string | string | string | timestamp | boolean | string | boolean | string | string | string |
| 1 | My Test | My Test Class | My Failing Test Method | My Test Class Path | API | Date.now() | false | Test Suite A | true | Some Failure Messsage | screenshotUrl | weblogUrl |
- id Automatically Generated
- test_name\* Name of test
- test_class\* Name of class
- test_method Name of failed method if failed else null
- test_path Path to test class
- test_type API/UI/Mobile
- test_timestamp UTC Timestamp
- test_retry Should test remedy failed tests
- origin Test Suite test belongs to
- failed Indicates if the test failed or not
- failed_message Failure Message of test or null
- screenshot_url Screenshot of failure
- weblog_url Log from the web console

View file

@ -0,0 +1,15 @@
import pg from "../postgres.js";
// Imports
import {
insertQuery,
selectWhereAnyQuery,
updateWhereAnyQuery,
} from "../pg-query.js";
// Constants
const table = "silenced_tests";
// Queries
export const getSilencedTests = () => {
const query = `SELECT * from ${table}`;
return pg.query(query);
};

View file

@ -0,0 +1,15 @@
import pg from "../postgres.js";
// Imports
import {
insertQuery,
selectWhereAnyQuery,
updateWhereAnyQuery,
} from "../pg-query.js";
// Constants
const table = "tests";
// Queries
export const getTests = () => {
const query = `SELECT * from ${table}`;
return pg.query(query);
};

View file

@ -0,0 +1,18 @@
import { Router, json as jsonMiddleware } from "express";
import { getSilencedTests } from "../database/queries/silenced_tests.js";
const router = Router();
// Apply Middlewares
router.use(jsonMiddleware());
// Get Routes
router.get("/silenced", (req, res) => {
getSilencedTests().then(res.send);
});
// Post Routes
router.post("/silence", (req,res)=>{
res.sendStatus(200);
});
export default router;

12
lib/routes/jobs-route.js Normal file
View file

@ -0,0 +1,12 @@
import { Router, json as jsonMiddleware } from "express";
import jobs from "../core/JobManager.js";
const router = Router();
router.get("/jobs", (req, res) => {
const { clients } = jobs;
const allJobs = [];
for(var c of clients) allJobs.push(...c.jobs);
res.json(allJobs);
});
export default router;

6
lib/routes/react-route.js vendored Normal file
View file

@ -0,0 +1,6 @@
import express, { Router } from "express";
const router = Router();
router.use("/qualiteer", express.static("build/"));
export default router;

View file

@ -1,9 +1,18 @@
import express from "express"; import { Router, json as jsonMiddleware } from "express";
import { getCurrentlyFailing } from "../database/queries/test_results.js"; import { getCurrentlyFailing } from "../database/queries/test_results.js";
const router = express.Router(); const router = Router();
// Apply Middlewares
router.use(jsonMiddleware());
// Get Routes
router.get("/failing", (req, res) => { router.get("/failing", (req, res) => {
res.send([]); res.send([]);
}); });
// Post Routes
router.post("/history", (req,res)=>{
res.send([]);
});
export default router; export default router;

22
lib/routes/tests-route.js Normal file
View file

@ -0,0 +1,22 @@
import { Router, json as jsonMiddleware } from "express";
import { getTests } from "../database/queries/tests.js";
const router = Router();
const maxSize = 1024 * 1024 * 100; // 100MB
// Apply Middlewares
router.use(jsonMiddleware({limit: maxSize}));
// Get Routes
router.get("/tests", async (req, res) => {
const tests = await getTests();
res.json(tests);
});
// Post Routes
router.post("/update", (req,res)=>{
// Update All Tests
res.sendStatus(200);
});
export default router;

View file

@ -1,6 +1,6 @@
{ {
"name": "qualiteer", "name": "qualiteer",
"version": "1.0.0", "version": "0.0.1",
"description": "QA Data Management", "description": "QA Data Management",
"license": "LGPL-2.1-only", "license": "LGPL-2.1-only",
"author": "Dunemask", "author": "Dunemask",