Skip to content

Commit

Permalink
fix(engine): no error message when threshold file is not found while … (
Browse files Browse the repository at this point in the history
#1161)

REFS: MON-35580

---------

Co-authored-by: David Boucher <[email protected]>
  • Loading branch information
bouda1 authored Feb 23, 2024
1 parent 7e120db commit 11570c5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
8 changes: 5 additions & 3 deletions engine/src/anomalydetection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1120,9 +1120,11 @@ void anomalydetection::init_thresholds() {
try {
t.open(_thresholds_file);
} catch (const std::system_error& e) {
SPDLOG_LOGGER_ERROR(log_v2::config(),
"Fail to read thresholds file '{}' : {}",
_thresholds_file, e.code().message());
if (!verify_config) {
SPDLOG_LOGGER_ERROR(log_v2::config(),
"Fail to read thresholds file '{}' : {}",
_thresholds_file, e.code().message());
}
return;
} catch (const std::exception& e) {
SPDLOG_LOGGER_ERROR(log_v2::config(),
Expand Down
20 changes: 20 additions & 0 deletions tests/broker-engine/anomaly-detection.robot
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ ANO_NOFILE
Stop Broker True
Stop Engine

ANO_NOFILE_VERIF_CONFIG_NO_ERROR
[Documentation] an anomaly detection without threshold file doesn't display error on config check
[Tags] broker engine anomaly MON-35580
Config Engine ${1} ${50} ${20}
Create Anomaly Detection ${0} ${1} ${1} metric
Remove File /tmp/anomaly_threshold.json
Clear Retention
Create Directory ${ENGINE_LOG}/config0
Start Process
... /usr/sbin/centengine
... -v
... ${EtcRoot}/centreon-engine/config0/centengine.cfg
... alias=e0
... stderr=${engineLog0}
... stdout=${engineLog0}
${result} Wait For Process e0 30
Should Be Equal As Integers ${result.rc} 0 engine not gracefully stopped
${content} Grep File ${engineLog0} Fail to read thresholds file
Should Be True len("""${content}""") < 2 anomalydetection error message must not be found

ANO_TOO_OLD_FILE
[Documentation] an anomaly detection with an oldest threshold file must be in unknown state
[Tags] broker engine anomaly
Expand Down

0 comments on commit 11570c5

Please sign in to comment.