Skip to content

Commit b172342

Browse files
committed
tests: replace hard-coded sleep with dynamic wait
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
1 parent 9748095 commit b172342

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

tests/bats/helpers.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,10 @@ get_all_cd_daemon_logs_for_cd_name() {
119119
--prefix \
120120
--all-containers \
121121
--timestamps
122-
}
122+
}
123+
124+
# Intended use case: one pod in Running state; then this function returns the
125+
# specific name of that pod.
126+
get_current_controller_pod_name() {
127+
kubectl get pod -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu | awk '{print $1}'
128+
}

tests/bats/tests.bats

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ log_objects() {
141141
assert_output --partial "channel2047"
142142
assert_output --partial "channel222"
143143
kubectl delete -f demo/specs/imex/channel-injection-all.yaml
144+
kubectl wait --for=delete pods imex-channel-injection-all --timeout=10s
144145
}
145146

146147
@test "CD daemon shutdown: confirm CD status cleanup" {
@@ -228,6 +229,7 @@ log_objects() {
228229
# Clean up.
229230
kubectl delete "${POD}"
230231
kubectl delete resourceclaim batssuite-rc-bad-opaque-config
232+
kubectl wait --for=delete "${POD}" --timeout=10s
231233
}
232234

233235
@test "nickelpie (NCCL send/recv/broadcast, 2 pods, 2 nodes, small payload)" {
@@ -365,11 +367,18 @@ log_objects() {
365367
kubectl wait --for=delete pods imex-channel-injection --timeout=10s
366368

367369
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+
# Reconfigure (only the) log verbosity for CD daemons spawned in the future.
371+
# The deployment mutation via `set env` below is expected to restart the
372+
# controller. Wait for the old controller pod to go away (to be sure that the
373+
# new LOG_VERBOSITY_CD_DAEMON setting applies).
374+
CPOD="$(get_current_controller_pod_name)"
375+
log_objects
370376
kubectl set env deployment nvidia-dra-driver-gpu-controller -n nvidia-dra-driver-gpu LOG_VERBOSITY_CD_DAEMON=0
377+
echo "waiting for pod $CPOD"
378+
kubectl wait --for=delete pods "$CPOD" -n nvidia-dra-driver-gpu --timeout=10s
379+
echo "done waiting"
380+
log_objects
371381

372-
sleep 5
373382
# Spawn new workload
374383
kubectl apply -f demo/specs/imex/channel-injection.yaml
375384
kubectl wait --for=condition=READY pods imex-channel-injection --timeout=100s

0 commit comments

Comments
 (0)