]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[gitlab1] shell tests for kea-netconf implemented.
authorTomek Mrugalski <tomasz@isc.org>
Tue, 14 Aug 2018 15:29:56 +0000 (17:29 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 21 Aug 2018 10:18:56 +0000 (12:18 +0200)
src/bin/netconf/tests/netconf_tests.sh.in [new file with mode: 0644]

diff --git a/src/bin/netconf/tests/netconf_tests.sh.in b/src/bin/netconf/tests/netconf_tests.sh.in
new file mode 100644 (file)
index 0000000..f7ab35b
--- /dev/null
@@ -0,0 +1,80 @@
+# Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Path to the temporary configuration file.
+CFG_FILE=@abs_top_builddir@/src/bin/netconf/tests/test_config.json
+# Path to the Kea log file.
+LOG_FILE=@abs_top_builddir@/src/bin/netconf/tests/test.log
+# Path to the Kea lease file.
+# Expected version
+EXPECTED_VERSION="@PACKAGE_VERSION@"
+
+# Kea-netconf configuration to be stored in the configuration file.
+CONFIG="{
+    \"Netconf\":
+    {
+       // some configuration will be stored here eventually.
+    },
+
+    \"Logging\":
+    {
+        \"loggers\": [
+        {
+            \"name\": \"kea-netconf\",
+            \"output_options\": [
+                {
+                    \"output\": \"$LOG_FILE\"
+                }
+            ],
+            \"severity\": \"INFO\"
+        }
+        ]
+    }
+}"
+
+# Set the location of the executable.
+bin="kea-netconf"
+bin_path=@abs_top_builddir@/src/bin/netconf
+
+# Import common test library.
+. @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh
+
+# This test verifies that help can be printed out.
+usage_test() {
+    local TESTNAME="${1}"
+    local PARAMS="${2}"
+    local EXP_CODE="${3}"
+
+    # Log the start of the test and print test name.
+    test_start $TESTNAME
+    # Remove dangling Kea instances and remove log files.
+    cleanup
+
+    # Create correct configuration file.
+    create_config "${CONFIG}"
+
+    # Check it
+    printf "Running command %s.\n" "\"${bin_path}/${bin} -t ${CFG_FILE}\""
+    ${bin_path}/${bin} ${PARAMS}
+    exit_code=$?
+    if [ ${exit_code} -ne $EXP_CODE ]; then
+        printf "ERROR: expected exit code ${EXP_CODE}, got ${exit_code}\n"
+        clean_exit 1
+    fi
+    test_finish 0
+}
+
+
+version_test "netconf.version"
+usage_test "netconf.invalid-param" "-f" 1
+usage_test "netconf.dash-h" "-h" 1
+usage_test "netconf.dash-v" "-v" 0
+
+# The following tests are currently disabled. Once we have a parser that is
+# able to understand logger configuration, those tests (imported from DHCPv4)
+# should work.
+#shutdown_test "netconf.sigterm_test" 15
+#shutdown_test "netconf.sigint_test" 2