From c1bc87f71e8ef38adc23b9e6e7ef4ae843b9287e Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Wed, 28 May 2025 08:06:36 +0530 Subject: [PATCH] qa: change processing of "nvme list" json output Revert changes made in 22f91cdc65246a0f9255e9348c15230670574e64 to processing of "nvme list -o json". nvme-cli has changed json output in 2.11 and then reverted the change in 2.13 release. So this commit goes back to 2.13 (or pre-2.11) processing of "nvme list" json output. Signed-off-by: Vallari Agrawal --- qa/tasks/nvmeof.py | 2 +- qa/workunits/nvmeof/basic_tests.sh | 2 +- qa/workunits/nvmeof/fio_test.sh | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/qa/tasks/nvmeof.py b/qa/tasks/nvmeof.py index 1069d0aabcb2b..e37d794da64b7 100644 --- a/qa/tasks/nvmeof.py +++ b/qa/tasks/nvmeof.py @@ -331,7 +331,7 @@ class NvmeofThrasher(Thrasher, Greenlet): def _get_devices(self, remote): GET_DEVICE_CMD = "sudo nvme list --output-format=json | " \ - "jq -r '.Devices[].Subsystems[] | select(.Controllers | all(.ModelNumber == \"Ceph bdev Controller\")) | .Namespaces | sort_by(.NSID) | .[] | .NameSpace'" + "jq -r '.Devices | sort_by(.NameSpace) | .[] | select(.ModelNumber == \"Ceph bdev Controller\") | .DevicePath'" devices = remote.sh(GET_DEVICE_CMD).split() return devices diff --git a/qa/workunits/nvmeof/basic_tests.sh b/qa/workunits/nvmeof/basic_tests.sh index 9e7a1f5134e98..132867997e2ab 100755 --- a/qa/workunits/nvmeof/basic_tests.sh +++ b/qa/workunits/nvmeof/basic_tests.sh @@ -39,7 +39,7 @@ connect_all() { sudo nvme connect-all --traddr=$NVMEOF_DEFAULT_GATEWAY_IP_ADDRESS --transport=tcp -l 3600 sleep 5 expected_devices_count=$1 - actual_devices=$(sudo nvme list --output-format=json | jq -r ".Devices[].Subsystems[] | select(.Controllers | all(.ModelNumber == \"$SPDK_CONTROLLER\")) | .Namespaces[].NameSpace" | wc -l) + actual_devices=$(sudo nvme list --output-format=json | grep -o "$SPDK_CONTROLLER" | wc -l) if [ "$actual_devices" -ne "$expected_devices_count" ]; then sudo nvme list --output-format=json return 1 diff --git a/qa/workunits/nvmeof/fio_test.sh b/qa/workunits/nvmeof/fio_test.sh index 20f338ec9d5cc..7aa26d973b652 100755 --- a/qa/workunits/nvmeof/fio_test.sh +++ b/qa/workunits/nvmeof/fio_test.sh @@ -34,7 +34,7 @@ done fio_file=$(mktemp -t nvmeof-fio-XXXX) all_drives_list=$(sudo nvme list --output-format=json | - jq -r '.Devices[].Subsystems[] | select(.Controllers | all(.ModelNumber == "Ceph bdev Controller")) | .Namespaces | sort_by(.NSID) | .[] | .NameSpace') + jq -r '.Devices | sort_by(.NameSpace) | .[] | select(.ModelNumber == "Ceph bdev Controller") | .DevicePath') # When the script is passed --start_ns and --end_ns (example: `nvmeof_fio_test.sh --start_ns 1 --end_ns 3`), # then fio runs on namespaces only in the defined range (which is 1 to 3 here). @@ -50,8 +50,6 @@ fi RUNTIME=${RUNTIME:-600} -filename=$(echo "$selected_drives" | sed -z 's/\n/:\/dev\//g' | sed 's/:\/dev\/$//') -filename="/dev/$filename" cat >> $fio_file <> "$fio_file" - echo "filename=/dev/$i" >> "$fio_file" + echo "filename=$i" >> "$fio_file" echo "" >> "$fio_file" # Adds a blank line done -- 2.39.5