diff --git a/.github/scripts/collect-test-robot.sh b/.github/scripts/collect-test-robot.sh index cd0ec5f1bff..34a5aa5d7da 100755 --- a/.github/scripts/collect-test-robot.sh +++ b/.github/scripts/collect-test-robot.sh @@ -6,6 +6,8 @@ export RUN_ENV=docker test_file=$1 database_type=$2 +#this env variable is a json that contains some test params +export TESTS_PARAMS='$3' . /etc/os-release distrib=${ID} diff --git a/.github/workflows/robot-nightly.yml b/.github/workflows/robot-nightly.yml index 92fcf0e941c..118d99b61ab 100644 --- a/.github/workflows/robot-nightly.yml +++ b/.github/workflows/robot-nightly.yml @@ -54,17 +54,31 @@ jobs: package_extension: rpm arch: amd64 database_type: mariadb + test_group_name: robot_test-mariadb-el9-amd64 + tests_params: '{}' - distrib: el9 image: centreon-collect-mysql-alma9 package_extension: rpm arch: amd64 database_type: mysql + test_group_name: robot_test-mysql-el9-amd64 + tests_params: '{}' - distrib: bullseye image: centreon-collect-debian-bullseye-arm64 package_extension: deb arch: arm64 database_type: mariadb - name: robot test ${{ matrix.database_type }} ${{ matrix.distrib }} ${{ matrix.arch }} + test_group_name: robot_test-mariadb-el9-arm64 + tests_params: '{}' + - distrib: el9 + image: centreon-collect-alma9 + package_extension: rpm + arch: amd64 + database_type: mariadb + test_group_name: robot_test-mariadb-el9-amd64-grpc + tests_params: '{"default_transport":"grpc","default_bbdo_version":"3.1.0"}' + + name: ${{ matrix.test_group_name }} uses: ./.github/workflows/robot-test.yml with: @@ -75,6 +89,8 @@ jobs: package_cache_key: cache-${{ github.sha }}-${{ matrix.package_extension}}-centreon-collect-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }} package_cache_path: ./*.${{ matrix.package_extension}} database_type: ${{ matrix.database_type }} + tests_params: ${{matrix.tests_params}} + test_group_name: ${{matrix.test_group_name}} secrets: registry_username: ${{ secrets.DOCKER_REGISTRY_ID }} registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }} diff --git a/.github/workflows/robot-test.yml b/.github/workflows/robot-test.yml index e537793ff7a..de04107906a 100644 --- a/.github/workflows/robot-test.yml +++ b/.github/workflows/robot-test.yml @@ -22,6 +22,12 @@ on: database_type: required: true type: string + tests_params: + required: true + type: string + test_group_name: + required: true + type: string secrets: registry_username: required: true @@ -64,7 +70,7 @@ jobs: matrix: feature: ${{ fromJson(needs.robot-test-list.outputs.features) }} - name: ${{ matrix.feature }} ${{inputs.database_type}} + name: ${{ matrix.feature }} ${{inputs.database_type}} ${{inputs.tests_params}} steps: - name: Checkout sources @@ -80,7 +86,7 @@ jobs: fail-on-cache-miss: true - name: Test ${{ matrix.feature }} - run: bash ./.github/scripts/collect-test-robot.sh ${{ matrix.feature }} ${{inputs.database_type}} + run: bash ./.github/scripts/collect-test-robot.sh ${{ matrix.feature }} ${{inputs.database_type}} ${{inputs.tests_params}} shell: bash env: AWS_ACCESS_KEY_ID: ${{ secrets.collect_s3_access_key }} @@ -91,7 +97,7 @@ jobs: if: ${{ !cancelled() }} run: | mkdir reports - FILE_PREFIX=`echo "${{ matrix.feature }}" | sed -e "s#/#__#g"`-${{inputs.database_type}} + FILE_PREFIX=`echo "${{ matrix.feature }}" | sed -e "s#/#__#g"`-${{inputs.test_group_name}} mv tests/log.html reports/$FILE_PREFIX-log.html mv tests/output.xml reports/$FILE_PREFIX-output.xml mv tests/report.html reports/$FILE_PREFIX-report.html @@ -103,7 +109,7 @@ jobs: if: ${{ !cancelled() }} uses: actions/upload-artifact@v3 with: - name: robot-test-reports-${{inputs.database_type}}-${{ inputs.distrib }}-${{ inputs.arch }} + name: reports-${{inputs.test_group_name}} path: reports retention-days: 1 @@ -118,7 +124,7 @@ jobs: - name: Download Artifacts uses: actions/download-artifact@v3 with: - name: robot-test-reports-${{inputs.database_type}}-${{ inputs.distrib }}-${{ inputs.arch }} + name: reports-${{inputs.test_group_name}} path: reports - uses: actions/setup-python@v4 diff --git a/tests/broker/bbdo-server-client-reversed.robot b/tests/broker/bbdo-server-client-reversed.robot index b846ff249aa..aa6273c7ebf 100644 --- a/tests/broker/bbdo-server-client-reversed.robot +++ b/tests/broker/bbdo-server-client-reversed.robot @@ -26,40 +26,40 @@ BSCSSR1 Repeat Keyword 5 times Start Stop Service 0 BSCSSRR1 - [Documentation] Start-Stop two instances of broker and no coredump. Connection with bbdo_server/bbdo_client, reversed and retention. central-broker-master-output is then a failover. + [Documentation] Start-Stop two instances of broker and no coredump. Connection with bbdo_server/bbdo_client, reversed and retention. centreon-broker-master-rrd is then a failover. [Tags] broker start-stop bbdo_server bbdo_client tcp Config Broker central Config Broker rrd Config Broker BBDO Input central bbdo_server 5669 tcp Config Broker BBDO Output central bbdo_server 5670 tcp - Broker Config Output set central central-broker-master-output retention yes + Broker Config Output set central centreon-broker-master-rrd retention yes Config Broker BBDO Input rrd bbdo_client 5670 tcp localhost Broker Config Log central config debug ${start}= Get Round Current Date Repeat Keyword 5 times Start Stop Service 0 - ${content}= Create List failover 'central-broker-master-output' construction. + ${content}= Create List failover 'centreon-broker-master-rrd' construction. ${result}= Find In Log With Timeout ${centralLog} ${start} ${content} 30 Should Be True ${result} msg=No information about TLS activation. BSCSSPRR1 - [Documentation] Start-Stop two instances of broker and no coredump. The server contains a listen address, reversed and retention. central-broker-master-output is then a failover. + [Documentation] Start-Stop two instances of broker and no coredump. The server contains a listen address, reversed and retention. centreon-broker-master-rrd is then a failover. [Tags] broker start-stop bbdo_server bbdo_client tcp Config Broker central Config Broker rrd Config Broker BBDO Input central bbdo_server 5669 tcp Config Broker BBDO Output central bbdo_server 5670 tcp localhost Config Broker BBDO Input rrd bbdo_client 5670 tcp localhost - Broker Config Output set central central-broker-master-output retention yes + Broker Config Output set central centreon-broker-master-rrd retention yes Broker Config Log central config info Repeat Keyword 5 times Start Stop Service 0 BSCSSRR2 - [Documentation] Start/Stop 10 times broker with 300ms interval and no coredump, reversed and retention. central-broker-master-output is then a failover. + [Documentation] Start/Stop 10 times broker with 300ms interval and no coredump, reversed and retention. centreon-broker-master-rrd is then a failover. [Tags] broker start-stop bbdo_server bbdo_client tcp Config Broker central Config Broker BBDO Input central bbdo_client 5669 tcp localhost Config Broker BBDO Output central bbdo_server 5670 tcp - Broker Config Output set central central-broker-master-output retention yes + Broker Config Output set central centreon-broker-master-rrd retention yes Repeat Keyword 10 times Start Stop Instance 300ms BSCSSGRR1 @@ -69,14 +69,14 @@ BSCSSGRR1 Config Broker rrd Config Broker BBDO Input central bbdo_server 5669 grpc localhost Config Broker BBDO Output central bbdo_server 5670 grpc - Broker Config Output set central central-broker-master-output retention yes + Broker Config Output set central centreon-broker-master-rrd retention yes Config Broker BBDO Input rrd bbdo_client 5670 grpc localhost Broker Config Log central config info ${start}= Get Round Current Date Repeat Keyword 5 times Start Stop Service 0 ${content}= Create List - ... endpoint applier: creating new failover 'central-broker-master-output' - ... failover 'central-broker-master-output' construction. + ... endpoint applier: creating new failover 'centreon-broker-master-rrd' + ... failover 'centreon-broker-master-rrd' construction. ${result}= Find In Log With Timeout ${centralLog} ${start} ${content} 30 Should Be True ${result} msg=No information about TLS activation. @@ -87,9 +87,9 @@ BSCSSTRR1 Config Broker rrd Config Broker BBDO Output central bbdo_server 5670 tcp Config Broker BBDO Input rrd bbdo_client 5670 tcp localhost - Broker Config Output set central central-broker-master-output encryption yes - Broker Config Output set central central-broker-master-output retention yes - Broker Config Input set rrd rrd-broker-master-input encryption yes + Broker Config Output set central centreon-broker-master-rrd encryption yes + Broker Config Output set central centreon-broker-master-rrd retention yes + Broker Config Input set rrd central-rrd-master-input encryption yes Broker Config Log central config off Broker Config Log central core off Broker Config Log central tls debug @@ -106,29 +106,29 @@ BSCSSTRR2 Config Broker rrd Config Broker BBDO Output central bbdo_server 5670 tcp Config Broker BBDO Input rrd bbdo_client 5670 tcp localhost - Broker Config Output set central central-broker-master-output encryption yes - Broker Config Output set central central-broker-master-output retention yes - Broker Config Input set rrd rrd-broker-master-input encryption yes + Broker Config Output set central centreon-broker-master-rrd encryption yes + Broker Config Output set central centreon-broker-master-rrd retention yes + Broker Config Input set rrd central-rrd-master-input encryption yes Broker Config Log central config off Broker Config Log central core off Broker Config Log central tls debug Broker Config Output set ... central - ... central-broker-master-output + ... centreon-broker-master-rrd ... private_key ... ${EtcRoot}/centreon-broker/server.key Broker Config Output set ... central - ... central-broker-master-output + ... centreon-broker-master-rrd ... certificate ... ${EtcRoot}/centreon-broker/server.crt Broker Config Output set ... central - ... central-broker-master-output + ... centreon-broker-master-rrd ... ca_certificate ... ${EtcRoot}/centreon-broker/client.crt - Broker Config Input set rrd rrd-broker-master-input private_key ${EtcRoot}/centreon-broker/client.key - Broker Config Input set rrd rrd-broker-master-input certificate ${EtcRoot}/centreon-broker/client.crt + Broker Config Input set rrd central-rrd-master-input private_key ${EtcRoot}/centreon-broker/client.key + Broker Config Input set rrd central-rrd-master-input certificate ${EtcRoot}/centreon-broker/client.crt ${start}= Get Round Current Date Repeat Keyword 5 times Start Stop Service 0 ${content}= Create List TLS: successful handshake @@ -142,9 +142,9 @@ BSCSSTGRR2 Config Broker rrd Config Broker BBDO Output central bbdo_server 5670 grpc Config Broker BBDO Input rrd bbdo_client 5670 grpc localhost - Broker Config Output set central central-broker-master-output encryption yes - Broker Config Output set central central-broker-master-output retention yes - Broker Config Input set rrd rrd-broker-master-input encryption yes + Broker Config Output set central centreon-broker-master-rrd encryption yes + Broker Config Output set central centreon-broker-master-rrd retention yes + Broker Config Input set rrd central-rrd-master-input encryption yes Broker Config Flush Log central 0 Broker Config Flush Log rrd 0 Broker Config Log central config off @@ -163,19 +163,19 @@ BSCSSTGRR2 Broker Config Output set ... central - ... central-broker-master-output + ... centreon-broker-master-rrd ... private_key ... ${EtcRoot}/centreon-broker/server.key Broker Config Output set ... central - ... central-broker-master-output + ... centreon-broker-master-rrd ... certificate ... ${EtcRoot}/centreon-broker/server.crt - Broker Config Input set rrd rrd-broker-master-input private_key ${EtcRoot}/centreon-broker/client.key - Broker Config Input set rrd rrd-broker-master-input certificate ${EtcRoot}/centreon-broker/client.crt + Broker Config Input set rrd central-rrd-master-input private_key ${EtcRoot}/centreon-broker/client.key + Broker Config Input set rrd central-rrd-master-input certificate ${EtcRoot}/centreon-broker/client.crt Broker Config Input set ... rrd - ... rrd-broker-master-input + ... central-rrd-master-input ... ca_certificate ... ${EtcRoot}/centreon-broker/server.crt ${start}= Get Round Current Date @@ -192,8 +192,8 @@ BSCSSCRR1 Config Broker rrd Config Broker BBDO Output central bbdo_server 5670 tcp Config Broker BBDO Input rrd bbdo_client 5670 tcp localhost - Broker Config Output set central central-broker-master-output compression yes - Broker Config Output set central central-broker-master-output retention yes + Broker Config Output set central centreon-broker-master-rrd compression yes + Broker Config Output set central centreon-broker-master-rrd retention yes Broker Config Log central config off Broker Config Log central core trace Broker Config Log rrd core trace @@ -212,8 +212,8 @@ BSCSSCRR2 Config Broker rrd Config Broker BBDO Output central bbdo_server 5670 tcp Config Broker BBDO Input rrd bbdo_client 5670 tcp localhost - Broker Config Output set central central-broker-master-output compression no - Broker Config Output set central central-broker-master-output retention yes + Broker Config Output set central centreon-broker-master-rrd compression no + Broker Config Output set central centreon-broker-master-rrd retention yes Broker Config Log central config off Broker Config Log central core off Broker Config Log rrd core trace @@ -233,8 +233,8 @@ BSCSSCGRR1 Config Broker rrd Config Broker BBDO Output central bbdo_server 5670 grpc Config Broker BBDO Input rrd bbdo_client 5670 grpc localhost - Broker Config Output set central central-broker-master-output compression yes - Broker Config Output set central central-broker-master-output retention yes + Broker Config Output set central centreon-broker-master-rrd compression yes + Broker Config Output set central centreon-broker-master-rrd retention yes Broker Config Log central config off Broker Config Log central core off Broker Config Log rrd core off @@ -255,8 +255,8 @@ BSCSSCGRR2 Config Broker rrd Config Broker BBDO Output central bbdo_server 5670 grpc Config Broker BBDO Input rrd bbdo_client 5670 grpc localhost - Broker Config Output set central central-broker-master-output compression no - Broker Config Output set central central-broker-master-output retention yes + Broker Config Output set central centreon-broker-master-rrd compression no + Broker Config Output set central centreon-broker-master-rrd retention yes Broker Config Log central config off Broker Config Log central core off Broker Config Log rrd core off diff --git a/tests/broker/bbdo-server-client.robot b/tests/broker/bbdo-server-client.robot index b40a51912e5..366ee8b627c 100644 --- a/tests/broker/bbdo-server-client.robot +++ b/tests/broker/bbdo-server-client.robot @@ -103,7 +103,7 @@ BSCSST1 Config Broker BBDO Output central bbdo_client 5670 tcp localhost Config Broker BBDO Input rrd bbdo_server 5670 tcp Broker Config Output set central central-broker-master-output encryption yes - Broker Config Input set rrd rrd-broker-master-input encryption yes + Broker Config Input set rrd central-rrd-master-input encryption yes Broker Config Log central config off Broker Config Log central core off Broker Config Log central tls debug @@ -122,7 +122,7 @@ BSCSST2 Config Broker BBDO Output central bbdo_client 5670 tcp localhost Config Broker BBDO Input rrd bbdo_server 5670 tcp Broker Config Output set central central-broker-master-output encryption yes - Broker Config Input set rrd rrd-broker-master-input encryption yes + Broker Config Input set rrd central-rrd-master-input encryption yes Broker Config Log central config off Broker Config Log central core off Broker Config Log central tls debug @@ -141,8 +141,8 @@ BSCSST2 ... central-broker-master-output ... ca_certificate ... ${EtcRoot}/centreon-broker/client.crt - Broker Config Input set rrd rrd-broker-master-input private_key ${EtcRoot}/centreon-broker/client.key - Broker Config Input set rrd rrd-broker-master-input certificate ${EtcRoot}/centreon-broker/client.crt + Broker Config Input set rrd central-rrd-master-input private_key ${EtcRoot}/centreon-broker/client.key + Broker Config Input set rrd central-rrd-master-input certificate ${EtcRoot}/centreon-broker/client.crt ${start}= Get Current Date Repeat Keyword 5 times Start Stop Service 0 ${content}= Create List TLS: successful handshake @@ -158,7 +158,7 @@ BSCSSTG1 Config Broker BBDO Output central bbdo_client 5670 gRPC localhost Config Broker BBDO Input rrd bbdo_server 5670 gRPC Broker Config Output set central central-broker-master-output encryption yes - Broker Config Input set rrd rrd-broker-master-input encryption yes + Broker Config Input set rrd central-rrd-master-input encryption yes Broker Config Log central config off Broker Config Log central core off Broker Config Log rrd core off @@ -184,7 +184,7 @@ BSCSSTG2 Config Broker BBDO Output central bbdo_client 5670 grpc localhost Config Broker BBDO Input rrd bbdo_server 5670 grpc Broker Config Output set central central-broker-master-output encryption yes - Broker Config Input set rrd rrd-broker-master-input encryption yes + Broker Config Input set rrd central-rrd-master-input encryption yes Broker Config Log central config off Broker Config Log central core off Broker Config Log rrd core off @@ -215,8 +215,8 @@ BSCSSTG2 ... central-broker-master-output ... ca_certificate ... ${EtcRoot}/centreon-broker/client.crt - Broker Config Input set rrd rrd-broker-master-input private_key ${EtcRoot}/centreon-broker/client.key - Broker Config Input set rrd rrd-broker-master-input certificate ${EtcRoot}/centreon-broker/client.crt + Broker Config Input set rrd central-rrd-master-input private_key ${EtcRoot}/centreon-broker/client.key + Broker Config Input set rrd central-rrd-master-input certificate ${EtcRoot}/centreon-broker/client.crt ${start}= Get Current Date Start Broker ${content}= Create List encrypted connection write: buff: write done: buff: @@ -233,7 +233,7 @@ BSCSSTG3 Config Broker BBDO Output central bbdo_client 5670 grpc localhost Config Broker BBDO Input rrd bbdo_server 5670 grpc Broker Config Output set central central-broker-master-output encryption yes - Broker Config Input set rrd rrd-broker-master-input encryption yes + Broker Config Input set rrd central-rrd-master-input encryption yes Broker Config Log central config off Broker Config Log central core off Broker Config Log rrd core off @@ -266,10 +266,10 @@ BSCSSTG3 ... ${EtcRoot}/centreon-broker/client.crt Broker Config Input set ... rrd - ... rrd-broker-master-input + ... central-rrd-master-input ... private_key ... ${EtcRoot}/centreon-broker/missing-client.key - Broker Config Input set rrd rrd-broker-master-input certificate ${EtcRoot}/centreon-broker/client.crt + Broker Config Input set rrd central-rrd-master-input certificate ${EtcRoot}/centreon-broker/client.crt ${start}= Get Current Date Start Broker ${content}= Create List @@ -349,7 +349,7 @@ BSCSSGA1 Config Broker BBDO Input central bbdo_server 5669 grpc Config Broker BBDO Output central bbdo_client 5670 grpc localhost Config Broker BBDO Input rrd bbdo_server 5670 grpc - Broker Config input set rrd rrd-broker-master-input authorization titus + Broker Config input set rrd central-rrd-master-input authorization titus Broker Config Log central config off Broker Config Log central core off Broker Config Log rrd core off @@ -372,7 +372,7 @@ BSCSSGA2 Config Broker BBDO Input central bbdo_server 5669 grpc Config Broker BBDO Output central bbdo_client 5670 grpc localhost Config Broker BBDO Input rrd bbdo_server 5670 grpc - Broker Config input set rrd rrd-broker-master-input authorization titus + Broker Config input set rrd central-rrd-master-input authorization titus Broker Config output set central central-broker-master-output authorization titus Broker Config Log central config trace Broker Config Log central core trace diff --git a/tests/resources/Broker.py b/tests/resources/Broker.py index 2fa10b46f03..377d74f136b 100755 --- a/tests/resources/Broker.py +++ b/tests/resources/Broker.py @@ -21,19 +21,10 @@ from google.protobuf import empty_pb2 from google.protobuf.json_format import MessageToJson from robot.libraries.BuiltIn import BuiltIn +from Common import DB_NAME_STORAGE, DB_NAME_CONF, DB_USER, DB_PASS, DB_HOST, DB_PORT, VAR_ROOT, ETC_ROOT, TESTS_PARAMS TIMEOUT = 30 -BuiltIn().import_resource('db_variables.robot') -DB_NAME_STORAGE = BuiltIn().get_variable_value("${DBName}") -DB_NAME_CONF = BuiltIn().get_variable_value("${DBNameConf}") -DB_USER = BuiltIn().get_variable_value("${DBUser}") -DB_PASS = BuiltIn().get_variable_value("${DBPass}") -DB_HOST = BuiltIn().get_variable_value("${DBHost}") -DB_PORT = BuiltIn().get_variable_value("${DBPort}") -VAR_ROOT = BuiltIn().get_variable_value("${VarRoot}") -ETC_ROOT = BuiltIn().get_variable_value("${EtcRoot}") - config = { "central": """{{ @@ -419,7 +410,7 @@ def _apply_conf(name, callback): f.close() -def config_broker(name, poller_inst: int = 1): +def config_broker(name: str, poller_inst: int = 1): makedirs(ETC_ROOT, mode=0o777, exist_ok=True) makedirs(VAR_ROOT, mode=0o777, exist_ok=True) makedirs(ETC_ROOT + "/centreon-broker", mode=0o777, exist_ok=True) @@ -450,6 +441,8 @@ def config_broker(name, poller_inst: int = 1): broker_name = "central-rrd-master" filename = "central-rrd.json" + default_bbdo_version = TESTS_PARAMS.get("default_bbdo_version") + default_transport = TESTS_PARAMS.get("default_transport") if name == 'module': for i in range(poller_inst): broker_name = f"{ETC_ROOT}/centreon-broker/central-module{i}.json" @@ -462,11 +455,32 @@ def config_broker(name, poller_inst: int = 1): f = open(broker_name, "w") f.write(json.dumps(conf, indent=2)) f.close() + if default_bbdo_version is not None: + broker_config_add_item( + f"{name}{i}", "bbdo_version", default_bbdo_version) + if default_transport == "grpc": + config_broker_bbdo_output( + f"{name}{i}", "bbdo_client", "5669", "grpc", "localhost") + else: f = open(f"{ETC_ROOT}/centreon-broker/{filename}", "w") f.write(config[name].format(broker_id, broker_name, DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME_STORAGE, VAR_ROOT)) f.close() + if default_bbdo_version is not None: + if default_bbdo_version >= "3.0.0" and (name == "central" or name == "central_map"): + config_broker_sql_output(name, 'unified_sql') + broker_config_add_item( + name, "bbdo_version", default_bbdo_version) + if default_transport == "grpc": + if name == "central" or name == "central_map": + config_broker_bbdo_input( + name, "bbdo_server", "5669", "grpc") + config_broker_bbdo_output( + name, "bbdo_client", "5670", "grpc", "localhost") + else: + config_broker_bbdo_input( + name, "bbdo_server", "5670", "grpc") def change_broker_tcp_output_to_grpc(name: str): @@ -475,6 +489,8 @@ def output_to_grpc(conf): for i, v in enumerate(output_dict): if v["type"] == "ipv4": v["type"] = "grpc" + if "transport_protocol" in v: + v["transport_protocol"] = "grpc" _apply_conf(name, output_to_grpc) @@ -493,6 +509,8 @@ def input_to_grpc(conf): for i, v in enumerate(input_dict): if v["type"] == "ipv4": v["type"] = "grpc" + if "transport_protocol" in v: + v["transport_protocol"] = "grpc" _apply_conf(name, input_to_grpc) @@ -605,12 +623,14 @@ def config_broker_bbdo_input(name, stream, port, proto, host=None): if stream == "bbdo_client" and host is None: raise Exception("A bbdo_client must specify a host to connect to") + input_name = f"{name}-broker-master-input" if name == 'central': filename = "central-broker.json" elif name.startswith('module'): filename = "central-{}.json".format(name) else: filename = "central-rrd.json" + input_name = "central-rrd-master-input" f = open(ETC_ROOT + "/centreon-broker/{}".format(filename), "r") buf = f.read() f.close() @@ -618,10 +638,10 @@ def config_broker_bbdo_input(name, stream, port, proto, host=None): io_dict = conf["centreonBroker"]["input"] # Cleanup for i, v in enumerate(io_dict): - if (v["type"] == "ipv4" or v["type"] == "grpc") and v["port"] == port: + if (v["type"] == "ipv4" or v["type"] == "grpc" or v["type"] == "bbdo_client" or v["type"] == "bbdo_server") and v["port"] == port: io_dict.pop(i) stream = { - "name": f"{name}-broker-master-input", + "name": input_name, "port": f"{port}", "transport_protocol": proto, "type": stream, @@ -644,6 +664,7 @@ def config_broker_bbdo_output(name, stream, port, proto, host=None): output_name = f"{name}-broker-master-output" if name == 'central': filename = "central-broker.json" + output_name = 'centreon-broker-master-rrd' elif name.startswith('module'): filename = "central-{}.json".format(name) output_name = 'central-module-master-output' @@ -656,7 +677,7 @@ def config_broker_bbdo_output(name, stream, port, proto, host=None): io_dict = conf["centreonBroker"]["output"] # Cleanup for i, v in enumerate(io_dict): - if (v["type"] == "ipv4" or v["type"] == "grpc") and v["port"] == port: + if (v["type"] == "ipv4" or v["type"] == "grpc" or v["type"] == "bbdo_client" or v["type"] == "bbdo_server") and v["port"] == port: io_dict.pop(i) stream = { "name": f"{output_name}", @@ -906,6 +927,9 @@ def broker_config_output_remove(name, output, key): conf["centreonBroker"]["output"]) if elem["name"] == output][0] if key in output_dict: output_dict.pop(key) + if key == "host": + if output_dict["type"] == "bbdo_client": + output_dict["type"] = "bbdo_server" with open(f"{ETC_ROOT}/centreon-broker/{filename}", "w") as f: f.write(json.dumps(conf, indent=2)) @@ -924,6 +948,8 @@ def broker_config_input_set(name, inp, key, value): input_dict = [elem for i, elem in enumerate( conf["centreonBroker"]["input"]) if elem["name"] == inp][0] input_dict[key] = value + if key == "host" and input_dict["type"] == "bbdo_server": + input_dict["type"] = "bbdo_client" with open(f"{ETC_ROOT}/centreon-broker/{filename}", "w") as f: f.write(json.dumps(conf, indent=2)) diff --git a/tests/resources/Common.py b/tests/resources/Common.py index 7e1bc46c4a1..9174d9f2a6a 100644 --- a/tests/resources/Common.py +++ b/tests/resources/Common.py @@ -3,13 +3,13 @@ import re import os import time +import json import psutil from dateutil import parser from datetime import datetime import pymysql.cursors from robot.libraries.BuiltIn import BuiltIn - TIMEOUT = 30 BuiltIn().import_resource('db_variables.robot') @@ -20,6 +20,18 @@ DB_HOST = BuiltIn().get_variable_value("${DBHost}") DB_PORT = BuiltIn().get_variable_value("${DBPort}") VAR_ROOT = BuiltIn().get_variable_value("${VarRoot}") +ETC_ROOT = BuiltIn().get_variable_value("${EtcRoot}") + + +def parse_tests_params(): + params = os.environ.get("TESTS_PARAMS") + if params is not None and len(params) > 4: + return json.loads(params) + else: + return {} + + +TESTS_PARAMS = parse_tests_params() def check_connection(port: int, pid1: int, pid2: int): diff --git a/tests/resources/resources.robot b/tests/resources/resources.robot index bd056087c60..5d4e1f461b0 100644 --- a/tests/resources/resources.robot +++ b/tests/resources/resources.robot @@ -177,7 +177,7 @@ Stop Engine Fail ${name} not correctly stopped (coredump generated) ELSE IF ${result.rc} != 0 and ${result.rc} != -15 - Copy Coredump In Failed Dir ${alias} /usr/sbin/centengine ${alias} + # Copy Coredump In Failed Dir ${alias} /usr/sbin/centengine ${alias} Coredump info ${alias} /usr/sbin/centengine ${alias} END Should Be True @@ -247,7 +247,8 @@ Save Logs Copy files ${centralLog} ${failDir} Copy files ${rrdLog} ${failDir} Copy files ${moduleLog0} ${failDir} - Copy files ${engineLog0} ${failDir} + # Copy files ${engineLog0} ${failDir} + Copy Files ${ENGINE_LOG}/config*/centengine.log ${failDir} Copy Files ${EtcRoot}/centreon-engine/config0/*.cfg ${failDir}/etc/centreon-engine/config0 Copy Files ${EtcRoot}/centreon-broker/*.json ${failDir}/etc/centreon-broker Move Files /tmp/lua*.log ${failDir}