Skip to content

Commit fcd74d1

Browse files
committed
tests: add nvmm helper
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
1 parent 977f421 commit fcd74d1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/bats/helpers.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,28 @@ apply_check_delete_workload_imex_chan_inject() {
172172
kubectl delete -f demo/specs/imex/channel-injection.yaml
173173
kubectl wait --for=delete pods imex-channel-injection --timeout=10s
174174
}
175+
176+
177+
# Run cmd in nvidia-mig-manager pod because that one has highest privileges. I
178+
# use this for example to run `nvcnt gb-nvl-027-compute06 nvidia-smi`
179+
nvmm() {
180+
if [ -z "$1" ]; then
181+
echo "Usage: nvcnt <node-name> [command...]"
182+
return 1
183+
fi
184+
local node="$1"
185+
shift # Remove first argument, leaving remaining args in $@
186+
187+
local pod
188+
pod=$(kubectl get pod -n gpu-operator -l app=nvidia-mig-manager \
189+
--field-selector spec.nodeName="$node" \
190+
--no-headers -o custom-columns=":metadata.name")
191+
192+
if [ -z "$pod" ]; then
193+
echo "No pod found on node $node"
194+
return 1
195+
fi
196+
197+
echo "Executing on pod $pod (node: $node)..."
198+
kubectl -n gpu-operator exec -it "$pod" -- "$@"
199+
}

0 commit comments

Comments
 (0)