Browse Source

[3785] Unembedded status_no_config_test

Francis Dupont 9 years ago
parent
commit
576b7c95c7
1 changed files with 84 additions and 17 deletions
  1. 84 17
      src/bin/keactrl/tests/keactrl_tests.sh.in

+ 84 - 17
src/bin/keactrl/tests/keactrl_tests.sh.in

@@ -392,22 +392,6 @@ Expected wait_for_message return %d, returned %d."
     assert_string_contains "DHCP DDNS: inactive" "${output}" \
     assert_string_contains "DHCP DDNS: inactive" "${output}" \
         "Expected keactrl status command return %s"
         "Expected keactrl status command return %s"
 
 
-    # Make sure that the status command no longer checks first 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}" \
-        "Expected keactrl status command return %s"
-    assert_string_contains "DHCPv6 server: inactive" "${output}" \
-        "Expected keactrl status command return %s"
-    assert_string_contains "DHCP DDNS: inactive" "${output}" \
-        "Expected keactrl status command return %s"
-    assert_string_contains "Configuration file for Kea does not exist" \
-	"${output}" "Expected keactrl status command return %s"
-
     # Use keactrl stop to shutdown the servers.
     # Use keactrl stop to shutdown the servers.
     printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
     printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
     ${keactrl} stop -c ${KEACTRL_CFG_FILE}
     ${keactrl} stop -c ${KEACTRL_CFG_FILE}
@@ -951,6 +935,89 @@ Expected wait_for_message return %d, returned %d."
     test_finish 0
     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
+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 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"
+
+    # Make sure that the status command no longer checks first 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}" \
+        "Expected keactrl status command return %s"
+    assert_string_contains "DHCPv6 server: inactive" "${output}" \
+        "Expected keactrl status command return %s"
+    assert_string_contains "DHCP DDNS: inactive" "${output}" \
+        "Expected keactrl status command return %s"
+    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
+}
 
 
 start_all_servers_no_verbose_test
 start_all_servers_no_verbose_test
 start_all_servers_verbose_test
 start_all_servers_verbose_test
@@ -959,4 +1026,4 @@ start_v6_server_test
 late_start_v4_server_test
 late_start_v4_server_test
 late_start_v6_server_test
 late_start_v6_server_test
 stop_selected_server_test
 stop_selected_server_test
-
+status_no_config_test