|
@@ -14,8 +14,6 @@
|
|
|
|
|
|
|
|
|
|
TEST_NAME="DynamicReconfiguration"
|
|
TEST_NAME="DynamicReconfiguration"
|
|
-
|
|
|
|
-BIN="../b10-dhcp6"
|
|
|
|
|
|
|
|
CFG_FILE="test_config.json"
|
|
CFG_FILE="test_config.json"
|
|
|
|
|
|
@@ -64,144 +62,99 @@ CONFIG_INVALID="{
|
|
}
|
|
}
|
|
}"
|
|
}"
|
|
|
|
|
|
-_GETPIDS1=
|
|
+
|
|
-_GETPIDS2=
|
|
+. dhcp6_test_func.sh
|
|
-getpids() {
|
|
|
|
- _GETPIDS1=`ps -o pid,command | grep b10-dhcp | grep -v grep | awk '{print $1}'`
|
|
|
|
- _GETPIDS2=`printf "%s" "${_GETPIDS1}" | wc -w | awk '{print $1}'`
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-cleanup() {
|
|
|
|
- getpids
|
|
|
|
- for pid in ${_GETPIDS1}
|
|
|
|
- do
|
|
|
|
- printf "Shutting down Kea proccess having pid %d.\n" ${pid}
|
|
|
|
- kill -9 ${pid}
|
|
|
|
- done
|
|
|
|
- rm -rf ${LOG_FILE}
|
|
|
|
- rm -rf ${CONFIG_FILE}
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-cleanexit() {
|
|
|
|
- if [ $1 -eq 0 ]; then
|
|
|
|
- cleanup
|
|
|
|
- printf "PASSED ${TEST_NAME}\n\n"
|
|
|
|
- else
|
|
|
|
- printf "Log file dump:\n"
|
|
|
|
- cat ${LOG_FILE}
|
|
|
|
- cleanup
|
|
|
|
- printf "FAILED ${TEST_NAME}\n\n"
|
|
|
|
- fi
|
|
|
|
- exit $1
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-_GETRECONFIGS=
|
|
|
|
-_GETRECONFIGERRORS=
|
|
|
|
-getreconfigs() {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- _GETRECONFIGS=`grep -o DHCP6_CONFIG_COMPLETE ${LOG_FILE} | wc -w`
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- _GETRECONFIGERRORS=`grep -o DHCP6_CONFIG_LOAD_FAIL ${LOG_FILE} | wc -w`
|
|
|
|
-
|
|
|
|
- ${_GETRECONFIGS##*[! ]}
|
|
|
|
- ${_GETRECONFIGERRORS##*[! ]}
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-printf "\nSTART TEST ${TEST_NAME}\n"
|
|
|
|
-
|
|
|
|
-printf "Creating Kea configuration file: %s.\n" ${CFG_FILE}
|
|
|
|
-printf "%b" ${CONFIG} > ${CFG_FILE}
|
|
|
|
-
|
|
|
|
-printf "Kea log will be stored in %s.\n" ${LOG_FILE}
|
|
|
|
-export B10_LOGGER_DESTINATION=${LOG_FILE}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-cleanup
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-printf "Running command %s.\n" "\"$BIN -c ${CFG_FILE}\""
|
|
|
|
-$BIN -c ${CFG_FILE} &
|
|
|
|
|
|
|
|
-
|
|
+
|
|
-sleep 1
|
|
+test_start
|
|
|
|
+
|
|
|
|
+cleanup
|
|
|
|
+
|
|
|
|
+create_config "${CONFIG}"
|
|
|
|
+
|
|
|
|
+set_logger
|
|
|
|
+
|
|
|
|
+start_kea
|
|
|
|
+
|
|
|
|
+wait_for_kea 20
|
|
|
|
+if [ ${_WAIT_FOR_KEA} -eq 0 ]; then
|
|
|
|
+ printf "ERROR: timeout waiting for Kea to start.\n"
|
|
|
|
+ clean_exit 1
|
|
|
|
+fi
|
|
|
|
|
|
-
|
|
+
|
|
-getpids
|
|
+
|
|
-if [ ${_GETPIDS2} -ne 1 ]; then
|
|
+get_pids
|
|
- printf "ERROR: expected one Kea process to be started. Found %d processes started.\n" ${_GETPIDS2}
|
|
+if [ ${_GET_PIDS_NUM} -ne 1 ]; then
|
|
- cleanexit 1
|
|
+ printf "ERROR: expected one Kea process to be started. Found %d processes started.\n" ${_GET_PIDS_NUM}
|
|
|
|
+ clean_exit 1
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-getreconfigs
|
|
+get_reconfigs
|
|
-if [ ${_GETRECONFIGS} -ne 1 ]; then
|
|
+if [ ${_GET_RECONFIGS} -ne 1 ]; then
|
|
printf "ERROR: server hasn't been configured.\n"
|
|
printf "ERROR: server hasn't been configured.\n"
|
|
- cleanexit 1
|
|
+ clean_exit 1
|
|
else
|
|
else
|
|
printf "Server successfully configured.\n"
|
|
printf "Server successfully configured.\n"
|
|
fi
|
|
fi
|
|
|
|
|
|
-printf "Creating configuration file with invalid configuration: %s.\n" ${CFG_FILE}
|
|
+
|
|
-printf "%b" ${CONFIG_INVALID} > ${CFG_FILE}
|
|
+create_config "${CONFIG_INVALID}"
|
|
|
|
|
|
-
|
|
+
|
|
-printf "Sending SIGHUP to Kea process (pid=%s) to reconfigure the server.\n" ${_GETPIDS1}
|
|
+send_signal 1
|
|
-kill -1 ${_GETPIDS1}
|
|
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
+wait_for_message 10 "DHCP6_CONFIG_LOAD_FAIL" 1
|
|
-sleep 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-getreconfigs
|
|
+get_reconfigs
|
|
-if [ ${_GETRECONFIGS} -ne 1 ]; then
|
|
+if [ ${_GET_RECONFIGS} -ne 1 ]; then
|
|
printf "ERROR: server has been reconfigured despite bogus configuration.\n"
|
|
printf "ERROR: server has been reconfigured despite bogus configuration.\n"
|
|
- cleanexit 1
|
|
+ clean_exit 1
|
|
-elif [ ${_GETRECONFIGERRORS} -ne 1 ]; then
|
|
+elif [ ${_GET_RECONFIG_ERRORS} -ne 1 ]; then
|
|
printf "ERROR: server did not report reconfiguration error despite attempt" \
|
|
printf "ERROR: server did not report reconfiguration error despite attempt" \
|
|
" to configure it with invalid configuration.\n"
|
|
" to configure it with invalid configuration.\n"
|
|
- cleanexit 1
|
|
+ clean_exit 1
|
|
fi
|
|
fi
|
|
|
|
|
|
-
|
|
|
|
-sleep 1
|
|
|
|
-
|
|
|
|
|
|
|
|
-getpids
|
|
+get_pids
|
|
-if [ ${_GETPIDS2} -ne 1 ]; then
|
|
+if [ ${_GET_PIDS_NUM} -ne 1 ]; then
|
|
printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
|
|
printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
|
|
- cleanexit 1
|
|
+ clean_exit 1
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
-printf "%b" ${CONFIG} > ${CFG_FILE}
|
|
+create_config "${CONFIG}"
|
|
|
|
|
|
|
|
|
|
-printf "Sending SIGHUP to Kea process (pid=%s) to reconfigure the server.\n" ${_GETPIDS1}
|
|
+send_signal 1
|
|
-kill -1 ${_GETPIDS1}
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+wait_for_message 10 "DHCP6_CONFIG_COMPLETE" 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-getreconfigs
|
|
+if [ ${_WAIT_FOR_MESSAGE} -eq 0 ]; then
|
|
-if [ ${_GETRECONFIGS} -ne 2 ]; then
|
|
|
|
printf "ERROR: server hasn't been reconfigured.\n"
|
|
printf "ERROR: server hasn't been reconfigured.\n"
|
|
- cleanexit 1
|
|
+ clean_exit 1
|
|
else
|
|
else
|
|
printf "Server successfully reconfigured.\n"
|
|
printf "Server successfully reconfigured.\n"
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
-getpids
|
|
+get_pids
|
|
-if [ ${_GETPIDS2} -ne 1 ]; then
|
|
+if [ ${_GET_PIDS_NUM} -ne 1 ]; then
|
|
printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
|
|
printf "ERROR: Kea process was killed when attempting reconfiguration.\n"
|
|
- cleanexit 1
|
|
+ clean_exit 1
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
-cleanexit 0
|
|
+clean_exit 0
|