From 3ed75735fd9de2b4066e6160ba6f0a1de30f5af9 Mon Sep 17 00:00:00 2001 From: Vishnu Challa Date: Sun, 3 Mar 2024 20:16:09 -0500 Subject: [PATCH] Refining Quay UI elements Signed-off-by: Vishnu Challa --- .../app/api/v1/commons/example_responses.py | 41 +++++++++ backend/app/api/v1/commons/ocp.py | 50 ++--------- backend/app/api/v1/commons/quay.py | 39 ++++++++ backend/app/api/v1/commons/utils.py | 37 +++++++- backend/app/api/v1/endpoints/cpt/maps/quay.py | 16 ++-- .../app/api/v1/endpoints/quay/quayGraphs.py | 5 +- backend/app/api/v1/endpoints/quay/quayJobs.py | 6 +- .../src/components/OCP/BenchmarkResults.js | 2 +- .../{commons => OCP}/InstallCard.js | 2 +- .../src/components/Quay/BenchmarkResults.js | 2 +- frontend/src/components/Quay/InstallCard.js | 90 +++++++++++++++++++ frontend/src/components/Quay/QuayHome.js | 26 ++++-- .../src/components/commons/DisplayGrafana.js | 2 +- frontend/src/store/Actions/ActionCreator.js | 22 ++++- frontend/src/store/reducers/InitialData.js | 39 ++++++++ .../src/store/reducers/QuayJobsReducer.js | 31 ++++--- frontend/src/store/reducers/Utils.js | 32 ++++++- 17 files changed, 353 insertions(+), 89 deletions(-) create mode 100644 backend/app/api/v1/commons/quay.py rename frontend/src/components/{commons => OCP}/InstallCard.js (98%) create mode 100644 frontend/src/components/Quay/InstallCard.js diff --git a/backend/app/api/v1/commons/example_responses.py b/backend/app/api/v1/commons/example_responses.py index 173a523f..af13f920 100644 --- a/backend/app/api/v1/commons/example_responses.py +++ b/backend/app/api/v1/commons/example_responses.py @@ -81,9 +81,50 @@ def response_422(): ] } +quay_response_example ={ + "startDate": "2023-09-20", + "endDate": "2023-09-20", + "results": [ + { + "ciSystem": "PROW", + "uuid": "CPT-e3865b03-ce78-454a-becb-b79aeb806a6b", + "releaseStream": "stable-3.10", + "platform": "AWS", + "clusterType": "self-managed", + "benchmark": "quay-load-test", + "hitSize": 100, + "concurrency": 50, + "imagePushPulls": 10, + "masterNodesCount": 3, + "workerNodesCount": 252, + "infraNodesCount": 3, + "masterNodesType": "m6a.8xlarge", + "workerNodesType": "m5.2xlarge", + "infraNodesType": "r5.4xlarge", + "totalNodesCount": 258, + "clusterName": "quaytest-123sffdf", + "ocpVersion": "4.14.0-0.nightly-2023-09-15-233408", + "networkType": "OVNKubernetes", + "buildTag": "1704299395064795136", + "jobStatus": "success", + "buildUrl": "https://example.com/1704299395064795136", + "upstreamJob": "quay-pipeline", + "executionDate": "2023-09-20T02:14:07Z", + "jobDuration": "5261", + "startDate": "2023-09-20T02:14:07Z", + "endDate": "2023-09-20T03:41:48Z", + "timestamp": "2023-09-20T02:14:07Z", + "shortVersion": "4.14" + }, + ] +} + def ocp_200_response(): return response_200(ocp_response_example) +def quay_200_response(): + return response_200(quay_response_example) + cpt_response_example ={ "startDate": "2023-11-18", "endDate": "2023-11-23", diff --git a/backend/app/api/v1/commons/ocp.py b/backend/app/api/v1/commons/ocp.py index 6959f15f..b5e8b48a 100644 --- a/backend/app/api/v1/commons/ocp.py +++ b/backend/app/api/v1/commons/ocp.py @@ -1,5 +1,6 @@ from datetime import date import pandas as pd +import app.api.v1.commons.utils as utils from app.services.search import ElasticService @@ -33,12 +34,12 @@ async def getData(start_datetime: date, end_datetime: date, configpath: str): 'publish', 'computeArch', 'controlPlaneArch']] = jobs[['ipsec', 'fips', 'encrypted', 'publish', 'computeArch', 'controlPlaneArch']].replace(r'^\s*$', "N/A", regex=True) jobs['encryptionType'] = jobs.apply(fillEncryptionType, axis=1) - jobs['benchmark'] = jobs.apply(updateBenchmark, axis=1) - jobs['platform'] = jobs.apply(clasifyAWSJobs, axis=1) - jobs['jobType'] = jobs.apply(jobType, axis=1) - jobs['isRehearse'] = jobs.apply(isRehearse, axis=1) - jobs['jobStatus'] = jobs.apply(updateStatus, axis=1) - jobs['build'] = jobs.apply(getBuild, axis=1) + jobs['benchmark'] = jobs.apply(utils.updateBenchmark, axis=1) + jobs['platform'] = jobs.apply(utils.clasifyAWSJobs, axis=1) + jobs['jobType'] = jobs.apply(utils.jobType, axis=1) + jobs['isRehearse'] = jobs.apply(utils.isRehearse, axis=1) + jobs['jobStatus'] = jobs.apply(utils.updateStatus, axis=1) + jobs['build'] = jobs.apply(utils.getBuild, axis=1) cleanJobs = jobs[jobs['platform'] != ""] @@ -47,43 +48,6 @@ async def getData(start_datetime: date, end_datetime: date, configpath: str): return jbs - -def updateStatus(row): - return row["jobStatus"].lower() - - -def updateBenchmark(row): - if row["upstreamJob"].__contains__("upgrade"): - return "upgrade-" + row["benchmark"] - return row["benchmark"] - - -def jobType(row): - if row["upstreamJob"].__contains__("periodic"): - return "periodic" - return "pull request" - - -def isRehearse(row): - if row["upstreamJob"].__contains__("rehearse"): - return "True" - return "False" - - -def clasifyAWSJobs(row): - if row["upstreamJob"].__contains__("rosa-hcp"): - return "AWS ROSA-HCP" - if row["clusterType"].__contains__("rosa"): - return "AWS ROSA" - return row["platform"] - - -def getBuild(row): - releaseStream = row["releaseStream"] + "-" - ocpVersion = row["ocpVersion"] - return ocpVersion.replace(releaseStream, "") - - def fillEncryptionType(row): if row["encrypted"] == "N/A": return "N/A" diff --git a/backend/app/api/v1/commons/quay.py b/backend/app/api/v1/commons/quay.py new file mode 100644 index 00000000..0f936852 --- /dev/null +++ b/backend/app/api/v1/commons/quay.py @@ -0,0 +1,39 @@ +from datetime import date +import pandas as pd +import app.api.v1.commons.utils as utils +from app.services.search import ElasticService + + +async def getData(start_datetime: date, end_datetime: date, configpath: str): + query = { + "query": { + "bool": { + "filter": { + "range": { + "timestamp": { + "format": "yyyy-MM-dd" + } + } + } + } + } + } + + es = ElasticService(configpath=configpath) + response = await es.post(query=query, start_date=start_datetime, end_date=end_datetime, timestamp_field='timestamp') + await es.close() + tasks = [item['_source'] for item in response] + jobs = pd.json_normalize(tasks) + if len(jobs) == 0: + return jobs + + jobs[['masterNodesCount', 'workerNodesCount', + 'infraNodesCount', 'totalNodesCount']] = jobs[['masterNodesCount', 'workerNodesCount', 'infraNodesCount', 'totalNodesCount']].fillna(0) + jobs.fillna('', inplace=True) + jobs['benchmark'] = jobs.apply(utils.updateBenchmark, axis=1) + jobs['platform'] = jobs.apply(utils.clasifyAWSJobs, axis=1) + jobs['jobStatus'] = jobs.apply(utils.updateStatus, axis=1) + jobs['build'] = jobs.apply(utils.getBuild, axis=1) + jobs['shortVersion'] = jobs['ocpVersion'].str.slice(0, 4) + + return jobs[jobs['platform'] != ""] diff --git a/backend/app/api/v1/commons/utils.py b/backend/app/api/v1/commons/utils.py index e1431713..90403eb8 100644 --- a/backend/app/api/v1/commons/utils.py +++ b/backend/app/api/v1/commons/utils.py @@ -14,4 +14,39 @@ async def getMetadata(uuid: str, configpath: str) : response = await es.post(query=query) await es.close() meta = [item['_source'] for item in response] - return meta[0] \ No newline at end of file + return meta[0] + +def updateStatus(job): + return job["jobStatus"].lower() + + +def updateBenchmark(job): + if job["upstreamJob"].__contains__("upgrade"): + return "upgrade-" + job["benchmark"] + return job["benchmark"] + + +def jobType(job): + if job["upstreamJob"].__contains__("periodic"): + return "periodic" + return "pull request" + + +def isRehearse(job): + if job["upstreamJob"].__contains__("rehearse"): + return "True" + return "False" + + +def clasifyAWSJobs(job): + if job["upstreamJob"].__contains__("rosa-hcp"): + return "AWS ROSA-HCP" + if job["clusterType"].__contains__("rosa"): + return "AWS ROSA" + return job["platform"] + + +def getBuild(job): + releaseStream = job["releaseStream"] + "-" + ocpVersion = job["ocpVersion"] + return ocpVersion.replace(releaseStream, "") \ No newline at end of file diff --git a/backend/app/api/v1/endpoints/cpt/maps/quay.py b/backend/app/api/v1/endpoints/cpt/maps/quay.py index 2a8a728b..43034749 100644 --- a/backend/app/api/v1/endpoints/cpt/maps/quay.py +++ b/backend/app/api/v1/endpoints/cpt/maps/quay.py @@ -1,19 +1,13 @@ -from ....commons.ocp import getData +from ....commons.quay import getData from datetime import date -################################################################ +##################################################################### # This will return a DataFrame from Quay required by the CPT endpoint -################################################################ +##################################################################### async def quayMapper(start_datetime: date, end_datetime: date, configpath: str): df = await getData(start_datetime, end_datetime, configpath) df.insert(len(df.columns), "product", "quay") - df["releaseStream"] = df.apply(getReleaseStream, axis=1) - df["version"] = df["shortVersion"] + df["version"] = df["releaseStream"] df["testName"] = df["benchmark"] - return df - -def getReleaseStream(row): - if row["releaseStream"].__contains__("nightly"): - return "Nightly" - return "Stable" \ No newline at end of file + return df \ No newline at end of file diff --git a/backend/app/api/v1/endpoints/quay/quayGraphs.py b/backend/app/api/v1/endpoints/quay/quayGraphs.py index ee7e45db..63c9e1a5 100644 --- a/backend/app/api/v1/endpoints/quay/quayGraphs.py +++ b/backend/app/api/v1/endpoints/quay/quayGraphs.py @@ -291,13 +291,14 @@ async def getMatchRuns(meta: dict): "query_string": { "query": ( f'benchmark: "{meta["benchmark"]}$"' + f' AND hitSize: "{meta["hitSize"]}"' + f' AND concurrency: "{meta["concurrency"]}"' + f' AND imagePushPulls: "{meta["imagePushPulls"]}"' f' AND workerNodesType: "{meta["workerNodesType"]}"' f' AND masterNodesType: "{meta["masterNodesType"]}"' f' AND masterNodesCount: "{meta["masterNodesCount"]}"' f' AND workerNodesCount: "{meta["workerNodesCount"]}"' - f' AND platform: "{meta["platform"]}"' f' AND releaseStream: "{meta["releaseStream"]}"' - f' AND ocpVersion: {version}*' f' AND jobStatus: success' ) } diff --git a/backend/app/api/v1/endpoints/quay/quayJobs.py b/backend/app/api/v1/endpoints/quay/quayJobs.py index d3656635..5d57a919 100644 --- a/backend/app/api/v1/endpoints/quay/quayJobs.py +++ b/backend/app/api/v1/endpoints/quay/quayJobs.py @@ -2,8 +2,8 @@ from fastapi import Response from datetime import datetime, timedelta, date from fastapi import APIRouter -from ...commons.ocp import getData -from ...commons.example_responses import ocp_200_response, response_422 +from ...commons.quay import getData +from ...commons.example_responses import quay_200_response, response_422 from fastapi.param_functions import Query router = APIRouter() @@ -17,7 +17,7 @@ `startDate`: will be set to the day of the request minus 5 days.\ `endDate`: will be set to the day of the request.", responses={ - 200: ocp_200_response(), + 200: quay_200_response(), 422: response_422(), },) async def jobs(start_date: date = Query(None, description="Start date for searching jobs, format: 'YYYY-MM-DD'", examples=["2020-11-10"]), diff --git a/frontend/src/components/OCP/BenchmarkResults.js b/frontend/src/components/OCP/BenchmarkResults.js index 9635502c..4d7da958 100644 --- a/frontend/src/components/OCP/BenchmarkResults.js +++ b/frontend/src/components/OCP/BenchmarkResults.js @@ -1,5 +1,5 @@ import {Grid, GridItem} from "@patternfly/react-core"; -import InstallCard from "../commons/InstallCard"; +import InstallCard from "./InstallCard"; import React from "react"; import {DisplayGraph} from "./DisplayGraph"; diff --git a/frontend/src/components/commons/InstallCard.js b/frontend/src/components/OCP/InstallCard.js similarity index 98% rename from frontend/src/components/commons/InstallCard.js rename to frontend/src/components/OCP/InstallCard.js index 07dfaf71..402ec84e 100644 --- a/frontend/src/components/commons/InstallCard.js +++ b/frontend/src/components/OCP/InstallCard.js @@ -4,7 +4,7 @@ import { Grid, GridItem } from '@patternfly/react-core'; import { Spinner } from '@patternfly/react-core'; import { formatTime } from '../../helpers/Formatters' import { FaCheck, FaExclamationCircle, FaExclamationTriangle } from "react-icons/fa"; -import { DisplayGrafana } from "./DisplayGrafana"; +import { DisplayGrafana } from "../commons/DisplayGrafana"; export default function InstallCard(props) { diff --git a/frontend/src/components/Quay/BenchmarkResults.js b/frontend/src/components/Quay/BenchmarkResults.js index f02804b8..82c49a76 100644 --- a/frontend/src/components/Quay/BenchmarkResults.js +++ b/frontend/src/components/Quay/BenchmarkResults.js @@ -1,5 +1,5 @@ import {Grid, GridItem} from "@patternfly/react-core"; -import InstallCard from "../commons/InstallCard"; +import InstallCard from "./InstallCard"; import React from "react"; import {DisplayGraph} from "./DisplayGraph"; diff --git a/frontend/src/components/Quay/InstallCard.js b/frontend/src/components/Quay/InstallCard.js new file mode 100644 index 00000000..2ca34b4b --- /dev/null +++ b/frontend/src/components/Quay/InstallCard.js @@ -0,0 +1,90 @@ +import React from 'react'; +import { Card, CardTitle, CardBody, CardFooter, CardHeader, CardExpandableContent } from '@patternfly/react-core'; +import { Grid, GridItem } from '@patternfly/react-core'; +import { Spinner } from '@patternfly/react-core'; +import { formatTime } from '../../helpers/Formatters' +import { FaCheck, FaExclamationCircle, FaExclamationTriangle } from "react-icons/fa"; +import { DisplayGrafana } from "../commons/DisplayGrafana"; + + +export default function InstallCard(props) { + let config = props.data + const [isExpanded, setExpanded] = React.useState([true, null]) + + + const onExpand = () => { + setExpanded(!isExpanded) + }; + + const icons = { + "failed": <>, + "success": <>, + "upstream_failed": <>, + + } + + if (config) { + return ( + + + Configs + + + + + + + Cluster Metadata +
    +
  • Release Binary: {config.cluster_version && config.cluster_version || config.ocpVersion}
  • +
  • Cluster Name: {config.cluster_name && config.cluster_name || config.clusterName}
  • +
  • Cluster Type: {config.cluster_type && config.cluster_type || config.clusterType}
  • +
  • Network Type: {config.network_type && config.network_type || config.networkType}
  • +
  • Benchmark Status: {icons[config.job_status && config.job_status || config.jobStatus] || config.job_status && config.job_status || config.jobStatus}
  • +
  • Duration: {formatTime(config.job_duration && config.job_duration || config.jobDuration)}
  • +
  • Test ID: {config.uuid}
  • +
+
+ + + Node Types +
    +
  • Master: {config.master_type && config.master_type || config.masterNodesType}
  • +
  • Worker: {config.worker_type && config.worker_type || config.workerNodesType}
  • +
  • Workload: {config.workload_type && config.workload_type || config.benchmark}
  • +
  • Infra: {config.infra_type && config.infra_type || config.infraNodesType}
  • +
+
+ Node Counts +
    +
  • Master: {config.master_count && config.master_count || config.masterNodesCount}
  • +
  • Worker: {config.worker_count && config.worker_count || config.workerNodesCount}
  • +
  • Infra: {config.infra_count && config.infra_count || config.infraNodesCount}
  • +
  • Total Nodes: {config.workload_count && config.workload_count || config.totalNodesCount}
  • +
+
+
+
+
+ + +
) + } else { + return ( + + Install Configuration +
Awaiting Results
+ +
+ ) + } + +} diff --git a/frontend/src/components/Quay/QuayHome.js b/frontend/src/components/Quay/QuayHome.js index 8b3ebcbe..c56f16ea 100644 --- a/frontend/src/components/Quay/QuayHome.js +++ b/frontend/src/components/Quay/QuayHome.js @@ -30,7 +30,10 @@ export function QuayHome() { const [platform, setPlatform] = useState(searchParams.get("platform") || quayJobs.selectedPlatform) const [benchmark, setBenchmark] = useState(searchParams.get("benchmark") || quayJobs.selectedBenchmark) const [workerCount, setWorkerCount] = useState(searchParams.get("workerCount") || quayJobs.selectedWorkerCount) - const [version, setVersion] = useState(searchParams.get("version") || quayJobs.selectedVersion) + const [releaseStream, setReleaseStream] = useState(searchParams.get("releaseStream") || quayJobs.selectedReleaseStream) + const [hitSize, setHitSize] = useState(searchParams.get("hitSize") || quayJobs.selectedHitSize) + const [concurrency, setConcurrency] = useState(searchParams.get('concurrency') || quayJobs.selectedConcurrency) + const [imagePushPull, setImagePushPull] = useState(searchParams.get('imagePushPull') || quayJobs.selectedImagePushPull) const [startDate, setStartDate] = useState(searchParams.get("startDate") || quayJobs.startDate) || "" const [endDate, setEndDate] = useState(searchParams.get("endDate") || quayJobs.endDate) || "" @@ -39,8 +42,11 @@ export function QuayHome() { {name: "Ci System", onChange: setCiSystem, value: ciSystem, options: quayJobs.ciSystems}, {name: "Platform", onChange: setPlatform, value: platform, options: quayJobs.platforms}, {name: "Benchmark", onChange: setBenchmark, value: benchmark, options:quayJobs.benchmarks }, - {name: "Versions", onChange: setVersion, value: version, options: quayJobs.versions}, - {name: "Workers Count", onChange: setWorkerCount, value: workerCount, options:quayJobs.workers } + {name: "Release Streams", onChange: setReleaseStream, value: releaseStream, options: quayJobs.releaseStreams}, + {name: "Workers Count", onChange: setWorkerCount, value: workerCount, options:quayJobs.workers }, + {name: "Hit Size", onChange: setHitSize, value: hitSize, options:quayJobs.hitSize }, + {name: "Concurrency", onChange: setConcurrency, value: concurrency, options:quayJobs.concurrency }, + {name: "Image Push/Pulls", onChange: setImagePushPull, value: imagePushPull, options:quayJobs.imagePushPull } ] useEffect(() => { @@ -48,17 +54,20 @@ export function QuayHome() { if(ciSystem !== '') buildParams += `&ciSystem=${ciSystem}` if(platform !== '') buildParams += `&platform=${platform}` if(benchmark !== '') buildParams += `&benchmark=${benchmark}` - if(version !== '') buildParams += `&version=${version}` + if(releaseStream !== '') buildParams += `&releaseStream=${releaseStream}` if(workerCount !== '') buildParams += `&workerCount=${workerCount}` + if(hitSize !== '') buildParams += `&hitSize=${hitSize}` + if(concurrency !== '') buildParams += `&concurrency=${concurrency}` + if(imagePushPull !== '') buildParams += `&imagePushPull=${imagePushPull}` if(startDate !== '') buildParams += `&startDate=${startDate}` if(endDate !== '') buildParams += `&endDate=${endDate}` history.push(`/quay?${buildParams.substring(1)}`, { replace: true }); - }, [history, ciSystem, platform, benchmark, version, workerCount, startDate, endDate]) + }, [history, ciSystem, platform, benchmark, releaseStream, workerCount, hitSize, concurrency, imagePushPull, startDate, endDate]) useEffect( ()=>{ - dispatch(updateQuayDataFilter({ciSystem, platform, benchmark, version, workerCount})) - }, [ ciSystem, platform, benchmark, version, workerCount, dispatch ]) + dispatch(updateQuayDataFilter({ciSystem, platform, benchmark, releaseStream, workerCount, hitSize, concurrency, imagePushPull})) + }, [ ciSystem, platform, benchmark, releaseStream, workerCount, hitSize, concurrency, imagePushPull, dispatch ]) useEffect(() => { if(startDate || endDate){ @@ -77,9 +86,8 @@ export function QuayHome() { return ( ); } diff --git a/frontend/src/components/commons/DisplayGrafana.js b/frontend/src/components/commons/DisplayGrafana.js index 844699f9..f80defb0 100644 --- a/frontend/src/components/commons/DisplayGrafana.js +++ b/frontend/src/components/commons/DisplayGrafana.js @@ -96,7 +96,7 @@ const getGrafanaData = (benchmarkConfigs) => { if (benchmarkConfigs.benchmark === "quay-load-test") { getGrafanaUrl = grafanaURL+quayDashboard+ "&from="+startDate+"&to="+endDate+ - "&var-uuid="+benchmarkConfigs.uuid+"&var-baseline_uuid="+benchmarkConfigs.uuid + "&var-uuid="+benchmarkConfigs.uuid } else { getGrafanaUrl = grafanaURL+dashboardURL+ diff --git a/frontend/src/store/Actions/ActionCreator.js b/frontend/src/store/Actions/ActionCreator.js index 9a1aac0d..7bfa7872 100644 --- a/frontend/src/store/Actions/ActionCreator.js +++ b/frontend/src/store/Actions/ActionCreator.js @@ -128,14 +128,18 @@ export const fetchQuayJobsData = (startDate = '', endDate='') => async dispatch const results = api_data.results if(results){ const benchmarks = GetBenchmarks(results) - const versions = GetVersions(results) + const releaseStreams = GetReleaseStreams(results) const platforms = GetPlatforms(results) const workers = GetWorkers(results) + const hitSizes = GetHitSizes(results) + const concurrencies = GetConcurrencies(results) + const imagePushPulls = GetImagePushPulls(results) const ciSystems = GetCiSystems(results) const updatedTime = new Date().toLocaleString().replace(', ', ' ').toString(); await dispatch(getQuayJobsData({ - data: results, benchmarks, versions, waitForUpdate: false, platforms, workers, - updatedTime, ciSystems, startDate: api_data.startDate, endDate: api_data.endDate + data: results, benchmarks, releaseStreams, waitForUpdate: false, platforms, workers, + hitSizes, concurrencies, imagePushPulls, updatedTime, ciSystems, startDate: api_data.startDate, + endDate: api_data.endDate })) await dispatch(updateQuayMetaData({data: results})) } @@ -220,6 +224,18 @@ const GetWorkers = (api_data) => { return Array.from(new Set(api_data.map(item => parseInt(item.workerNodesCount)))).sort((a, b) => a-b) } +const GetHitSizes = (api_data) => { + return Array.from(new Set(api_data.map(item => parseInt(item.hitSize)))).sort((a, b) => a-b) +} + +const GetConcurrencies = (api_data) => { + return Array.from(new Set(api_data.map(item => parseInt(item.concurrency)))).sort((a, b) => a-b) +} + +const GetImagePushPulls = (api_data) => { + return Array.from(new Set(api_data.map(item => parseInt(item.imagePushPull)))).sort((a, b) => a-b) +} + const GetNetworkTypes = (api_data) => { return Array.from(new Set(api_data.map(item => item.networkType.toUpperCase().trim()))).sort() } diff --git a/frontend/src/store/reducers/InitialData.js b/frontend/src/store/reducers/InitialData.js index ba292458..641f3023 100644 --- a/frontend/src/store/reducers/InitialData.js +++ b/frontend/src/store/reducers/InitialData.js @@ -52,6 +52,45 @@ export const OCP_INITIAL_DATA = { {name: "Status", value: "jobStatus"}], } +export const QUAY_INITIAL_DATA = { + initialState: true, + success: 0, + failure: 0, + total: 0, + others: 0, + duration:0, + ciSystems: ["All"], + platforms: ["All"], + benchmarks: ["All"], + releaseStreams: ["All"], + workers: ["All"], + hitSizes: ["All"], + concurrencies: ["All"], + imagePushPulls: ["All"], + selectedCiSystem: "All", + selectedPlatform: "All", + selectedBenchmark: "All", + selectedReleaseStream: "All", + selectedWorkerCount: "All", + selectedHitSize: "All", + selectedConcurrency: "All", + selectedImagePushPull: "All", + waitForUpdate: false, + copyData: [], + data: [], + updatedTime: 'Loading', + error: null, + startDate: '', + endDate: '', + tableData : [{ name: "Benchmark", value: "benchmark" }, + {name:"Release Stream", value: "releaseStream"}, + {name:"Platform", value: "platform"}, + {name: "Worker Count", value: "workerNodesCount"}, + {name: "Start Date", value: "startDate"}, + {name: "End Date", value: "endDate"}, + {name: "Status", value: "jobStatus"}], +} + export const CPT_INITIAL_DATA = { initialState: true, success: 0, diff --git a/frontend/src/store/reducers/QuayJobsReducer.js b/frontend/src/store/reducers/QuayJobsReducer.js index 78e3067c..c9028198 100644 --- a/frontend/src/store/reducers/QuayJobsReducer.js +++ b/frontend/src/store/reducers/QuayJobsReducer.js @@ -1,10 +1,10 @@ import {createSlice, original} from "@reduxjs/toolkit"; -import {OCP_INITIAL_DATA} from "./InitialData"; -import { getOCPUpdatedData, getOCPSummary } from './Utils'; +import {QUAY_INITIAL_DATA} from "./InitialData"; +import { getQuayUpdatedData, getQuaySummary } from './Utils'; const jobsSlice = createSlice({ initialState: { - ...OCP_INITIAL_DATA, + ...QUAY_INITIAL_DATA, }, name: 'quayES', reducers: { @@ -13,31 +13,38 @@ const jobsSlice = createSlice({ state.copyData = action.payload.data state.data = action.payload.data state.benchmarks = ["All", ...action.payload.benchmarks] - state.versions = ["All", ...action.payload.versions] + state.releaseStreams = ["All", ...action.payload.releaseStreams] state.waitForUpdate = action.payload.waitForUpdate state.platforms = ["All", ...action.payload.platforms] state.workers = ["All", ...action.payload.workers] + state.hitSizes = ["All", ...action.payload.hitSizes] + state.concurrencies = ["All", ...action.payload.concurrencies] + state.imagePushPulls = ["All", ...action.payload.imagePushPulls] state.ciSystems = ["All", ...action.payload.ciSystems] state.updatedTime = action.payload.updatedTime state.error = null - Object.assign(state, getOCPSummary(state.data)) + Object.assign(state, getQuaySummary(state.data)) state.startDate = action.payload.startDate state.endDate = action.payload.endDate }, updateQuayDataFilter: (state, action) => { - const {ciSystem, platform, benchmark, version, workerCount} = action.payload + const {ciSystem, platform, benchmark, releaseStream, workerCount, hitSize, concurrency, imagePushPull} = action.payload state.selectedBenchmark = benchmark - state.selectedVersion = version + state.selectedReleaseStream = releaseStream state.selectedPlatform = platform state.selectedWorkerCount = workerCount state.selectedCiSystem = ciSystem - state.data = getOCPUpdatedData(original(state.copyData), platform, benchmark, version, workerCount, 'all', ciSystem, 'all', 'all') - Object.assign(state, getOCPSummary(state.data)) + state.selectedHitSize = hitSize + state.selectedConcurrency = concurrency + state.selectedImagePushPull = imagePushPull + state.data = getQuayUpdatedData(original(state.copyData), platform, benchmark, releaseStream, workerCount, ciSystem, hitSize, concurrency, imagePushPull) + Object.assign(state, getQuaySummary(state.data)) }, updateQuayMetaData: (state, action) => { - state.data = getOCPUpdatedData(action.payload.data, state.selectedPlatform, state.selectedBenchmark, - state.selectedVersion, state.selectedWorkerCount, 'all', state.selectedCiSystem, 'all', 'all') - Object.assign(state, getOCPSummary(state.data)) + state.data = getQuayUpdatedData(action.payload.data, state.selectedPlatform, state.selectedBenchmark, + state.selectedReleaseStream, state.selectedWorkerCount, state.selectedCiSystem, state.selectedHitSize, + state.selectedConcurrency, state.selectedImagePushPull) + Object.assign(state, getQuaySummary(state.data)) }, setWaitForQuayUpdate: (state, action) => { state.waitForUpdate = action.payload.waitForUpdate diff --git a/frontend/src/store/reducers/Utils.js b/frontend/src/store/reducers/Utils.js index 54922fb1..d5b8197e 100644 --- a/frontend/src/store/reducers/Utils.js +++ b/frontend/src/store/reducers/Utils.js @@ -42,6 +42,20 @@ const getOCPUpdatedData = (data, platform, benchmark, version, workerCount, netw return filteredData } +const getQuayUpdatedData = (data, platform, benchmark, releaseStream, workerCount, ciSystem, hitSize, concurrency, imagePushPull) => { + const filterValues = { + "platform": platform, "benchmark": benchmark, + "releaseStream": releaseStream, "workerNodesCount": workerCount, + "ciSystem": ciSystem, "hitSize": hitSize, "concurrency": concurrency, + "imagePushPull": imagePushPull, + } + let filteredData = data + for (let [keyName, value] of Object.entries(filterValues)) + filteredData = getFilteredData(filteredData, value, keyName) + + return filteredData +} + const getCPTSummary = (api_data) => { let success = 0; let failure = 0; @@ -70,5 +84,21 @@ const getOCPSummary = (api_data) => { return {success, failure, others, total, duration} } +const getQuaySummary = (api_data) => { + let success = 0; + let failure = 0; + let others = 0; + let duration = 0; + api_data.forEach(item => { + if(item.jobStatus.toLowerCase() === "success") success++ + else if(item.jobStatus.toLowerCase() === "failure") failure++; + else others++; + duration += parseInt(item.jobDuration) ? parseInt(item.jobDuration) : 0; + }) + const total = success + failure + others + + return { success, failure, others, total, duration }; +} + -export { getCPTUpdatedData, getOCPUpdatedData, getCPTSummary, getOCPSummary }; \ No newline at end of file +export { getCPTUpdatedData, getOCPUpdatedData, getQuayUpdatedData, getCPTSummary, getOCPSummary, getQuaySummary }; \ No newline at end of file