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")
This commit is contained in:
Kristof Provost 2022-10-17 18:28:23 +02:00
parent 188e069670
commit 713efe0542

View file

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