From: Marcin Siodelski Date: Fri, 13 Jun 2014 08:46:13 +0000 (+0200) Subject: [3422] Fix distcheck issues with shell tests. X-Git-Tag: trac3434_base~6^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4fbc4c17450e62cfabd54573ce82ec7a02e2f6a0;p=thirdparty%2Fkea.git [3422] Fix distcheck issues with shell tests. --- diff --git a/configure.ac b/configure.ac index bd3b4fc13a..01bfbb0d7a 100644 --- a/configure.ac +++ b/configure.ac @@ -1446,12 +1446,14 @@ AC_CONFIG_FILES([compatcheck/Makefile src/bin/d2/tests/test_data_files_config.h src/bin/dhcp4/Makefile src/bin/dhcp4/spec_config.h.pre + src/bin/dhcp4/tests/dhcp4_process_tests.sh src/bin/dhcp4/tests/Makefile src/bin/dhcp4/tests/marker_file.h src/bin/dhcp4/tests/test_data_files_config.h src/bin/dhcp4/tests/test_libraries.h src/bin/dhcp6/Makefile src/bin/dhcp6/spec_config.h.pre + src/bin/dhcp6/tests/dhcp6_process_tests.sh src/bin/dhcp6/tests/Makefile src/bin/dhcp6/tests/marker_file.h src/bin/dhcp6/tests/test_data_files_config.h @@ -1564,6 +1566,7 @@ AC_CONFIG_FILES([compatcheck/Makefile src/lib/python/isc/util/Makefile src/lib/python/isc/util/tests/Makefile src/lib/python/Makefile + src/lib/testutils/dhcp_test_lib.sh src/lib/testutils/Makefile src/lib/testutils/testdata/Makefile src/lib/util/io/Makefile @@ -1592,6 +1595,8 @@ AC_CONFIG_FILES([compatcheck/Makefile chmod +x src/bin/bindctl/tests/bindctl_test chmod +x src/bin/cmdctl/run_b10-cmdctl.sh chmod +x src/bin/cmdctl/tests/cmdctl_test + chmod +x src/bin/dhcp4/tests/dhcp4_process_tests.sh + chmod +x src/bin/dhcp6/tests/dhcp6_process_tests.sh chmod +x src/bin/keactrl/keactrl chmod +x src/bin/keactrl/tests/keactrl_tests.sh chmod +x src/bin/msgq/run_msgq.sh diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 1f43434618..ede68a5411 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -1,6 +1,10 @@ # The following build order must be maintained. SUBDIRS = bind10 bindctl cfgmgr msgq cmdctl \ usermgr stats tests sockcreator dhcp4 dhcp6 \ - d2 sysinfo keactrl + d2 sysinfo + +if CONFIG_BACKEND_JSON +SUBDIRS += keactrl +endif check-recursive: all-recursive diff --git a/src/bin/dhcp4/tests/.gitignore b/src/bin/dhcp4/tests/.gitignore index 5983892923..f4e97ce2c8 100644 --- a/src/bin/dhcp4/tests/.gitignore +++ b/src/bin/dhcp4/tests/.gitignore @@ -2,3 +2,4 @@ /marker_file.h /test_data_files_config.h /test_libraries.h +/dhcp4_process_tests.sh diff --git a/src/bin/dhcp4/tests/Makefile.am b/src/bin/dhcp4/tests/Makefile.am index 7437fedcc1..f309aabcaa 100644 --- a/src/bin/dhcp4/tests/Makefile.am +++ b/src/bin/dhcp4/tests/Makefile.am @@ -5,16 +5,13 @@ SHTESTS = # The test of dynamic reconfiguration based on signals will work only # if we are using file based configuration approach. if CONFIG_BACKEND_JSON -SHTESTS += dhcp4_reconfigure_test.sh -SHTESTS += dhcp4_sigterm_test.sh -SHTESTS += dhcp4_sigint_test.sh +SHTESTS += dhcp4_process_tests.sh endif +noinst_SCRIPTS = dhcp4_process_tests.sh + EXTRA_DIST = $(PYTESTS) -EXTRA_DIST += dhcp4_reconfigure_test.sh -EXTRA_DIST += dhcp4_sigterm_test.sh -EXTRA_DIST += dhcp4_sigint_test.sh -EXTRA_DIST += dhcp4_shutdown_test.sh +EXTRA_DIST += dhcp4_process_tests.sh.in # Explicitly specify paths to dynamic libraries required by loadable python # modules. That is required on Mac OS systems. Otherwise we will get exception diff --git a/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in b/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in new file mode 100755 index 0000000000..8bfb46814b --- /dev/null +++ b/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in @@ -0,0 +1,231 @@ +# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# Path to the temporary configuration file. +CFG_FILE=@abs_top_builddir@/src/bin/dhcp4/tests/test_config.json +# Path to the Kea log file. +LOG_FILE=@abs_top_builddir@/src/bin/dhcp4/tests/test.log +# Kea configuration to be stored in the configuration file. +CONFIG="{ + \"Dhcp4\": + { + \"interfaces\": [ ], + \"valid-lifetime\": 4000, + \"renew-timer\": 1000, + \"rebind-timer\": 2000, + \"lease-database\": + { + \"type\": \"memfile\", + \"persist\": false + }, + \"subnet4\": [ + { + \"subnet\": \"10.0.0.0/8\", + \"pool\": [ \"10.0.0.10-10.0.0.100\" ] + } ] + } +}" +# Invalid configuration (negative valid-lifetime) to check that Kea +# gracefully handles reconfiguration errors. +CONFIG_INVALID="{ + \"Dhcp4\": + { + \"interfaces\": [ ], + \"valid-lifetime\": -3, + \"renew-timer\": 1000, + \"rebind-timer\": 2000, + \"lease-database\": + { + \"type\": \"memfile\", + \"persist\": false + }, + \"subnet4\": [ + { + \"subnet\": \"10.0.0.0/8\", + \"pool\": [ \"10.0.0.10-10.0.0.100\" ] + } ] + } +}" + +# Set the location of the executable. +bin="b10-dhcp4" +bin_path=@abs_top_builddir@/src/bin/dhcp4 + +# Import common test library. +. @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh + +# This test verifies that DHCPv4 can be reconfigured with a SIGHUP signal. +dynamic_reconfiguration_test() { + # Log the start of the test and print test name. + test_start "dhcpv4_srv.dynamic_reconfiguration" + # Remove dangling Kea instances and remove log files. + cleanup + # Create new configuration file. + create_config "${CONFIG}" + # Instruct Kea to log to the specific file. + set_logger + # Start Kea. + start_kea ${bin_path}/${bin} + # Wait up to 20s for Kea to start. + wait_for_kea 20 + if [ ${_WAIT_FOR_KEA} -eq 0 ]; then + printf "ERROR: timeout waiting for Kea 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_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 1 ]; then + printf "ERROR: expected one Kea 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 hasn't been configured.\n" + clean_exit 1 + else + printf "Server successfully configured.\n" + fi + + # Now use invalid configuration. + create_config "${CONFIG_INVALID}" + + # Try to reconfigure by sending SIGHUP + send_signal 1 ${bin} + + # The configuration should fail and the error message should be there. + wait_for_message 10 "DHCP4_CONFIG_LOAD_FAIL" 1 + + # After receiving SIGHUP the server should try to reconfigure itself. + # The configuration provided is invalid so it should result in + # reconfiguration failure but the server should still be running. + get_reconfigs + if [ ${_GET_RECONFIGS} -ne 1 ]; then + printf "ERROR: server has been reconfigured despite bogus configuration.\n" + clean_exit 1 + elif [ ${_GET_RECONFIG_ERRORS} -ne 1 ]; then + printf "ERROR: server did not report reconfiguration error despite attempt\ + to configure it with invalid configuration.\n" + clean_exit 1 + fi + + # Make sure the server is still operational. + get_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 1 ]; then + printf "ERROR: Kea process was killed when attempting reconfiguration.\n" + clean_exit 1 + fi + + # Restore the good configuration. + create_config "${CONFIG}" + + # Reconfigure the server with SIGHUP. + send_signal 1 ${bin} + + # There should be two occurrences of the DHCP4_CONFIG_COMPLETE messages. + # Wait for it up to 10s. + wait_for_message 10 "DHCP4_CONFIG_COMPLETE" 2 + + # After receiving SIGHUP the server should get reconfigured and the + # reconfiguration should be noted in the log file. We should now + # have two configurations logged in the log file. + if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then + printf "ERROR: server hasn't been reconfigured.\n" + clean_exit 1 + else + printf "Server successfully reconfigured.\n" + fi + + # Make sure the server is still operational. + get_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 1 ]; then + printf "ERROR: Kea process was killed when attempting reconfiguration.\n" + clean_exit 1 + fi + + # All ok. Shut down Kea and exit. + test_finish 0 +} + +# This test verifies that DHCPv4 server 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 Kea instances and remove log files. + cleanup + # Create new configuration file. + create_config "${CONFIG}" + # Instruct Kea to log to the specific file. + set_logger + # Start Kea. + start_kea ${bin_path}/${bin} + # Wait up to 20s for Kea to start. + wait_for_kea 20 + if [ ${_WAIT_FOR_KEA} -eq 0 ]; then + printf "ERROR: timeout waiting for Kea 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_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 1 ]; then + printf "ERROR: expected one Kea 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 hasn't been configured.\n" + clean_exit 1 + else + printf "Server successfully configured.\n" + fi + + # Send signal to Kea (SIGTERM, SIGINT etc.) + send_signal ${signum} ${bin} + + # Wait up to 10s for the server's graceful shutdown. The graceful shut down + # should be recorded in the log file with the appropriate message. + wait_for_message 10 "DHCP4_SHUTDOWN" 1 + if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then + printf "ERROR: Server did not record shutdown in the log.\n" + clean_exit 1 + fi + + # Server should have shut down. + get_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 0 ]; then + printf "ERROR: Kea did not shut down after receiving signal.\n"\ + ${_GET_PIDS_NUM} + clean_exit 1 + fi + + test_finish 0 +} + +dynamic_reconfiguration_test +shutdown_test "dhcpv4.sigterm_test" 15 +shutdown_test "dhcpv4.sigint_test" 2 diff --git a/src/bin/dhcp4/tests/dhcp4_reconfigure_test.sh b/src/bin/dhcp4/tests/dhcp4_reconfigure_test.sh deleted file mode 100755 index d265473fc8..0000000000 --- a/src/bin/dhcp4/tests/dhcp4_reconfigure_test.sh +++ /dev/null @@ -1,161 +0,0 @@ -# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# Path to the temporary configuration file. -CFG_FILE="test_config.json" -# Path to the Kea log file. -LOG_FILE="test.log" -# Kea configuration to be stored in the configuration file. -CONFIG="{ - \"Dhcp4\": - { - \"interfaces\": [ ], - \"valid-lifetime\": 4000, - \"renew-timer\": 1000, - \"rebind-timer\": 2000, - \"lease-database\": - { - \"type\": \"memfile\", - \"persist\": false - }, - \"subnet4\": [ - { - \"subnet\": \"10.0.0.0/8\", - \"pool\": [ \"10.0.0.10-10.0.0.100\" ] - } ] - } -}" -# Invalid configuration (negative valid-lifetime) to check that Kea -# gracefully handles reconfiguration errors. -CONFIG_INVALID="{ - \"Dhcp4\": - { - \"interfaces\": [ ], - \"valid-lifetime\": -3, - \"renew-timer\": 1000, - \"rebind-timer\": 2000, - \"lease-database\": - { - \"type\": \"memfile\", - \"persist\": false - }, - \"subnet4\": [ - { - \"subnet\": \"10.0.0.0/8\", - \"pool\": [ \"10.0.0.10-10.0.0.100\" ] - } ] - } -}" - -# Set the location of the executable. -bin="b10-dhcp4" -bin_path=".." - -# Import common test library. -. $(dirname $0)/../../../lib/testutils/dhcp_test_lib.sh - -# Log the start of the test and print test name. -test_start "dhcpv4_srv.dynamic_reconfiguration" -# Remove dangling Kea instances and remove log files. -cleanup -# Create new configuration file. -create_config "${CONFIG}" -# Instruct Kea to log to the specific file. -set_logger -# Start Kea. -start_kea ${bin_path}/${bin} -# Wait up to 20s for Kea to start. -wait_for_kea 20 -if [ ${_WAIT_FOR_KEA} -eq 0 ]; then - printf "ERROR: timeout waiting for Kea 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_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 1 ]; then - printf "ERROR: expected one Kea 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 hasn't been configured.\n" - clean_exit 1 -else - printf "Server successfully configured.\n" -fi - -# Now use invalid configuration. -create_config "${CONFIG_INVALID}" - -# Try to reconfigure by sending SIGHUP -send_signal 1 ${bin} - -# The configuration should fail and the error message should be there. -wait_for_message 10 "DHCP4_CONFIG_LOAD_FAIL" 1 - -# After receiving SIGHUP the server should try to reconfigure itself. -# The configuration provided is invalid so it should result in -# reconfiguration failure but the server should still be running. -get_reconfigs -if [ ${_GET_RECONFIGS} -ne 1 ]; then - printf "ERROR: server has been reconfigured despite bogus configuration.\n" - clean_exit 1 -elif [ ${_GET_RECONFIG_ERRORS} -ne 1 ]; then - printf "ERROR: server did not report reconfiguration error despite attempt\ - to configure it with invalid configuration.\n" - clean_exit 1 -fi - -# Make sure the server is still operational. -get_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 1 ]; then - printf "ERROR: Kea process was killed when attempting reconfiguration.\n" - clean_exit 1 -fi - -# Restore the good configuration. -create_config "${CONFIG}" - -# Reconfigure the server with SIGHUP. -send_signal 1 ${bin} - -# There should be two occurrences of the DHCP4_CONFIG_COMPLETE messages. -# Wait for it up to 10s. -wait_for_message 10 "DHCP4_CONFIG_COMPLETE" 2 - -# After receiving SIGHUP the server should get reconfigured and the -# reconfiguration should be noted in the log file. We should now -# have two configurations logged in the log file. -if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then - printf "ERROR: server hasn't been reconfigured.\n" - clean_exit 1 -else - printf "Server successfully reconfigured.\n" -fi - -# Make sure the server is still operational. -get_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 1 ]; then - printf "ERROR: Kea process was killed when attempting reconfiguration.\n" - clean_exit 1 -fi - -# All ok. Shut down Kea and exit. -clean_exit 0 diff --git a/src/bin/dhcp4/tests/dhcp4_shutdown_test.sh b/src/bin/dhcp4/tests/dhcp4_shutdown_test.sh deleted file mode 100755 index 5b91ec893d..0000000000 --- a/src/bin/dhcp4/tests/dhcp4_shutdown_test.sh +++ /dev/null @@ -1,111 +0,0 @@ -# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -if [ $# -ne 2 ]; then - printf "USAGE: dhcp4_shutdown_test.sh \n" - exit 1 -fi - -# Test name -test_name=${1} -# Signal number to be used for this test. -SIG_NUM=$2 -# Path to the temporary configuration file. -CFG_FILE="test_config.json" -# Path to the Kea log file. -LOG_FILE="test.log" -# Kea configuration to be stored in the configuration file. -CONFIG="{ - \"Dhcp4\": - { - \"interfaces\": [ ], - \"valid-lifetime\": 4000, - \"renew-timer\": 1000, - \"rebind-timer\": 2000, - \"lease-database\": - { - \"type\": \"memfile\", - \"persist\": false - }, - \"subnet4\": [ - { - \"subnet\": \"10.0.0.0/8\", - \"pool\": [ \"10.0.0.10-10.0.0.100\" ] - } ] - } -}" - -# Set the location of the executable. -bin="b10-dhcp4" -bin_path=".." - -# Import common test library. -. $(dirname $0)/../../../lib/testutils/dhcp_test_lib.sh - -# Log the start of the test and print test name. -test_start ${test_name} -# Remove dangling Kea instances and remove log files. -cleanup -# Create new configuration file. -create_config "${CONFIG}" -# Instruct Kea to log to the specific file. -set_logger -# Start Kea. -start_kea ${bin_path}/${bin} -# Wait up to 20s for Kea to start. -wait_for_kea 20 -if [ ${_WAIT_FOR_KEA} -eq 0 ]; then - printf "ERROR: timeout waiting for Kea 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_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 1 ]; then - printf "ERROR: expected one Kea 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 hasn't been configured.\n" - clean_exit 1 -else - printf "Server successfully configured.\n" -fi - -# Send signal to Kea (SIGTERM, SIGINT etc.) -send_signal ${SIG_NUM} ${bin} - -# Wait up to 10s for the server's graceful shutdown. The graceful shut down -# should be recorded in the log file with the appropriate message. -wait_for_message 10 "DHCP4_SHUTDOWN" 1 -if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then - printf "ERROR: Server did not record shutdown in the log.\n" - clean_exit 1 -fi - -# Server should have shut down. -get_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 0 ]; then - printf "ERROR: Kea did not shut down after receiving signal.\n"\ - ${_GET_PIDS_NUM} - clean_exit 1 -fi - -clean_exit 0 diff --git a/src/bin/dhcp4/tests/dhcp4_sigint_test.sh b/src/bin/dhcp4/tests/dhcp4_sigint_test.sh deleted file mode 100755 index 32b02a9da5..0000000000 --- a/src/bin/dhcp4/tests/dhcp4_sigint_test.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# Run a test that sends SIGINT to Kea and checks if it shuts down gracefully. -$(dirname $0)/dhcp4_shutdown_test.sh "dhcpv4_srv.sigint" 2 diff --git a/src/bin/dhcp4/tests/dhcp4_sigterm_test.sh b/src/bin/dhcp4/tests/dhcp4_sigterm_test.sh deleted file mode 100755 index 0b74cddd67..0000000000 --- a/src/bin/dhcp4/tests/dhcp4_sigterm_test.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# Run a test that sends SIGTERM to Kea and checks if it shuts down gracefully. -$(dirname $0)/dhcp4_shutdown_test.sh "dhcpv4_srv.sigterm" 15 diff --git a/src/bin/dhcp6/tests/.gitignore b/src/bin/dhcp6/tests/.gitignore index f4ca7830e1..aa55c4d9ad 100644 --- a/src/bin/dhcp6/tests/.gitignore +++ b/src/bin/dhcp6/tests/.gitignore @@ -2,3 +2,4 @@ /marker_file.h /test_data_files_config.h /test_libraries.h +/dhcp6_process_tests.sh diff --git a/src/bin/dhcp6/tests/Makefile.am b/src/bin/dhcp6/tests/Makefile.am index 301e509a6d..6388ffbd4d 100644 --- a/src/bin/dhcp6/tests/Makefile.am +++ b/src/bin/dhcp6/tests/Makefile.am @@ -4,16 +4,13 @@ SHTESTS = # The test of dynamic reconfiguration based on signals will work only # if we are using file based configuration approach. if CONFIG_BACKEND_JSON -SHTESTS += dhcp6_reconfigure_test.sh -SHTESTS += dhcp6_sigterm_test.sh -SHTESTS += dhcp6_sigint_test.sh +SHTESTS += dhcp6_process_tests.sh endif +noinst_SCRIPTS = dhcp6_process_tests.sh + EXTRA_DIST = $(PYTESTS) -EXTRA_DIST += dhcp6_reconfigure_test.sh -EXTRA_DIST += dhcp6_sigterm_test.sh -EXTRA_DIST += dhcp6_sigint_test.sh -EXTRA_DIST += dhcp6_shutdown_test.sh +EXTRA_DIST += dhcp6_process_tests.sh.in # Explicitly specify paths to dynamic libraries required by loadable python # modules. That is required on Mac OS systems. Otherwise we will get exception diff --git a/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in b/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in new file mode 100755 index 0000000000..31a65dd152 --- /dev/null +++ b/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in @@ -0,0 +1,234 @@ +# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# Path to the temporary configuration file. +CFG_FILE=@abs_top_builddir@/src/bin/dhcp6/tests/test_config.json +# Path to the Kea log file. +LOG_FILE=@abs_top_builddir@/src/bin/dhcp6/tests/test.log +# Kea configuration to be stored in the configuration file. +CONFIG="{ + \"Dhcp6\": + { + \"interfaces\": [ ], + \"preferred-lifetime\": 3000, + \"valid-lifetime\": 4000, + \"renew-timer\": 1000, + \"rebind-timer\": 2000, + \"lease-database\": + { + \"type\": \"memfile\", + \"persist\": false + }, + \"subnet6\": [ + { + \"subnet\": \"2001:db8:1::/64\", + \"pool\": [ \"2001:db8:1::10-2001:db8:1::100\" ] + } ] + } +}" +# Invalid configuration (negative preferred-lifetime) to check that Kea +# gracefully handles reconfiguration errors. +CONFIG_INVALID="{ + \"Dhcp6\": + { + \"interfaces\": [ ], + \"preferred-lifetime\": -3, + \"valid-lifetime\": 4000, + \"renew-timer\": 1000, + \"rebind-timer\": 2000, + \"lease-database\": + { + \"type\": \"memfile\", + \"persist\": false + }, + \"subnet6\": [ + { + \"subnet\": \"2001:db8:1::/64\", + \"pool\": [ \"2001:db8:1::10-2001:db8:1::100\" ] + } ] + } +}" + +# Set the location of the executable. +bin="b10-dhcp6" +bin_path=@abs_top_builddir@/src/bin/dhcp6 + +# Import common test library. +. @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh + +# This test verifies that DHCPv6 can be reconfigured with a SIGHUP signal. +dynamic_reconfiguration_test() { + # Log the start of the test and print test name. + test_start "dhcpv6_srv.dynamic_reconfiguration" + # Remove dangling Kea instances and remove log files. + cleanup + # Create new configuration file. + create_config "${CONFIG}" + # Instruct Kea to log to the specific file. + set_logger + # Start Kea. + start_kea ${bin_path}/${bin} + # Wait up to 20s for Kea to start. + wait_for_kea 20 + if [ ${_WAIT_FOR_KEA} -eq 0 ]; then + printf "ERROR: timeout waiting for Kea 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_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 1 ]; then + printf "ERROR: expected one Kea 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 hasn't been configured.\n" + clean_exit 1 + else + printf "Server successfully configured.\n" + fi + + # Now use invalid configuration. + create_config "${CONFIG_INVALID}" + + # Try to reconfigure by sending SIGHUP + send_signal 1 ${bin} + + # The configuration should fail and the error message should be there. + wait_for_message 10 "DHCP6_CONFIG_LOAD_FAIL" 1 + + # After receiving SIGHUP the server should try to reconfigure itself. + # The configuration provided is invalid so it should result in + # reconfiguration failure but the server should still be running. + get_reconfigs + if [ ${_GET_RECONFIGS} -ne 1 ]; then + printf "ERROR: server has been reconfigured despite bogus configuration.\n" + clean_exit 1 + elif [ ${_GET_RECONFIG_ERRORS} -ne 1 ]; then + printf "ERROR: server did not report reconfiguration error despite attempt\ + to configure it with invalid configuration.\n" + clean_exit 1 + fi + + # Make sure the server is still operational. + get_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 1 ]; then + printf "ERROR: Kea process was killed when attempting reconfiguration.\n" + clean_exit 1 + fi + + # Restore the good configuration. + create_config "${CONFIG}" + + # Reconfigure the server with SIGHUP. + send_signal 1 ${bin} + + # There should be two occurrences of the DHCP6_CONFIG_COMPLETE messages. + # Wait for it up to 10s. + wait_for_message 10 "DHCP6_CONFIG_COMPLETE" 2 + + # After receiving SIGHUP the server should get reconfigured and the + # reconfiguration should be noted in the log file. We should now + # have two configurations logged in the log file. + if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then + printf "ERROR: server hasn't been reconfigured.\n" + clean_exit 1 + else + printf "Server successfully reconfigured.\n" + fi + + # Make sure the server is still operational. + get_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 1 ]; then + printf "ERROR: Kea process was killed when attempting reconfiguration.\n" + clean_exit 1 + fi + + # All ok. Shut down Kea and exit. + test_finish 0 +} + +# This test verifies that DHCPv6 server 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 Kea instances and remove log files. + cleanup + # Create new configuration file. + create_config "${CONFIG}" + # Instruct Kea to log to the specific file. + set_logger + # Start Kea. + start_kea ${bin_path}/${bin} + # Wait up to 20s for Kea to start. + wait_for_kea 20 + if [ ${_WAIT_FOR_KEA} -eq 0 ]; then + printf "ERROR: timeout waiting for Kea 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_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 1 ]; then + printf "ERROR: expected one Kea 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 hasn't been configured.\n" + clean_exit 1 + else + printf "Server successfully configured.\n" + fi + + # Send signal to Kea (SIGTERM, SIGINT etc.) + send_signal ${signum} ${bin} + + # Wait up to 10s for the server's graceful shutdown. The graceful shut down + # should be recorded in the log file with the appropriate message. + wait_for_message 10 "DHCP6_SHUTDOWN" 1 + if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then + printf "ERROR: Server did not record shutdown in the log.\n" + clean_exit 1 + fi + + # Server should have shut down. + get_pids ${bin} + if [ ${_GET_PIDS_NUM} -ne 0 ]; then + printf "ERROR: Kea did not shut down after receiving signal.\n"\ + ${_GET_PIDS_NUM} + clean_exit 1 + fi + + test_finish 0 +} + +dynamic_reconfiguration_test +shutdown_test "dhcpv4.sigterm_test" 15 +shutdown_test "dhcpv4.sigint_test" 2 diff --git a/src/bin/dhcp6/tests/dhcp6_reconfigure_test.sh b/src/bin/dhcp6/tests/dhcp6_reconfigure_test.sh deleted file mode 100755 index 708dd92bff..0000000000 --- a/src/bin/dhcp6/tests/dhcp6_reconfigure_test.sh +++ /dev/null @@ -1,163 +0,0 @@ -# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# Path to the temporary configuration file. -CFG_FILE="test_config.json" -# Path to the Kea log file. -LOG_FILE="test.log" -# Kea configuration to be stored in the configuration file. -CONFIG="{ - \"Dhcp6\": - { - \"interfaces\": [ ], - \"preferred-lifetime\": 3000, - \"valid-lifetime\": 4000, - \"renew-timer\": 1000, - \"rebind-timer\": 2000, - \"lease-database\": - { - \"type\": \"memfile\", - \"persist\": false - }, - \"subnet6\": [ - { - \"subnet\": \"2001:db8:1::/64\", - \"pool\": [ \"2001:db8:1::10-2001:db8:1::100\" ] - } ] - } -}" -# Invalid configuration (negative preferred-lifetime) to check that Kea -# gracefully handles reconfiguration errors. -CONFIG_INVALID="{ - \"Dhcp6\": - { - \"interfaces\": [ ], - \"preferred-lifetime\": -3, - \"valid-lifetime\": 4000, - \"renew-timer\": 1000, - \"rebind-timer\": 2000, - \"lease-database\": - { - \"type\": \"memfile\", - \"persist\": false - }, - \"subnet6\": [ - { - \"subnet\": \"2001:db8:1::/64\", - \"pool\": [ \"2001:db8:1::10-2001:db8:1::100\" ] - } ] - } -}" - -# Set the location of the executable. -bin="b10-dhcp6" -bin_path=".." - -# Import common test library. -. $(dirname $0)/../../../lib/testutils/dhcp_test_lib.sh - -# Log the start of the test and print test name. -test_start "dhcpv6_srv.dynamic_reconfiguration" -# Remove dangling Kea instances and remove log files. -cleanup -# Create new configuration file. -create_config "${CONFIG}" -# Instruct Kea to log to the specific file. -set_logger -# Start Kea. -start_kea ${bin_path}/${bin} -# Wait up to 20s for Kea to start. -wait_for_kea 20 -if [ ${_WAIT_FOR_KEA} -eq 0 ]; then - printf "ERROR: timeout waiting for Kea 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_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 1 ]; then - printf "ERROR: expected one Kea 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 hasn't been configured.\n" - clean_exit 1 -else - printf "Server successfully configured.\n" -fi - -# Now use invalid configuration. -create_config "${CONFIG_INVALID}" - -# Try to reconfigure by sending SIGHUP -send_signal 1 ${bin} - -# The configuration should fail and the error message should be there. -wait_for_message 10 "DHCP6_CONFIG_LOAD_FAIL" 1 - -# After receiving SIGHUP the server should try to reconfigure itself. -# The configuration provided is invalid so it should result in -# reconfiguration failure but the server should still be running. -get_reconfigs -if [ ${_GET_RECONFIGS} -ne 1 ]; then - printf "ERROR: server has been reconfigured despite bogus configuration.\n" - clean_exit 1 -elif [ ${_GET_RECONFIG_ERRORS} -ne 1 ]; then - printf "ERROR: server did not report reconfiguration error despite attempt\ - to configure it with invalid configuration.\n" - clean_exit 1 -fi - -# Make sure the server is still operational. -get_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 1 ]; then - printf "ERROR: Kea process was killed when attempting reconfiguration.\n" - clean_exit 1 -fi - -# Restore the good configuration. -create_config "${CONFIG}" - -# Reconfigure the server with SIGHUP. -send_signal 1 ${bin} - -# There should be two occurrences of the DHCP6_CONFIG_COMPLETE messages. -# Wait for it up to 10s. -wait_for_message 10 "DHCP6_CONFIG_COMPLETE" 2 - -# After receiving SIGHUP the server should get reconfigured and the -# reconfiguration should be noted in the log file. We should now -# have two configurations logged in the log file. -if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then - printf "ERROR: server hasn't been reconfigured.\n" - clean_exit 1 -else - printf "Server successfully reconfigured.\n" -fi - -# Make sure the server is still operational. -get_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 1 ]; then - printf "ERROR: Kea process was killed when attempting reconfiguration.\n" - clean_exit 1 -fi - -# All ok. Shut down Kea and exit. -clean_exit 0 diff --git a/src/bin/dhcp6/tests/dhcp6_shutdown_test.sh b/src/bin/dhcp6/tests/dhcp6_shutdown_test.sh deleted file mode 100755 index 17e8b4e8e8..0000000000 --- a/src/bin/dhcp6/tests/dhcp6_shutdown_test.sh +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -if [ $# -ne 2 ]; then - printf "USAGE: dhcp6_shutdown_test.sh \n" - exit 1 -fi - -# Test name -test_name=${1} -# Signal number to be used for this test. -SIG_NUM=$2 -# Path to the temporary configuration file. -CFG_FILE="test_config.json" -# Path to the Kea log file. -LOG_FILE="test.log" -# Kea configuration to be stored in the configuration file. -CONFIG="{ - \"Dhcp6\": - { - \"interfaces\": [ ], - \"preferred-lifetime\": 3000, - \"valid-lifetime\": 4000, - \"renew-timer\": 1000, - \"rebind-timer\": 2000, - \"lease-database\": - { - \"type\": \"memfile\", - \"persist\": false - }, - \"subnet6\": [ - { - \"subnet\": \"2001:db8:1::/64\", - \"pool\": [ \"2001:db8:1::10-2001:db8:1::100\" ] - } ] - } -}" - -# Set the location of the executable. -bin="b10-dhcp6" -bin_path=".." - -# Import common test library. -. $(dirname $0)/../../../lib/testutils/dhcp_test_lib.sh - -# Log the start of the test and print test name. -test_start ${test_name} -# Remove dangling Kea instances and remove log files. -cleanup -# Create new configuration file. -create_config "${CONFIG}" -# Instruct Kea to log to the specific file. -set_logger -# Start Kea. -start_kea ${bin_path}/${bin} -# Wait up to 20s for Kea to start. -wait_for_kea 20 -if [ ${_WAIT_FOR_KEA} -eq 0 ]; then - printf "ERROR: timeout waiting for Kea 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_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 1 ]; then - printf "ERROR: expected one Kea 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 hasn't been configured.\n" - clean_exit 1 -else - printf "Server successfully configured.\n" -fi - -# Send signal to Kea (SIGTERM, SIGINT etc.) -send_signal ${SIG_NUM} ${bin} - -# Wait up to 10s for the server's graceful shutdown. The graceful shut down -# should be recorded in the log file with the appropriate message. -wait_for_message 10 "DHCP6_SHUTDOWN" 1 -if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then - printf "ERROR: Server did not record shutdown in the log.\n" - clean_exit 1 -fi - -# Server should have shut down. -get_pids ${bin} -if [ ${_GET_PIDS_NUM} -ne 0 ]; then - printf "ERROR: Kea did not shut down after receiving signal.\n"\ - ${_GET_PIDS_NUM} - clean_exit 1 -fi - -clean_exit 0 diff --git a/src/bin/dhcp6/tests/dhcp6_sigint_test.sh b/src/bin/dhcp6/tests/dhcp6_sigint_test.sh deleted file mode 100755 index bccfcb9265..0000000000 --- a/src/bin/dhcp6/tests/dhcp6_sigint_test.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# Run a test that sends SIGINT to Kea and checks if it shuts down gracefully. -$(dirname $0)/dhcp6_shutdown_test.sh "dhcpv6_srv.sigint" 2 diff --git a/src/bin/dhcp6/tests/dhcp6_sigterm_test.sh b/src/bin/dhcp6/tests/dhcp6_sigterm_test.sh deleted file mode 100755 index 039e0f60cb..0000000000 --- a/src/bin/dhcp6/tests/dhcp6_sigterm_test.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# Run a test that sends SIGTERM to Kea and checks if it shuts down gracefully. -$(dirname $0)/dhcp6_shutdown_test.sh "dhcpv6_srv.sigterm" 15 diff --git a/src/bin/keactrl/tests/Makefile.am b/src/bin/keactrl/tests/Makefile.am index 1ec9fc16d3..78bc478c5d 100644 --- a/src/bin/keactrl/tests/Makefile.am +++ b/src/bin/keactrl/tests/Makefile.am @@ -3,7 +3,7 @@ SUBDIRS = . SHTESTS = keactrl_tests.sh noinst_SCRIPTS = keactrl_tests.sh -CLEANFILES = keactrl_tests.sh + CLEANFILES = *.log *.json EXTRA_DIST = keactrl_tests.sh.in @@ -14,5 +14,5 @@ check-local: chmod +x $(abs_builddir)/$$shtest ; \ export KEACTRL_BUILD_DIR=$(abs_top_builddir); \ export KEACTRL_CONF=$(abs_top_builddir)/src/bin/keactrl/tests/keactrl_test.conf; \ - $(abs_srcdir)/$$shtest || exit ; \ + $(abs_builddir)/$$shtest || exit ; \ done diff --git a/src/lib/testutils/.gitignore b/src/lib/testutils/.gitignore new file mode 100644 index 0000000000..ba01f3c6c2 --- /dev/null +++ b/src/lib/testutils/.gitignore @@ -0,0 +1 @@ +/dhcp_test_lib.sh \ No newline at end of file diff --git a/src/lib/testutils/Makefile.am b/src/lib/testutils/Makefile.am index 0f105dc06c..5618f55b8d 100644 --- a/src/lib/testutils/Makefile.am +++ b/src/lib/testutils/Makefile.am @@ -16,6 +16,8 @@ libkea_testutils_la_LIBADD += $(top_builddir)/src/lib/dns/libkea-dns++.la endif # Include common libraries being used by shell-based tests. -SHLIBS = dhcp_test_lib.sh +SHLIBS = dhcp_test_lib.sh.in EXTRA_DIST = portconfig.h socket_request.h $(SHLIBS) + +CLEANFILES = dhcp_test_lib.sh diff --git a/src/lib/testutils/dhcp_test_lib.sh b/src/lib/testutils/dhcp_test_lib.sh.in old mode 100755 new mode 100644 similarity index 99% rename from src/lib/testutils/dhcp_test_lib.sh rename to src/lib/testutils/dhcp_test_lib.sh.in index d71e542e52..00282a8483 --- a/src/lib/testutils/dhcp_test_lib.sh +++ b/src/lib/testutils/dhcp_test_lib.sh.in @@ -231,7 +231,7 @@ clean_exit() { # Starts Kea process in background using a configuration file specified # in the global variable ${CFG_FILE}. start_kea() { - bin=${1} + local bin=${1} if [ -z ${bin} ]; then test_lib_error "binary name must be specified for start_kea" clean_exit 1 @@ -337,7 +337,7 @@ send_signal() { case ${sig} in ''|*[!0-9]*) test_lib_error "signal number passed to send_signal \ -must bea number" +must be a number" clean_exit 1 ;; esac # Validate process name