Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/bats/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ get_device_attrs_from_any_gpu_slice() {
kubectl get resourceslices.resource.k8s.io -o yaml "${slicename}" > "${spath}"
log "wrote resource slice content to: ${spath}"

# Log contents, for https://github.com/NVIDIA/k8s-dra-driver-gpu/issues/902
cat "${spath}" >&2

# For the first device in that slice (of given type), extract the set of
# device attribute _keys_. Emit those keys, one per line. If a node_name was
# provided, filter for the GPU plugin resource slice on that node. Using
Expand Down
4 changes: 3 additions & 1 deletion tests/bats/test_gpu_basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ bats::on_failure() {
"addressingMode"
)

local attrs=$(get_device_attrs_from_any_gpu_slice "gpu")
run get_device_attrs_from_any_gpu_slice "gpu"
assert_success
local attrs="$output"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change (also in the other places) makes the test more explicitly fail during execution of get_device_attrs_from_any_gpu_slice. Without this change, the failure would be ignored as of the sub shell usage in local attrs=$(get_device_attrs_from_any_gpu_slice "gpu").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, here we capture both, stderr and stdout into output (that's how run works). That breaks things because deliberately in that function we emit log output to stderr, and payload output to stdout. So, we need this instead:

  local attrs
  attrs=$(get_device_attrs_from_any_gpu_slice "gpu")

This crashes the test when the sub shell fails, and cleanly directs log output to where it should be.

assert_attrs_equal "$attrs" "${reference[@]}"
}
10 changes: 7 additions & 3 deletions tests/bats/test_gpu_dynmig.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ setup_file () {
# Give a bit of time for the kubelet plugins to update
# resource slices. See
# https://github.com/NVIDIA/k8s-dra-driver-gpu/issues/902
sleep 2
sleep 6
}

# Executed before entering each test in this file.
Expand Down Expand Up @@ -60,7 +60,9 @@ confirm_mig_mode_disabled_all_nodes() {
"addressingMode"
)

local attrs=$(get_device_attrs_from_any_gpu_slice "gpu")
run get_device_attrs_from_any_gpu_slice "gpu"
assert_success
local attrs="$output"
assert_attrs_equal "$attrs" "${reference[@]}"
}

Expand All @@ -82,7 +84,9 @@ confirm_mig_mode_disabled_all_nodes() {
"profile"
)

local attrs=$(get_device_attrs_from_any_gpu_slice "mig")
run get_device_attrs_from_any_gpu_slice "mig"
assert_success
local attrs="$output"
assert_attrs_equal "$attrs" "${reference[@]}"
}

Expand Down
4 changes: 3 additions & 1 deletion tests/bats/test_gpu_mig.bats
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ bats::on_failure() {
"addressingMode"
)

local attrs=$(get_device_attrs_from_any_gpu_slice "mig" "$node")
run get_device_attrs_from_any_gpu_slice "mig" "$node"
assert_success
local attrs="$output"
assert_attrs_equal "$attrs" "${reference[@]}"
}

Expand Down
Loading