keactrl_tests.sh.in 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. #!/bin/sh
  2. # Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
  3. #
  4. # Permission to use, copy, modify, and/or distribute this software for any
  5. # purpose with or without fee is hereby granted, provided that the above
  6. # copyright notice and this permission notice appear in all copies.
  7. #
  8. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  9. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  10. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  12. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  13. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  14. # PERFORMANCE OF THIS SOFTWARE.
  15. # Include common test library.
  16. . @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh
  17. # Set location of the keactrl.
  18. keactrl=@abs_top_builddir@/src/bin/keactrl/keactrl
  19. # A name of the configuration file to be used by Kea.
  20. CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/test_config.json
  21. # A name of the keactrl config file
  22. KEACTRL_CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/keactrl_test.conf
  23. # Path to the Kea log file.
  24. LOG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/test.log
  25. # Binaries' names
  26. wildcard_name="kea-dhcp"
  27. kea4_name="${wildcard_name}4"
  28. kea6_name="${wildcard_name}6"
  29. d2_name="${wildcard_name}-ddns"
  30. # Kea configuration
  31. config="{
  32. \"Dhcp4\":
  33. {
  34. \"interfaces-config\": {
  35. \"interfaces\": [ ]
  36. },
  37. \"valid-lifetime\": 4000,
  38. \"renew-timer\": 1000,
  39. \"rebind-timer\": 2000,
  40. \"lease-database\":
  41. {
  42. \"type\": \"memfile\",
  43. \"persist\": false
  44. },
  45. \"subnet4\": [
  46. {
  47. \"subnet\": \"10.0.0.0/24\",
  48. \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]
  49. } ]
  50. },
  51. \"Dhcp6\":
  52. {
  53. \"interfaces-config\": {
  54. \"interfaces\": [ ]
  55. },
  56. \"preferred-lifetime\": 3000,
  57. \"valid-lifetime\": 4000,
  58. \"renew-timer\": 1000,
  59. \"rebind-timer\": 2000,
  60. \"lease-database\":
  61. {
  62. \"type\": \"memfile\",
  63. \"persist\": false
  64. },
  65. \"subnet6\": [
  66. {
  67. \"subnet\": \"2001:db8:1::/64\",
  68. \"pools\": [ { \"pool\": \"2001:db8:1::10-2001:db8:1::100\" } ]
  69. } ]
  70. },
  71. \"DhcpDdns\":
  72. {
  73. \"ip_address\": \"127.0.0.1\",
  74. \"port\": 53001,
  75. \"tsig_keys\": [],
  76. \"forward_ddns\" : {},
  77. \"reverse_ddns\" : {}
  78. },
  79. \"Logging\":
  80. {
  81. \"loggers\": [
  82. {
  83. \"name\": \"kea-dhcp4\",
  84. \"output_options\": [
  85. {
  86. \"output\": \"$LOG_FILE\"
  87. }
  88. ],
  89. \"severity\": \"INFO\"
  90. },
  91. {
  92. \"name\": \"kea-dhcp6\",
  93. \"output_options\": [
  94. {
  95. \"output\": \"$LOG_FILE\"
  96. }
  97. ],
  98. \"severity\": \"INFO\"
  99. },
  100. {
  101. \"name\": \"kea-dhcp-ddns\",
  102. \"output_options\": [
  103. {
  104. \"output\": \"$LOG_FILE\"
  105. }
  106. ],
  107. \"severity\": \"INFO\"
  108. }
  109. ]
  110. }
  111. }"
  112. # Fixed part of the keactrl configuration file.
  113. keactrl_fixed_config="dhcp4_srv=${KEACTRL_BUILD_DIR}/src/bin/dhcp4/kea-dhcp4\n\
  114. dhcp6_srv=${KEACTRL_BUILD_DIR}/src/bin/dhcp6/kea-dhcp6\n\
  115. dhcp_ddns_srv=${KEACTRL_BUILD_DIR}/src/bin/d2/kea-dhcp-ddns\n"
  116. # This test checks that DHCPv4, DHCPv6 and D2 server can be started and
  117. # shut down.
  118. start_all_servers_no_verbose_test() {
  119. # Create configuration file for keactrl. This configuration enables
  120. # DHCPv4, DHCPv6 and D2 server.
  121. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
  122. dhcp_ddns=yes\nkea_verbose=no\n${keactrl_fixed_config}"
  123. test_start "keactrl.start_all_servers_no_verbose_test"
  124. # Create configuration file for Kea and for keactrl.
  125. create_config "${config}"
  126. create_keactrl_config "${keactrl_config}"
  127. # Set logging to a file.
  128. set_logger
  129. # Start servers using keactrl script.
  130. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE} -s all\n"
  131. # Append the -s option to specify all servers. This is not necessary
  132. # because all should be a default but let's see if it is accepted
  133. # by the command line parser.
  134. ${keactrl} start -c ${KEACTRL_CFG_FILE} -s all
  135. ret=${?}
  136. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d"
  137. # Wait up to 20s for the DHCPv6 server to configure.
  138. wait_for_message 20 "DHCP6_CONFIG_COMPLETE" 1
  139. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  140. "Timeout waiting for ${kea6_name} to start. \
  141. Expected wait_for_message return %d, returned %d."
  142. # Wait up to 20s for the DHCPv4 server to configure.
  143. wait_for_message 20 "DHCP4_CONFIG_COMPLETE" 1
  144. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  145. "Timeout waiting for ${kea4_name} to start. \
  146. Expected wait_for_message return %d, returned %d."
  147. wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1
  148. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  149. "Timeout waiting for ${d2_name} to start. \
  150. Expected wait_for_message return %d, returned %d."
  151. # Make sure that debug messages are logged for neither
  152. # server (non-verbose mode).
  153. get_log_messages "DHCP6_START_INFO"
  154. assert_eq 0 ${_GET_LOG_MESSAGES} \
  155. "Expected get_log_messages return %d, returned %d."
  156. get_log_messages "DHCP4_START_INFO"
  157. assert_eq 0 ${_GET_LOG_MESSAGES} \
  158. "Expected get_log_messages return %d, returned %d."
  159. get_log_messages "DCTL_STANDALONE"
  160. assert_eq 0 ${_GET_LOG_MESSAGES} \
  161. "Expected get_log_messages return %d, returned %d."
  162. # Server may shut down imediatelly after configuration has competed.
  163. # Give it some time to shutdown.
  164. sleep 3
  165. # Make sure that all servers are running.
  166. get_pids ${kea4_name}
  167. assert_eq 1 ${_GET_PIDS_NUM} \
  168. "Expected %d ${kea4_name} process running, found %d processes running"
  169. get_pids ${kea6_name}
  170. assert_eq 1 ${_GET_PIDS_NUM} \
  171. "Expected %d ${kea6_name} process running, found %d processes running"
  172. get_pids ${d2_name}
  173. assert_eq 1 ${_GET_PIDS_NUM} \
  174. "Expected %d ${d2_name} process running, found %d processes running"
  175. # Use keactrl stop to shutdown the servers.
  176. printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
  177. ${keactrl} stop -c ${KEACTRL_CFG_FILE}
  178. ret=${?}
  179. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  180. # Wait up to 10s for the DHCPv6 server to stop.
  181. wait_for_message 10 "DHCP6_SHUTDOWN" 1
  182. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  183. "Timeout waiting for ${kea6_name} to shutdown. \
  184. Expected wait_for_message return %d, returned %d."
  185. # Wait up to 10s for the DHCPv4 server to stop.
  186. wait_for_message 10 "DHCP4_SHUTDOWN" 1
  187. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  188. "Timeout waiting for ${kea4_name} to shutdown. \
  189. Expected wait_for_message return %d, returned %d."
  190. # Wait up to 10s for the D2 server to stop.
  191. wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
  192. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  193. "Timeout waiting for ${d2_name} to shutdown. \
  194. Expected wait_for_message return %d, returned %d."
  195. # Make sure that all servers are down.
  196. wait_for_server_down 5 ${wildcard_name}
  197. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  198. "Expected wait_for_server_down return %d, returned %d"
  199. test_finish 0
  200. }
  201. # This test checks that both DHCPv4 and DHCPv6 server can be started in
  202. # a verbose mode.
  203. start_all_servers_verbose_test() {
  204. # Create configuration file for keactrl. This configuration enables
  205. # all servers.
  206. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
  207. dhcp_ddns=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
  208. test_start "keactrl.start_all_servers_verbose_test"
  209. # Create configuration file for Kea and for keactrl.
  210. create_config "${config}"
  211. create_keactrl_config "${keactrl_config}"
  212. # Set logging to a file.
  213. set_logger
  214. # Start servers using keactrl script.
  215. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
  216. ${keactrl} start -c ${KEACTRL_CFG_FILE}
  217. ret=${?}
  218. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d"
  219. # Wait up to 20s for the DHCPv6 server to configure.
  220. wait_for_message 20 "DHCP6_CONFIG_COMPLETE" 1
  221. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  222. "Timeout waiting for ${kea6_name} to start. \
  223. Expected wait_for_message return %d, returned %d."
  224. # Wait up to 20s for the DHCPv4 server to configure.
  225. wait_for_message 20 "DHCP4_CONFIG_COMPLETE" 1
  226. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  227. "Timeout waiting for ${kea4_name} to start. \
  228. Expected wait_for_message return %d, returned %d."
  229. # Wait up to 20s for the D2 server to configure.
  230. wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1
  231. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  232. "Timeout waiting for ${d2_name} to start. \
  233. Expected wait_for_message return %d, returned %d."
  234. # Check if the debug messages are present, which should only be
  235. # the case if the verbose mode is on.
  236. get_log_messages "DHCP6_START_INFO" 1
  237. assert_eq 1 ${_GET_LOG_MESSAGES} \
  238. "Expected get_log_messages for DHCP6_START_INFO return %d, returned %d."
  239. get_log_messages "DHCP4_START_INFO" 1
  240. assert_eq 1 ${_GET_LOG_MESSAGES} \
  241. "Expected get_log_messages for DHCP4_START_INFO return %d, returned %d."
  242. get_log_messages "DCTL_STANDALONE" 1
  243. assert_eq 1 ${_GET_LOG_MESSAGES} \
  244. "Expected get_log_messages for DCT_STANDALONE return %d, returned %d."
  245. # Server may shut down imediatelly after configuration has competed.
  246. # Give it some time to shutdown.
  247. sleep 3
  248. # Make sure that all servers are running.
  249. get_pids ${kea4_name}
  250. assert_eq 1 ${_GET_PIDS_NUM} \
  251. "Expected %d ${kea4_name} process running, found %d processes running"
  252. get_pids ${kea6_name}
  253. assert_eq 1 ${_GET_PIDS_NUM} \
  254. "Expected %d ${kea6_name} process running, found %d processes running"
  255. get_pids ${d2_name}
  256. assert_eq 1 ${_GET_PIDS_NUM} \
  257. "Expected %d ${d2_name} process running, found %d processes running"
  258. # Use keactrl stop to shutdown the servers.
  259. printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
  260. ${keactrl} stop -c ${KEACTRL_CFG_FILE}
  261. ret=${?}
  262. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  263. # Wait up to 10s for the DHCPv6 server to stop.
  264. wait_for_message 10 "DHCP6_SHUTDOWN" 1
  265. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  266. "Timeout waiting for ${kea6_name} to shutdown. \
  267. Expected wait_for_message return %d, returned %d."
  268. # Wait up to 10s for the DHCPv4 server to stop.
  269. wait_for_message 10 "DHCP4_SHUTDOWN" 1
  270. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  271. "Timeout waiting for ${kea4_name} to shutdown. \
  272. Expected wait_for_message return %d, returned %d."
  273. # Wait up to 10s for the D2 server to stop.
  274. wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
  275. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  276. "Timeout waiting for ${d2_name} to shutdown. \
  277. Expected wait_for_message return %d, returned %d."
  278. # Make sure that all servers are down.
  279. wait_for_server_down 5 ${wildcard_name}
  280. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  281. "Expected wait_for_server_down return %d, returned %d"
  282. test_finish 0
  283. }
  284. # This test checks that only DHCPv4 server can be started and that other
  285. # servers are not started.
  286. start_v4_server_test() {
  287. # Create configuration file for keactrl. This configuration enables
  288. # DHCPv4 server but disables other servers.
  289. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\
  290. dhcp_ddns=no\nkea_verbose=no\n${keactrl_fixed_config}"
  291. test_start "keactrl.start_v4_server_test"
  292. # Create configuration file for Kea and for keactrl.
  293. create_config "${config}"
  294. create_keactrl_config "${keactrl_config}"
  295. # Set logging to a file.
  296. set_logger
  297. # Start DHCPv4 server using keactrl script.
  298. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
  299. ${keactrl} start -c ${KEACTRL_CFG_FILE}
  300. ret=${?}
  301. assert_eq 0 ${ret} "Expected keactrl to retrun 0, returned value was ${ret}"
  302. # Wait up to 20s for the DHCPv4 server to configure.
  303. wait_for_message 20 "DHCP4_CONFIG_COMPLETE" 1
  304. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  305. "Timeout waiting for ${kea4_name} to start. \
  306. Expected wait_for_message return %d, returned %d."
  307. # Server may shut down imediatelly after configuration has competed.
  308. # Give it some time to shutdown.
  309. sleep 3
  310. # Make sure that DHCPv4 server is running.
  311. get_pids ${kea4_name}
  312. assert_eq 1 ${_GET_PIDS_NUM} \
  313. "Expected %d ${kea4_name} process running, found %d processes running"
  314. # Make sure that DHCPv6 server is not running.
  315. get_pids ${kea6_name}
  316. assert_eq 0 ${_GET_PIDS_NUM} \
  317. "Expected %d ${kea6_name} process running, found %d processes running"
  318. # Make sure that D2 server is not running.
  319. get_pids ${d2_name}
  320. assert_eq 0 ${_GET_PIDS_NUM} \
  321. "Expected %d ${d2_name} process running, found %d processes running"
  322. # Make sure that the status command returns appropriate status.
  323. printf "Getting status of Kea modules: %s\n" "${keactrl} status \
  324. -c ${KEACTRL_CFG_FILE}"
  325. output=$( ${keactrl} status -c ${KEACTRL_CFG_FILE} )
  326. ret=${?}
  327. assert_eq 0 ${ret} "Expected keactrl to return %d, returned %d"
  328. assert_string_contains "DHCPv4 server: active" "${output}" \
  329. "Expected keactrl status command return %s"
  330. assert_string_contains "DHCPv6 server: inactive" "${output}" \
  331. "Expected keactrl status command return %s"
  332. assert_string_contains "DHCP DDNS: inactive" "${output}" \
  333. "Expected keactrl status command return %s"
  334. # Use keactrl stop to shutdown the servers.
  335. printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
  336. ${keactrl} stop -c ${KEACTRL_CFG_FILE}
  337. ret=${?}
  338. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  339. # Wait up to 10s for the DHCPv4 server to stop.
  340. wait_for_message 10 "DHCP4_SHUTDOWN" 1
  341. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  342. "Timeout waiting for ${kea4_name} to shutdown. \
  343. Expected wait_for_message return %d, returned %d."
  344. # Make sure that all servers are down.
  345. wait_for_server_down 5 ${wildcard_name}
  346. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  347. "Expected wait_for_server_down return %d, returned %d"
  348. test_finish 0
  349. }
  350. # This test checks that only DHCPv6 server can be started and that other
  351. # servers are not started.
  352. start_v6_server_test() {
  353. # Create configuration file for keactrl. This configuration enables
  354. # DHCPv6 server but disables other servers..
  355. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=no\ndhcp6=yes\n\
  356. dhcp_ddns=no\nkea_verbose=no\n${keactrl_fixed_config}"
  357. test_start "keactrl.start_v6_server_test"
  358. # Create configuration file for Kea and for keactrl.
  359. create_config "${config}"
  360. create_keactrl_config "${keactrl_config}"
  361. # Set logging to a file.
  362. set_logger
  363. # Start DHCPv6 server using keactrl script.
  364. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
  365. ${keactrl} start -c ${KEACTRL_CFG_FILE}
  366. ret=${?}
  367. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d"
  368. # Wait up to 20s for the DHCPv6 server to configure.
  369. wait_for_message 20 "DHCP6_CONFIG_COMPLETE" 1
  370. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  371. "Timeout waiting for ${kea6_name} to start. \
  372. Expected wait_for_message return %d, returned %d."
  373. # Server may shut down imediatelly after configuration has competed.
  374. # Give it some time to shutdown.
  375. sleep 3
  376. # Make sure that DHCPv6 server is running.
  377. get_pids ${kea6_name}
  378. assert_eq 1 ${_GET_PIDS_NUM} \
  379. "Expected %d ${kea6_name} process running, found %d processes running"
  380. # Make sure that DHCPv4 server is not running.
  381. get_pids ${kea4_name}
  382. assert_eq 0 ${_GET_PIDS_NUM} \
  383. "Expected %d ${kea4_name} process running, found %d processes running"
  384. # Make sure that D2 server is not running.
  385. get_pids ${d2_name}
  386. assert_eq 0 ${_GET_PIDS_NUM} \
  387. "Expected %d ${d2_name} process running, found %d processes running"
  388. # Make sure that the status command returns appropriate status.
  389. printf "Getting status of Kea modules: %s\n" "${keactrl} status -c ${KEACTRL_CFG_FILE}"
  390. output=$( ${keactrl} status -c ${KEACTRL_CFG_FILE} )
  391. ret=${?}
  392. assert_eq 0 ${ret} "Expected keactrl to return %d, returned %d"
  393. assert_string_contains "DHCPv4 server: inactive" "${output}" \
  394. "Expected keactrl status command return %s"
  395. assert_string_contains "DHCPv6 server: active" "${output}" \
  396. "Expected keactrl status command return %s"
  397. assert_string_contains "DHCP DDNS: inactive" "${output}" \
  398. "Expected keactrl status command return %s"
  399. # Use keactrl stop to shutdown the servers.
  400. printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
  401. ${keactrl} stop -c ${KEACTRL_CFG_FILE}
  402. ret=${?}
  403. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  404. # Wait up to 10s for the DHCPv6 server to stop.
  405. wait_for_message 10 "DHCP6_SHUTDOWN" 1
  406. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  407. "Timeout waiting for ${kea6_name} to shutdown. \
  408. Expected wait_for_message return %d, returned %d."
  409. # Make sure that all servers are down.
  410. wait_for_server_down 5 ${wildcard_name}
  411. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  412. "Expected wait_for_server_down return %d, returned %d"
  413. test_finish 0
  414. }
  415. # This test checks that the DHCPv4 server can be started first, and then the
  416. # other servers can be started while DHCPv4 server is already running.
  417. # Also check that both servers can be reconfigured.
  418. late_start_v4_server_test() {
  419. # Create configuration file for keactrl. This configuration enables
  420. # DHCPv6 server but disables other servers.
  421. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=no\ndhcp6=yes\n\
  422. dhcp_ddns=no\nkea_verbose=no\n${keactrl_fixed_config}"
  423. test_start "keactrl.late_start_v4_server_test"
  424. # Create configuration file for Kea and for keactrl.
  425. create_config "${config}"
  426. create_keactrl_config "${keactrl_config}"
  427. # Set logging to a file.
  428. set_logger
  429. # Start DHCPv6 server using keactrl script.
  430. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
  431. ${keactrl} start -c ${KEACTRL_CFG_FILE}
  432. ret=${?}
  433. assert_eq 0 ${ret} "Expected keactrl to retrun 0, returned value was ${ret}"
  434. # Wait up to 20s for the DHCPv6 server to configure.
  435. wait_for_message 20 "DHCP6_CONFIG_COMPLETE" 1
  436. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  437. "Timeout waiting for ${kea6_name} to start. \
  438. Expected wait_for_message return %d, returned %d."
  439. # Server may shut down imediatelly after configuration has competed.
  440. # Give it some time to shutdown.
  441. sleep 3
  442. # Make sure that DHCPv6 server is running.
  443. get_pids ${kea6_name}
  444. assert_eq 1 ${_GET_PIDS_NUM} \
  445. "Expected %d ${kea6_name} process running, found %d processes running"
  446. # Make sure that DHCPv4 server is not running.
  447. get_pids ${kea4_name}
  448. assert_eq 0 ${_GET_PIDS_NUM} \
  449. "Expected %d ${kea4_name} process running, found %d processes running"
  450. # Trigger reconfiguration, make sure that the DHCPv6 server reconfigured.
  451. printf "Reconfiguring the DHCPv6 server: ${keactrl} reload -c ${KEACTRL_CFG_FILE}\n"
  452. ${keactrl} reload -c ${KEACTRL_CFG_FILE}
  453. ret=${?}
  454. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d"
  455. # There should be two completed reconfigurations so far.
  456. wait_for_message 10 "DHCP6_CONFIG_COMPLETE" 2
  457. assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea6_name} to reconfigure. \
  458. Expected wait_for_message to return %d, returned %d."
  459. # Update keactrl config to enable other servers.
  460. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
  461. dhcp_ddns=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
  462. create_keactrl_config "${keactrl_config}"
  463. # Start other servers using keactrl script.
  464. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
  465. ${keactrl} start -c ${KEACTRL_CFG_FILE}
  466. ret=${?}
  467. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d"
  468. # Wait up to 20s for the DHCPv4 server to configure.
  469. wait_for_message 20 "DHCP4_CONFIG_COMPLETE" 1
  470. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  471. "Timeout waiting for ${kea4_name} to start. \
  472. Expected wait_for_message return %d, returned %d."
  473. # Wait up to 20s for the D2 server to configure.
  474. wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1
  475. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  476. "Timeout waiting for ${kea4_name} to start. \
  477. Expected wait_for_message return %d, returned %d."
  478. # Make sure that DHCPv6 server is running.
  479. get_pids ${kea6_name}
  480. assert_eq 1 ${_GET_PIDS_NUM} \
  481. "Expected %d ${kea6_name} process running, found %d processes running"
  482. # Make sure that DHCPv4 server is running.
  483. get_pids ${kea4_name}
  484. assert_eq 1 ${_GET_PIDS_NUM} \
  485. "Expected %d ${kea4_name} process running, found %d processes running"
  486. # Make sure that D2 server is running.
  487. get_pids ${d2_name}
  488. assert_eq 1 ${_GET_PIDS_NUM} \
  489. "Expected %d ${d2_name} process running, found %d processes running"
  490. # Trigger reconfiguration, make sure that servers are reconfigured.
  491. printf "Reconfiguring all servers: ${keactrl} reload \
  492. -c ${KEACTRL_CFG_FILE}\n"
  493. ${keactrl} reload -c ${KEACTRL_CFG_FILE}
  494. ret=${?}
  495. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d"
  496. # There should be three completed configurations of DHCPv6 server.
  497. wait_for_message 10 "DHCP6_CONFIG_COMPLETE" 3
  498. assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea6_name} to reconfigure. \
  499. Expected wait_for_message to return %d, returned %d."
  500. # There should be two completed configurations of DHCPv4 server.
  501. wait_for_message 10 "DHCP4_CONFIG_COMPLETE" 2
  502. assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea4_name} to reconfigure. \
  503. Expected wait_for_message to return %d, returned %d."
  504. # There should be two completed configurations of D2 server.
  505. wait_for_message 10 "DCTL_CONFIG_COMPLETE" 2
  506. assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${d2_name} to reconfigure. \
  507. Expected wait_for_message to return %d, returned %d."
  508. # Use keactrl stop to shutdown the servers.
  509. printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
  510. ${keactrl} stop -c ${KEACTRL_CFG_FILE}
  511. ret=${?}
  512. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  513. # Wait up to 10s for the DHCPv6 server to stop.
  514. wait_for_message 10 "DHCP6_SHUTDOWN" 1
  515. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  516. "Timeout waiting for ${kea6_name} to shutdown. \
  517. Expected wait_for_message return %d, returned %d."
  518. # Wait up to 10s for the DHCPv4 server to stop.
  519. wait_for_message 10 "DHCP4_SHUTDOWN" 1
  520. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  521. "Timeout waiting for ${kea4_name} to shutdown. \
  522. Expected wait_for_message return %d, returned %d."
  523. # Wait up to 10s for the D2 server to stop.
  524. wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
  525. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  526. "Timeout waiting for ${d2_name} to shutdown. \
  527. Expected wait_for_message return %d, returned %d."
  528. # Make sure that all servers are down.
  529. wait_for_server_down 5 ${wildcard_name}
  530. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  531. "Expected wait_for_server_down return %d, returned %d"
  532. test_finish 0
  533. }
  534. # This test checks that the DHCPv4 server can be started first, and then the
  535. # other servers can be started while DHCPv4 server is already running.
  536. # Also check that both servers can be reconfigured.
  537. late_start_v6_server_test() {
  538. # Create configuration file for keactrl. This configuration enables
  539. # DHCPv4 server but disables DHCPv6 server.
  540. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\
  541. dhcp_ddns=no\nkea_verbose=yes\n${keactrl_fixed_config}"
  542. test_start "keactrl.late_start_v6_server_test"
  543. # Create configuration file for Kea and for keactrl.
  544. create_config "${config}"
  545. create_keactrl_config "${keactrl_config}"
  546. # Set logging to a file.
  547. set_logger
  548. # Start DHCPv4 server using keactrl script.
  549. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
  550. ${keactrl} start -c ${KEACTRL_CFG_FILE}
  551. ret=${?}
  552. assert_eq 0 ${ret} "Expected keactrl to retrun 0, returned value was ${ret}"
  553. # Wait up to 20s for the DHCPv4 server to configure.
  554. wait_for_message 20 "DHCP4_CONFIG_COMPLETE" 1
  555. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  556. "Timeout waiting for ${kea4_name} to start. \
  557. Expected wait_for_message return %d, returned %d."
  558. # Server may shut down imediatelly after configuration has competed.
  559. # Give it some time to shutdown.
  560. sleep 3
  561. # Make sure that DHCPv4 server is running.
  562. get_pids ${kea4_name}
  563. assert_eq 1 ${_GET_PIDS_NUM} \
  564. "Expected %d ${kea4_name} process running, found %d processes running"
  565. # Make sure that DHCPv6 server is not running.
  566. get_pids ${kea6_name}
  567. assert_eq 0 ${_GET_PIDS_NUM} \
  568. "Expected %d ${kea6_name} process running, found %d processes running"
  569. # Make sure that D2 server is not running.
  570. get_pids ${d2_name}
  571. assert_eq 0 ${_GET_PIDS_NUM} \
  572. "Expected %d ${d2_name} process running, found %d processes running"
  573. # Trigger reconfiguration, make sure that the DHCPv4 server is reconfigured.
  574. printf "Reconfiguring the DHCPv4 server: ${keactrl} reload -c ${KEACTRL_CFG_FILE}\n"
  575. ${keactrl} reload -c ${KEACTRL_CFG_FILE}
  576. ret=${?}
  577. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d"
  578. # There should be two completed reconfigurations so far.
  579. wait_for_message 10 "DHCP4_CONFIG_COMPLETE" 2
  580. assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea4_name} to reconfigure. \
  581. Expected wait_for_message to return %d, returned %d."
  582. # Update keactrl config to enable other servers.
  583. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
  584. dhcp_ddns=yes\nkea_verbose=no\n${keactrl_fixed_config}"
  585. create_keactrl_config "${keactrl_config}"
  586. # Start other servers using keactrl script.
  587. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
  588. ${keactrl} start -c ${KEACTRL_CFG_FILE}
  589. ret=${?}
  590. assert_eq 0 ${ret} "Expected keactrl to retrun 0, returned value was ${ret}"
  591. # Wait up to 20s for the DHCPv6 server to configure.
  592. wait_for_message 20 "DHCP6_CONFIG_COMPLETE" 1
  593. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  594. "Timeout waiting for ${kea4_name} to start. \
  595. Expected wait_for_message return %d, returned %d."
  596. # Wait up to 20s for the D2 server to configure.
  597. wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1
  598. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  599. "Timeout waiting for ${d2_name} to start. \
  600. Expected wait_for_message return %d, returned %d."
  601. # Make sure that DHCPv6 server is running.
  602. get_pids ${kea6_name}
  603. assert_eq 1 ${_GET_PIDS_NUM} \
  604. "Expected %d ${kea6_name} process running, found %d processes running"
  605. # Make sure that DHCPv4 server is running.
  606. get_pids ${kea4_name}
  607. assert_eq 1 ${_GET_PIDS_NUM} \
  608. "Expected %d ${kea4_name} process running, found %d processes running"
  609. # Make sure that D2 server is running.
  610. get_pids ${d2_name}
  611. assert_eq 1 ${_GET_PIDS_NUM} \
  612. "Expected %d ${d2_name} process running, found %d processes running"
  613. # Trigger reconfiguration, make sure that servers are reconfigured.
  614. printf "Reconfiguring DHCPv6 and DHCPv4 servers: ${keactrl} reload \
  615. -c ${KEACTRL_CFG_FILE}\n"
  616. ${keactrl} reload -c ${KEACTRL_CFG_FILE}
  617. ret=${?}
  618. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d"
  619. # There should be three completed configurations of DHCPv4 server.
  620. wait_for_message 10 "DHCP4_CONFIG_COMPLETE" 3
  621. assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea4_name} to reconfigure. \
  622. Expected wait_for_message to return %d, returned %d."
  623. # There should be two completed configurations of DHCPv6 server.
  624. wait_for_message 10 "DHCP6_CONFIG_COMPLETE" 2
  625. assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea6_name} to reconfigure. \
  626. Expected wait_for_message to return %d, returned %d."
  627. # There should be two completed configurations of Dd2 server.
  628. wait_for_message 10 "DCTL_CONFIG_COMPLETE" 2
  629. assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${d2_name} to reconfigure. \
  630. Expected wait_for_message to return %d, returned %d."
  631. # Use keactrl stop to shutdown the servers.
  632. printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
  633. ${keactrl} stop -c ${KEACTRL_CFG_FILE}
  634. ret=${?}
  635. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  636. # Wait up to 10s for the DHCPv6 server to stop.
  637. wait_for_message 10 "DHCP6_SHUTDOWN" 1
  638. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  639. "Timeout waiting for ${kea6_name} to shutdown. \
  640. Expected wait_for_message return %d, returned %d."
  641. # Wait up to 10s for the DHCPv4 server to stop.
  642. wait_for_message 10 "DHCP4_SHUTDOWN" 1
  643. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  644. "Timeout waiting for ${kea4_name} to shutdown. \
  645. Expected wait_for_message return %d, returned %d."
  646. # Wait up to 10s for the d2 server to stop.
  647. wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
  648. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  649. "Timeout waiting for ${d2_name} to shutdown. \
  650. Expected wait_for_message return %d, returned %d."
  651. # Make sure that all servers are down.
  652. wait_for_server_down 5 ${wildcard_name}
  653. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  654. "Expected wait_for_server_down return %d, returned %d"
  655. test_finish 0
  656. }
  657. # This test checks that the servers can be shutdown selectively.
  658. stop_selected_server_test() {
  659. # Create configuration file for keactrl. This configuration enables
  660. # all servers.
  661. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
  662. dhcp_ddns=yes\nkea_verbose=no\n${keactrl_fixed_config}"
  663. test_start "keactrl.stop_selected_server_test"
  664. # Create configuration file for Kea and for keactrl.
  665. create_config "${config}"
  666. create_keactrl_config "${keactrl_config}"
  667. # Set logging to a file.
  668. set_logger
  669. # Start servers using keactrl script.
  670. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
  671. ${keactrl} start -c ${KEACTRL_CFG_FILE}
  672. ret=${?}
  673. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d"
  674. # Wait up to 20s for the DHCPv6 server to configure.
  675. wait_for_message 20 "DHCP6_CONFIG_COMPLETE" 1
  676. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  677. "Timeout waiting for ${kea6_name} to start. \
  678. Expected wait_for_message return %d, returned %d."
  679. # Wait up to 20s for the DHCPv4 server to configure.
  680. wait_for_message 20 "DHCP4_CONFIG_COMPLETE" 1
  681. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  682. "Timeout waiting for ${kea4_name} to start. \
  683. Expected wait_for_message return %d, returned %d."
  684. # Wait up to 20s for the D2 server to configure.
  685. wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1
  686. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  687. "Timeout waiting for ${d2_name} to start. \
  688. Expected wait_for_message return %d, returned %d."
  689. # Make sure that debug messages are not logged (non-verbose mode).
  690. get_log_messages "DHCP6_START_INFO"
  691. assert_eq 0 ${_GET_LOG_MESSAGES} \
  692. "Expected get_log_messages return %d, returned %d."
  693. get_log_messages "DHCP4_START_INFO"
  694. assert_eq 0 ${_GET_LOG_MESSAGES} \
  695. "Expected get_log_messages return %d, returned %d."
  696. get_log_messages "DCTL_STANDALONE"
  697. assert_eq 0 ${_GET_LOG_MESSAGES} \
  698. "Expected get_log_messages return %d, returned %d."
  699. # Server may shut down imediatelly after configuration has competed.
  700. # Give it some time to shutdown.
  701. sleep 3
  702. # Make sure that both servers are running.
  703. get_pids ${kea4_name}
  704. assert_eq 1 ${_GET_PIDS_NUM} \
  705. "Expected %d ${kea4_name} process running, found %d processes running"
  706. get_pids ${kea6_name}
  707. assert_eq 1 ${_GET_PIDS_NUM} \
  708. "Expected %d ${kea6_name} process running, found %d processes running"
  709. get_pids ${d2_name}
  710. assert_eq 1 ${_GET_PIDS_NUM} \
  711. "Expected %d ${d2_name} process running, found %d processes running"
  712. # Use keactrl stop to shutdown DHCPv4 server.
  713. printf "Stopping DHCPv4 server: ${keactrl} stop -s dhcp4 -c ${KEACTRL_CFG_FILE}\n"
  714. ${keactrl} stop -s dhcp4 -c ${KEACTRL_CFG_FILE}
  715. ret=${?}
  716. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  717. # Wait up to 10s for the DHCPv4 server to stop.
  718. wait_for_message 10 "DHCP4_SHUTDOWN" 1
  719. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  720. "Timeout waiting for ${kea4_name} to shutdown. \
  721. Expected wait_for_message return %d, returned %d."
  722. # Make sure that the DHCPv4 server is down.
  723. wait_for_server_down 5 ${kea4_name}
  724. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  725. "Expected wait_for_server_down return %d, returned %d"
  726. # Make sure DHCPv6 server is still running
  727. get_pids ${kea6_name}
  728. assert_eq 1 ${_GET_PIDS_NUM} \
  729. "Expected %d ${kea6_name} process running, found %d processes running"
  730. # Make sure D2 server is still running
  731. get_pids ${kea6_name}
  732. assert_eq 1 ${_GET_PIDS_NUM} \
  733. "Expected %d ${d2_name} process running, found %d processes running"
  734. # Use keactrl stop to shutdown DHCPv6 server.
  735. printf "Stopping DHCPv6 server: ${keactrl} stop -s dhcp6 -c ${KEACTRL_CFG_FILE}\n"
  736. ${keactrl} stop -s dhcp6 -c ${KEACTRL_CFG_FILE}
  737. ret=${?}
  738. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  739. # Wait up to 10s for the DHCPv6 server to stop.
  740. wait_for_message 10 "DHCP6_SHUTDOWN" 1
  741. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  742. "Timeout waiting for ${kea6_name} to shutdown. \
  743. Expected wait_for_message return %d, returned %d."
  744. # Make sure that the DHCPv6 server is down.
  745. wait_for_server_down 5 ${kea6_name}
  746. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  747. "Expected wait_for_server_down return %d, returned %d"
  748. # Make sure D2 server is still running
  749. get_pids ${d2_name}
  750. assert_eq 1 ${_GET_PIDS_NUM} \
  751. "Expected %d ${d2_name} process running, found %d processes running"
  752. # Use keactrl stop to shutdown D2 server.
  753. printf "Stopping DHCP DDNS server: ${keactrl} stop -s dhcp_ddns -c ${KEACTRL_CFG_FILE}\n"
  754. ${keactrl} stop -s dhcp_ddns -c ${KEACTRL_CFG_FILE}
  755. ret=${?}
  756. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  757. # Wait up to 10s for the D2 server to stop.
  758. wait_for_message 10 "DHCP_DDNS_SHUTDOWN" 1
  759. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  760. "Timeout waiting for ${d2_name} to shutdown. \
  761. Expected wait_for_message return %d, returned %d."
  762. # Make sure that the D2 server is down.
  763. wait_for_server_down 5 ${d2_name}
  764. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  765. "Expected wait_for_server_down return %d, returned %d"
  766. test_finish 0
  767. }
  768. # This test checks that the status command no longer checks first config file
  769. # It is essentially a copy of start_v4_server_test with a modified test
  770. status_no_config_test() {
  771. # Create configuration file for keactrl. This configuration enables
  772. # DHCPv4 server but disables other servers.
  773. keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\
  774. dhcp_ddns=no\nkea_verbose=no\n${keactrl_fixed_config}"
  775. test_start "keactrl.status_no_config_test"
  776. # Create configuration file for Kea and for keactrl.
  777. create_config "${config}"
  778. create_keactrl_config "${keactrl_config}"
  779. # Set logging to a file.
  780. set_logger
  781. # Start DHCPv4 server using keactrl script.
  782. printf "Starting Kea: ${keactrl} start -c ${KEACTRL_CFG_FILE}\n"
  783. ${keactrl} start -c ${KEACTRL_CFG_FILE}
  784. ret=${?}
  785. assert_eq 0 ${ret} "Expected keactrl to retrun 0, returned value was ${ret}"
  786. # Wait up to 20s for the DHCPv4 server to configure.
  787. wait_for_message 20 "DHCP4_CONFIG_COMPLETE" 1
  788. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  789. "Timeout waiting for ${kea4_name} to start. \
  790. Expected wait_for_message return %d, returned %d."
  791. # Server may shut down imediatelly after configuration has competed.
  792. # Give it some time to shutdown.
  793. sleep 3
  794. # Make sure that DHCPv4 server is running.
  795. get_pids ${kea4_name}
  796. assert_eq 1 ${_GET_PIDS_NUM} \
  797. "Expected %d ${kea4_name} process running, found %d processes running"
  798. # Make sure that DHCPv6 server is not running.
  799. get_pids ${kea6_name}
  800. assert_eq 0 ${_GET_PIDS_NUM} \
  801. "Expected %d ${kea6_name} process running, found %d processes running"
  802. # Make sure that D2 server is not running.
  803. get_pids ${d2_name}
  804. assert_eq 0 ${_GET_PIDS_NUM} \
  805. "Expected %d ${d2_name} process running, found %d processes running"
  806. # Make sure that the status command no longer checks first config file
  807. printf "Getting status without a Kea config file\n"
  808. mv ${CFG_FILE} ${CFG_FILE}.saved
  809. output=$( ${keactrl} status -c ${KEACTRL_CFG_FILE} )
  810. ret=${?}
  811. mv ${CFG_FILE}.saved ${CFG_FILE}
  812. assert_eq 1 ${ret} "Expected keactrl to return %d, returned %d"
  813. assert_string_contains "DHCPv4 server: active" "${output}" \
  814. "Expected keactrl status command return %s"
  815. assert_string_contains "DHCPv6 server: inactive" "${output}" \
  816. "Expected keactrl status command return %s"
  817. assert_string_contains "DHCP DDNS: inactive" "${output}" \
  818. "Expected keactrl status command return %s"
  819. assert_string_contains "Configuration file for Kea does not exist" \
  820. "${output}" "Expected keactrl status command return %s"
  821. # Use keactrl stop to shutdown the servers.
  822. printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
  823. ${keactrl} stop -c ${KEACTRL_CFG_FILE}
  824. ret=${?}
  825. assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
  826. # Wait up to 10s for the DHCPv4 server to stop.
  827. wait_for_message 10 "DHCP4_SHUTDOWN" 1
  828. assert_eq 1 ${_WAIT_FOR_MESSAGE} \
  829. "Timeout waiting for ${kea4_name} to shutdown. \
  830. Expected wait_for_message return %d, returned %d."
  831. # Make sure that all servers are down.
  832. wait_for_server_down 5 ${wildcard_name}
  833. assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
  834. "Expected wait_for_server_down return %d, returned %d"
  835. test_finish 0
  836. }
  837. start_all_servers_no_verbose_test
  838. start_all_servers_verbose_test
  839. start_v4_server_test
  840. start_v6_server_test
  841. late_start_v4_server_test
  842. late_start_v6_server_test
  843. stop_selected_server_test
  844. status_no_config_test