[PATCH blktests] nbd/004: avoid left connection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The test case nbd/004 disconnects /dev/nbd0 in most cases, but sometimes
leaves it in connected status. The test case stops the nbd server then
/dev/nbd0 does not work even when it is in connected status. This makes
"udevadm settle" command to wait for nbd udev events infinitely and
causes failures of following test cases.

There are two causes of the left connection. The first cause is left
nbd-client process. The test case waits for completion of its child
process connect_and_disconnect. However, it does not wait for completion
of nbd-client process that connect_and_disconnect spawns. After the test
case end, the left nbd-client process establishes the connection of
/dev/nbd0. The second cause is missing disconnect operation. The
connect_and_disconnect process repeats _netlink_connect and
_netlink_disconnect. When this process is killed after _netlink_connect
and before _netlink_disconnect, the connected status is left.

To avoid the left connection, wait for nbd-client process completion
and call _netlink_disconnect at the test case end.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx>
---
 tests/nbd/004 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tests/nbd/004 b/tests/nbd/004
index deb9673..1758859 100755
--- a/tests/nbd/004
+++ b/tests/nbd/004
@@ -31,6 +31,8 @@ connect_and_disconnect() {
 test() {
 	echo "Running ${TEST_NAME}"
 
+	local pid1 pid2 i=0
+
 	_start_nbd_server_netlink
 
 	module_load_and_unload &
@@ -53,6 +55,18 @@ test() {
 			echo "Fail"
 	fi
 
+	# Ensure nbd-client completion and clean up left connection
+	# shellcheck disable=SC2009
+	while ps | grep -qe nbd-client; do
+		sleep .5
+		if ((i == 10)); then
+			echo "nbd-client process is left"
+			break
+		fi
+		i=$((i + 1))
+	done
+	_netlink_disconnect
+
 	echo "Test complete"
 }
 
-- 
2.41.0




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux