in packages/web-api/src/controllers/health-check-controller.ts [96:140]
private getHealthReport(queryResponse: ApplicationInsightsQueryResponse, releaseId: string): HealthReport {
const table = queryResponse.tables[0];
const columns = table.columns;
let testsPassed = 0;
let testsFailed = 0;
const testRuns: TestRun[] = [];
table.rows.forEach((row) => {
const result = this.getColumnValue(columns, row, 'result') as TestRunResult;
if (result === 'pass') {
testsPassed += 1;
} else {
testsFailed += 1;
}
const testRun: TestRun = {
testContainer: this.getColumnValue(columns, row, 'testContainer'),
testName: this.getColumnValue(columns, row, 'testName'),
scenarioName: this.getColumnValue(columns, row, 'scenarioName'),
scanId: this.getColumnValue(columns, row, 'scanId'),
result: result,
timestamp: new Date(this.getColumnValue(columns, row, 'timestamp')),
};
if (result === 'fail') {
testRun.error = this.getColumnValue(columns, row, 'error');
}
testRuns.push(testRun);
});
const environment = this.getColumnValue(columns, table.rows[0], 'environment') as TestEnvironment;
const runId = this.getColumnValue(columns, table.rows[0], 'runId');
const healthStatus = testRuns.length > 0 ? (testsFailed === 0 ? 'pass' : 'fail') : 'warn';
return {
healthStatus,
environment: environment,
releaseId: releaseId,
runId: runId,
testRuns: testRuns,
testsPassed: testsPassed,
testsFailed: testsFailed,
};
}