Skip to content

Commit 6209cac

Browse files
hbelmiroopenshift-merge-bot[bot]
authored andcommitted
Add logging and event collection for failed integration tests
Signed-off-by: Helber Belmiro <[email protected]>
1 parent 166893d commit 6209cac

File tree

2 files changed

+60
-34
lines changed

2 files changed

+60
-34
lines changed

.github/scripts/tests/collect_logs.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
DSPA_NS=""
6+
DSPO_NS=""
7+
8+
while [[ "$#" -gt 0 ]]; do
9+
case $1 in
10+
--dspa-ns) DSPA_NS="$2"; shift ;;
11+
--dspo-ns) DSPO_NS="$2"; shift ;;
12+
*) echo "Unknown parameter passed: $1"; exit 1 ;;
13+
esac
14+
shift
15+
done
16+
17+
if [[ -z "$DSPA_NS" || -z "$DSPO_NS" ]]; then
18+
echo "Both --dspa-ns and --dspo-ns parameters are required."
19+
exit 1
20+
fi
21+
22+
function check_namespace {
23+
if ! kubectl get namespace "$1" &>/dev/null; then
24+
echo "Namespace '$1' does not exist."
25+
exit 1
26+
fi
27+
}
28+
29+
function display_pod_info {
30+
local NAMESPACE=$1
31+
local POD_NAMES
32+
33+
POD_NAMES=$(kubectl -n "${DSPA_NS}" get pods -o custom-columns=":metadata.name")
34+
35+
if [[ -z "${POD_NAMES}" ]]; then
36+
echo "No pods found in namespace '${NAMESPACE}'."
37+
return
38+
fi
39+
40+
for POD_NAME in ${POD_NAMES}; do
41+
echo "===== Pod: ${POD_NAME} in ${NAMESPACE} ====="
42+
43+
echo "----- EVENTS -----"
44+
kubectl describe pod "${POD_NAME}" -n "${NAMESPACE}" | grep -A 100 Events || echo "No events found for pod ${POD_NAME}."
45+
46+
echo "----- LOGS -----"
47+
kubectl logs "${POD_NAME}" -n "${NAMESPACE}" || echo "No logs found for pod ${POD_NAME}."
48+
49+
echo "==========================="
50+
echo ""
51+
done
52+
}
53+
54+
check_namespace "$DSPA_NS"
55+
check_namespace "$DSPO_NS"
56+
57+
display_pod_info "$DSPA_NS"
58+
display_pod_info "$DSPO_NS"

.github/workflows/kind-integration.yml

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,7 @@ jobs:
5555

5656
- name: Collect events and logs
5757
if: steps.test.outcome != 'success'
58+
working-directory: ${{ github.workspace }}/.github/scripts/tests
5859
run: |
59-
kubectl -n test-dspa get pods
60-
kubectl -n opendatahub get pods
61-
62-
POD_NAMES=$(kubectl -n test-dspa get pods -o custom-columns=":metadata.name")
63-
64-
for POD_NAME in ${POD_NAMES}; do
65-
echo "===== Pod: ${POD_NAME} ====="
66-
67-
echo "----- EVENTS -----"
68-
kubectl describe pod ${POD_NAME} -n test-dspa | grep -A 100 Events
69-
70-
echo "----- LOGS -----"
71-
kubectl logs ${POD_NAME} -n test-dspa
72-
73-
echo "==========================="
74-
echo ""
75-
done
76-
77-
POD_NAMES=$(kubectl -n opendatahub get pods -o custom-columns=":metadata.name")
78-
79-
for POD_NAME in ${POD_NAMES}; do
80-
echo "===== Pod: ${POD_NAME} ====="
81-
82-
echo "----- EVENTS -----"
83-
kubectl describe pod ${POD_NAME} -n opendatahub | grep -A 100 Events
84-
85-
echo "----- LOGS -----"
86-
kubectl logs ${POD_NAME} -n opendatahub
87-
88-
echo "==========================="
89-
echo ""
90-
done
91-
60+
./collect_logs.sh --dspa-ns test-dspa --dspo-ns opendatahub
9261
exit 1
93-

0 commit comments

Comments
 (0)