Skip to content

Commit

Permalink
fix(Gorgone): use default engine cmd file.
Browse files Browse the repository at this point in the history
Gorgone don't seem to correctly take the configuration modules:engine:command_file. The default /var/lib/centreon-engine/rw/centengine.cmd is used instead, this should be investigated in a separate ticket.

Refs:MON-144643
  • Loading branch information
Evan-Adam committed Sep 23, 2024
1 parent 5047cec commit 063aae4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gorgone/tests/robot/config/engine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ gorgone:
- name: engine
package: "gorgone::modules::centreon::engine::hooks"
enable: true
command_file: "/var/lib/centreon-engine/rw/centengine_poller.cmd"
command_file: "/var/lib/centreon-engine/rw/centengine.cmd"
36 changes: 21 additions & 15 deletions gorgone/tests/robot/tests/centreon/legacycmd.robot
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@ Legacycmd Teardown

Push Engine And vmware Configuration
[Arguments] ${comm}= ${poller_id}=2
Copy File ${CURDIR}${/}legacycmd${/}centreon_vmware.json /var/cache/centreon/config/vmware/${poller_id}/
Copy File ${CURDIR}${/}legacycmd${/}broker.cfg /var/cache/centreon/config/broker/${poller_id}/
Copy File ${CURDIR}${/}legacycmd${/}engine-hosts.cfg /var/cache/centreon/config/engine/${poller_id}/

Copy File ${CURDIR}${/}legacycmd${/}centreon_vmware.json /var/cache/centreon/config/vmware/${poller_id}/
Copy File ${CURDIR}${/}legacycmd${/}broker.cfg /var/cache/centreon/config/broker/${poller_id}/
Copy File ${CURDIR}${/}legacycmd${/}engine-hosts.cfg /var/cache/centreon/config/engine/${poller_id}/
# we change all the configuration files to be sure it was copied in this run and not a rest of another test.
Run sed -i -e 's/@COMMUNICATION_MODE@/${comm}/g' /var/cache/centreon/config/vmware/${poller_id}/centreon_vmware.json
Run sed -i -e 's/@COMMUNICATION_MODE@/${comm}/g' /var/cache/centreon/config/broker/${poller_id}/broker.cfg
Run sed -i -e 's/@COMMUNICATION_MODE@/${comm}/g' /var/cache/centreon/config/engine/${poller_id}/engine.cfg
Run sed -i -e 's/@COMMUNICATION_MODE@/${comm}/g' /var/cache/centreon/config/vmware/${poller_id}/centreon_vmware.json
Run sed -i -e 's/@COMMUNICATION_MODE@/${comm}/g' /var/cache/centreon/config/broker/${poller_id}/broker.cfg
Run sed -i -e 's/@COMMUNICATION_MODE@/${comm}/g' /var/cache/centreon/config/engine/${poller_id}/engine-hosts.cfg
Run chown www-data:www-data /var/cache/centreon/config/*/${poller_id}/*
Run chmod 644 /var/cache/centreon/config/*/${poller_id}/*

# gorgone central should get these files, and send it to poller in /etc/centreon/, /etc/centreon-broker/, /etc/centreon-engine/
${log_query} Create List /var/cache/centreon/config/vmware/2/centreon_vmware.json
${log_query} Create List centreon_vmware.json
# SENDCFGFILE say to gorgone to push conf to poller for a poller id.
Run echo SENDCFGFILE:${poller_id} > /var/lib/centreon/centcore/random.cmd
${log_status} Ctn Find In Log With Timeout log=/var/log/centreon-gorgone/${comm}_gorgone_central/gorgoned.log content=${log_query} regex=0 timeout=20
Expand All @@ -58,35 +61,38 @@ Push Engine And vmware Configuration
Should Be Equal As Strings ${res} {"communication mode": "${comm}"} data in /etc/centreon/centreon_vmware.json is not correct.
# check the user/group and permission are right. as gorgone run as root in the tests and as centreon-gorgone in prod, this might be different from real life.
${vmware_stat}= Run stat -c "%a %U %G" /etc/centreon/centreon_vmware.json
Should Be Equal As Strings ${vmware_stat} 664 centreon-gorgone centreon
Should Be Equal As Strings ${vmware_stat} 644 centreon-gorgone centreon for vmware file

# check engine conf file
${res}= Run cat /etc/centreon-engine/engine-hosts.cfg
Should Be Equal As Strings ${res} Engine conf, communicationmode:${comm} data in /etc/centreon-engine/engine-hosts.cfg is not correct.
${vmware_stat}= Run stat -c "%a %U %G" /etc/centreon-engine/engine-hosts.cfg
Should Be Equal As Strings ${vmware_stat} 664 centreon-engine centreon
Should Be Equal As Strings ${vmware_stat} 644 centreon-engine centreon

#check Broker conf file
${res}= Run cat /etc/centreon-broker/broker.cfg
Should Be Equal As Strings ${res} Broker conf, communication mode:${comm} data in /etc/centreon-broker/broker.cfg is not correct.
${vmware_stat}= Run stat -c "%a %U %G" /etc/centreon-broker/broker.cfg
Should Be Equal As Strings ${vmware_stat} 664 centreon-broker centreon
Should Be Equal As Strings ${vmware_stat} 644 centreon-broker centreon

Force Check Execution On Poller
[Arguments] ${comm}=

# @TODO: This pipe name seem hard coded somewhere in gorgone, changing it is the engine.yaml configuration don't work.
# this should be investigated, maybe some other configuration have the same problem too ?
${process} Start Process
... /usr/bin/perl
... ${CURDIR}${/}..${/}..${/}..${/}..${/}contrib${/}named_pipe_reader.pl
... --pipename
... /var/lib/centreon-engine/rw/centengine_poller.cmd
... /var/lib/centreon-engine/rw/centengine.cmd
... --logfile
... /var/log/centreon-gorgone/${comm}_gorgone_central/legacycmd-pipe-poller.log
... alias=pipeWatcher_${comm}

Sleep 0.5
${forced_check_command}= Set Variable EXTERNALCMD:2:[1724242926] SCHEDULE_FORCED_SVC_CHECK;local2_${comm};Cpu;1724242926
Run echo "${forced_check_command}" > /var/lib/centreon/centcore/random.cmd
${date}= Get Time
${forced_check_command}= Set Variable SCHEDULE_FORCED_SVC_CHECK;local2_${comm};Cpu;${date}
Run echo "EXTERNALCMD:2:[1724242926] ${forced_check_command}" > /var/lib/centreon/centcore/random.cmd
Sleep 0.5
${log_query} Create List ${forced_check_command}
${log_status} Ctn Find In Log With Timeout log=/var/log/centreon-gorgone/${comm}_gorgone_central/legacycmd-pipe-poller.log content=${log_query} regex=0 timeout=20
Should Be True ${log_status} Didn't found the logs : ${log_status}

0 comments on commit 063aae4

Please sign in to comment.