Message ID | 20250103031920.2868-1-lizhijian@fujitsu.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [blktests,v3,1/2] tests/rnbd: Add a basic RNBD test | expand |
On Jan 03, 2025 / 11:19, Li Zhijian wrote: > It attempts to connect and disconnect the rnbd service on localhost. > Actually, It also reveals a real kernel issue[0]. Good to find another bug and another test case, thanks :) Please find a nit comment below. [...] > diff --git a/tests/rnbd/001.out b/tests/rnbd/001.out > new file mode 100644 > index 000000000000..c1f9980d0f7b > --- /dev/null > +++ b/tests/rnbd/001.out > @@ -0,0 +1,2 @@ > +Running rnbd/001 > +Test complete > diff --git a/tests/rnbd/rc b/tests/rnbd/rc > new file mode 100644 > index 000000000000..1cf98ad5c498 > --- /dev/null > +++ b/tests/rnbd/rc > @@ -0,0 +1,51 @@ > +#!/bin/bash > +# SPDX-License-Identifier: GPL-3.0+ > +# Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved. > +# > +# RNBD tests. > + > +. common/rc > +. common/multipath-over-rdma > + > +_have_rnbd() { > + if [[ "$USE_RXE" != 1 ]]; then > + SKIP_REASONS+=("Only USE_RXE=1 is supported") > + fi > + _have_driver rdma_rxe > + _have_driver rnbd_server > + _have_driver rnbd_client > +} > + > +_setup_rnbd() { > + start_soft_rdma The added test cases check exit status of this _setup_rnbd() function, but this function is not likely return non-zero exist status. I think the line below instead of the line above will make the exit status checks more valuable. start_soft_rdma || return $?
On 07/01/2025 10:04, Shinichiro Kawasaki wrote: > On Jan 03, 2025 / 11:19, Li Zhijian wrote: >> It attempts to connect and disconnect the rnbd service on localhost. >> Actually, It also reveals a real kernel issue[0]. > > Good to find another bug and another test case, thanks :) > Please find a nit comment below. > > [...] > >> diff --git a/tests/rnbd/001.out b/tests/rnbd/001.out >> new file mode 100644 >> index 000000000000..c1f9980d0f7b >> --- /dev/null >> +++ b/tests/rnbd/001.out >> @@ -0,0 +1,2 @@ >> +Running rnbd/001 >> +Test complete >> diff --git a/tests/rnbd/rc b/tests/rnbd/rc >> new file mode 100644 >> index 000000000000..1cf98ad5c498 >> --- /dev/null >> +++ b/tests/rnbd/rc >> @@ -0,0 +1,51 @@ >> +#!/bin/bash >> +# SPDX-License-Identifier: GPL-3.0+ >> +# Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved. >> +# >> +# RNBD tests. >> + >> +. common/rc >> +. common/multipath-over-rdma >> + >> +_have_rnbd() { >> + if [[ "$USE_RXE" != 1 ]]; then >> + SKIP_REASONS+=("Only USE_RXE=1 is supported") >> + fi >> + _have_driver rdma_rxe >> + _have_driver rnbd_server >> + _have_driver rnbd_client >> +} >> + >> +_setup_rnbd() { >> + start_soft_rdma > > The added test cases check exit status of this _setup_rnbd() function, but > this function is not likely return non-zero exist status. I think the line > below instead of the line above will make the exit status checks more > valuable. > > start_soft_rdma || return $? Yes, you are right.
diff --git a/tests/rnbd/001 b/tests/rnbd/001 new file mode 100755 index 000000000000..ace2f8ea8a2b --- /dev/null +++ b/tests/rnbd/001 @@ -0,0 +1,39 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved. +# +# Basic RNBD test +# +. tests/rnbd/rc + +DESCRIPTION="Start Stop RNBD" +CHECK_DMESG=1 +QUICK=1 + +requires() { + _have_rnbd + _have_loop +} + +test_start_stop() +{ + _setup_rnbd || return + + local loop_dev + loop_dev="$(losetup -f)" + + if _start_rnbd_client "${loop_dev}"; then + sleep 0.5 + _stop_rnbd_client || echo "Failed to disconnect rnbd" + else + echo "Failed to connect rnbd" + fi + + _cleanup_rnbd +} + +test() { + echo "Running ${TEST_NAME}" + test_start_stop + echo "Test complete" +} diff --git a/tests/rnbd/001.out b/tests/rnbd/001.out new file mode 100644 index 000000000000..c1f9980d0f7b --- /dev/null +++ b/tests/rnbd/001.out @@ -0,0 +1,2 @@ +Running rnbd/001 +Test complete diff --git a/tests/rnbd/rc b/tests/rnbd/rc new file mode 100644 index 000000000000..1cf98ad5c498 --- /dev/null +++ b/tests/rnbd/rc @@ -0,0 +1,51 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved. +# +# RNBD tests. + +. common/rc +. common/multipath-over-rdma + +_have_rnbd() { + if [[ "$USE_RXE" != 1 ]]; then + SKIP_REASONS+=("Only USE_RXE=1 is supported") + fi + _have_driver rdma_rxe + _have_driver rnbd_server + _have_driver rnbd_client +} + +_setup_rnbd() { + start_soft_rdma + for i in $(rdma_network_interfaces) + do + ipv4_addr=$(get_ipv4_addr "$i") + if [[ -n "${ipv4_addr}" ]]; then + def_traddr=${ipv4_addr} + fi + done +} + +_cleanup_rnbd() +{ + stop_soft_rdma +} + +_stop_rnbd_client() { + local s sessions + + sessions=$(ls -d /sys/block/rnbd* 2>/dev/null) + for s in $sessions + do + grep -qx blktest "$s"/rnbd/session && echo "normal" > "$s"/rnbd/unmap_device + done +} + +_start_rnbd_client() { + local blkdev=$1 + + # Stop potential remaining blktest sessions first + _stop_rnbd_client + echo "sessname=blktest path=ip:$def_traddr device_path=$blkdev" > /sys/devices/virtual/rnbd-client/ctl/map_device +}