diff mbox series

[blktests,v3,1/2] tests/rnbd: Add a basic RNBD test

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

Commit Message

Li Zhijian Jan. 3, 2025, 3:19 a.m. UTC
It attempts to connect and disconnect the rnbd service on localhost.
Actually, It also reveals a real kernel issue[0].

Please note that currently, only RTRS over RXE is supported.

[0] https://lore.kernel.org/linux-rdma/20241231013416.1290920-1-lizhijian@fujitsu.com/

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
V3:
  new patch, add a seperate basic rnbd test and simplify the _start_rnbd_client

Copy to the RDMA/rtrs guys:

Cc: Jack Wang <jinpu.wang@ionos.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: "Md. Haris Iqbal" <haris.iqbal@ionos.com>
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
 tests/rnbd/001     | 39 +++++++++++++++++++++++++++++++++++
 tests/rnbd/001.out |  2 ++
 tests/rnbd/rc      | 51 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+)
 create mode 100755 tests/rnbd/001
 create mode 100644 tests/rnbd/001.out
 create mode 100644 tests/rnbd/rc

Comments

Shinichiro Kawasaki Jan. 7, 2025, 2:04 a.m. UTC | #1
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 $?
Li Zhijian Jan. 7, 2025, 4:03 a.m. UTC | #2
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 mbox series

Patch

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
+}