Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add html template for test case risk analysis
- Loading branch information
Showing
3 changed files
with
246 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<html lang="en"> | ||
<head> | ||
<title>Risk Analysis</title> | ||
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> | ||
<meta name="description" | ||
content="Risk analysis is performed by Sippy to attempt to determine if the failures in this job are | ||
abnormal when compared to results for similar jobs over the past week, and amidst on-going incidents | ||
in the CI infrastructure. Risk analysis API will not catch everything and is a relatively simple | ||
implementation today, please reach out to the Technical Release Team if you spot abnormalities or | ||
have suggestions."> | ||
</head> | ||
<body onLoad="buildTestCaseTable('#test_case_results')"> | ||
<h1> | ||
</h1> | ||
<p> | ||
"<a href="TEST_RISK_ANALYSIS_SIPPY_URL_GOES_HERE">Link to Sippy</a>" | ||
</p> | ||
|
||
<table id="test_case_results" border="1" width="100%"> | ||
</table> | ||
|
||
<script> | ||
var testResult = TEST_RISK_ANALYSIS_JSON_GOES_HERE | ||
|
||
function buildOpenBugs(openBugs) { | ||
td$ = $('<td/>') | ||
if (openBugs.length > 0) { | ||
cell$ = $('<ul/>') | ||
for (var i = 0; i < openBugs.length; i++) { | ||
li$ = $('<li>') | ||
bug = "<a href=" + openBugs[i].url + ">" + openBugs[i].id + "</a>: " + openBugs[i].summary | ||
li$.append($('<li>').html(bug)) | ||
cell$.append(li$) | ||
} | ||
td$.append(cell$) | ||
} | ||
return td$ | ||
} | ||
|
||
function buildRiskReasons(reasons) { | ||
td$ = $('<td/>') | ||
if (reasons.length > 0) { | ||
cell$ = $('<ul/>') | ||
for (var i = 0; i < reasons.length; i++) { | ||
li$ = $('<li>') | ||
li$.append($('<li>').html(reasons[i])) | ||
cell$.append(li$) | ||
} | ||
td$.append(cell$) | ||
} | ||
return td$ | ||
} | ||
|
||
function buildRiskLevel(level) { | ||
td$ = $('<td/>') | ||
if (level.Level >= 10) { | ||
td$.css("background-color", "red"); | ||
} else if (level.Level >= 5) { | ||
td$.css("background-color", "yellow"); | ||
} else { | ||
td$.css("background-color", "green"); | ||
} | ||
td$.append(level.Name) | ||
return td$ | ||
} | ||
|
||
// Build Test Case Table | ||
function buildTestCaseTable(selector) { | ||
$( "h1" ).append("Risk Analysis for: " + testResult.ProwJobName + " ID: " + testResult.ProwJobRunID) | ||
|
||
// Add table headers | ||
addColumnHeaders(selector); | ||
|
||
// Build Overall Row | ||
var row$ = $('<tr/>'); | ||
row$.append($('<td/>').html("Overall")); | ||
row$.append(buildRiskLevel(testResult.OverallRisk.Level)) | ||
row$.append(buildRiskReasons(testResult.OverallRisk.Reasons)) | ||
row$.append(buildOpenBugs(testResult.OpenBugs)) | ||
$(selector).append(row$); | ||
|
||
// First sort the tests by risk factor | ||
testResult.Tests.sort(function(a, b){return b.Risk.Level.Level - a.Risk.Level.Level}) | ||
// Build rows for all tests | ||
for (var i = 0; i < testResult.Tests.length; i++) { | ||
var row$ = $('<tr/>'); | ||
row$.append($('<td/>').html(testResult.Tests[i].Name)); | ||
row$.append(buildRiskLevel(testResult.Tests[i].Risk.Level)) | ||
row$.append(buildRiskReasons(testResult.Tests[i].Risk.Reasons)) | ||
row$.append(buildOpenBugs(testResult.Tests[i].OpenBugs)) | ||
$(selector).append(row$); | ||
} | ||
} | ||
|
||
function addColumnHeaders(selector) { | ||
var headerTr$ = $('<tr/>'); | ||
headerTr$.append($('<th/>').html("Test Name")); | ||
headerTr$.append($('<th/>').html("Risk Level")); | ||
headerTr$.append($('<th/>').html("Risk Reason")); | ||
headerTr$.append($('<th/>').html("Open Bugs")); | ||
|
||
$(selector).append(headerTr$); | ||
} | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.