diff options
author | Francis Dupont <fdupont@isc.org> | 2018-11-22 15:22:12 +0100 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2018-11-26 14:25:12 +0100 |
commit | 856a1aa4e84bd6335664915853b5fe1185d9037e (patch) | |
tree | 923b78fccee3b78c991cb0c1f2e27a7b90201545 /src/bin/netconf | |
parent | [master] Updated ChangeLog for #204, !97 (diff) | |
download | kea-856a1aa4e84bd6335664915853b5fe1185d9037e.tar.xz kea-856a1aa4e84bd6335664915853b5fe1185d9037e.zip |
[177-serialize-netconf-tests] Moved shell tests into tests/shtests
Diffstat (limited to 'src/bin/netconf')
-rw-r--r-- | src/bin/netconf/tests/Makefile.am | 20 | ||||
-rw-r--r-- | src/bin/netconf/tests/netconf_tests.sh.in | 218 |
2 files changed, 3 insertions, 235 deletions
diff --git a/src/bin/netconf/tests/Makefile.am b/src/bin/netconf/tests/Makefile.am index 3b249a65f9..321a5ff577 100644 --- a/src/bin/netconf/tests/Makefile.am +++ b/src/bin/netconf/tests/Makefile.am @@ -1,20 +1,6 @@ -SHTESTS = +SUBDIRS = . shtests -SHTESTS += netconf_tests.sh - -noinst_SCRIPTS = netconf_tests.sh - -EXTRA_DIST = netconf_tests.sh.in -EXTRA_DIST += testdata/get_config.json - -# test using command-line arguments, so use check-local target instead of TESTS -check-local: - for shtest in $(SHTESTS) ; do \ - echo Running test: $$shtest ; \ - export KEA_LOCKFILE_DIR=$(abs_top_builddir); \ - export KEA_PIDFILE_DIR=$(abs_top_builddir); \ - ${SHELL} $(abs_builddir)/$$shtest || exit ; \ - done +EXTRA_DIST = testdata/get_config.json AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_builddir)/src @@ -26,7 +12,7 @@ AM_CPPFLAGS += $(BOOST_INCLUDES) CLEANFILES = *.json *.log -DISTCLEANFILES = netconf_tests.sh test_data_files_config.h test_libraries.h +DISTCLEANFILES = test_data_files_config.h test_libraries.h AM_CXXFLAGS = $(KEA_CXXFLAGS) diff --git a/src/bin/netconf/tests/netconf_tests.sh.in b/src/bin/netconf/tests/netconf_tests.sh.in deleted file mode 100644 index 4fc8807771..0000000000 --- a/src/bin/netconf/tests/netconf_tests.sh.in +++ /dev/null @@ -1,218 +0,0 @@ -# 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 -# Expected version -EXPECTED_VERSION="@PACKAGE_VERSION@" - -# Kea-netconf configuration to be stored in the configuration file. -CONFIG="{ - \"Netconf\": - { - \"managed-servers\": - { - \"dhcp4\": - { - \"comment\": \"simply use defaults...\" - } - } - }, - - \"Logging\": - { - \"loggers\": [ - { - \"name\": \"kea-netconf\", - \"output_options\": [ - { - \"output\": \"$LOG_FILE\" - } - ], - \"severity\": \"INFO\" - } - ] - } -}" - -# Invalid configuration (syntax error) to check that Kea can check syntax. -CONFIG_BAD_SYNTAX="{ - \"Netconf\": - { - \"boot-update\": BOGUS - } -}" - -# Invalid configuration (invalid url) to check that Kea can check syntax. -CONFIG_BAD_VALUE="{ - \"Netconf\": - { - \"managed-servers\": - { - \"dhcp4\": - { - \"control-socket\": - { - \"socket-type\": \"http\", - \"socket-url\": \"BOGUS\" - } - } - } - } -}" - -# 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 -} - -# This test verifies that no argument is not reported as a PID file error. -no_argument_test() { - local TESTNAME="${1}" - local EXP_CODE="${2}" - - # Log the start of the test and print test name. - test_start $TESTNAME - # Remove dangling Kea instances and remove log files. - cleanup - - # Check it - printf "Running command %s.\n" "\"${bin_path}/${bin}\"" - ${bin_path}/${bin} | grep PID 2>&1 - 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 -} - -# This test verifies that syntax checking works properly. This function -# requires 3 parameters: -# testname -# config - string with a content of the config (will be written to a file) -# exp_code - expected exit code returned by kea (0 - success, 1 - failure) -syntax_check_test() { - local TESTNAME="${1}" - local CONFIG="${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} -t ${CFG_FILE} - 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 -} - -# This test verifies that Netconf Agent is shut down gracefully when it -# receives a SIGINT or SIGTERM signal. -shutdown_test() { - test_name=${1} # Test name - signum=${2} # Signal number - # Log the start of the test and print test name. - test_start ${test_name} - # Remove dangling Netconf instances and remove log files. - cleanup - # Create new configuration file. - create_config "${CONFIG}" - # Instruct Netconf Agent to log to the specific file. - set_logger - # Start Netconf Agent. - start_kea ${bin_path}/${bin} - # Wait up to 20s for Netconf Agent to start. - wait_for_kea 20 - if [ ${_WAIT_FOR_KEA} -eq 0 ]; then - printf "ERROR: timeout waiting for Netconf Agent to start.\n" - clean_exit 1 - fi - - # Check if it is still running. It could have terminated (e.g. as a result - # of configuration failure). - get_pid ${bin} - if [ ${_GET_PIDS_NUM} -ne 1 ]; then - printf "ERROR: expected one Netconf Agent process to be started. Found %d processes\ - started.\n" ${_GET_PIDS_NUM} - clean_exit 1 - fi - - # Check in the log file, how many times server has been configured. - # It should be just once on startup. - get_reconfigs - if [ ${_GET_RECONFIGS} -ne 1 ]; then - printf "ERROR: server been configured ${_GET_RECONFIGS} time(s), but exactly 1 was expected.\n" - clean_exit 1 - else - printf "Server successfully configured.\n" - fi - - # Send signal to Netconf Agent (SIGTERM, SIGINT etc.) - send_signal ${signum} ${bin} - - # Now wait for process to log that it is exiting. - wait_for_message 10 "DCTL_SHUTDOWN" 1 - if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then - printf "ERROR: Netconf Agent did not log shutdown.\n" - clean_exit 1 - fi - - # Make sure the server is down. - wait_for_server_down 5 ${bin} - assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \ - "Expected wait_for_server_down return %d, returned %d" - - 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 -no_argument_test "netconf.no-argument" 1 -shutdown_test "netconf.sigterm_test" 15 -shutdown_test "netconf.sigint_test" 2 -logger_vars_test "netconf.variables" -syntax_check_test "netconf.syntax_check_success" "${CONFIG}" 0 -syntax_check_test "netconf.syntax_check_bad_syntax" "${CONFIG_BAD_SYNTAX}" 1 -syntax_check_test "netconf.syntax_check_bad_values" "${CONFIG_BAD_VALUE}" 1 |