From a125e6edc5efa1d938ce5fae10fd0b87e4f82f78 Mon Sep 17 00:00:00 2001 From: David Boucher Date: Tue, 27 Feb 2024 21:15:02 +0100 Subject: [PATCH] enh(tests): new tests on downtimes with 5 pollers REFS: MON-36711 --------- Co-authored-by: sfarouq-ext --- tests/broker-engine/downtimes.robot | 502 +++++++++++++++------------- tests/resources/resources.robot | 45 +-- 2 files changed, 298 insertions(+), 249 deletions(-) diff --git a/tests/broker-engine/downtimes.robot b/tests/broker-engine/downtimes.robot index 641149ca17f..c5c554acfae 100644 --- a/tests/broker-engine/downtimes.robot +++ b/tests/broker-engine/downtimes.robot @@ -1,252 +1,298 @@ *** Settings *** -Resource ../resources/resources.robot -Suite Setup Clean Downtimes Before Suite -Suite Teardown Clean After Suite -Test Setup Stop Processes -Test Teardown Save logs If Failed - -Documentation Centreon Broker and Engine progressively add services -Library Process -Library DatabaseLibrary -Library OperatingSystem -Library DateTime -Library Collections -Library ../resources/Engine.py -Library ../resources/Broker.py -Library ../resources/Common.py +Resource ../resources/resources.robot +Suite Setup Clean Downtimes Before Suite +Suite Teardown Clean After Suite +Test Setup Stop Processes +Test Teardown Save logs If Failed + +Documentation Centreon Broker and Engine progressively add services +Library Process +Library DatabaseLibrary +Library OperatingSystem +Library DateTime +Library Collections +Library ../resources/Engine.py +Library ../resources/Broker.py +Library ../resources/Common.py *** Test Cases *** BEDTMASS1 - [Documentation] New services with several pollers are created. Then downtimes are set on all configured hosts. This action results on 1050 downtimes if we also count impacted services. Then all these downtimes are removed. This test is done with BBDO 3.0.0 - [Tags] Broker Engine services protobuf - Config Engine ${3} ${50} ${20} - Engine Config Set Value ${0} log_level_functions trace - Engine Config Set Value ${1} log_level_functions trace - Engine Config Set Value ${2} log_level_functions trace - Config Broker rrd - Config Broker central - Config Broker module ${3} - Broker Config Log central sql debug - Broker Config Log module0 neb debug - Broker Config Log module1 neb debug - Broker Config Log module2 neb debug - - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item module2 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 - Broker Config Log central sql debug - Config Broker Sql Output central unified_sql - Clear Retention - ${start}= Get Current Date - Start Broker - Start Engine - # Let's wait for the initial service states. - ${content}= Create List INITIAL SERVICE STATE: host_50;service_1000; - ${result}= Find In Log with Timeout ${engineLog2} ${start} ${content} 60 - Should Be True ${result} msg=An Initial service state on service (50, 1000) should be raised before we can start external commands. - - # It's time to schedule downtimes - FOR ${i} IN RANGE ${17} - ${host0}= Catenate SEPARATOR= host_ ${i + 1} - ${host1}= Catenate SEPARATOR= host_ ${i + 18} - ${host2}= Catenate SEPARATOR= host_ ${i + 35} - Schedule host downtime ${0} ${host0} ${3600} - Schedule host downtime ${1} ${host1} ${3600} - Schedule host downtime ${2} ${host2} ${3600} - END - - ${result}= check number of downtimes ${1050} ${start} ${60} - Should be true ${result} msg=We should have 1050 downtimes enabled. - - # It's time to delete downtimes - FOR ${i} IN RANGE ${17} - ${host0}= Catenate SEPARATOR= host_ ${i + 1} - ${host1}= Catenate SEPARATOR= host_ ${i + 18} - ${host2}= Catenate SEPARATOR= host_ ${i + 35} - Delete host downtimes ${0} ${host0} - Delete host downtimes ${1} ${host1} - Delete host downtimes ${2} ${host2} - END - - ${result}= check number of downtimes ${0} ${start} ${60} - Should be true ${result} msg=We should have no downtime enabled. - - Stop Engine - Kindly Stop Broker + [Documentation] New services with several pollers are created. Then downtimes are set on all configured hosts. This action results on 1050 downtimes if we also count impacted services. Then all these downtimes are removed. This test is done with BBDO 3.0.0 + [Tags] Broker Engine services protobuf + Config Engine ${3} ${50} ${20} + Engine Config Set Value ${0} log_level_functions trace + Engine Config Set Value ${1} log_level_functions trace + Engine Config Set Value ${2} log_level_functions trace + Config Broker rrd + Config Broker central + Config Broker module ${3} + Broker Config Log central sql debug + Broker Config Log module0 neb debug + Broker Config Log module1 neb debug + Broker Config Log module2 neb debug + + Broker Config Add Item module0 bbdo_version 3.0.0 + Broker Config Add Item module1 bbdo_version 3.0.0 + Broker Config Add Item module2 bbdo_version 3.0.0 + Broker Config Add Item central bbdo_version 3.0.0 + Broker Config Add Item rrd bbdo_version 3.0.0 + Broker Config Log central sql debug + Config Broker Sql Output central unified_sql + Clear Retention + ${start} Get Current Date + Start Broker + Start Engine + # Let's wait for the external command check start + ${content} Create List check_for_external_commands() + ${result} Find In Log With Timeout ${engineLog2} ${start} ${content} 60 + Should Be True ${result} A message telling check_for_external_commands() should be available. + + # It's time to schedule downtimes + FOR ${i} IN RANGE ${17} + Schedule Host Downtime ${0} host_${i + 1} ${3600} + Schedule Host Downtime ${1} host_${i + 18} ${3600} + Schedule Host Downtime ${2} host_${i + 35} ${3600} + END + + ${result} check number of downtimes ${1050} ${start} ${60} + Should be true ${result} We should have 1050 downtimes enabled. + + # It's time to delete downtimes + FOR ${i} IN RANGE ${17} + Delete Host Downtimes ${0} host_${i + 1} + Delete Host Downtimes ${1} host_${i + 18} + Delete Host Downtimes ${2} host_${i + 35} + END + + ${result} check number of downtimes ${0} ${start} ${60} + Should be true ${result} We should have no downtime enabled. + + Stop Engine + Kindly Stop Broker BEDTMASS2 - [Documentation] New services with several pollers are created. Then downtimes are set on all configured hosts. This action results on 1050 downtimes if we also count impacted services. Then all these downtimes are removed. This test is done with BBDO 2.0 - [Tags] Broker Engine services protobuf - Config Engine ${3} ${50} ${20} - Engine Config Set Value ${0} log_level_functions trace - Engine Config Set Value ${1} log_level_functions trace - Engine Config Set Value ${2} log_level_functions trace - Config Broker rrd - Config Broker central - Config Broker module ${3} - Broker Config Log central sql debug - Broker Config Log module0 neb debug - Broker Config Log module1 neb debug - Broker Config Log module2 neb debug - - Broker Config Log central sql debug - Clear Retention - ${start}= Get Current Date - Start Broker - Start Engine - # Let's wait for the initial service states. - ${content}= Create List INITIAL SERVICE STATE: host_50;service_1000; - ${result}= Find In Log with Timeout ${engineLog2} ${start} ${content} 60 - Should Be True ${result} msg=An Initial service state on service (50, 1000) should be raised before we can start external commands. - - # It's time to schedule downtimes - FOR ${i} IN RANGE ${17} - ${host0}= Catenate SEPARATOR= host_ ${i + 1} - ${host1}= Catenate SEPARATOR= host_ ${i + 18} - ${host2}= Catenate SEPARATOR= host_ ${i + 35} - Schedule host downtime ${0} ${host0} ${3600} - Schedule host downtime ${1} ${host1} ${3600} - Schedule host downtime ${2} ${host2} ${3600} - END - - ${result}= check number of downtimes ${1050} ${start} ${60} - Should be true ${result} msg=We should have 1050 downtimes enabled. - - # It's time to delete downtimes - FOR ${i} IN RANGE ${17} - ${host0}= Catenate SEPARATOR= host_ ${i + 1} - ${host1}= Catenate SEPARATOR= host_ ${i + 18} - ${host2}= Catenate SEPARATOR= host_ ${i + 35} - Delete host downtimes ${0} ${host0} - Delete host downtimes ${1} ${host1} - Delete host downtimes ${2} ${host2} - END - - ${result}= check number of downtimes ${0} ${start} ${60} - Should be true ${result} msg=We should have no downtime enabled. - - Stop Engine - Kindly Stop Broker + [Documentation] New services with several pollers are created. Then downtimes are set on all configured hosts. This action results on 1050 downtimes if we also count impacted services. Then all these downtimes are removed. This test is done with BBDO 2.0 + [Tags] Broker Engine services protobuf + Config Engine ${3} ${50} ${20} + Engine Config Set Value ${0} log_level_functions trace + Engine Config Set Value ${1} log_level_functions trace + Engine Config Set Value ${2} log_level_functions trace + Config Broker rrd + Config Broker central + Config Broker module ${3} + Broker Config Log central sql debug + Broker Config Log module0 neb debug + Broker Config Log module1 neb debug + Broker Config Log module2 neb debug + + Broker Config Log central sql debug + Clear Retention + ${start} Get Current Date + Start Broker + Start Engine + # Let's wait for the external command check start + ${content} Create List check_for_external_commands() + ${result} Find In Log With Timeout ${engineLog2} ${start} ${content} 60 + Should Be True ${result} A message telling check_for_external_commands() should be available. + + # It's time to schedule downtimes + FOR ${i} IN RANGE ${17} + Schedule Host Downtime ${0} host_${i + 1} ${3600} + Schedule Host Downtime ${1} host_${i + 18} ${3600} + Schedule Host Downtime ${2} host_${i + 35} ${3600} + END + + ${result} check number of downtimes ${1050} ${start} ${60} + Should be true ${result} We should have 1050 downtimes enabled. + + # It's time to delete downtimes + FOR ${i} IN RANGE ${17} + Delete Host Downtimes ${0} host_${i + 1} + Delete Host Downtimes ${1} host_${i + 18} + Delete Host Downtimes ${2} host_${i + 35} + END + + ${result} check number of downtimes ${0} ${start} ${60} + Should be true ${result} We should have no downtime enabled. + + Stop Engine + Kindly Stop Broker BEDTSVCREN1 - [Documentation] A downtime is set on a service then the service is renamed. The downtime is still active on the renamed service. The downtime is removed from the renamed service and it is well removed. - [Tags] Broker Engine services downtime - Config Engine ${1} - Engine Config Set Value ${0} log_level_functions trace - Config Broker rrd - Config Broker central - Config Broker module ${1} - Broker Config Log central sql debug - Broker Config Log module0 neb debug + [Documentation] A downtime is set on a service then the service is renamed. The downtime is still active on the renamed service. The downtime is removed from the renamed service and it is well removed. + [Tags] Broker Engine services downtime + Config Engine ${1} + Engine Config Set Value ${0} log_level_functions trace + Config Broker rrd + Config Broker central + Config Broker module ${1} + Broker Config Log central sql debug + Broker Config Log module0 neb debug - Clear Retention - ${start}= Get Current Date - Start Broker - Start Engine - # Let's wait for the check of external commands - ${content}= Create List check_for_external_commands - ${result}= Find In Log with Timeout ${engineLog0} ${start} ${content} 60 - Should Be True ${result} msg=No check for external commands executed for 1mn. + Clear Retention + ${start} Get Current Date + Start Broker + Start Engine + # Let's wait for the check of external commands + ${content} Create List check_for_external_commands + ${result} Find In Log with Timeout ${engineLog0} ${start} ${content} 60 + Should Be True ${result} No check for external commands executed for 1mn. - # It's time to schedule a downtime - Schedule service downtime host_1 service_1 ${3600} + # It's time to schedule a downtime + Schedule service downtime host_1 service_1 ${3600} - ${result}= check number of downtimes ${1} ${start} ${60} - Should be true ${result} msg=We should have 1 downtime enabled. + ${result} check number of downtimes ${1} ${start} ${60} + Should be true ${result} We should have 1 downtime enabled. - # Let's rename the service service_1 - Rename Service ${0} host_1 service_1 toto_1 + # Let's rename the service service_1 + Rename Service ${0} host_1 service_1 toto_1 - Reload Engine - # Let's wait for the check of external commands - ${content}= Create List check_for_external_commands - ${result}= Find In Log with Timeout ${engineLog0} ${start} ${content} 60 - Should Be True ${result} msg=No check for external commands executed for 1mn. + Reload Engine + # Let's wait for the check of external commands + ${content} Create List check_for_external_commands + ${result} Find In Log with Timeout ${engineLog0} ${start} ${content} 60 + Should Be True ${result} No check for external commands executed for 1mn. - Delete service downtime full ${0} host_1 toto_1 + Delete service downtime full ${0} host_1 toto_1 - ${result}= check number of downtimes ${0} ${start} ${60} - Should be true ${result} msg=We should have no downtime enabled. + ${result} check number of downtimes ${0} ${start} ${60} + Should be true ${result} We should have no downtime enabled. - Stop Engine - Kindly Stop Broker + Stop Engine + Kindly Stop Broker BEDTSVCFIXED - [Documentation] A downtime is set on a service, the total number of downtimes is really 1 then we delete this downtime and the number of downtime is 0. - [Tags] Broker Engine downtime - Config Engine ${1} - Engine Config Set Value ${0} log_level_functions trace - Config Broker rrd - Config Broker central - Config Broker module ${1} - Broker Config Log central sql debug - Broker Config Log module0 neb debug - - Clear Retention - ${start}= Get Current Date - Start Broker - Start Engine - # Let's wait for the check of external commands - ${content}= Create List check_for_external_commands - ${result}= Find In Log with Timeout ${engineLog0} ${start} ${content} 60 - Should Be True ${result} msg=No check for external commands executed for 1mn. - - # It's time to schedule a downtime - Schedule service downtime host_1 service_1 ${3600} - - ${result}= check number of downtimes ${1} ${start} ${60} - Should be true ${result} msg=We should have 1 downtime enabled. - - Delete service downtime full ${0} host_1 service_1 - - ${result}= check number of downtimes ${0} ${start} ${60} - Should be true ${result} msg=We should have no downtime enabled. - - Stop Engine - Kindly Stop Broker + [Documentation] A downtime is set on a service, the total number of downtimes is really 1 then we delete this downtime and the number of downtime is 0. + [Tags] Broker Engine downtime + Config Engine ${1} + Engine Config Set Value ${0} log_level_functions trace + Config Broker rrd + Config Broker central + Config Broker module ${1} + Broker Config Log central sql debug + Broker Config Log module0 neb debug + + Clear Retention + ${start} Get Current Date + Start Broker + Start Engine + # Let's wait for the check of external commands + ${content} Create List check_for_external_commands + ${result} Find In Log with Timeout ${engineLog0} ${start} ${content} 60 + Should Be True ${result} No check for external commands executed for 1mn. + + # It's time to schedule a downtime + Schedule service downtime host_1 service_1 ${3600} + + ${result} check number of downtimes ${1} ${start} ${60} + Should be true ${result} We should have 1 downtime enabled. + + Delete service downtime full ${0} host_1 service_1 + + ${result} check number of downtimes ${0} ${start} ${60} + Should be true ${result} We should have no downtime enabled. + + Stop Engine + Kindly Stop Broker BEDTHOSTFIXED - [Documentation] A downtime is set on a host, the total number of downtimes is really 21 (1 for the host and 20 for its 20 services) then we delete this downtime and the number is 0. - [Tags] Broker Engine downtime - Config Engine ${1} - Engine Config Set Value ${0} log_level_functions trace - Config Broker rrd - Config Broker central - Config Broker module ${1} - Broker Config Log central sql debug - Broker Config Log module0 neb debug - Config Broker Sql Output central unified_sql - - Clear Retention - ${start}= Get Current Date - Start Broker - Start Engine - # Let's wait for the check of external commands - ${content}= Create List check_for_external_commands - ${result}= Find In Log with Timeout ${engineLog0} ${start} ${content} 60 - Should Be True ${result} msg=No check for external commands executed for 1mn. - - # It's time to schedule downtimes - Schedule host fixed downtime ${0} host_1 ${3600} - - ${result}= check number of downtimes ${21} ${start} ${60} - Should be true ${result} msg=We should have 21 downtimes (1 host + 20 services) enabled. - - # It's time to delete downtimes - Delete host downtimes ${0} host_1 - - ${result}= check number of downtimes ${0} ${start} ${60} - Should be true ${result} msg=We should have no downtime enabled. - - Stop Engine - Kindly Stop Broker + [Documentation] A downtime is set on a host, the total number of downtimes is really 21 (1 for the host and 20 for its 20 services) then we delete this downtime and the number is 0. + [Tags] Broker Engine downtime + Config Engine ${1} + Engine Config Set Value ${0} log_level_functions trace + Config Broker rrd + Config Broker central + Config Broker module ${1} + Broker Config Log central sql debug + Broker Config Log module0 neb debug + Config Broker Sql Output central unified_sql + + Clear Retention + ${start} Get Current Date + Start Broker + Start Engine + # Let's wait for the check of external commands + ${content} Create List check_for_external_commands + ${result} Find In Log with Timeout ${engineLog0} ${start} ${content} 60 + Should Be True ${result} No check for external commands executed for 1mn. + + # It's time to schedule downtimes + Schedule host fixed downtime ${0} host_1 ${3600} + + ${result} check number of downtimes ${21} ${start} ${60} + Should be true ${result} We should have 21 downtimes (1 host + 20 services) enabled. + + # It's time to delete downtimes + Delete host downtimes ${0} host_1 + + ${result} check number of downtimes ${0} ${start} ${60} + Should be true ${result} We should have no downtime enabled. + + Stop Engine + Kindly Stop Broker + +DTIM + [Documentation] New services with several pollers are created. Then downtimes are set on all configured hosts. This action results on 5250 downtimes if we also count impacted services. Then all these downtimes are removed. This test is done with BBDO 3.0.1 + [Tags] broker engine services host downtimes MON-36711 + Config Engine ${5} ${250} ${20} + Engine Config Set Value ${0} log_level_functions trace + Engine Config Set Value ${1} log_level_functions trace + Engine Config Set Value ${2} log_level_functions trace + Engine Config Set Value ${3} log_level_functions trace + Engine Config Set Value ${4} log_level_functions trace + Config Broker rrd + Config Broker central + Config Broker module ${5} + Broker Config Add Item module0 bbdo_version 3.0.1 + Broker Config Add Item module1 bbdo_version 3.0.1 + Broker Config Add Item module2 bbdo_version 3.0.1 + Broker Config Add Item module3 bbdo_version 3.0.1 + Broker Config Add Item module4 bbdo_version 3.0.1 + Broker Config Add Item central bbdo_version 3.0.1 + Broker Config Add Item rrd bbdo_version 3.0.1 + Config Broker Sql Output central unified_sql + Clear Retention + + ${start} Get Current Date + Start Broker + Start Engine + + # Let's wait for the external command check start + ${content} Create List check_for_external_commands() + ${result} Find In Log With Timeout ${engineLog4} ${start} ${content} 60 + Should Be True ${result} A message telling check_for_external_commands() should be available. + + # It's time to schedule downtimes + FOR ${i} IN RANGE ${50} + Schedule Host Fixed Downtime ${0} host_${i + 1} ${3600} + Schedule Host Fixed Downtime ${1} host_${i + 51} ${3600} + Schedule Host Fixed Downtime ${2} host_${i + 101} ${3600} + Schedule Host Fixed Downtime ${3} host_${i + 151} ${3600} + Schedule Host Fixed Downtime ${4} host_${i + 201} ${3600} + END + + ${result} Check Number Of Downtimes ${5250} ${start} ${60} + Should be true ${result} We should have 5250 downtimes enabled. + + # It's time to delete downtimes + FOR ${i} IN RANGE ${50} + Delete Host Downtimes ${0} host_${i + 1} + Delete Host Downtimes ${1} host_${i + 51} + Delete Host Downtimes ${2} host_${i + 101} + Delete Host Downtimes ${3} host_${i + 151} + Delete Host Downtimes ${4} host_${i + 201} + END + + ${result} Check Number Of Downtimes ${0} ${start} ${60} + Should Be True ${result} There are still some downtimes enabled. + + Stop Engine + Kindly Stop Broker *** Keywords *** Clean Downtimes Before Suite - Clean Before Suite - - Connect To Database pymysql ${DBName} ${DBUser} ${DBPass} ${DBHost} ${DBPort} - ${output}= Execute SQL String DELETE FROM downtimes WHERE deletion_time IS NULL + Clean Before Suite + + Connect To Database pymysql ${DBName} ${DBUser} ${DBPass} ${DBHost} ${DBPort} + ${output} Execute SQL String DELETE FROM downtimes WHERE deletion_time IS NULL diff --git a/tests/resources/resources.robot b/tests/resources/resources.robot index 2254c0eea38..1e4181dc978 100644 --- a/tests/resources/resources.robot +++ b/tests/resources/resources.robot @@ -1,8 +1,28 @@ *** Settings *** -Resource ./db_variables.robot -Library Process -Library OperatingSystem -Library Common.py +Resource ./db_variables.robot +Library Process +Library OperatingSystem +Library Common.py + + +*** Variables *** +${BROKER_LOG} ${VarRoot}/log/centreon-broker +${BROKER_LIB} ${VarRoot}/lib/centreon-broker +${ENGINE_LOG} ${VarRoot}/log/centreon-engine +${SCRIPTS} ${CURDIR}${/}scripts${/} +${centralLog} ${BROKER_LOG}/central-broker-master.log +${moduleLog0} ${BROKER_LOG}/central-module-master0.log +${moduleLog1} ${BROKER_LOG}/central-module-master1.log +${moduleLog2} ${BROKER_LOG}/central-module-master2.log +${moduleLog3} ${BROKER_LOG}/central-module-master3.log +${moduleLog4} ${BROKER_LOG}/central-module-master4.log +${rrdLog} ${BROKER_LOG}/central-rrd-master.log + +${engineLog0} ${ENGINE_LOG}/config0/centengine.log +${engineLog1} ${ENGINE_LOG}/config1/centengine.log +${engineLog2} ${ENGINE_LOG}/config2/centengine.log +${engineLog3} ${ENGINE_LOG}/config3/centengine.log +${engineLog4} ${ENGINE_LOG}/config4/centengine.log *** Keywords *** Config BBDO3 @@ -249,20 +269,3 @@ Clear Metrics Execute SQL String DELETE FROM metrics Execute SQL String DELETE FROM index_data Execute SQL String DELETE FROM data_bin - -*** Variables *** -${BROKER_LOG} ${VarRoot}/log/centreon-broker -${BROKER_LIB} ${VarRoot}/lib/centreon-broker -${ENGINE_LOG} ${VarRoot}/log/centreon-engine -${SCRIPTS} ${CURDIR}${/}scripts${/} -${centralLog} ${BROKER_LOG}/central-broker-master.log -${moduleLog0} ${BROKER_LOG}/central-module-master0.log -${moduleLog1} ${BROKER_LOG}/central-module-master1.log -${moduleLog2} ${BROKER_LOG}/central-module-master2.log -${moduleLog3} ${BROKER_LOG}/central-module-master3.log -${rrdLog} ${BROKER_LOG}/central-rrd-master.log - -${engineLog0} ${ENGINE_LOG}/config0/centengine.log -${engineLog1} ${ENGINE_LOG}/config1/centengine.log -${engineLog2} ${ENGINE_LOG}/config2/centengine.log -${engineLog3} ${ENGINE_LOG}/config3/centengine.log