From 27948e1371756e6186ac10d2b455766aff5619b9 Mon Sep 17 00:00:00 2001 From: Alexander Dubrawski Date: Mon, 16 Nov 2020 12:13:55 +0100 Subject: [PATCH] Adjust workload names (#772) * Adjust workload name in frontend * Adjust workload name extraction * Run linting * Refactor comment * Adjust benchmark names in e2e helper * Rename regex obj --- hyrisecockpit/frontend/src/meta/workloads.ts | 33 +++++++++++++++++-- .../frontend/tests/e2e/setup/helpers.ts | 8 ++--- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/hyrisecockpit/frontend/src/meta/workloads.ts b/hyrisecockpit/frontend/src/meta/workloads.ts index b1144f1b1..9a4e7448f 100644 --- a/hyrisecockpit/frontend/src/meta/workloads.ts +++ b/hyrisecockpit/frontend/src/meta/workloads.ts @@ -1,16 +1,43 @@ import { isInTestMode } from "../../config"; +function getDisplayWorkloadName(workloadType: string): string { + const workload_type_map: Record = { + tpch: "TPC-H", + tpcds: "TPC-DS", + tpcc: "TPC-C", + job: "Join Order Benchmark", + }; + return workload_type_map[workloadType]; +} + export function getWorkloadName( workloadType: string, scaleFactor: string ): string { - return `${workloadType.toUpperCase()} SF ${scaleFactor}`; + return `${getDisplayWorkloadName(workloadType)} (SF ${scaleFactor})`; } + +// The following code is pretty complex. The workload selector component is working somehow +// with the workload name. So every time a workload is selected from the workload name (displayed name) +// the name and scale factor needs to be retrieved. If for example the *name: job, scalefactor: 1* is transformed to +// *Join Order Benchmark (SF 1)* we need to extract job *name: job, scalefactor: 1*. For that we are using regex. +// TODO: Re-factor display workload settings component to use objects (name, sf) instead of a string. export function getWorkloadType(workloadName: string): string { - return workloadName.split(" ")[0].toLowerCase(); + const workload_type_map: Record = { + "TPC-H": "tpch", + "TPC-DS": "tpcds", + "TPC-C": "tpcc", + "Join Order Benchmark": "job", + }; + const workload: string = workloadName.split(" (")[0]; + return workload_type_map[workload]; } + export function getScaleFactor(workloadName: string): string { - return workloadName.split(" ")[2]; + const regExtractScaleFactor = /\(([^)]+)\)/; + const matches = regExtractScaleFactor.exec(workloadName); + // @ts-ignore + return matches[1].split(" ")[1]; } export function getTableName(table: string): string { diff --git a/hyrisecockpit/frontend/tests/e2e/setup/helpers.ts b/hyrisecockpit/frontend/tests/e2e/setup/helpers.ts index cf7e122fb..0604419a4 100644 --- a/hyrisecockpit/frontend/tests/e2e/setup/helpers.ts +++ b/hyrisecockpit/frontend/tests/e2e/setup/helpers.ts @@ -43,10 +43,10 @@ export type DatabaseState = "workloadRunning"; export const benchmarks = ["tpch", "tpcds", "job", "tpcc"]; export const displayedBenchmark = { - tpch: "TPCH SF 1", - tpcds: "TPCDS SF 1", - tpcc: "TPCC SF 1", - job: "JOB SF 1", + tpch: "TPC-H (SF 1)", + tpcds: "TPC-DS (SF 1)", + tpcc: "TPC-C (SF 1)", + job: "Join Order Benchmark (SF 1)", }; export const comparisonRequests: Request[] = [