src/bin/d2/Makefile
src/bin/d2/spec_config.h.pre
src/bin/d2/tests/Makefile
+ src/bin/d2/tests/d2_process_tests.sh
src/bin/d2/tests/test_data_files_config.h
src/bin/dhcp4/Makefile
src/bin/dhcp4/spec_config.h.pre
# The test of dynamic reconfiguration based on signals will work only
# if we are using file based configuration approach.
if CONFIG_BACKEND_JSON
-SHTESTS += d2_reconfigure_test.sh
-SHTESTS += d2_sigterm_test.sh
-SHTESTS += d2_sigint_test.sh
+SHTESTS += d2_process_tests.sh
endif
-EXTRA_DIST = $(PYTESTS)
-EXTRA_DIST += d2_reconfigure_test.sh
-EXTRA_DIST += d2_sigterm_test.sh
-EXTRA_DIST += d2_sigint_test.sh
-EXTRA_DIST += d2_shutdown_test.sh
+noinst_SCRIPTS = d2_process_tests.sh
+
+EXTRA_DIST = $(PYTESTS)
+EXTRA_DIST += d2_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
for shtest in $(SHTESTS) ; do \
echo Running test: $$shtest ; \
export B10_LOCKFILE_DIR_FROM_BUILD=$(abs_top_builddir); \
- $(abs_srcdir)/$$shtest || exit ; \
+ ${SHELL} $(abs_builddir)/$$shtest || exit ; \
done
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
CLEANFILES = $(builddir)/interfaces.txt $(builddir)/logger_lockfile
+DISTCLEANFILES = d2_process_tests.sh
+
AM_CXXFLAGS = $(B10_CXXFLAGS)
if USE_CLANGPP
# Disable unused parameter warning caused by some Boost headers when compiling with clang
--- /dev/null
+# 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/d2/tests/test_config.json
+# Path to the D2 log file.
+LOG_FILE=@abs_top_builddir@/src/bin/d2/tests/test.log
+# D2 configuration to be stored in the configuration file.
+CONFIG="{
+ \"DhcpDdns\":
+ {
+ \"ip_address\": \"127.0.0.1\",
+ \"port\": 53001,
+ \"tsig_keys\": [],
+ \"forward_ddns\" : {},
+ \"reverse_ddns\" : {}
+ }
+}"
+
+# Invalid configuration (invalid port) to check that D2
+# gracefully handles reconfiguration errors.
+CONFIG_INVALID="{
+ \"DhcpDdns\":
+ {
+ \"ip_address\": \"127.0.0.1\",
+ \"port\": BOGUS,
+ \"tsig_keys\": [],
+ \"forward_ddns\" : {},
+ \"reverse_ddns\" : {}
+ }
+}"
+
+# Set the location of the executable.
+bin="b10-dhcp-ddns"
+bin_path=@abs_top_builddir@/src/bin/d2
+
+# Import common test library.
+. @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh
+
+# This test verifies that D2 can be reconfigured with a SIGHUP signal.
+dynamic_reconfiguration_test() {
+ # Log the start of the test and print test name.
+ test_start "dhcp_ddns.dynamic_reconfiguration"
+ # Remove dangling D2 instances and remove log files.
+ cleanup
+ # Create new configuration file.
+ create_config "${CONFIG}"
+ # Instruct D2 to log to the specific file.
+ set_logger
+ # Start D2.
+ start_kea ${bin_path}/${bin}
+ # Wait up to 20s for D2 to start.
+ wait_for_kea 20
+ if [ ${_WAIT_FOR_KEA} -eq 0 ]; then
+ printf "ERROR: timeout waiting for D2 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 D2 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: D2 hasn't been configured.\n"
+ clean_exit 1
+ else
+ printf "D2 successfully configured.\n"
+ fi
+
+ # Now use invalid configuration.
+ create_config "${CONFIG_INVALID}"
+
+ # Try to reconfigure by sending SIGHUP
+ send_signal 1 ${bin}
+
+ # Wait up to 10s for the D2Controller to log reload signal received.
+ wait_for_message 10 "DHCP_DDNS_CFG_FILE_RELOAD_SIGNAL_RECVD" 1
+ if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
+ printf "ERROR: D2 did report the reload signal receipt.\n"
+ clean_exit 1
+ fi
+
+ # 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.
+ wait_for_message 10 "DHCP_DDNS_CFG_FILE_RELOAD_ERROR" 1
+ if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
+ printf "ERROR: D2 did not report reload error.\n"
+ clean_exit 1
+ fi
+
+ # Make sure the server is still operational.
+ get_pids ${bin}
+ if [ ${_GET_PIDS_NUM} -ne 1 ]; then
+ printf "ERROR: D2 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 "DCTL_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: D2 hasn't been reconfigured.\n"
+ clean_exit 1
+ else
+ printf "D2 successfully reconfigured.\n"
+ fi
+
+ # Make sure the server is still operational.
+ get_pids ${bin}
+ if [ ${_GET_PIDS_NUM} -ne 1 ]; then
+ printf "ERROR: D2 was killed when attempting reconfiguration.\n"
+ clean_exit 1
+ fi
+
+ # All ok. Shut down D2 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 D2 instances and remove log files.
+ cleanup
+ # Create new configuration file.
+ create_config "${CONFIG}"
+ # Instruct D2 to log to the specific file.
+ set_logger
+ # Start D2.
+ start_kea ${bin_path}/${bin}
+ # Wait up to 20s for D2 to start.
+ wait_for_kea 20
+ if [ ${_WAIT_FOR_KEA} -eq 0 ]; then
+ printf "ERROR: timeout waiting for D2 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 D2 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 D2 (SIGTERM, SIGINT etc.)
+ send_signal ${signum} ${bin}
+
+ # Wait up to 10s for the D2Controller to log shutdown received.
+ wait_for_message 10 "DHCP_DDNS_SHUTDOWN_SIGNAL_RECVD" 1
+ if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
+ printf "ERROR: D2Process did report the shutdown signal receipt.\n"
+ clean_exit 1
+ fi
+
+ # Wait up to 10s for the D2Process to log graceful shutdown.
+ wait_for_message 10 "DHCP_DDNS_CLEARED_FOR_SHUTDOWN" 1
+ if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
+ printf "ERROR: D2Process did not log orderly shutdown.\n"
+ clean_exit 1
+ fi
+
+ # Now wait for D2Controller to log that it is exiting.
+ wait_for_message 10 "DCTL_STOPPING" 1
+ if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
+ printf "ERROR: D2Controller did not log shutdown.\n"
+ clean_exit 1
+ fi
+
+ # Server should have shut down.
+ get_pids ${bin}
+ if [ ${_GET_PIDS_NUM} -ne 0 ]; then
+ printf "ERROR: D2 did not shut down after receiving signal.\n"\
+ ${_GET_PIDS_NUM}
+ clean_exit 1
+ fi
+
+ test_finish 0
+}
+
+dynamic_reconfiguration_test
+shutdown_test "dhcp-ddns.sigterm_test" 15
+shutdown_test "dhcp-ddns.sigint_test" 2
+++ /dev/null
-# 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.
-
-# Test name
-TEST_NAME="D2.dynamicReconfiguration"
-# 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="{
- \"DhcpDdns\":
- {
- \"ip_address\": \"127.0.0.1\",
- \"port\": 53001,
- \"tsig_keys\": [],
- \"forward_ddns\" : {},
- \"reverse_ddns\" : {}
- }
-}"
-
-# Invalid configuration (negative valid-lifetime) to check that Kea
-# gracefully handles reconfiguration errors.
-CONFIG_INVALID="{
- \"DhcpDdns\":
- {
- \"ip_address\": \"127.0.0.1\",
- \"port\": BOGUS,
- \"tsig_keys\": [],
- \"forward_ddns\" : {},
- \"reverse_ddns\" : {}
- }
-}"
-
-
-# Set the location of the executable.
-BIN="b10-dhcp-ddns"
-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
-# 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
-# Wait up to 20s for Kea to start.
-wait_for_kea 20
-if [ ${_WAIT_FOR_KEA} -eq 0 ]; then
- printf "ERROR: timeout waiting for D2 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
-if [ ${_GET_PIDS_NUM} -ne 1 ]; then
- printf "ERROR: expected one D2 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: D2 hasn't been configured.\n"
- clean_exit 1
-else
- printf "D2 successfully configured.\n"
-fi
-
-# Now use invalid configuration.
-create_config "${CONFIG_INVALID}"
-
-# Try to reconfigure by sending SIGHUP
-send_signal 1
-
-# Wait up to 10s for the D2Controller to log reload signal received.
-wait_for_message 10 "DHCP_DDNS_CFG_FILE_RELOAD_SIGNAL_RECVD" 1
-if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
- printf "ERROR: D2Process did report the reload signal receipt.\n"
- clean_exit 1
-fi
-
-# 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.
-wait_for_message 10 "DHCP_DDNS_CFG_FILE_RELOAD_ERROR" 1
-if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
- printf "ERROR: D2 did not report reload error.\n"
- clean_exit 1
-fi
-
-# Make sure the server is still operational.
-get_pids
-if [ ${_GET_PIDS_NUM} -ne 1 ]; then
- printf "ERROR: D2 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
-
-# There should be two occurrences of the DCTL_CONFIG_COMPLETE messages.
-# Wait for it up to 10s.
-wait_for_message 10 "DCTL_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: D2 hasn't been reconfigured.\n"
- clean_exit 1
-else
- printf "D2 successfully reconfigured.\n"
-fi
-
-# Make sure the server is still operational.
-get_pids
-if [ ${_GET_PIDS_NUM} -ne 1 ]; then
- printf "ERROR: D2 process was killed when attempting reconfiguration.\n"
- clean_exit 1
-fi
-
-# All ok. Shut down Kea and exit.
-clean_exit 0
+++ /dev/null
-# 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: d2_shutdown_test.sh <test_name> <signal_num>\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="{
- \"DhcpDdns\":
- {
- \"ip_address\": \"127.0.0.1\",
- \"port\": 53001,
- \"tsig_keys\": [],
- \"forward_ddns\" : {},
- \"reverse_ddns\" : {}
- }
-}"
-
-# Set the location of the executable.
-BIN="b10-dhcp-ddns"
-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
-# 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
-# Wait up to 20s for Kea to start.
-wait_for_kea 20
-if [ ${_WAIT_FOR_KEA} -eq 0 ]; then
- printf "ERROR: timeout waiting for D2 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
-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 D2 been configured. It should
-# be just once on startup.
-get_reconfigs
-if [ ${_GET_RECONFIGS} -ne 1 ]; then
- printf "ERROR: D2 hasn't been configured.\n"
- clean_exit 1
-else
- printf "D2 successfully configured.\n"
-fi
-
-# Send signal to D2 (SIGTERM, SIGINT etc.)
-send_signal ${SIG_NUM}
-
-# Wait up to 10s for the D2Controller to log shutdown received.
-wait_for_message 10 "DHCP_DDNS_SHUTDOWN_SIGNAL_RECVD" 1
-if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
- printf "ERROR: D2Process did report the shutdown signal receipt.\n"
- clean_exit 1
-fi
-
-# Wait up to 10s for the D2Process to log graceful shutdown.
-wait_for_message 10 "DHCP_DDNS_CLEARED_FOR_SHUTDOWN" 1
-if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
- printf "ERROR: D2Process did not log orderly shutdown.\n"
- clean_exit 1
-fi
-
-# Now wait for D2Controller to log that it is exiting.
-wait_for_message 10 "DCTL_STOPPING" 1
-if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
- printf "ERROR: D2Controller did not log shutdown.\n"
- clean_exit 1
-fi
-
-# Server should have shut down.
-get_pids
-if [ ${_GET_PIDS_NUM} -ne 0 ]; then
- printf "ERROR: D2 did not shut down after receiving signal.\n"\
- ${_GET_PIDS_NUM}
- clean_exit 1
-fi
-
-clean_exit 0
+++ /dev/null
-# 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)/d2_shutdown_test.sh "D2.sigint" 2
+++ /dev/null
-# 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)/d2_shutdown_test.sh "D2.sigterm" 15