Skip to content

Commit

Permalink
enh(robot): new tests on compression
Browse files Browse the repository at this point in the history
  • Loading branch information
bouda1 committed Dec 10, 2021
1 parent 9b5dd98 commit 687e476
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ build/*
cmake-build-debug/*
centreon-clib/script/*
centreon-clib/inc/com/centreon/clib/version.hh
output.xml
log.html
report.html
76 changes: 76 additions & 0 deletions centreon-tests/robot/broker-engine/compression.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
*** Settings ***
Documentation Centreon Broker and Engine communication with or without compression
Library Process
Library OperatingSystem
Library ../engine/Engine.py
Library ../broker/Broker.py
Library Common.py

*** Test cases ***
BECC1: Broker/Engine communication - broker with compression=yes and engine with compression=yes
[Tags] Broker Engine start-stop
Remove Logs
Config Engine ${1}
Config Broker central
Config Broker module
Config Broker rrd
Broker Config Input set central central-broker-master-input compression yes
Broker Config Output set module central-module-master-output compression yes
Start Broker
Start Engine
Sleep 5s
${result}= Check Connections
Should Be True ${result}
Stop Broker
Stop Engine

*** Keywords ***
Remove Logs
Remove Files ${ENGINE_LOG}${/}centengine.log ${ENGINE_LOG}${/}centengine.debug
Remove Files ${BROKER_LOG}${/}central-broker-master.log ${BROKER_LOG}${/}central-rrd-master.log ${BROKER_LOG}${/}central-module-master.log

Start Broker
Start Process /usr/sbin/cbd /etc/centreon-broker/central-broker.json alias=b1
Start Process /usr/sbin/cbd /etc/centreon-broker/central-rrd.json alias=b2

Stop Broker
${result}= Terminate Process b1
Should Be Equal As Integers ${result.rc} 0
${result}= Terminate Process b2
Should Be Equal As Integers ${result.rc} 0

Start Engine
${count}= Get Engines Count
FOR ${idx} IN RANGE 0 ${count}
${alias}= Catenate SEPARATOR= e ${idx}
${conf}= Catenate SEPARATOR= /etc/centreon-engine/config ${idx} /centengine.cfg
Start Process /usr/sbin/centengine ${conf} alias=${alias}
END

Stop Engine
${count}= Get Engines Count
FOR ${idx} IN RANGE 0 ${count}
${alias}= Catenate SEPARATOR= e ${idx}
${result}= Terminate Process ${alias}
Log To Console value of result=${result.rc}
Should Be Equal As Integers ${result.rc} 0
END

Check Connections
${count}= Get Engines Count
${pid1}= Get Process Id b1
FOR ${idx} IN RANGE 0 ${count}
${alias}= Catenate SEPARATOR= e ${idx}
${pid2}= Get Process Id ${alias}
${retval}= Check Connection 5669 ${pid1} ${pid2}
IF ${retval} == ${False}
[Return] ${False}
END
END
${pid2}= Get Process Id b2
${retval}= Check Connection 5670 ${pid1} ${pid2}
[Return] ${retval}

*** Variables ***
${BROKER_LOG} /var/log/centreon-broker
${ENGINE_LOG} /var/log/centreon-engine
53 changes: 49 additions & 4 deletions centreon-tests/robot/broker-engine/start-stop.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Library ../broker/Broker.py
Library Common.py

*** Test cases ***
BESS1: Start-Stop Broker/Engine - Broker first
BESS1: Start-Stop Broker/Engine - Broker started first - Broker stopped first
[Tags] Broker Engine start-stop
Remove Logs
Config Engine ${1}
Expand All @@ -22,6 +22,50 @@ BESS1: Start-Stop Broker/Engine - Broker first
Stop Broker
Stop Engine

BESS2: Start-Stop Broker/Engine - Broker started first - Engine stopped first
[Tags] Broker Engine start-stop
Remove Logs
Config Engine ${1}
Config Broker central
Config Broker module
Config Broker rrd
Start Broker
Start Engine
Sleep 5s
${result}= Check Connections
Should Be True ${result}
Stop Engine
Stop Broker

BESS3: Start-Stop Broker/Engine - Engine started first - Engine stopped first
[Tags] Broker Engine start-stop
Remove Logs
Config Engine ${1}
Config Broker central
Config Broker module
Config Broker rrd
Start Engine
Start Broker
Sleep 5s
${result}= Check Connections
Should Be True ${result}
Stop Engine
Stop Broker

BESS4: Start-Stop Broker/Engine - Engine started first - Broker stopped first
[Tags] Broker Engine start-stop
Remove Logs
Config Engine ${1}
Config Broker central
Config Broker module
Config Broker rrd
Start Engine
Start Broker
Sleep 5s
${result}= Check Connections
Should Be True ${result}
Stop Broker
Stop Engine

*** Keywords ***
Remove Logs
Expand All @@ -34,9 +78,9 @@ Start Broker

Stop Broker
${result}= Terminate Process b1
Should Be True ${result.rc} == -15 or ${result.rc} == 0
Should Be Equal As Integers ${result.rc} 0
${result}= Terminate Process b2
Should Be True ${result.rc} == -15 or ${result.rc} == 0
Should Be Equal As Integers ${result.rc} 0

Start Engine
${count}= Get Engines Count
Expand All @@ -51,7 +95,8 @@ Stop Engine
FOR ${idx} IN RANGE 0 ${count}
${alias}= Catenate SEPARATOR= e ${idx}
${result}= Terminate Process ${alias}
Should Be True ${result.rc} == -15 or ${result.rc} == 0
Log To Console value of result=${result.rc}
Should Be Equal As Integers ${result.rc} 0
END

Check Connections
Expand Down
63 changes: 56 additions & 7 deletions centreon-tests/robot/broker/Broker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from robot.api import logger
import json

config = {
Expand Down Expand Up @@ -253,7 +254,7 @@ def config_broker(name):
f.write(config[name].format(broker_id, broker_name))
f.close()

def config_output(name, output, value):
def broker_config_output_set(name, output, key, value):
if name == 'central':
filename = "central-broker.json"
elif name == 'module':
Expand All @@ -264,13 +265,61 @@ def config_output(name, output, value):
buf = f.read()
f.close()
conf = json.loads(buf)
output_dict = [elem for i, elem in enumerate(conf["centreonBroker"]["output"]) if elem["name"] == "centreon-broker-master-rrd"][0]
if value == "one_peer_retention":
if "host" in output_dict:
output_dict.pop("host")
output_dict["one_peer_retention_mode"] = "yes"
output_dict = [elem for i, elem in enumerate(conf["centreonBroker"]["output"]) if elem["name"] == output][0]
output_dict[key] = value
f = open("/etc/centreon-broker/{}".format(filename), "w")
f.write(json.dumps(conf, indent=2))
f.close()

#config_output("central", "centreon-broker-master-rrd", "one_peer_retention")
def broker_config_output_remove(name, output, key):
if name == 'central':
filename = "central-broker.json"
elif name == 'module':
filename = "central-module.json"
else:
filename = "central-rrd.json"
f = open("/etc/centreon-broker/{}".format(filename), "r")
buf = f.read()
f.close()
conf = json.loads(buf)
output_dict = [elem for i, elem in enumerate(conf["centreonBroker"]["output"]) if elem["name"] == output][0]
if key in output_dict:
output_dict.pop(key)
f = open("/etc/centreon-broker/{}".format(filename), "w")
f.write(json.dumps(conf, indent=2))
f.close()

def broker_config_input_set(name, inp, key, value):
if name == 'central':
filename = "central-broker.json"
elif name == 'module':
filename = "central-module.json"
else:
filename = "central-rrd.json"
f = open("/etc/centreon-broker/{}".format(filename), "r")
buf = f.read()
f.close()
conf = json.loads(buf)
input_dict = [elem for i, elem in enumerate(conf["centreonBroker"]["input"]) if elem["name"] == inp][0]
input_dict[key] = value
f = open("/etc/centreon-broker/{}".format(filename), "w")
f.write(json.dumps(conf, indent=2))
f.close()

def broker_config_input_remove(name, inp, key):
if name == 'central':
filename = "central-broker.json"
elif name == 'module':
filename = "central-module.json"
else:
filename = "central-rrd.json"
f = open("/etc/centreon-broker/{}".format(filename), "r")
buf = f.read()
f.close()
conf = json.loads(buf)
input_dict = [elem for i, elem in enumerate(conf["centreonBroker"]["input"]) if elem["name"] == inp][0]
if key in input_dict:
input_dict.pop(key)
f = open("/etc/centreon-broker/{}".format(filename), "w")
f.write(json.dumps(conf, indent=2))
f.close()
11 changes: 5 additions & 6 deletions centreon-tests/robot/broker/start-stop.robot
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ BSS5: Start-Stop with reversed connection on TCP acceptor with only one instance
[Tags] Broker start-stop
Remove Logs
Config Broker central
Config Output central centreon-broker-master-rrd one_peer_retention
Broker Config Output Set central centreon-broker-master-rrd one_peer_retention_mode yes
Broker Config Output Remove central centreon-broker-master-rrd host
Repeat Keyword 5 times Start Stop Instance 1s

BSS2: Start/Stop 10 times broker with 300ms interval and no coredump
Expand All @@ -44,18 +45,16 @@ Start Stop Service
Start Process /usr/sbin/cbd /etc/centreon-broker/central-rrd.json alias=b2
Sleep ${interval}
${result1}= Terminate Process b1
Should Be True ${result1.rc} == -15 or ${result1.rc} == 0
Terminate Process b1
Should Be Equal As Integers ${result1.rc} 0
${result2}= Terminate Process b2
Should Be True ${result2.rc} == -15 or ${result2.rc} == 0
Terminate Process b2
Should Be Equal As Integers ${result2.rc} 0

Start Stop Instance
[Arguments] ${interval}
Start Process /usr/sbin/cbd /etc/centreon-broker/central-broker.json
Sleep ${interval}
${result}= Terminate Process
Should Be True ${result.rc} == -15 or ${result.rc} == 0
Should Be Equal As Integers ${result.rc} 0

Remove Logs
Remove Files ${BROKER_LOG}${/}central-broker-master.log ${BROKER_LOG}${/}central-rrd-master.log ${BROKER_LOG}${/}central-module-master.log
Expand Down

0 comments on commit 687e476

Please sign in to comment.