Skip to content

Commit 9748095

Browse files
committed
tests: cover CD daemon log levels
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
1 parent 4767092 commit 9748095

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

tests/bats/helpers.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,16 @@ wait_for_pod_event() {
107107
sleep 2
108108
done
109109
}
110+
111+
get_all_cd_daemon_logs_for_cd_name() {
112+
CD_NAME="$1"
113+
CD_UID=$(kubectl describe computedomains.resource.nvidia.com "${CD_NAME}" | grep UID | awk '{print $2}')
114+
CD_LABEL_KV="resource.nvidia.com/computeDomain=${CD_UID}"
115+
kubectl logs \
116+
-n nvidia-dra-driver-gpu \
117+
-l "${CD_LABEL_KV}" \
118+
--tail=-1 \
119+
--prefix \
120+
--all-containers \
121+
--timestamps
122+
}

tests/bats/tests.bats

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,48 @@ log_objects() {
337337
iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs
338338
assert_output --partial '"Response" verb="GET"'
339339

340+
# Delete workload and hence CD daemon
341+
kubectl delete -f demo/specs/imex/channel-injection.yaml
342+
kubectl wait --for=delete pods imex-channel-injection --timeout=10s
343+
}
344+
345+
@test "CD daemon: test log verbosity levels" {
346+
log_objects
347+
348+
# Delete workload if it exists
349+
kubectl delete -f demo/specs/imex/channel-injection.yaml || true
350+
351+
echo "test level 6"
352+
local _iargs=("--set" "logVerbosity=6")
353+
iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs
354+
355+
kubectl apply -f demo/specs/imex/channel-injection.yaml
356+
kubectl wait --for=condition=READY pods imex-channel-injection --timeout=100s
357+
358+
# Confirm that the CD daemon logs on level six
359+
run get_all_cd_daemon_logs_for_cd_name "imex-channel-injection"
360+
assert_output --partial 'wait for nodes update' # level 1 msg
361+
assert_output --partial 'round_trippers.go' # level 6 msg
362+
363+
# Delete workload and hence CD daemon
364+
kubectl delete -f demo/specs/imex/channel-injection.yaml
365+
kubectl wait --for=delete pods imex-channel-injection --timeout=10s
366+
367+
echo "test level 0"
368+
# Reconfigure log verbosity for CD daemons spawned in the future.
369+
# This deployment mutation is expected to restart the controller.
370+
kubectl set env deployment nvidia-dra-driver-gpu-controller -n nvidia-dra-driver-gpu LOG_VERBOSITY_CD_DAEMON=0
371+
372+
sleep 5
373+
# Spawn new workload
374+
kubectl apply -f demo/specs/imex/channel-injection.yaml
375+
kubectl wait --for=condition=READY pods imex-channel-injection --timeout=100s
376+
377+
# Confirm that the CD daemon now does not contain a level 1 msg
378+
run get_all_cd_daemon_logs_for_cd_name "imex-channel-injection"
379+
refute_output --partial 'wait for nodes update' # expected level 1 msg
380+
381+
# Delete workload
340382
kubectl delete -f demo/specs/imex/channel-injection.yaml
341383
kubectl wait --for=delete pods imex-channel-injection --timeout=10s
342384
}

0 commit comments

Comments
 (0)