Skip to content

Commit 2e58b3e

Browse files
committed
♻️ Rename e2e-summary.json to e2e-summary.md
The E2E test summary file contains Markdown content (with mermaid charts), not JSON. This updates the file extension and parsing logic throughout the memory profiling scripts to correctly handle the Markdown format. Changes: - run-profiled-test.sh: Output to e2e-summary.md instead of .json - analyze-profiles.sh: Parse Markdown Alerts section instead of JSON - compare-profiles.sh: Compare Markdown alert sections between tests
1 parent 349da35 commit 2e58b3e

File tree

3 files changed

+46
-68
lines changed

3 files changed

+46
-68
lines changed

hack/tools/memory-profiling/analyze-profiles.sh

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -209,47 +209,30 @@ EOF
209209
fi
210210

211211
# Prometheus Alerts Analysis
212-
if [ -f "${OUTPUT_DIR}/e2e-summary.json" ]; then
212+
if [ -f "${OUTPUT_DIR}/e2e-summary.md" ]; then
213213
log_info "Analyzing Prometheus alerts..."
214214
cat >> "${REPORT_FILE}" << 'EOF'
215215
216216
## Prometheus Alerts
217217
218218
EOF
219219

220-
# Check if jq is available for JSON parsing
221-
if command -v jq >/dev/null 2>&1; then
222-
# Extract alerts from e2e-summary.json
223-
ALERTS=$(jq -r '.prometheusAlerts // [] | .[] | "- **\(.labels.alertname)** (Severity: \(.labels.severity // "unknown"))\n - \(.annotations.description // .annotations.message // "No description")"' "${OUTPUT_DIR}/e2e-summary.json" 2>/dev/null || echo "")
220+
# Extract the Alerts section from the markdown file
221+
# Look for "## Alerts" section and extract until next ## section or end
222+
ALERTS_SECTION=$(sed -n '/^## Alerts/,/^##/p' "${OUTPUT_DIR}/e2e-summary.md" | sed '$d' | tail -n +2)
224223

225-
if [ -n "${ALERTS}" ]; then
226-
cat >> "${REPORT_FILE}" << EOF
227-
### Alerts Detected
224+
if [ -n "${ALERTS_SECTION}" ] && [ "${ALERTS_SECTION}" != "None." ]; then
225+
cat >> "${REPORT_FILE}" << EOF
226+
${ALERTS_SECTION}
228227
229-
${ALERTS}
228+
Full E2E test summary available at: \`e2e-summary.md\`
230229
231230
EOF
232-
else
233-
cat >> "${REPORT_FILE}" << 'EOF'
234-
No Prometheus alerts detected during test execution.
235-
236-
EOF
237-
fi
238-
239-
# Extract test failures if any
240-
TEST_FAILURES=$(jq -r '.testFailures // [] | .[] | "- \(.test): \(.message)"' "${OUTPUT_DIR}/e2e-summary.json" 2>/dev/null || echo "")
241-
242-
if [ -n "${TEST_FAILURES}" ]; then
243-
cat >> "${REPORT_FILE}" << EOF
244-
### Test Failures
245-
246-
${TEST_FAILURES}
247-
248-
EOF
249-
fi
250231
else
251232
cat >> "${REPORT_FILE}" << 'EOF'
252-
E2E summary available at `e2e-summary.json` (install `jq` for detailed alert parsing)
233+
No Prometheus alerts detected during test execution.
234+
235+
Full E2E test summary available at: `e2e-summary.md`
253236
254237
EOF
255238
fi

hack/tools/memory-profiling/compare-profiles.sh

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -286,69 +286,64 @@ cat >> "${REPORT_FILE}" << 'EOF'
286286
EOF
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
316321
EOF
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
322327
EOF
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+
327334
EOF
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
347342
EOF
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
353348
EOF
354349
fi

hack/tools/memory-profiling/run-profiled-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ log_info "Output directory: ${OUTPUT_DIR}"
9191
log_info "Starting e2e test (${TEST_TARGET})..."
9292
# Set E2E_SUMMARY_OUTPUT to capture prometheus alerts and other test metrics
9393
# Use absolute path because e2e tests may change directories
94-
E2E_SUMMARY_OUTPUT="${OUTPUT_DIR_ABS}/e2e-summary.json" make "${TEST_TARGET}" > "${OUTPUT_DIR}/test.log" 2>&1 &
94+
E2E_SUMMARY_OUTPUT="${OUTPUT_DIR_ABS}/e2e-summary.md" make "${TEST_TARGET}" > "${OUTPUT_DIR}/test.log" 2>&1 &
9595
TEST_PID=$!
9696
log_info "Test started (PID: ${TEST_PID})"
9797

0 commit comments

Comments
 (0)