git: 713efe054297 - main - if_ovpn tests: fix timeout test case

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 18 Oct 2022 08:23:14 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=713efe0542975362cbde9c07479ac8bdd4cb8803

commit 713efe0542975362cbde9c07479ac8bdd4cb8803
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-10-17 16:28:23 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-10-18 08:12:23 +0000

    if_ovpn tests: fix timeout test case
    
    Use the management interface to work out if we've timed out the client,
    rather than looking for an openvpn process to die (with incorrect
    syntax).
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 tests/sys/net/if_ovpn/if_ovpn.sh | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/tests/sys/net/if_ovpn/if_ovpn.sh b/tests/sys/net/if_ovpn/if_ovpn.sh
index 531a4fc2c856..83bf13bf0cba 100644
--- a/tests/sys/net/if_ovpn/if_ovpn.sh
+++ b/tests/sys/net/if_ovpn/if_ovpn.sh
@@ -407,6 +407,7 @@ timeout_client_body()
 
 	vnet_mkjail a ${l}a
 	jexec a ifconfig ${l}a 192.0.2.1/24 up
+	jexec a ifconfig lo0 127.0.0.1/8 up
 	vnet_mkjail b ${l}b
 	jexec b ifconfig ${l}b 192.0.2.2/24 up
 
@@ -434,6 +435,8 @@ timeout_client_body()
 		topology subnet
 
 		keepalive 2 10
+
+		management 192.0.2.1 1234
 	"
 	ovpn_start b "
 		dev tun0
@@ -449,8 +452,7 @@ timeout_client_body()
 		key $(atf_get_srcdir)/client.key
 		dh $(atf_get_srcdir)/dh.pem
 
-		ping 2
-		ping-exit 10
+		keepalive 2 10
 	"
 
 	# Give the tunnel time to come up
@@ -458,16 +460,16 @@ timeout_client_body()
 
 	atf_check -s exit:0 -o ignore jexec b ping -c 3 198.51.100.1
 
-	# Kill the server
-	jexec a killall openvpn
+	# Kill the client
+	jexec b killall openvpn
 
-	# Now wait for the client to notice
-	sleep 20
+	# Now wait for the server to notice
+	sleep 15
 
-	if [ jexec b pgrep openvpn ]; then
-		jexec b ps auxf
-		atf_fail "OpenVPN client still running?"
-	fi
+	while echo "status" | jexec a nc -N 192.0.2.1 1234 | grep 192.0.2.2; do
+		echo "Client disconnect not discovered"
+		sleep 1
+	done
 }
 
 timeout_client_cleanup()