8000 test run name by ludeknovy · Pull Request #154 · ludeknovy/jtl-reporter-be · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test run name #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions migrations/1644908662609_test-run-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exports.up = (pgm) => {
pgm.addColumn({ schema: "jtl", name: "items" }, {
name: {
type: "VARCHAR(200)",
"default": null,
},
})
}

5 changes: 3 additions & 2 deletions src/server/controllers/item/create-item-async-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ItemStatus, ReportStatus } from "../../queries/items.model"
import { StatusCode } from "../../utils/status-code"

export const createItemAsyncController = async (req: Request, res: Response) => {
const { environment, note, status = ItemStatus.None, hostname } = req.body
const { environment, note, status = ItemStatus.None, hostname, name } = req.body
const { scenarioName, projectName } = req.params

logger.info(`Creating new item for scenario: ${scenarioName}`)
Expand All @@ -20,7 +20,8 @@ export const createItemAsyncController = async (req: Request, res: Response) =>
status,
projectName,
hostname,
ReportStatus.InProgress
ReportStatus.InProgress,
name
))
const itemId = item.id
logger.info(`New item for scenario: ${scenarioName} created with id: ${itemId}`)
Expand Down
5 changes: 3 additions & 2 deletions src/server/controllers/item/create-item-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const SECONDS_DIVISOR = 1000
export const createItemController = (req: Request, res: Response, next: NextFunction) => {
upload(req, res, async error => {
const HOSTNAME_LENGTH = 200
const { environment, note, status = ItemStatus.None, hostname } = req.body
const { environment, note, status = ItemStatus.None, hostname, name } = req.body
if (!req.files) {
return next(boom.badRequest())
}
Expand Down Expand Up @@ -66,7 +66,8 @@ export const createItemController = (req: Request, res: Response, next: NextFunc
status,
projectName,
hostname,
ReportStatus.InProgress
ReportStatus.InProgress,
name
))
const itemId = item.id

Expand Down
3 changes: 2 additions & 1 deletion src/server/controllers/item/get-item-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const getItemController = async (req: Request, res: Response) => {
// eslint-disable-next-line @typescript-eslint/naming-convention
base_id,
status, hostname, reportStatus, thresholds,
analysisEnabled, zeroErrorToleranceEnabled, topMetricsSettings,
analysisEnabled, zeroErrorToleranceEnabled, topMetricsSettings, name,
} = await db.one(findItem(itemId, projectName, scenarioName))
const { stats: statistics, overview, sutOverview } = await db.one(findItemStats(itemId))

Expand All @@ -34,6 +34,7 @@ export const getItemController = async (req: Request, res: Response) => {
overview, sutOverview, statistics, status,
plot, note, environment, hostname, reportStatus, thresholds, analysisEnabled,
baseId: base_id, isBase: base_id === itemId, zeroErrorToleranceEnabled, topMetricsSettings,
name,
monitoring: {
cpu: {
data: monitoringAdjusted,
Expand Down
4 changes: 2 additions & 2 deletions src/server/controllers/item/update-item-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { StatusCode } from "../../utils/status-code"

export const updateItemController = async (req: Request, res: Response, next: NextFunction) => {
const { projectName, scenarioName, itemId } = req.params
const { note, environment, hostname, base } = req.body
const { note, environment, hostname, base, name } = req.body
try {
await db.query("BEGIN")
await db.none(updateTestItemInfo(itemId, scenarioName, projectName, note, environment, hostname))
await db.none(updateTestItemInfo(itemId, scenarioName, projectName, note, environment, hostname, name))
if (base) {
await db.none(removeCurrentBaseFlag(scenarioName, projectName))
await db.none(setBaseFlag(itemId, scenarioName, projectName))
Expand Down
16 changes: 8 additions & 8 deletions src/server/queries/items.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable max-lines */
// eslint-disable-next-line max-len
export const createNewItem = (scenarioName, startTime, environment, note, status, projectName, hostname, reportStatus) => {
export const createNewItem = (scenarioName, startTime, environment, note, status, projectName, hostname, reportStatus, name) => {
return {
// eslint-disable-next-line max-len
text: `INSERT INTO jtl.items(scenario_id, start_time, environment, note, status, hostname, report_status) VALUES(
text: `INSERT INTO jtl.items(scenario_id, start_time, environment, note, status, hostname, report_status, name) VALUES(
(SELECT sc.id FROM jtl.scenario as sc
LEFT JOIN jtl.projects as p ON p.id = sc.project_id
WHERE sc.name = $1
AND p.project_name = $6), $2, $3, $4, $5, $7, $8) RETURNING id`,
values: [scenarioName, startTime, environment, note, status, projectName, hostname, reportStatus],
AND p.project_name = $6), $2, $3, $4, $5, $7, $8, $9) RETURNING id`,
values: [scenarioName, startTime, environment, note, status, projectName, hostname, reportStatus, name],
}
}

Expand All @@ -24,7 +24,7 @@ export const findItem = (itemId, projectName, scenarioName) => {
// eslint-disable-next-line max-len
text: `SELECT charts.plot_data, note, environment, status, hostname, s.analysis_enabled as "analysisEnabled",
s.zero_error_tolerance_enabled as "zeroErrorToleranceEnabled", threshold_result as "thresholds",
report_status as "reportStatus", p.item_top_statistics_settings as "topMetricsSettings",
report_status as "reportStatus", p.item_top_statistics_settings as "topMetricsSettings", items.name,
(SELECT items.id FROM jtl.items as items
LEFT JOIN jtl.charts as charts ON charts.item_id = items.id
LEFT JOIN jtl.scenario as s ON s.id = items.scenario_id
Expand Down Expand Up @@ -57,15 +57,15 @@ export const saveItemStats = (itemId, stats, overview, sutOverview) => {
}
}

export const updateTestItemInfo = (itemId, scenarioName, projectName, note, environment, hostname) => {
export const updateTestItemInfo = (itemId, scenarioName, projectName, note, environment, hostname, name) => {
return {
text: `UPDATE jtl.items as it
SET note = $3, environment = $4, hostname = $6
SET note = $3, environment = $4, hostname = $6, name = $7
FROM jtl.scenario as s
WHERE it.id = $1
AND s.project_id = (SELECT id FROM jtl.projects WHERE project_name = $2)
AND s.name = $5`,
values: [itemId, projectName, note, environment, scenarioName, hostname],
values: [itemId, projectName, note, environment, scenarioName, hostname, name],
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/server/queries/scenario.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
export const findItemsForScenario = (projectName, scenarioName, limit, offset) => {
return {
text: `SELECT it.id, environment, upload_time as "uploadTime", base, status, st.overview->>'startDate' as "startTime", note, hostname, threshold_result->'passed' as "thresholdPassed", overview FROM jtl.items as it
text: `SELECT it.id, environment, upload_time as "uploadTime", base, status, st.overview->>'startDate' as "startTime", note, hostname, it.name, threshold_result->'passed' as "thresholdPassed", overview FROM jtl.items as it
LEFT JOIN jtl.scenario as s ON s.id = it.scenario_id
LEFT JOIN jtl.item_stat as st ON st.item_id = it.id
LEFT JOIN jtl.projects as p ON p.id = s.project_id
Expand Down Expand Up @@ -86,7 +86,7 @@ export const findScenarios = projectName => {

export const findScenariosData = (projectName) => {
return {
text: `SELECT s.id as scenario_id, name, s.analysis_enabled, st.overview FROM jtl.item_stat st
text: `SELECT s.id as scenario_id, s.name, s.analysis_enabled, st.overview FROM jtl.item_stat st
LEFT JOIN jtl.items as it ON it.id = st.item_id
LEFT JOIN jtl.scenario as s ON s.id = it.scenario_id
WHERE st.item_id IN (
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/test-data-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class TestDataSetup {
// eslint-disable-next-line no-case-declarations
const [item] = await db.any(createNewItem("test-scenario",
"2019-09-22 20:20:23.265", "localhost", "test note",
"1", "test-project", "localhost", ReportStatus.Ready))
"1", "test-project", "localhost", ReportStatus.Ready, "test-name"))
await db.any(saveItemStats(
item.id, JSON.stringify(testStats),
JSON.stringify(testOverview),
Expand Down
2 changes: 2 additions & 0 deletions src/server/schema-validator/item-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Joi from "joi"
const NOTE_MAX_LENGTH = 250
const HOSTNAME_MAX_LENGTH = 200
const ENVIRONMENT_MAX_LENGTH = 50
const TEST_NAME_MAX_LENGTH = 200

const projectName = Joi.string().required()
const environment = Joi.string().min(1).max(ENVIRONMENT_MAX_LENGTH).required()
Expand Down Expand Up @@ -41,6 +42,7 @@ export const updateItemBodySchema = Joi.object().keys({
base: Joi.boolean().required(),
hostname,
environment,
name: Joi.string().max(TEST_NAME_MAX_LENGTH).allow("").allow(null),
})

export const newAsyncItemStartBodySchema = Joi.object().keys({
Expand Down
0