@@ -286,69 +286,64 @@ cat >> "${REPORT_FILE}" << 'EOF'
286286EOF
287287
288288# Compare prometheus alerts if available
289- if [ -f " ${TEST1_DIR} /e2e-summary.json " ] || [ -f " ${TEST2_DIR} /e2e-summary.json " ]; then
290- if command -v jq > /dev/null 2>&1 ; then
291- # Test 1 alerts
292- if [ -f " ${TEST1_DIR} /e2e-summary.json " ] ; then
293- ALERTS1= $( jq -r ' .prometheusAlerts // [] | length ' " ${TEST1_DIR} /e2e-summary.json " 2> /dev/null || echo " 0 " )
294- ALERTS1_NAMES= $( jq -r ' .prometheusAlerts // [] | .[].labels.alertname ' " ${TEST1_DIR} /e2e-summary.json " 2> /dev/null | sort | uniq || echo " " )
289+ if [ -f " ${TEST1_DIR} /e2e-summary.md " ] || [ -f " ${TEST2_DIR} /e2e-summary.md " ]; then
290+ # Test 1 alerts
291+ if [ -f " ${TEST1_DIR} /e2e-summary.md " ] ; then
292+ ALERTS1_SECTION= $( sed -n ' /^## Alerts/,/^##/p ' " ${TEST1_DIR} /e2e-summary.md " | sed ' $d ' | tail -n +2 )
293+ if [ -n " ${ALERTS1_SECTION} " ] && [ " ${ALERTS1_SECTION} " != " None. " ] ; then
294+ ALERTS1= " Present "
295295 else
296- ALERTS1=" N/A"
297- ALERTS1_NAMES=" "
296+ ALERTS1=" None"
298297 fi
298+ else
299+ ALERTS1=" N/A"
300+ fi
299301
300- # Test 2 alerts
301- if [ -f " ${TEST2_DIR} /e2e-summary.json" ]; then
302- ALERTS2=$( jq -r ' .prometheusAlerts // [] | length' " ${TEST2_DIR} /e2e-summary.json" 2> /dev/null || echo " 0" )
303- ALERTS2_NAMES=$( jq -r ' .prometheusAlerts // [] | .[].labels.alertname' " ${TEST2_DIR} /e2e-summary.json" 2> /dev/null | sort | uniq || echo " " )
302+ # Test 2 alerts
303+ if [ -f " ${TEST2_DIR} /e2e-summary.md" ]; then
304+ ALERTS2_SECTION=$( sed -n ' /^## Alerts/,/^##/p' " ${TEST2_DIR} /e2e-summary.md" | sed ' $d' | tail -n +2)
305+ if [ -n " ${ALERTS2_SECTION} " ] && [ " ${ALERTS2_SECTION} " != " None." ]; then
306+ ALERTS2=" Present"
304307 else
305- ALERTS2=" N/A"
306- ALERTS2_NAMES=" "
308+ ALERTS2=" None"
307309 fi
310+ else
311+ ALERTS2=" N/A"
312+ fi
308313
309- cat >> " ${REPORT_FILE} " << EOF
314+ cat >> " ${REPORT_FILE} " << EOF
310315### Alert Summary
311316
312317| Metric | ${TEST1} | ${TEST2} |
313318|--------|----------|----------|
314- | Alert Count | ${ALERTS1} | ${ALERTS2} |
319+ | Alerts | ${ALERTS1} | ${ALERTS2} |
315320
316321EOF
317322
318- if [ -n " ${ALERTS1_NAMES } " ] || [ -n " ${ALERTS2_NAMES} " ]; then
319- cat >> " ${REPORT_FILE} " << 'EOF '
320- ### Alerts by Test
323+ if [ " ${ALERTS1 } " = " Present " ] || [ " ${ALERTS2} " = " Present " ]; then
324+ cat >> " ${REPORT_FILE} " << 'EOF '
325+ ### Alert Details
321326
322327EOF
323328
324- if [ -n " ${ALERTS1_NAMES} " ]; then
325- cat >> " ${REPORT_FILE} " << EOF
329+ if [ " ${ALERTS1} " = " Present " ]; then
330+ cat >> " ${REPORT_FILE} " << EOF
326331**${TEST1} :**
332+ ${ALERTS1_SECTION}
333+
327334EOF
328- echo " ${ALERTS1_NAMES} " | while read -r alert; do
329- [ -n " ${alert} " ] && echo " - ${alert} " >> " ${REPORT_FILE} "
330- done
331- echo " " >> " ${REPORT_FILE} "
332- fi
333-
334- if [ -n " ${ALERTS2_NAMES} " ]; then
335- cat >> " ${REPORT_FILE} " << EOF
335+ fi
336+
337+ if [ " ${ALERTS2} " = " Present" ]; then
338+ cat >> " ${REPORT_FILE} " << EOF
336339**${TEST2} :**
337- EOF
338- echo " ${ALERTS2_NAMES} " | while read -r alert; do
339- [ -n " ${alert} " ] && echo " - ${alert} " >> " ${REPORT_FILE} "
340- done
341- echo " " >> " ${REPORT_FILE} "
342- fi
343- else
344- cat >> " ${REPORT_FILE} " << 'EOF '
345- No alerts detected in either test.
340+ ${ALERTS2_SECTION}
346341
347342EOF
348343 fi
349344 else
350345 cat >> " ${REPORT_FILE} " << 'EOF '
351- E2E summaries available but `jq` not installed for parsing .
346+ No alerts detected in either test .
352347
353348EOF
354349 fi
0 commit comments