-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds new endpoint for jenkins jobs (#17)
* Adds new endpoint for jenkins jobs Adds new tab for Jenkins jobs Abstracts logic to reuse methods when fetching data from ES Signed-off-by: Vicente Zepeda Mas <[email protected]> * Dropping errored runs from the results Signed-off-by: Vicente Zepeda Mas <[email protected]> --------- Signed-off-by: Vicente Zepeda Mas <[email protected]>
- Loading branch information
Showing
10 changed files
with
121 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea | ||
backend/ocpperf.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from datetime import datetime,timedelta | ||
import trio | ||
import semver | ||
import pandas as pd | ||
from app.services.search import ElasticService | ||
|
||
from app.async_util import trio_run_with_asyncio | ||
|
||
|
||
async def getData(type): | ||
query = { | ||
"query": { | ||
"bool": { | ||
"must": [ | ||
{ | ||
"query_string": { | ||
"query": "ciSystem == " + type | ||
} | ||
}, | ||
{ | ||
"range": { | ||
"timestamp": { | ||
"gte": "now-10d" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
es = ElasticService() | ||
response = await es.post(query) | ||
await es.close() | ||
tasks = [item['_source'] for item in response["hits"]["hits"]] | ||
jobs = pd.json_normalize(tasks) | ||
cleanJobs = jobs[jobs['platform'] != ""] | ||
|
||
drop = ['endDate','clusterName','upstreamJobBuild','executionDate', | ||
'startDate','buildTag','upstreamJob','releaseStream','timestamp', | ||
'jobDuration','networkType','workerNodesType','infraNodesType','masterNodesType', | ||
'workerNodesCount','infraNodesCount','masterNodesCount'] | ||
cleanJobs = cleanJobs.drop(columns=drop) | ||
cleanJobs['shortVersion'] = cleanJobs['ocpVersion'].str.slice(0,4) | ||
|
||
df = {'response': group_by_platform(cleanJobs)} | ||
|
||
return df | ||
|
||
def group_by_platform(data_frame: pd.DataFrame): | ||
return [ | ||
get_table(group[0], group[1].drop(columns=['platform'])) | ||
for group in data_frame.groupby(by=['platform']) | ||
] | ||
|
||
|
||
def get_table(title: str, data_frame: pd.DataFrame): | ||
return { | ||
'title': title, | ||
'data' : get_framelist(data_frame) | ||
} | ||
|
||
def get_framelist(data_frame: pd.DataFrame): | ||
return [ | ||
get_frame(group[0], (group[1].drop( | ||
columns=['nodeName', 'ocpVersion']))) | ||
for group in data_frame.groupby(by=['shortVersion']) | ||
] | ||
|
||
|
||
def get_frame(title: str, data_frame: pd.DataFrame): | ||
return { | ||
'version' : title.title(), | ||
'cloud_data': data_frame.values.tolist(), | ||
'columns' : [name.replace('_', ' ').title() | ||
for name in data_frame.columns.tolist()] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from .common import getData | ||
from fastapi import APIRouter | ||
|
||
from app.async_util import trio_run_with_asyncio | ||
|
||
router = APIRouter() | ||
|
||
@router.post('/api/jenkins') | ||
@router.get('/api/jenkins') | ||
async def jobs(): | ||
return await getData("JENKINS") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import './PlatformView.css'; | ||
import "@patternfly/react-core/dist/styles/base.css"; | ||
import PlatformTabs from './Tabs/Platform'; | ||
import useESPerfData from '../../hooks/useESPerfData'; | ||
import React from 'react'; | ||
|
||
|
||
export default function JenkinsView() { | ||
const perfData = useESPerfData("jenkins") | ||
return ( | ||
<> | ||
<div className="PlatformView"> | ||
<PlatformTabs id="PlatformTabs" data={perfData} /> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters