Commit e97919a2 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3785] Simplified the unit test for keactrl status command.

parent 576b7c95
......@@ -935,62 +935,25 @@ Expected wait_for_message return %d, returned %d."
test_finish 0
}
# This test checks that the status command no longer checks first config file
# It is essentially a copy of start_v4_server_test with a modified test
# This test checks that the "status" command doesn't check the presence of the
# config file.
status_no_config_test() {
# Create configuration file for keactrl. This configuration enables
# DHCPv4 server but disables other servers.
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\
dhcp_ddns=no\nkea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.status_no_config_test"
# Create configuration file for Kea and for keactrl.
create_config "${config}"
create_keactrl_config "${keactrl_config}"
# Set logging to a file.
set_logger
# Start DHCPv4 server using keactrl script.
printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
${keactrl} start -c ${KEACTRL_CFG_FILE}
ret=${?}
assert_eq 0 ${ret} "Expected keactrl to retrun 0, returned value was ${ret}"
# Wait up to 20s for the DHCPv4 server to configure.
wait_for_message 20 "DHCP4_CONFIG_COMPLETE" 1
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${kea4_name} to start. \
Expected wait_for_message return %d, returned %d."
# Server may shut down imediatelly after configuration has competed.
# Give it some time to shutdown.
sleep 3
# Make sure that DHCPv4 server is running.
get_pids ${kea4_name}
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${kea4_name} process running, found %d processes running"
# Make sure that DHCPv6 server is not running.
get_pids ${kea6_name}
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${kea6_name} process running, found %d processes running"
# Make sure that all config files are removed.
cleanup
# Make sure that D2 server is not running.
get_pids ${d2_name}
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running"
# Create keactrl configuration file.
create_keactrl_config "${keactrl_config}"
# Make sure that the status command no longer checks first config file
# Make sure that the "status" command doesn't check the presence of
# the config file.
printf "Getting status without a Kea config file\n"
mv ${CFG_FILE} ${CFG_FILE}.saved
output=$( ${keactrl} status -c ${KEACTRL_CFG_FILE} )
ret=${?}
mv ${CFG_FILE}.saved ${CFG_FILE}
assert_eq 1 ${ret} "Expected keactrl to return %d, returned %d"
assert_string_contains "DHCPv4 server: active" "${output}" \
assert_string_contains "DHCPv4 server: inactive" "${output}" \
"Expected keactrl status command return %s"
assert_string_contains "DHCPv6 server: inactive" "${output}" \
"Expected keactrl status command return %s"
......@@ -999,23 +962,6 @@ Expected wait_for_message return %d, returned %d."
assert_string_contains "Configuration file for Kea does not exist" \
"${output}" "Expected keactrl status command return %s"
# Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -c ${KEACTRL_CFG_FILE}
ret=${?}
assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
# Wait up to 10s for the DHCPv4 server to stop.
wait_for_message 10 "DHCP4_SHUTDOWN" 1
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${kea4_name} to shutdown. \
Expected wait_for_message return %d, returned %d."
# Make sure that all servers are down.
wait_for_server_down 5 ${wildcard_name}
assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
"Expected wait_for_server_down return %d, returned %d"
test_finish 0
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment