Skip to content

Commit 0dab2a7

Browse files
tests: add debugging when certain errors occur
Add a _testdbg function that takes resource names after an error message, for each resource print the YAML and describe info. Signed-off-by: John Mulligan <[email protected]>
1 parent ba8fe32 commit 0dab2a7

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

tests/common.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,21 @@ _error() {
1515
echo "$@"
1616
exit 1
1717
}
18+
19+
_errordbg() {
20+
local errmsg="$1"
21+
shift
22+
echo ERROR: "$errmsg"
23+
for resource in "$@"; do
24+
echo "---------"
25+
dcmd=(kubectl get -o yaml "${resource}")
26+
echo ">" "${dcmd[@]}"
27+
! "${dcmd[@]}"
28+
echo "---------"
29+
dcmd=(kubectl describe "${resource}")
30+
echo ">" "${dcmd[@]}"
31+
! "${dcmd[@]}"
32+
done
33+
echo "---------"
34+
_error "$errmsg"
35+
}

tests/test-deploy-ad-member.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ done
3434
echo
3535
kubectl get pod
3636
echo
37-
echo "$podstatus" | grep -q 'Running' || _error "Pod did not reach Running state"
37+
echo "$podstatus" | grep -q 'Running' || \
38+
_errordbg "Pod did not reach Running state" "pod/${podname}"
3839

3940
echo "waiting for samba to become reachable"
4041
tries=0

tests/test-deploy-ad-server.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ done
3737
echo
3838
kubectl get pod
3939
echo
40-
echo "$podstatus" | grep -q 'Running' || _error "Pod did not reach Running state"
40+
echo "$podstatus" | grep -q 'Running' || \
41+
_errordbg "Pod did not reach Running state" "deployment/${AD_DEPLOYMENT_NAME}" "pod/${podname}"
4142

4243
echo "waiting for samba to become reachable"
4344
tries=0

0 commit comments

Comments
 (0)