From ea490fe8cab61b512a34ee2f806f6ae99caaf339 Mon Sep 17 00:00:00 2001 From: tuntoja Date: Mon, 18 Mar 2024 15:11:41 +0100 Subject: [PATCH 1/4] chore(release): bump collect version to 23.04.10 --- .version | 2 ++ CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .version diff --git a/.version b/.version new file mode 100644 index 0000000000..c135e9c81a --- /dev/null +++ b/.version @@ -0,0 +1,2 @@ +MAJOR=23.04 +MINOR=10 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2538bc52a2..aa80be6018 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,7 +116,7 @@ endif() # Version. set(COLLECT_MAJOR 23) set(COLLECT_MINOR 04) -set(COLLECT_PATCH 9) +set(COLLECT_PATCH 10) set(COLLECT_VERSION "${COLLECT_MAJOR}.${COLLECT_MINOR}.${COLLECT_PATCH}") add_definitions(-DCENTREON_CONNECTOR_VERSION=\"${COLLECT_VERSION}\") From 9d42fc9ab69c4345861ab92e75f231e86e457ab5 Mon Sep 17 00:00:00 2001 From: David Boucher Date: Mon, 18 Mar 2024 13:41:54 +0100 Subject: [PATCH 2/4] enh(bam): sometimes kpi creation may break BA's consistency REFS: MON-38134 --- broker/bam/src/ba.cc | 2 +- broker/bam/src/configuration/applier/kpi.cc | 8 +- tests/bam/bam_pb.robot | 162 ++++++++++++++++++++ tests/resources/Common.py | 22 ++- tests/resources/Engine.py | 15 +- tests/resources/db_conf.py | 15 +- tests/resources/resources.robot | 17 ++ 7 files changed, 234 insertions(+), 7 deletions(-) diff --git a/broker/bam/src/ba.cc b/broker/bam/src/ba.cc index 88f80ca4b0..2d7bb098a8 100644 --- a/broker/bam/src/ba.cc +++ b/broker/bam/src/ba.cc @@ -619,7 +619,7 @@ void ba::update_from(computable* child, io::stream* visitor) { kpi_child->get_id()); bool changed = _apply_changes(kpi_child, new_hard_impact, new_soft_impact, kpi_in_downtime); - SPDLOG_LOGGER_TRACE(log_v2::bam(), "BA has changed: {}", changed); + SPDLOG_LOGGER_TRACE(log_v2::bam(), "BA {} has changed: {}", _id, changed); // Check for inherited downtimes. _compute_inherited_downtime(visitor); diff --git a/broker/bam/src/configuration/applier/kpi.cc b/broker/bam/src/configuration/applier/kpi.cc index 73c4ad5135..01efa6a1db 100644 --- a/broker/bam/src/configuration/applier/kpi.cc +++ b/broker/bam/src/configuration/applier/kpi.cc @@ -93,10 +93,10 @@ void applier::kpi::apply(bam::configuration::state::kpis const& my_kpis, bam::configuration::state::kpis to_create(my_kpis); // Iterate through configuration. - for (bam::configuration::state::kpis::iterator it(to_create.begin()), - end(to_create.end()); + for (bam::configuration::state::kpis::iterator it = to_create.begin(), + end = to_create.end(); it != end;) { - std::map::iterator cfg_it(to_delete.find(it->first)); + std::map::iterator cfg_it = to_delete.find(it->first); // Found = modify (or not). if (cfg_it != to_delete.end()) { // Configuration mismatch, modify object @@ -353,6 +353,8 @@ void applier::kpi::_resolve_kpi(configuration::kpi const& cfg, my_ba->add_impact(kpi); kpi->add_parent(my_ba); + /* The propagation is forced to be sure all the ba is coherent. */ + my_ba->notify_parents_of_change(nullptr); } /** diff --git a/tests/bam/bam_pb.robot b/tests/bam/bam_pb.robot index e3d9e9f651..4fb5326e49 100644 --- a/tests/bam/bam_pb.robot +++ b/tests/bam/bam_pb.robot @@ -1113,6 +1113,147 @@ BA_RATIO_PERCENT_BA_4_SERVICE [Teardown] Run Keywords Stop Engine AND Kindly Stop Broker +BA_CHANGED + [Documentation] A BA of type worst is configured with one service kpi. + ... Then it is modified so that the service kpi is replaced + ... by a boolean rule kpi. When cbd is reloaded, the BA is + ... well updated. + [Tags] MON-34895 + Ctn Bam Init + + @{svc} Set Variable ${{ [("host_16", "service_302")] }} + ${ba} Ctn Create Ba With Services test worst ${svc} + + Ctn Start Broker + ${start} Get Current Date + Ctn Start Engine + # Let's wait for the external command check start + ${content} Create List check_for_external_commands() + ${result} Ctn Find In Log With Timeout ${engineLog0} ${start} ${content} 60 + Should Be True ${result} A message telling check_for_external_commands() should be available. + + # Both services ${state} => The BA parent is ${state} + Ctn Process Service Result Hard + ... host_16 + ... service_302 + ... 0 + ... output OK for service 302 + + ${result} Ctn Check Ba Status With Timeout test 0 30 + Ctn Dump Ba On Error ${result} ${ba[0]} + Should Be True ${result} The BA test is not OK as expected + + Ctn Remove Service Kpi ${ba[0]} host_16 service_302 + Ctn Add Boolean Kpi + ... ${ba[0]} + ... {host_16 service_302} {IS} {OK} + ... False + ... 100 + + Ctn Reload Broker + Remove File /tmp/ba.dot + Ctn Broker Get Ba 51001 ${ba[0]} /tmp/ba.dot + Wait Until Created /tmp/ba.dot + ${result} Grep File /tmp/ba.dot Boolean exp + Should Not Be Empty ${result} + + Ctn Add Boolean Kpi + ... ${ba[0]} + ... {host_16 service_303} {IS} {WARNING} + ... False + ... 100 + + Ctn Reload Broker + Remove File /tmp/ba.dot + Ctn Broker Get Ba 51001 ${ba[0]} /tmp/ba.dot + Wait Until Created /tmp/ba.dot + ${result} Grep File /tmp/ba.dot BOOL Service (16, 303) + Should Not Be Empty ${result} + [Teardown] Run Keywords Ctn Stop engine AND Ctn Kindly Stop Broker + + +BA_IMPACT_IMPACT + [Documentation] A BA of type impact is defined with two BAs of type impact + ... as children. The first child has an impact of 90 and the + ... second one of 10. When they are impacting both, the + ... parent should be critical. When they are not impacting, + ... the parent should be ok. + [Tags] MON-34895 + Ctn Bam Init + + ${parent_ba} Ctn Create Ba parent impact 20 99 + @{svc1} Set Variable ${{ [("host_16", "service_302")] }} + ${child1_ba} Ctn Create Ba child1 impact 20 99 + Ctn Add Service Kpi host_16 service_302 ${child1_ba[0]} 100 2 3 + ${child2_ba} Ctn Create Ba child2 impact 20 99 + Ctn Add Service Kpi host_16 service_303 ${child2_ba[0]} 100 2 3 + + Ctn Add Ba Kpi ${child1_ba[0]} ${parent_ba[0]} 90 2 3 + Ctn Add Ba Kpi ${child2_ba[0]} ${parent_ba[0]} 10 2 3 + + Ctn Start Broker + ${start} Get Current Date + Ctn Start Engine + # Let's wait for the external command check start + ${content} Create List check_for_external_commands() + ${result} Ctn Find In Log With Timeout ${engineLog0} ${start} ${content} 60 + Should Be True ${result} A message telling check_for_external_commands() should be available. + + FOR ${state} ${value} IN + ... OK 0 + ... CRITICAL 2 + ... OK 0 + ... CRITICAL 2 + # Both services ${state} => The BA parent is ${state} + Ctn Process Service Result Hard + ... host_16 + ... service_302 + ... ${value} + ... output ${state} for service 302 + + Ctn Process Service Result Hard + ... host_16 + ... service_303 + ... ${value} + ... output ${state} for service 302 + + ${result} Ctn Check Service Status With Timeout host_16 service_302 ${value} 60 HARD + Should Be True ${result} The service (host_16,service_302) is not ${state} as expected + ${result} Ctn Check Service Status With Timeout host_16 service_303 ${value} 60 HARD + Should Be True ${result} The service (host_16,service_303) is not ${state} as expected + + ${result} Ctn Check Ba Status With Timeout child1 ${value} 30 + Ctn Dump Ba On Error ${result} ${child1_ba[0]} + Should Be True ${result} The BA child1 is not ${state} as expected + + ${result} Ctn Check Ba Status With Timeout child2 ${value} 30 + Ctn Dump Ba On Error ${result} ${child2_ba[0]} + Should Be True ${result} The BA child2 is not ${state} as expected + + ${result} Ctn Check Ba Status With Timeout parent ${value} 30 + Ctn Dump Ba On Error ${result} ${parent_ba[0]} + Should Be True ${result} The BA parent is not ${state} as expected + + Remove Files /tmp/parent1.dot /tmp/parent2.dot + Ctn Broker Get Ba 51001 ${parent_ba[0]} /tmp/parent1.dot + Wait Until Created /tmp/parent1.dot + + ${start} Get Current Date + Ctn Reload Broker + ${content} Create List Inherited downtimes and BA states restored + ${result} Ctn Find In Log With Timeout ${centralLog} ${start} ${content} 60 + Should Be True ${result} It seems that no cache has been restored into BAM. + + Ctn Broker Get Ba 51001 ${parent_ba[0]} /tmp/parent2.dot + Wait Until Created /tmp/parent2.dot + + ${result} Ctn Compare Dot Files /tmp/parent1.dot /tmp/parent2.dot + Should Be True ${result} The BA changed during Broker reload. + END + + [Teardown] Run Keywords Ctn Stop engine AND Ctn Kindly Stop Broker + + *** Keywords *** BAM Setup Stop Processes @@ -1124,3 +1265,24 @@ BAM Setup Execute SQL String DELETE FROM mod_bam_reporting_ba_events Execute SQL String ALTER TABLE mod_bam_reporting_ba_events AUTO_INCREMENT = 1 Execute SQL String SET GLOBAL FOREIGN_KEY_CHECKS=1 + +Ctn Bam Init + Ctn Clear Commands Status + Ctn Clear Retention + Ctn Clear Db Conf mod_bam + Ctn Config Broker module + Ctn Config Broker central + Ctn Config Broker rrd + Ctn Broker Config Log central bam trace + Ctn Broker Config Log central sql trace + Ctn Broker Config Log central config trace + Ctn Broker Config Source Log central 1 + Ctn Config BBDO3 ${1} + Ctn Config Engine ${1} + # This is to avoid parasite status. + Ctn Set Services Passive ${0} service_30. + + Ctn Config Broker Sql Output central unified_sql + Ctn Clone Engine Config To Db + Ctn Add Bam Config To Engine + Ctn Add Bam Config To Broker central diff --git a/tests/resources/Common.py b/tests/resources/Common.py index 9824ee8175..beaeade338 100644 --- a/tests/resources/Common.py +++ b/tests/resources/Common.py @@ -925,7 +925,27 @@ def clear_db(table: str): connection.commit() -def check_service_severity_with_timeout(host_id: int, service_id: int, severity_id, timeout: int): +def ctn_clear_db_conf(table: str): + """ + Erase a table's sontent in the configuration database. + + Args: + table: The table to clear. + """ + connection = pymysql.connect(host=DB_HOST, + user=DB_USER, + password=DB_PASS, + database=DB_NAME_CONF, + charset='utf8mb4', + cursorclass=pymysql.cursors.DictCursor) + + with connection: + with connection.cursor() as cursor: + cursor.execute(f"DELETE FROM {table}") + connection.commit() + + +def ctn_check_service_severity_with_timeout(host_id: int, service_id: int, severity_id, timeout: int): limit = time.time() + timeout while time.time() < limit: connection = pymysql.connect(host=DB_HOST, diff --git a/tests/resources/Engine.py b/tests/resources/Engine.py index 5223c9b8b7..cb5767687a 100755 --- a/tests/resources/Engine.py +++ b/tests/resources/Engine.py @@ -1275,7 +1275,20 @@ def add_service_kpi(host: str, serv: str, id_ba: int, critical_impact: int, warn host, serv, id_ba, critical_impact, warning_impact, unknown_impact) -def get_command_id(service: int): +def ctn_remove_service_kpi(id_ba: int, host: str, svc: str): + """ + Remove a service kpi given by hostname/service description from a ba given by its id. + + Args: + id_ba: The BA ID. + host: the host name. + svc: the service description. + """ + global dbconf + dbconf.ctn_remove_service_kpi(id_ba, host, svc) + + +def ctn_get_command_id(service: int): """ Get the command ID of the service with the given ID. diff --git a/tests/resources/db_conf.py b/tests/resources/db_conf.py index 917fb195a6..8d5808a8ac 100755 --- a/tests/resources/db_conf.py +++ b/tests/resources/db_conf.py @@ -285,7 +285,20 @@ def add_service_kpi(self, host: str, serv: str, id_ba: int, critical_impact: int connection.commit() - def add_boolean_kpi(self, id_ba: int, expression: str, impact_if: bool, critical_impact: int): + def ctn_remove_service_kpi(self, id_ba: int, host: str, svc: str): + connection = pymysql.connect(host=DB_HOST, + user=DB_USER, + password=DB_PASS, + database=DB_NAME_CONF, + charset='utf8mb4', + cursorclass=pymysql.cursors.DictCursor) + + with connection: + with connection.cursor() as cursor: + cursor.execute(f"DELETE FROM mod_bam_kpi WHERE host_id={self.host[host]} AND service_id={self.service[svc]} AND id_ba={id_ba}") + connection.commit() + + def ctn_add_boolean_kpi(self, id_ba: int, expression: str, impact_if: bool, critical_impact: int): connection = pymysql.connect(host=DB_HOST, user=DB_USER, password=DB_PASS, diff --git a/tests/resources/resources.robot b/tests/resources/resources.robot index 1e4181dc97..21389a7800 100644 --- a/tests/resources/resources.robot +++ b/tests/resources/resources.robot @@ -269,3 +269,20 @@ Clear Metrics Execute SQL String DELETE FROM metrics Execute SQL String DELETE FROM index_data Execute SQL String DELETE FROM data_bin + +Ctn Dump Ba On Error + [Arguments] ${result} ${ba_id} + IF not ${result} + Ctn Save Logs + Ctn Broker Get Ba 51001 ${ba_id} failed/${Test Name}/ba_${ba_id}.dot + END + +Ctn Process Service Result Hard + [Arguments] ${host} ${svc} ${state} ${output} + Repeat Keyword + ... 3 times + ... Ctn Process Service Check Result + ... ${host} + ... ${svc} + ... ${state} + ... ${output} From 94b9f870515e42eff83e3d953899d814732721b4 Mon Sep 17 00:00:00 2001 From: David Boucher Date: Mon, 18 Mar 2024 16:05:34 +0100 Subject: [PATCH 3/4] fix(tests): conflict to fix in tests --- tests/bam/bam_pb.robot | 122 ++++++++++++++++---------------- tests/resources/resources.robot | 10 +-- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/tests/bam/bam_pb.robot b/tests/bam/bam_pb.robot index 4fb5326e49..9faf93b841 100644 --- a/tests/bam/bam_pb.robot +++ b/tests/bam/bam_pb.robot @@ -1119,57 +1119,57 @@ BA_CHANGED ... by a boolean rule kpi. When cbd is reloaded, the BA is ... well updated. [Tags] MON-34895 - Ctn Bam Init + Bam Init @{svc} Set Variable ${{ [("host_16", "service_302")] }} - ${ba} Ctn Create Ba With Services test worst ${svc} + ${ba} Create Ba With Services test worst ${svc} - Ctn Start Broker + Start Broker ${start} Get Current Date - Ctn Start Engine + Start Engine # Let's wait for the external command check start ${content} Create List check_for_external_commands() - ${result} Ctn Find In Log With Timeout ${engineLog0} ${start} ${content} 60 + ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 Should Be True ${result} A message telling check_for_external_commands() should be available. # Both services ${state} => The BA parent is ${state} - Ctn Process Service Result Hard + Process Service Result Hard ... host_16 ... service_302 ... 0 ... output OK for service 302 - ${result} Ctn Check Ba Status With Timeout test 0 30 - Ctn Dump Ba On Error ${result} ${ba[0]} + ${result} Check Ba Status With Timeout test 0 30 + Dump Ba On Error ${result} ${ba[0]} Should Be True ${result} The BA test is not OK as expected - Ctn Remove Service Kpi ${ba[0]} host_16 service_302 - Ctn Add Boolean Kpi + Remove Service Kpi ${ba[0]} host_16 service_302 + Add Boolean Kpi ... ${ba[0]} ... {host_16 service_302} {IS} {OK} ... False ... 100 - Ctn Reload Broker + Reload Broker Remove File /tmp/ba.dot - Ctn Broker Get Ba 51001 ${ba[0]} /tmp/ba.dot + Broker Get Ba 51001 ${ba[0]} /tmp/ba.dot Wait Until Created /tmp/ba.dot ${result} Grep File /tmp/ba.dot Boolean exp Should Not Be Empty ${result} - Ctn Add Boolean Kpi + Add Boolean Kpi ... ${ba[0]} ... {host_16 service_303} {IS} {WARNING} ... False ... 100 - Ctn Reload Broker + Reload Broker Remove File /tmp/ba.dot - Ctn Broker Get Ba 51001 ${ba[0]} /tmp/ba.dot + Broker Get Ba 51001 ${ba[0]} /tmp/ba.dot Wait Until Created /tmp/ba.dot ${result} Grep File /tmp/ba.dot BOOL Service (16, 303) Should Not Be Empty ${result} - [Teardown] Run Keywords Ctn Stop engine AND Ctn Kindly Stop Broker + [Teardown] Run Keywords Stop engine AND Kindly Stop Broker BA_IMPACT_IMPACT @@ -1179,24 +1179,24 @@ BA_IMPACT_IMPACT ... parent should be critical. When they are not impacting, ... the parent should be ok. [Tags] MON-34895 - Ctn Bam Init + Bam Init - ${parent_ba} Ctn Create Ba parent impact 20 99 + ${parent_ba} Create Ba parent impact 20 99 @{svc1} Set Variable ${{ [("host_16", "service_302")] }} - ${child1_ba} Ctn Create Ba child1 impact 20 99 - Ctn Add Service Kpi host_16 service_302 ${child1_ba[0]} 100 2 3 - ${child2_ba} Ctn Create Ba child2 impact 20 99 - Ctn Add Service Kpi host_16 service_303 ${child2_ba[0]} 100 2 3 + ${child1_ba} Create Ba child1 impact 20 99 + Add Service Kpi host_16 service_302 ${child1_ba[0]} 100 2 3 + ${child2_ba} Create Ba child2 impact 20 99 + Add Service Kpi host_16 service_303 ${child2_ba[0]} 100 2 3 - Ctn Add Ba Kpi ${child1_ba[0]} ${parent_ba[0]} 90 2 3 - Ctn Add Ba Kpi ${child2_ba[0]} ${parent_ba[0]} 10 2 3 + Add Ba Kpi ${child1_ba[0]} ${parent_ba[0]} 90 2 3 + Add Ba Kpi ${child2_ba[0]} ${parent_ba[0]} 10 2 3 - Ctn Start Broker + Start Broker ${start} Get Current Date - Ctn Start Engine + Start Engine # Let's wait for the external command check start ${content} Create List check_for_external_commands() - ${result} Ctn Find In Log With Timeout ${engineLog0} ${start} ${content} 60 + ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 Should Be True ${result} A message telling check_for_external_commands() should be available. FOR ${state} ${value} IN @@ -1205,53 +1205,53 @@ BA_IMPACT_IMPACT ... OK 0 ... CRITICAL 2 # Both services ${state} => The BA parent is ${state} - Ctn Process Service Result Hard + Process Service Result Hard ... host_16 ... service_302 ... ${value} ... output ${state} for service 302 - Ctn Process Service Result Hard + Process Service Result Hard ... host_16 ... service_303 ... ${value} ... output ${state} for service 302 - ${result} Ctn Check Service Status With Timeout host_16 service_302 ${value} 60 HARD + ${result} Check Service Status With Timeout host_16 service_302 ${value} 60 HARD Should Be True ${result} The service (host_16,service_302) is not ${state} as expected - ${result} Ctn Check Service Status With Timeout host_16 service_303 ${value} 60 HARD + ${result} Check Service Status With Timeout host_16 service_303 ${value} 60 HARD Should Be True ${result} The service (host_16,service_303) is not ${state} as expected - ${result} Ctn Check Ba Status With Timeout child1 ${value} 30 - Ctn Dump Ba On Error ${result} ${child1_ba[0]} + ${result} Check Ba Status With Timeout child1 ${value} 30 + Dump Ba On Error ${result} ${child1_ba[0]} Should Be True ${result} The BA child1 is not ${state} as expected - ${result} Ctn Check Ba Status With Timeout child2 ${value} 30 - Ctn Dump Ba On Error ${result} ${child2_ba[0]} + ${result} Check Ba Status With Timeout child2 ${value} 30 + Dump Ba On Error ${result} ${child2_ba[0]} Should Be True ${result} The BA child2 is not ${state} as expected - ${result} Ctn Check Ba Status With Timeout parent ${value} 30 - Ctn Dump Ba On Error ${result} ${parent_ba[0]} + ${result} Check Ba Status With Timeout parent ${value} 30 + Dump Ba On Error ${result} ${parent_ba[0]} Should Be True ${result} The BA parent is not ${state} as expected Remove Files /tmp/parent1.dot /tmp/parent2.dot - Ctn Broker Get Ba 51001 ${parent_ba[0]} /tmp/parent1.dot + Broker Get Ba 51001 ${parent_ba[0]} /tmp/parent1.dot Wait Until Created /tmp/parent1.dot ${start} Get Current Date - Ctn Reload Broker + Reload Broker ${content} Create List Inherited downtimes and BA states restored - ${result} Ctn Find In Log With Timeout ${centralLog} ${start} ${content} 60 + ${result} Find In Log With Timeout ${centralLog} ${start} ${content} 60 Should Be True ${result} It seems that no cache has been restored into BAM. - Ctn Broker Get Ba 51001 ${parent_ba[0]} /tmp/parent2.dot + Broker Get Ba 51001 ${parent_ba[0]} /tmp/parent2.dot Wait Until Created /tmp/parent2.dot - ${result} Ctn Compare Dot Files /tmp/parent1.dot /tmp/parent2.dot + ${result} Compare Dot Files /tmp/parent1.dot /tmp/parent2.dot Should Be True ${result} The BA changed during Broker reload. END - [Teardown] Run Keywords Ctn Stop engine AND Ctn Kindly Stop Broker + [Teardown] Run Keywords Stop engine AND Kindly Stop Broker *** Keywords *** @@ -1266,23 +1266,23 @@ BAM Setup Execute SQL String ALTER TABLE mod_bam_reporting_ba_events AUTO_INCREMENT = 1 Execute SQL String SET GLOBAL FOREIGN_KEY_CHECKS=1 -Ctn Bam Init - Ctn Clear Commands Status - Ctn Clear Retention - Ctn Clear Db Conf mod_bam - Ctn Config Broker module - Ctn Config Broker central - Ctn Config Broker rrd - Ctn Broker Config Log central bam trace - Ctn Broker Config Log central sql trace - Ctn Broker Config Log central config trace - Ctn Broker Config Source Log central 1 - Ctn Config BBDO3 ${1} - Ctn Config Engine ${1} +Bam Init + Clear Commands Status + Clear Retention + Clear Db Conf mod_bam + Config Broker module + Config Broker central + Config Broker rrd + Broker Config Log central bam trace + Broker Config Log central sql trace + Broker Config Log central config trace + Broker Config Source Log central 1 + Config BBDO3 ${1} + Config Engine ${1} # This is to avoid parasite status. - Ctn Set Services Passive ${0} service_30. + Set Services Passive ${0} service_30. - Ctn Config Broker Sql Output central unified_sql - Ctn Clone Engine Config To Db - Ctn Add Bam Config To Engine - Ctn Add Bam Config To Broker central + Config Broker Sql Output central unified_sql + Clone Engine Config To Db + Add Bam Config To Engine + Add Bam Config To Broker central diff --git a/tests/resources/resources.robot b/tests/resources/resources.robot index 21389a7800..ba585b9fc8 100644 --- a/tests/resources/resources.robot +++ b/tests/resources/resources.robot @@ -270,18 +270,18 @@ Clear Metrics Execute SQL String DELETE FROM index_data Execute SQL String DELETE FROM data_bin -Ctn Dump Ba On Error +Dump Ba On Error [Arguments] ${result} ${ba_id} IF not ${result} - Ctn Save Logs - Ctn Broker Get Ba 51001 ${ba_id} failed/${Test Name}/ba_${ba_id}.dot + Save Logs + Broker Get Ba 51001 ${ba_id} failed/${Test Name}/ba_${ba_id}.dot END -Ctn Process Service Result Hard +Process Service Result Hard [Arguments] ${host} ${svc} ${state} ${output} Repeat Keyword ... 3 times - ... Ctn Process Service Check Result + ... Process Service Check Result ... ${host} ... ${svc} ... ${state} From f6fe0c98664504802600e07748a3ebd897f28d8a Mon Sep 17 00:00:00 2001 From: David Boucher Date: Mon, 18 Mar 2024 16:06:12 +0100 Subject: [PATCH 4/4] fix(tests): Ctn prefix too early for a hostfix --- tests/resources/Common.py | 4 ++-- tests/resources/Engine.py | 6 +++--- tests/resources/db_conf.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/resources/Common.py b/tests/resources/Common.py index beaeade338..aac30b6ae0 100644 --- a/tests/resources/Common.py +++ b/tests/resources/Common.py @@ -925,7 +925,7 @@ def clear_db(table: str): connection.commit() -def ctn_clear_db_conf(table: str): +def clear_db_conf(table: str): """ Erase a table's sontent in the configuration database. @@ -945,7 +945,7 @@ def ctn_clear_db_conf(table: str): connection.commit() -def ctn_check_service_severity_with_timeout(host_id: int, service_id: int, severity_id, timeout: int): +def check_service_severity_with_timeout(host_id: int, service_id: int, severity_id, timeout: int): limit = time.time() + timeout while time.time() < limit: connection = pymysql.connect(host=DB_HOST, diff --git a/tests/resources/Engine.py b/tests/resources/Engine.py index cb5767687a..d47568c8e7 100755 --- a/tests/resources/Engine.py +++ b/tests/resources/Engine.py @@ -1275,7 +1275,7 @@ def add_service_kpi(host: str, serv: str, id_ba: int, critical_impact: int, warn host, serv, id_ba, critical_impact, warning_impact, unknown_impact) -def ctn_remove_service_kpi(id_ba: int, host: str, svc: str): +def remove_service_kpi(id_ba: int, host: str, svc: str): """ Remove a service kpi given by hostname/service description from a ba given by its id. @@ -1285,10 +1285,10 @@ def ctn_remove_service_kpi(id_ba: int, host: str, svc: str): svc: the service description. """ global dbconf - dbconf.ctn_remove_service_kpi(id_ba, host, svc) + dbconf.remove_service_kpi(id_ba, host, svc) -def ctn_get_command_id(service: int): +def get_command_id(service: int): """ Get the command ID of the service with the given ID. diff --git a/tests/resources/db_conf.py b/tests/resources/db_conf.py index 8d5808a8ac..5f9ef7ea41 100755 --- a/tests/resources/db_conf.py +++ b/tests/resources/db_conf.py @@ -285,7 +285,7 @@ def add_service_kpi(self, host: str, serv: str, id_ba: int, critical_impact: int connection.commit() - def ctn_remove_service_kpi(self, id_ba: int, host: str, svc: str): + def remove_service_kpi(self, id_ba: int, host: str, svc: str): connection = pymysql.connect(host=DB_HOST, user=DB_USER, password=DB_PASS, @@ -298,7 +298,7 @@ def ctn_remove_service_kpi(self, id_ba: int, host: str, svc: str): cursor.execute(f"DELETE FROM mod_bam_kpi WHERE host_id={self.host[host]} AND service_id={self.service[svc]} AND id_ba={id_ba}") connection.commit() - def ctn_add_boolean_kpi(self, id_ba: int, expression: str, impact_if: bool, critical_impact: int): + def add_boolean_kpi(self, id_ba: int, expression: str, impact_if: bool, critical_impact: int): connection = pymysql.connect(host=DB_HOST, user=DB_USER, password=DB_PASS,