Skip to contentSkip to conversation

Add connection test suite

RFC PATCH New Steffan Karger 1 participant 1 message Nov 26, 2022

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Add connection test suite

Add a local connection test suite, that is able to set up connections and verify in the process output that the process believes the connection was successful.

This is not a replacement for the t_client test suite, but rather a fast, simple, local suite to validate .e.g control channel setup. It can replace t_cltsrv.sh (as a much faster alternative), but does require python3 and pytest to run.

---
This is an RFC to get comments on whether you believe this approach is a useful addition to our current test suite. We can add many more useful tests once we agree on the approach.

 tests/Makefile.am                       |   6 +-
 tests/connection_tests/test_examples.py | 303 ++++++++++++++++++++++++
 tests/t_connection.sh                   |  24 ++
 3 files changed, 331 insertions(+), 2 deletions(-)
 create mode 100644 tests/connection_tests/test_examples.py
 create mode 100755 tests/t_connection.sh
tests/Makefile.am +4 -2
index 89180f60..96b8565b 100644
@@ -14,12 +14,14 @@ MAINTAINERCLEANFILES = \
 
 SUBDIRS = unit_tests
 
-test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh
+test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh t_connection.sh
 if HAVE_SITNL
 test_scripts += t_net.sh
 endif
 
-TESTS_ENVIRONMENT = top_srcdir="$(top_srcdir)"
+TESTS_ENVIRONMENT = \
+	top_builddir="$(top_builddir)" \
+	top_srcdir="$(top_srcdir)"
 TESTS = $(test_scripts)
 
 dist_noinst_SCRIPTS = \
tests/connection_tests/test_examples.py new file +303 -0

303 lines not on this page · raw message

tests/t_connection.sh new file +24 -0
new file mode 100755
index 00000000..846dd4e3
@@ -0,0 +1,24 @@
+#!/bin/sh
+set -eu
+
+# by changing this to 1 we can force automated builds to fail
+# that are expected to have all the prerequisites
+TCLIENT_SKIP_RC="${TCLIENT_SKIP_RC:-77}"
+export OPENVPN_BINARY="$(readlink -f ${top_builddir}/src/openvpn/openvpn)"
+export WORK_DIR="$(readlink -f ${top_srcdir}/sample/)"
+
+if ! which python3 > /dev/null; then
+    echo "$0: Python3 not found, skipping connection tests."
+    exit "${TCLIENT_SKIP_RC}"
+fi
+
+if ! python3 -m pytest --version 2> /dev/null; then
+    echo "$0: Pytest not found, skipping connection tests."
+    exit "${TCLIENT_SKIP_RC}"
+fi
+
+# TODO - possible improvements
+# - Create and run from venv?
+# - Integrate as separate target through Makefile.am ?
+# - Use configure to create test config file ?
+(cd "${top_srcdir}/tests/connection_tests" && python3 -m pytest -v)
Signature · 1 line
2.25.1