From 36ff742e30e9200f6cc5643e991b36bfc3eb4ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Chapron?= <34628915+sc979@users.noreply.github.com> Date: Thu, 19 Oct 2023 10:18:51 +0200 Subject: [PATCH 01/39] enh(SAST): Move scan analysis in robot job (#921) --- .github/workflows/centreon-collect.yml | 16 --------------- .github/workflows/robot-nightly.yml | 16 +++++++++++++++ .github/workflows/veracode-analysis.yml | 26 +++++++++++++------------ .veracode-exclusions | 1 + 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/.github/workflows/centreon-collect.yml b/.github/workflows/centreon-collect.yml index d1496855a0b..664d7841757 100644 --- a/.github/workflows/centreon-collect.yml +++ b/.github/workflows/centreon-collect.yml @@ -46,22 +46,6 @@ jobs: get-version: uses: ./.github/workflows/get-version.yml - veracode-analysis: - needs: [get-version] - uses: ./.github/workflows/veracode-analysis.yml - with: - module_name: centreon-collect - major_version: ${{ needs.get-version.outputs.version }} - minor_version: ${{ needs.get-version.outputs.patch }} - stability: ${{ needs.get-version.outputs.stability }} - img_version: ${{ needs.get-version.outputs.img_version }} - secrets: - veracode_api_id: ${{ secrets.VERACODE_API_ID_COLL }} - veracode_api_key: ${{ secrets.VERACODE_API_KEY_COLL }} - veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }} - docker_registry_id: ${{ secrets.DOCKER_REGISTRY_ID }} - docker_registry_passwd: ${{ secrets.DOCKER_REGISTRY_PASSWD }} - unit-test: needs: [get-version] if: ${{ ! contains(fromJson('["stable"]'), needs.get-version.outputs.stability) }} diff --git a/.github/workflows/robot-nightly.yml b/.github/workflows/robot-nightly.yml index 92fcf0e941c..95a4ef40126 100644 --- a/.github/workflows/robot-nightly.yml +++ b/.github/workflows/robot-nightly.yml @@ -33,6 +33,22 @@ jobs: get-version: uses: ./.github/workflows/get-version.yml + veracode-analysis: + needs: [get-version] + uses: ./.github/workflows/veracode-analysis.yml + if: github.ref_name == 'develop' + with: + module_name: centreon-collect + major_version: ${{ needs.get-version.outputs.version }} + minor_version: ${{ needs.get-version.outputs.patch }} + img_version: ${{ needs.get-version.outputs.img_version }} + secrets: + veracode_api_id: ${{ secrets.VERACODE_API_ID_COLL }} + veracode_api_key: ${{ secrets.VERACODE_API_KEY_COLL }} + veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }} + docker_registry_id: ${{ secrets.DOCKER_REGISTRY_ID }} + docker_registry_passwd: ${{ secrets.DOCKER_REGISTRY_PASSWD }} + package: needs: [get-version] uses: ./.github/workflows/package-collect.yml diff --git a/.github/workflows/veracode-analysis.yml b/.github/workflows/veracode-analysis.yml index 90b11c9c0f6..759b2eaffca 100644 --- a/.github/workflows/veracode-analysis.yml +++ b/.github/workflows/veracode-analysis.yml @@ -11,9 +11,6 @@ on: minor_version: required: true type: string - stability: - required: true - type: string img_version: required: true type: string @@ -33,7 +30,6 @@ jobs: build: name: Binary preparation runs-on: [self-hosted, collect] - if: github.event_name != 'pull_request' && (inputs.stability == 'stable' || inputs.stability == 'unstable') container: image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-collect-alma9:${{ inputs.img_version }} credentials: @@ -73,10 +69,18 @@ jobs: sudo ninja + echo "[DEBUG] - Find compiled files" + find ./ -name "*.so" + echo "[DEBUG] - Build size" + du -sh ./lib/*.so | sort -rh + - name: Binary preparation run: | echo "[INFO] - Keeping only compiled files" - find ./build -type f -not \( -name "*.so" -o -name "*.h" -o -name "*.cc" -o -name "*.hpp" \) -delete + # preserve binaries from cleaning + mv ./build/bin ./ + find ./build -type f -not \( -name "*.so" \) -delete + mv ./bin ./build echo "[INFO] - Removing veracode exclusions" if [[ -f ".veracode-exclusions" ]]; then @@ -90,12 +94,15 @@ jobs: elif [[ -z "$LINE" ]]; then echo "[INFO] - empty directive. Skipping this line" else - echo "[WARN] - target to exclude not found. Skipping: '$LINE'" + echo "::warning::Target to exclude from analysis not found. Skipping: '$LINE'" fi done else - echo "[WARN] - No '.veracode-exclusions' file found for this module. Skipping exclusion step" + echo "::warning::No '.veracode-exclusions' file found for this module. Skipping exclusion step" fi + echo "[INFO] - Keeping only build's non empty folders" + find ./build -empty -type d -delete + ls -la ./build echo "[INFO] - Generating the tarball" tar cvzf "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.tar.gz" build @@ -113,9 +120,6 @@ jobs: steps: - name: Promote latest scan - # Only last develop should be promoted to policy scan - if: github.ref_name == 'develop' - env: VERACODE_API_ID: "${{ secrets.veracode_api_id }}" VERACODE_API_SECRET: "${{ secrets.veracode_api_key }}" @@ -148,8 +152,6 @@ jobs: createprofile: true createsandbox: true sandboxname: "${{ github.ref_name }}" - #scantimeout: 120 includenewmodules: true scanallnonfataltoplevelmodules: true deleteincompletescan: 2 - scanpollinginterval: 120 # time between two checks in seconds / [30 to 120] diff --git a/.veracode-exclusions b/.veracode-exclusions index 49e09c0ea80..ae5b950d44e 100644 --- a/.veracode-exclusions +++ b/.veracode-exclusions @@ -35,3 +35,4 @@ engine/src/simumod/coder.pl grpc/centreon-rpc-client.py tests packaging +/root/.conan/ From edbcff993e3d585b6fbde7862e6a8cd5742493ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Chapron?= <34628915+sc979@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:32:34 +0200 Subject: [PATCH 02/39] enh(SAST): Move scan analysis in robot job (#930) --- .github/workflows/centreon-collect.yml | 16 --------------- .github/workflows/robot-nightly.yml | 16 +++++++++++++++ .github/workflows/veracode-analysis.yml | 26 +++++++++++++------------ .veracode-exclusions | 1 + 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/.github/workflows/centreon-collect.yml b/.github/workflows/centreon-collect.yml index d1496855a0b..664d7841757 100644 --- a/.github/workflows/centreon-collect.yml +++ b/.github/workflows/centreon-collect.yml @@ -46,22 +46,6 @@ jobs: get-version: uses: ./.github/workflows/get-version.yml - veracode-analysis: - needs: [get-version] - uses: ./.github/workflows/veracode-analysis.yml - with: - module_name: centreon-collect - major_version: ${{ needs.get-version.outputs.version }} - minor_version: ${{ needs.get-version.outputs.patch }} - stability: ${{ needs.get-version.outputs.stability }} - img_version: ${{ needs.get-version.outputs.img_version }} - secrets: - veracode_api_id: ${{ secrets.VERACODE_API_ID_COLL }} - veracode_api_key: ${{ secrets.VERACODE_API_KEY_COLL }} - veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }} - docker_registry_id: ${{ secrets.DOCKER_REGISTRY_ID }} - docker_registry_passwd: ${{ secrets.DOCKER_REGISTRY_PASSWD }} - unit-test: needs: [get-version] if: ${{ ! contains(fromJson('["stable"]'), needs.get-version.outputs.stability) }} diff --git a/.github/workflows/robot-nightly.yml b/.github/workflows/robot-nightly.yml index 92fcf0e941c..95a4ef40126 100644 --- a/.github/workflows/robot-nightly.yml +++ b/.github/workflows/robot-nightly.yml @@ -33,6 +33,22 @@ jobs: get-version: uses: ./.github/workflows/get-version.yml + veracode-analysis: + needs: [get-version] + uses: ./.github/workflows/veracode-analysis.yml + if: github.ref_name == 'develop' + with: + module_name: centreon-collect + major_version: ${{ needs.get-version.outputs.version }} + minor_version: ${{ needs.get-version.outputs.patch }} + img_version: ${{ needs.get-version.outputs.img_version }} + secrets: + veracode_api_id: ${{ secrets.VERACODE_API_ID_COLL }} + veracode_api_key: ${{ secrets.VERACODE_API_KEY_COLL }} + veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }} + docker_registry_id: ${{ secrets.DOCKER_REGISTRY_ID }} + docker_registry_passwd: ${{ secrets.DOCKER_REGISTRY_PASSWD }} + package: needs: [get-version] uses: ./.github/workflows/package-collect.yml diff --git a/.github/workflows/veracode-analysis.yml b/.github/workflows/veracode-analysis.yml index 90b11c9c0f6..759b2eaffca 100644 --- a/.github/workflows/veracode-analysis.yml +++ b/.github/workflows/veracode-analysis.yml @@ -11,9 +11,6 @@ on: minor_version: required: true type: string - stability: - required: true - type: string img_version: required: true type: string @@ -33,7 +30,6 @@ jobs: build: name: Binary preparation runs-on: [self-hosted, collect] - if: github.event_name != 'pull_request' && (inputs.stability == 'stable' || inputs.stability == 'unstable') container: image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-collect-alma9:${{ inputs.img_version }} credentials: @@ -73,10 +69,18 @@ jobs: sudo ninja + echo "[DEBUG] - Find compiled files" + find ./ -name "*.so" + echo "[DEBUG] - Build size" + du -sh ./lib/*.so | sort -rh + - name: Binary preparation run: | echo "[INFO] - Keeping only compiled files" - find ./build -type f -not \( -name "*.so" -o -name "*.h" -o -name "*.cc" -o -name "*.hpp" \) -delete + # preserve binaries from cleaning + mv ./build/bin ./ + find ./build -type f -not \( -name "*.so" \) -delete + mv ./bin ./build echo "[INFO] - Removing veracode exclusions" if [[ -f ".veracode-exclusions" ]]; then @@ -90,12 +94,15 @@ jobs: elif [[ -z "$LINE" ]]; then echo "[INFO] - empty directive. Skipping this line" else - echo "[WARN] - target to exclude not found. Skipping: '$LINE'" + echo "::warning::Target to exclude from analysis not found. Skipping: '$LINE'" fi done else - echo "[WARN] - No '.veracode-exclusions' file found for this module. Skipping exclusion step" + echo "::warning::No '.veracode-exclusions' file found for this module. Skipping exclusion step" fi + echo "[INFO] - Keeping only build's non empty folders" + find ./build -empty -type d -delete + ls -la ./build echo "[INFO] - Generating the tarball" tar cvzf "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.tar.gz" build @@ -113,9 +120,6 @@ jobs: steps: - name: Promote latest scan - # Only last develop should be promoted to policy scan - if: github.ref_name == 'develop' - env: VERACODE_API_ID: "${{ secrets.veracode_api_id }}" VERACODE_API_SECRET: "${{ secrets.veracode_api_key }}" @@ -148,8 +152,6 @@ jobs: createprofile: true createsandbox: true sandboxname: "${{ github.ref_name }}" - #scantimeout: 120 includenewmodules: true scanallnonfataltoplevelmodules: true deleteincompletescan: 2 - scanpollinginterval: 120 # time between two checks in seconds / [30 to 120] diff --git a/.veracode-exclusions b/.veracode-exclusions index 49e09c0ea80..ae5b950d44e 100644 --- a/.veracode-exclusions +++ b/.veracode-exclusions @@ -35,3 +35,4 @@ engine/src/simumod/coder.pl grpc/centreon-rpc-client.py tests packaging +/root/.conan/ From 1e3f6d0947b0fde0d0b4ba336978b250a5f88710 Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Tue, 31 Oct 2023 17:11:03 +0100 Subject: [PATCH 03/39] chore(release): bump major version to 24.04.0 (#939) * chore(release): bump major version to 24.04.0 * add new .version file for versioning --- .version | 2 ++ CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .version diff --git a/.version b/.version new file mode 100644 index 00000000000..9a1d1d75c3b --- /dev/null +++ b/.version @@ -0,0 +1,2 @@ +MAJOR=24.04 +MINOR=0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 935229c2312..273ca6aedef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,8 +123,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") endif() # Version. -set(COLLECT_MAJOR 23) -set(COLLECT_MINOR 10) +set(COLLECT_MAJOR 24) +set(COLLECT_MINOR 04) set(COLLECT_PATCH 0) set(COLLECT_VERSION "${COLLECT_MAJOR}.${COLLECT_MINOR}.${COLLECT_PATCH}") add_definitions(-DCENTREON_CONNECTOR_VERSION=\"${COLLECT_VERSION}\") From 4841ffb057a1f8341c3f2198b8d2fa06a877e4d8 Mon Sep 17 00:00:00 2001 From: jean-christophe81 <98889244+jean-christophe81@users.noreply.github.com> Date: Mon, 6 Nov 2023 09:31:01 +0100 Subject: [PATCH 04/39] Mon 22230 create a dedicated docker image of centreon collect (#923) * use of test images * pass image in cache * enh(test):factor database creation and package install * add other configuration to test * test: install bdd and others in docker-builder * no more ssh2 package * review comments * review comments * fix conanfile opentelemetry grpc conflict --- .../docker/Dockerfile.centreon-collect-alma8 | 1 - .../docker/Dockerfile.centreon-collect-alma9 | 1 - .../Dockerfile.centreon-collect-alma9-test | 53 +++++++++++ ...file.centreon-collect-debian-bullseye-test | 53 +++++++++++ .../Dockerfile.centreon-collect-mysql-alma9 | 1 - ...ckerfile.centreon-collect-mysql-alma9-test | 52 ++++++++++ .github/scripts/collect-prepare-test-robot.sh | 95 +++++++++++++++++++ .github/scripts/collect-test-robot.sh | 56 +---------- .github/workflows/docker-builder.yml | 27 +++++- .github/workflows/get-version.yml | 9 +- .github/workflows/robot-nightly.yml | 8 +- .github/workflows/robot-test.yml | 79 ++++++++++++--- conanfile.txt | 1 + 13 files changed, 364 insertions(+), 72 deletions(-) create mode 100644 .github/docker/Dockerfile.centreon-collect-alma9-test create mode 100644 .github/docker/Dockerfile.centreon-collect-debian-bullseye-test create mode 100644 .github/docker/Dockerfile.centreon-collect-mysql-alma9-test create mode 100755 .github/scripts/collect-prepare-test-robot.sh diff --git a/.github/docker/Dockerfile.centreon-collect-alma8 b/.github/docker/Dockerfile.centreon-collect-alma8 index 9406c331f0f..430b6237274 100644 --- a/.github/docker/Dockerfile.centreon-collect-alma8 +++ b/.github/docker/Dockerfile.centreon-collect-alma8 @@ -36,7 +36,6 @@ dnf install -y cmake \ MariaDB-server \ gnutls-devel \ libgcrypt-devel \ - libssh2-devel \ lua-devel \ make \ perl-ExtUtils-Embed.noarch \ diff --git a/.github/docker/Dockerfile.centreon-collect-alma9 b/.github/docker/Dockerfile.centreon-collect-alma9 index 1f9e2500212..12d7e59c10c 100644 --- a/.github/docker/Dockerfile.centreon-collect-alma9 +++ b/.github/docker/Dockerfile.centreon-collect-alma9 @@ -31,7 +31,6 @@ dnf install -y cmake \ mariadb \ gnutls-devel \ libgcrypt-devel \ - libssh2-devel \ lua-devel \ make \ perl-ExtUtils-Embed.noarch \ diff --git a/.github/docker/Dockerfile.centreon-collect-alma9-test b/.github/docker/Dockerfile.centreon-collect-alma9-test new file mode 100644 index 00000000000..5e3a68e11ac --- /dev/null +++ b/.github/docker/Dockerfile.centreon-collect-alma9-test @@ -0,0 +1,53 @@ +ARG REGISTRY_URL + +FROM ${REGISTRY_URL}/almalinux:9 + +COPY . /tmp/collect + +RUN <> /etc/yum.conf +echo 'assumeyes=1' >> /etc/yum.conf +sed -i 's/best=True/best=False/g' /etc/dnf/dnf.conf +dnf install -y dnf-plugins-core +dnf config-manager --set-enabled crb + +dnf install -y epel-release + +dnf install -y \ + gcc \ + gcc-c++ \ + gdb \ + git \ + openssh-server \ + mariadb-server \ + mariadb \ + gnutls \ + libgcrypt \ + lua \ + perl-ExtUtils-Embed \ + python3 \ + python3-devel \ + python3-pip \ + perl-Thread-Queue \ + rrdtool \ + perl \ + procps-ng \ + zstd \ + psmisc \ + sudo + +echo "install robot and dependencies" + +pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil +pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3 + +cd /tmp/collect + +.github/scripts/collect-prepare-test-robot.sh mariadb + +/bin/rm -rf /tmp/collect + +EOF + diff --git a/.github/docker/Dockerfile.centreon-collect-debian-bullseye-test b/.github/docker/Dockerfile.centreon-collect-debian-bullseye-test new file mode 100644 index 00000000000..bcd3259e271 --- /dev/null +++ b/.github/docker/Dockerfile.centreon-collect-debian-bullseye-test @@ -0,0 +1,53 @@ +ARG REGISTRY_URL + +FROM ${REGISTRY_URL}/debian:bullseye + + +COPY . /tmp/collect + +RUN <> /etc/yum.conf +echo 'assumeyes=1' >> /etc/yum.conf +sed -i 's/best=True/best=False/g' /etc/dnf/dnf.conf +dnf install -y dnf-plugins-core +dnf config-manager --set-enabled crb + +dnf install -y epel-release + +dnf install -y gcc \ + gcc-c++ \ + gdb \ + git \ + openssh-server \ + mysql-server \ + mysql \ + gnutls \ + libgcrypt \ + lua \ + perl-ExtUtils-Embed \ + python3 \ + python3-devel \ + python3-pip \ + perl-Thread-Queue \ + rrdtool \ + perl \ + procps-ng \ + zstd \ + psmisc \ + sudo \ + iproute + +echo "install robot and dependencies" + +pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil +pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3 + +cd /tmp/collect + +.github/scripts/collect-prepare-test-robot.sh mysql + +/bin/rm -rf /tmp/collect + +EOF diff --git a/.github/scripts/collect-prepare-test-robot.sh b/.github/scripts/collect-prepare-test-robot.sh new file mode 100755 index 00000000000..e0eb711bfb3 --- /dev/null +++ b/.github/scripts/collect-prepare-test-robot.sh @@ -0,0 +1,95 @@ +#!/bin/bash +set -e +set -x + + +database_type=$1 + +. /etc/os-release +distrib=${ID} +distrib=$(echo $distrib | tr '[:lower:]' '[:upper:]') + + +echo "########################### Configure sshd ###########################" +ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -P "" << /dev/null 2>&1 & + else + mkdir -p /run/mysqld + chown mysql:mysql /run/mysqld + mariadbd --socket=/run/mysqld/mysqld.sock --user=root > /dev/null 2>&1 & + fi + sleep 5 + + echo "########################### Init centreon database ############################" + + mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED BY 'centreon';" + mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED BY 'centreon';" +fi + +mysql -e "GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,DROP,INDEX,ALTER,LOCK TABLES,CREATE TEMPORARY TABLES, EVENT,CREATE VIEW ON *.* TO 'centreon'@'localhost';" +mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root_centreon'@'localhost'" + +cat resources/centreon.sql | sed "s/DBNameConf/centreon/g" > /tmp/centreon.sql + +mysql -u root_centreon -pcentreon < resources/centreon_storage.sql +mysql -u root_centreon -pcentreon < /tmp/centreon.sql + +cd tests + +if [ "$distrib" = "ALMALINUX" ]; then + dnf groupinstall -y "Development Tools" + dnf install -y python3-devel +else + apt-get update + apt-get install -y build-essential + apt-get install -y python3-dev +fi + + +echo "########################## Install centreon collect ###########################" +cd .. +echo "Installation..." +if [ "$distrib" = "ALMALINUX" ]; then + dnf clean all + rm -f ./*-selinux-*.rpm # avoid to install selinux packages which are dependent to centreon-common-selinux + dnf install -y ./*.rpm +else + apt-get update +# apt-get install -y ./*.deb +fi + + +if [ $database_type == 'mysql' ]; then + killall -w mysqldtoto +else + killall -w mariadbd +fi + +cd .. + +\rm -rf * + diff --git a/.github/scripts/collect-test-robot.sh b/.github/scripts/collect-test-robot.sh index da38d9aa372..03567ceb6b4 100755 --- a/.github/scripts/collect-test-robot.sh +++ b/.github/scripts/collect-test-robot.sh @@ -24,75 +24,25 @@ if [ ${database_type} == 'mysql' ] && [ ! -f tests/${test_file}.mysql ]; then exit 0 fi -echo "########################### Configure and start sshd ###########################" -ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -P "" << /dev/null 2>&1 & else - mkdir -p /run/mysqld - chown mysql:mysql /run/mysqld mariadbd --socket=/run/mysqld/mysqld.sock --user=root > /dev/null 2>&1 & fi sleep 5 - echo "########################### Init centreon database ############################" - - mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED BY 'centreon';" - mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED BY 'centreon';" -fi - -mysql -e "GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,DROP,INDEX,ALTER,LOCK TABLES,CREATE TEMPORARY TABLES, EVENT,CREATE VIEW ON *.* TO 'centreon'@'localhost';" -mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root_centreon'@'localhost'" - -cat resources/centreon.sql | sed "s/DBNameConf/centreon/g" > /tmp/centreon.sql - -mysql -u root_centreon -pcentreon < resources/centreon_storage.sql -mysql -u root_centreon -pcentreon < /tmp/centreon.sql - -#remove git dubious ownership -git config --global --add safe.directory $PWD - -echo "########################### Install Robot Framework ###########################" -cd tests -pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil - -if [ "$distrib" = "ALMALINUX" ]; then - dnf groupinstall -y "Development Tools" - dnf install -y python3-devel -else - apt-get update - apt-get install -y build-essential - apt-get install -y python3-dev fi -pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3 echo "########################## Install centreon collect ###########################" -cd .. echo "Installation..." if [ "$distrib" = "ALMALINUX" ]; then dnf clean all @@ -103,9 +53,13 @@ else apt-get install -y ./*.deb fi + ulimit -c unlimited echo '/tmp/core.%p' > /proc/sys/kernel/core_pattern +#remove git dubious ownership +/usr/bin/git config --global --add safe.directory $PWD + echo "##### Starting tests #####" cd tests ./init-proto.sh diff --git a/.github/workflows/docker-builder.yml b/.github/workflows/docker-builder.yml index f23175eabb4..ee224b96c10 100644 --- a/.github/workflows/docker-builder.yml +++ b/.github/workflows/docker-builder.yml @@ -30,18 +30,39 @@ jobs: - runner: collect dockerfile: centreon-collect-alma8 image: centreon-collect-alma8 + tag: ${{ needs.get-version.outputs.img_version }} - runner: collect dockerfile: centreon-collect-alma9 image: centreon-collect-alma9 + tag: ${{ needs.get-version.outputs.img_version }} + - runner: collect + dockerfile: centreon-collect-alma9-test + image: centreon-collect-alma9-test + tag: ${{ needs.get-version.outputs.test_img_version }} - runner: collect dockerfile: centreon-collect-mysql-alma9 image: centreon-collect-mysql-alma9 + tag: ${{ needs.get-version.outputs.img_version }} + - runner: collect + dockerfile: centreon-collect-mysql-alma9-test + image: centreon-collect-mysql-alma9-test + tag: ${{ needs.get-version.outputs.test_img_version }} - runner: collect dockerfile: centreon-collect-debian-bullseye image: centreon-collect-debian-bullseye + tag: ${{ needs.get-version.outputs.img_version }} + - runner: collect + dockerfile: centreon-collect-debian-bullseye-test + image: centreon-collect-debian-bullseye-test + tag: ${{ needs.get-version.outputs.test_img_version }} - runner: collect-arm64 dockerfile: centreon-collect-debian-bullseye image: centreon-collect-debian-bullseye-arm64 + tag: ${{ needs.get-version.outputs.img_version }} + - runner: collect-arm64 + dockerfile: centreon-collect-debian-bullseye-test + image: centreon-collect-debian-bullseye-arm64-test + tag: ${{ needs.get-version.outputs.test_img_version }} runs-on: ${{ fromJson(format('["self-hosted", "{0}"]', matrix.runner)) }} @@ -67,7 +88,8 @@ jobs: - uses: docker/setup-buildx-action@v2 - - uses: docker/build-push-action@v3 + - name: Build image ${{ matrix.image }}:${{ matrix.tag }} + uses: docker/build-push-action@v3 with: file: .github/docker/Dockerfile.${{ matrix.dockerfile }} context: . @@ -75,4 +97,5 @@ jobs: platforms: ${{ contains(matrix.runner, 'arm') && 'linux/arm64' || 'linux/amd64' }} pull: true push: true - tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-version.outputs.img_version }} + tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ matrix.tag }} + diff --git a/.github/workflows/get-version.yml b/.github/workflows/get-version.yml index add097da665..8bdbbcab148 100644 --- a/.github/workflows/get-version.yml +++ b/.github/workflows/get-version.yml @@ -4,6 +4,9 @@ on: img_version: description: "docker image version (conan checksum)" value: ${{ jobs.get-version.outputs.img_version }} + test_img_version: + description: "test docker image version (checksum of database sql, script and dockerfiles)" + value: ${{ jobs.get-version.outputs.test_img_version }} version: description: "major version" value: ${{ jobs.get-version.outputs.version }} @@ -25,6 +28,7 @@ jobs: runs-on: ubuntu-22.04 outputs: img_version: ${{ steps.get_version.outputs.img_version }} + test_img_version: ${{ steps.get_version.outputs.test_img_version }} version: ${{ steps.get_version.outputs.version }} patch: ${{ steps.get_version.outputs.patch }} release: ${{ steps.get_version.outputs.release }} @@ -36,10 +40,12 @@ jobs: - id: get_version run: | - IMG_VERSION=$(md5sum conanfile.txt | awk '{print substr($1, 0, 8)}') + IMG_VERSION=$( cat `ls .github/docker/Dockerfile.centreon-collect-* | grep -v test` conanfile.txt | md5sum | awk '{print substr($1, 0, 8)}') + TEST_IMG_VERSION=$(cat .github/docker/Dockerfile.centreon-collect-*-test .github/scripts/collect-prepare-test-robot.sh resources/*.sql | md5sum | cut -c1-8) VERSION=$(awk '$1 ~ "COLLECT_MAJOR" {maj=substr($2, 1, length($2)-1)} $1 ~ "COLLECT_MINOR" {min=substr($2, 1, length($2)-1) ; print maj "." min}' CMakeLists.txt) PATCH=$(awk '$1 ~ "COLLECT_PATCH" {print substr($2, 1, length($2) - 1)}' CMakeLists.txt) echo "img_version=$IMG_VERSION" >> $GITHUB_OUTPUT + echo "test_img_version=$TEST_IMG_VERSION" >> $GITHUB_OUTPUT echo "version=$VERSION" >> $GITHUB_OUTPUT echo "patch=$PATCH" >> $GITHUB_OUTPUT @@ -79,3 +85,4 @@ jobs: echo "env=$VERSION-$ENV" >> $GITHUB_OUTPUT echo "GH_ENV: $VERSION-$ENV" shell: bash + diff --git a/.github/workflows/robot-nightly.yml b/.github/workflows/robot-nightly.yml index c938381d9e4..90df44b9bd9 100644 --- a/.github/workflows/robot-nightly.yml +++ b/.github/workflows/robot-nightly.yml @@ -58,22 +58,23 @@ jobs: robot-test: needs: [get-version, package] + strategy: fail-fast: false matrix: include: - distrib: el9 - image: centreon-collect-alma9 + image: centreon-collect-alma9-test package_extension: rpm arch: amd64 database_type: mariadb - distrib: el9 - image: centreon-collect-mysql-alma9 + image: centreon-collect-mysql-alma9-test package_extension: rpm arch: amd64 database_type: mysql - distrib: bullseye - image: centreon-collect-debian-bullseye-arm64 + image: centreon-collect-debian-bullseye-arm64-test package_extension: deb arch: arm64 database_type: mariadb @@ -84,6 +85,7 @@ jobs: distrib: ${{ matrix.distrib }} arch: ${{ matrix.arch }} image: ${{ matrix.image }} + image_test: ${{ matrix.image }}:${{ needs.get-version.outputs.test_img_version }} image_version: ${{ needs.get-version.outputs.img_version }} 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}} diff --git a/.github/workflows/robot-test.yml b/.github/workflows/robot-test.yml index 3f87f26baa5..6a459989e00 100644 --- a/.github/workflows/robot-test.yml +++ b/.github/workflows/robot-test.yml @@ -10,6 +10,9 @@ on: image: required: true type: string + image_test: + required: true + type: string image_version: required: true type: string @@ -34,7 +37,44 @@ on: jobs: + test-image-to-cache: + runs-on: ${{ contains(inputs.image, 'arm') && fromJson('["self-hosted", "collect-arm64"]') || 'ubuntu-22.04' }} + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Login to Registry + uses: docker/login-action@v2 + with: + registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }} + username: ${{ secrets.registry_username }} + password: ${{ secrets.registry_password }} + + - name: Login to Proxy Registry + uses: docker/login-action@v2 + with: + registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }} + username: ${{ secrets.registry_username }} + password: ${{ secrets.registry_password }} + + - name: load image + run: | + docker pull ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image_test}} + shell: bash + + - name: image to disk + run: | + docker save -o /tmp/${{inputs.image}} ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image_test}} + shell: bash + + - name: image to cache + uses: actions/cache/save@v3 + with: + path: /tmp/${{inputs.image}} + key: ${{inputs.image_test}} + robot-test-list: + needs: [test-image-to-cache] runs-on: ubuntu-22.04 outputs: features: ${{ steps.list-features.outputs.features }} @@ -52,12 +92,6 @@ jobs: robot-test: needs: [robot-test-list] runs-on: ${{ contains(inputs.image, 'arm') && fromJson('["self-hosted", "collect-arm64"]') || 'ubuntu-22.04' }} - container: - image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}:${{ inputs.image_version }} - options: --privileged --ulimit core=-1 --security-opt seccomp=unconfined - credentials: - username: ${{ secrets.registry_username }} - password: ${{ secrets.registry_password }} strategy: fail-fast: false @@ -72,20 +106,41 @@ jobs: with: fetch-depth: 0 + - name: Restore image + uses: actions/cache@v3 + with: + path: /tmp/${{inputs.image}} + key: ${{inputs.image_test}} + fail-on-cache-miss: true + - name: Restore packages uses: actions/cache@v3 with: path: ${{ inputs.package_cache_path }} key: ${{ inputs.package_cache_key }} fail-on-cache-miss: true + + - name: load image + run: | + docker load --input /tmp/${{ inputs.image }} - name: Test ${{ matrix.feature }} - run: bash ./.github/scripts/collect-test-robot.sh ${{ matrix.feature }} ${{inputs.database_type}} - shell: bash + run: | + docker run --rm --privileged --ulimit core=-1 --security-opt seccomp=unconfined \ + -v $(pwd):/test_collect \ + --env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ + --env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ + --env AWS_BUCKET=centreon-collect-robot-report \ + --workdir /test_collect \ + ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image_test}} \ + ./.github/scripts/collect-test-robot.sh \ + ${{ matrix.feature }} ${{inputs.database_type}} + + env: AWS_ACCESS_KEY_ID: ${{ secrets.collect_s3_access_key }} AWS_SECRET_ACCESS_KEY: ${{ secrets.collect_s3_secret_key }} - AWS_BUCKET: centreon-collect-robot-report + - name: Move reports if: ${{ failure() }} @@ -93,9 +148,9 @@ jobs: mkdir reports FILE_PREFIX=`echo "${{ matrix.feature }}" | sed -e "s#/#__#g"`-${{inputs.database_type}} if [ -d tests/failed ] ; then - mv tests/log.html reports/$FILE_PREFIX-log.html - mv tests/output.xml reports/$FILE_PREFIX-output.xml - mv tests/failed reports/$FILE_PREFIX-failed + cp -rp tests/failed reports/$FILE_PREFIX-failed + cp tests/log.html reports/$FILE_PREFIX-log.html + cp tests/output.xml reports/$FILE_PREFIX-output.xml fi - name: Upload Test Results diff --git a/conanfile.txt b/conanfile.txt index 3a04a12c93d..f0534039f18 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -12,6 +12,7 @@ nlohmann_json/3.11.2 opentelemetry-cpp/1.8.1 spdlog/1.11.0 zlib/1.2.13 +abseil/20230125.3 [generators] cmake From 68967209250b1af9acac74bb217bcbfaa24336bb Mon Sep 17 00:00:00 2001 From: hamzabessa <148857497+hamzabessa@users.noreply.github.com> Date: Thu, 9 Nov 2023 06:59:21 +0100 Subject: [PATCH 05/39] feat(ci): add linting to worflow and actions files (#933) --- .github/actions/release/action.yml | 2 +- .github/workflows/actionlint.yml | 30 +++++++++++++++++++++++++++++ .github/workflows/robot-nightly.yml | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml index b6b0d85885a..bf3891050d4 100644 --- a/.github/actions/release/action.yml +++ b/.github/actions/release/action.yml @@ -56,4 +56,4 @@ runs: --header 'Content-Type: application/json' \ --data ''$VERSION_DATA'' - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml index 42a391e17a2..b5cf10c1146 100644 --- a/.github/workflows/actionlint.yml +++ b/.github/workflows/actionlint.yml @@ -38,3 +38,33 @@ jobs: -pyflakes= \ -color shell: bash + yaml-lint: + runs-on: ubuntu-22.04 + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Yaml + run: | + pip install yamllint==1.32.0 + + - name: Add Yaml Lint Rules + run: | + cat <>./yamllint_rules.yml + extends: default + + rules: + document-start: disable + line-length: disable + truthy: + check-keys: false + level: error + indentation: + spaces: 2 + indent-sequences: true + check-multi-line-strings: false + EOF + + - name: Lint YAML files + run: | + yamllint -c ./yamllint_rules.yml ./.github/actions/ ./.github/workflows/ diff --git a/.github/workflows/robot-nightly.yml b/.github/workflows/robot-nightly.yml index 90df44b9bd9..943a326895a 100644 --- a/.github/workflows/robot-nightly.yml +++ b/.github/workflows/robot-nightly.yml @@ -95,7 +95,7 @@ jobs: registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }} collect_s3_access_key: ${{ secrets.COLLECT_S3_ACCESS_KEY }} collect_s3_secret_key: ${{ secrets.COLLECT_S3_SECRET_KEY }} - + deliver-rpm: if: ${{ contains(fromJson('["unstable"]'), needs.get-version.outputs.stability) }} needs: [robot-test, get-version] From 27ecd9c1557b5c394ad74dedc26e6100f640095f Mon Sep 17 00:00:00 2001 From: jean-christophe81 <98889244+jean-christophe81@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:01:31 +0100 Subject: [PATCH 06/39] MON-11584 output of ba dump kpi names instead of id (#932) * output of ba dump kpi names instead of id * update bam tests REFS:MON-23573 --- .../centreon/broker/bam/configuration/kpi.hh | 9 +- broker/bam/inc/com/centreon/broker/bam/kpi.hh | 4 +- .../bam/inc/com/centreon/broker/bam/kpi_ba.hh | 2 +- .../com/centreon/broker/bam/kpi_boolexp.hh | 2 +- .../com/centreon/broker/bam/kpi_service.hh | 3 +- broker/bam/src/ba_impact.cc | 2 +- broker/bam/src/ba_worst.cc | 4 +- broker/bam/src/configuration/applier/kpi.cc | 27 ++--- broker/bam/src/configuration/kpi.cc | 65 +---------- broker/bam/src/configuration/reader_v2.cc | 34 +++++- broker/bam/src/kpi.cc | 3 +- broker/bam/src/kpi_ba.cc | 3 +- broker/bam/src/kpi_boolexp.cc | 6 +- broker/bam/src/kpi_service.cc | 5 +- broker/bam/test/ba/kpi_ba.cc | 72 +++++++----- broker/bam/test/ba/kpi_service.cc | 97 ++++++++++------ broker/bam/test/exp_builder/exp_builder.cc | 8 +- tests/bam/bam_pb.robot | 109 ++++++++++++++++-- tests/resources/resources.robot | 8 +- 19 files changed, 286 insertions(+), 177 deletions(-) diff --git a/broker/bam/inc/com/centreon/broker/bam/configuration/kpi.hh b/broker/bam/inc/com/centreon/broker/bam/configuration/kpi.hh index 2de9e92abe6..02fc7075f4d 100644 --- a/broker/bam/inc/com/centreon/broker/bam/configuration/kpi.hh +++ b/broker/bam/inc/com/centreon/broker/bam/configuration/kpi.hh @@ -52,6 +52,7 @@ class kpi { double _impact_critical; double _impact_unknown; KpiEvent _event; + std::string _name; public: kpi(uint32_t id = 0, @@ -69,10 +70,9 @@ class kpi { bool ignoreacknowledgement = false, double warning = 0, double critical = 0, - double unknown = 0); - kpi(kpi const& other); - ~kpi(); - kpi& operator=(kpi const& other); + double unknown = 0, + const std::string& name = ""); + bool operator==(kpi const& other) const; bool operator!=(kpi const& other) const; @@ -97,6 +97,7 @@ class kpi { double get_impact_critical() const; double get_impact_unknown() const; const KpiEvent& get_opened_event() const; + const std::string get_name() const { return _name; } void set_id(uint32_t id); void set_state_type(short state_type); diff --git a/broker/bam/inc/com/centreon/broker/bam/kpi.hh b/broker/bam/inc/com/centreon/broker/bam/kpi.hh index ac1f2f315ad..59e57b23994 100644 --- a/broker/bam/inc/com/centreon/broker/bam/kpi.hh +++ b/broker/bam/inc/com/centreon/broker/bam/kpi.hh @@ -45,11 +45,12 @@ class kpi : public computable { const uint32_t _ba_id; absl::optional _event; std::vector _initial_events; + std::string _name; void _event_init(); public: - kpi(uint32_t kpi_id, uint32_t ba_id); + kpi(uint32_t kpi_id, uint32_t ba_id, const std::string& name); virtual ~kpi() noexcept = default; kpi& operator=(const kpi&) = delete; kpi(const kpi&) = delete; @@ -62,6 +63,7 @@ class kpi : public computable { virtual void visit(io::stream* visitor) = 0; virtual bool in_downtime() const; virtual bool ok_state() const = 0; + const std::string& get_name() const { return _name; }; void commit_initial_events(io::stream* visitor); }; diff --git a/broker/bam/inc/com/centreon/broker/bam/kpi_ba.hh b/broker/bam/inc/com/centreon/broker/bam/kpi_ba.hh index a515fc45434..ec3f266b25c 100644 --- a/broker/bam/inc/com/centreon/broker/bam/kpi_ba.hh +++ b/broker/bam/inc/com/centreon/broker/bam/kpi_ba.hh @@ -57,7 +57,7 @@ class kpi_ba : public kpi { const timestamp& event_start_time); public: - kpi_ba(uint32_t kpi_id, uint32_t ba_id); + kpi_ba(uint32_t kpi_id, uint32_t ba_id, const std::string& ba_name); ~kpi_ba() noexcept = default; kpi_ba(const kpi_ba&) = delete; kpi_ba& operator=(const kpi_ba&) = delete; diff --git a/broker/bam/inc/com/centreon/broker/bam/kpi_boolexp.hh b/broker/bam/inc/com/centreon/broker/bam/kpi_boolexp.hh index c9b424c7c36..b5e5f7bc6b8 100644 --- a/broker/bam/inc/com/centreon/broker/bam/kpi_boolexp.hh +++ b/broker/bam/inc/com/centreon/broker/bam/kpi_boolexp.hh @@ -49,7 +49,7 @@ class kpi_boolexp : public kpi { void _open_new_event(io::stream* visitor, int impact, state state); public: - kpi_boolexp(uint32_t kpi_id, uint32_t ba_id); + kpi_boolexp(uint32_t kpi_id, uint32_t ba_id, const std::string& bool_name); ~kpi_boolexp() noexcept = default; kpi_boolexp(const kpi_boolexp&) = delete; kpi_boolexp& operator=(const kpi_boolexp&) = delete; diff --git a/broker/bam/inc/com/centreon/broker/bam/kpi_service.hh b/broker/bam/inc/com/centreon/broker/bam/kpi_service.hh index aac1446cd7c..0d8919b2d7c 100644 --- a/broker/bam/inc/com/centreon/broker/bam/kpi_service.hh +++ b/broker/bam/inc/com/centreon/broker/bam/kpi_service.hh @@ -61,7 +61,8 @@ class kpi_service : public service_listener, public kpi { kpi_service(uint32_t kpi_id, uint32_t ba_id, uint32_t host_id, - uint32_t service_id); + uint32_t service_id, + const std::string& host_serv); ~kpi_service() noexcept = default; kpi_service(const kpi_service&) = delete; kpi_service& operator=(const kpi_service&) = delete; diff --git a/broker/bam/src/ba_impact.cc b/broker/bam/src/ba_impact.cc index 1321935767e..1eea3f89564 100644 --- a/broker/bam/src/ba_impact.cc +++ b/broker/bam/src/ba_impact.cc @@ -169,7 +169,7 @@ std::string ba_impact::get_output() const { for (auto it = _impacts.begin(), end = _impacts.end(); it != end; ++it) { if (it->second.hard_impact.get_nominal() > eps) { lst.emplace_back(fmt::format( - "KPI{} (impact: {})", it->first->get_id(), + "KPI {} (impact: {})", it->first->get_name(), static_cast(it->second.hard_impact.get_nominal()))); } } diff --git a/broker/bam/src/ba_worst.cc b/broker/bam/src/ba_worst.cc index 956e8a8e503..f917ac61863 100644 --- a/broker/bam/src/ba_worst.cc +++ b/broker/bam/src/ba_worst.cc @@ -150,8 +150,8 @@ std::string ba_worst::get_output() const { state state = it->second.hard_impact.get_state(); assert(static_cast(state) < 4); if (state != state_ok) { - retval.emplace_back(fmt::format("KPI{} is in {} state", - it->first->get_id(), state_str[state])); + retval.emplace_back(fmt::format( + "KPI {} is in {} state", it->first->get_name(), state_str[state])); } } return retval; diff --git a/broker/bam/src/configuration/applier/kpi.cc b/broker/bam/src/configuration/applier/kpi.cc index 83fb3edd414..e86ce4cc529 100644 --- a/broker/bam/src/configuration/applier/kpi.cc +++ b/broker/bam/src/configuration/applier/kpi.cc @@ -267,11 +267,12 @@ std::shared_ptr applier::kpi::_new_kpi( std::shared_ptr my_kpi; if (cfg.is_service()) { log_v2::bam()->info( - "BAM: creating new KPI {} of service ({}, {}) impacting BA {}", - cfg.get_id(), cfg.get_host_id(), cfg.get_service_id(), cfg.get_ba_id()); - auto obj{std::make_shared(cfg.get_id(), cfg.get_ba_id(), - cfg.get_host_id(), - cfg.get_service_id())}; + "BAM: creating new KPI {} of service {} ({}, {}) impacting BA {}", + cfg.get_id(), cfg.get_name(), cfg.get_host_id(), cfg.get_service_id(), + cfg.get_ba_id()); + auto obj{std::make_shared( + cfg.get_id(), cfg.get_ba_id(), cfg.get_host_id(), cfg.get_service_id(), + cfg.get_name())}; obj->set_acknowledged(cfg.is_acknowledged()); obj->set_downtimed(cfg.is_downtimed()); obj->set_impact_critical(cfg.get_impact_critical()); @@ -282,21 +283,21 @@ std::shared_ptr applier::kpi::_new_kpi( _book->listen(cfg.get_host_id(), cfg.get_service_id(), obj.get()); my_kpi = std::static_pointer_cast(obj); } else if (cfg.is_ba()) { - log_v2::bam()->info("BAM: creating new KPI {} of BA {} impacting BA {}", - cfg.get_id(), cfg.get_indicator_ba_id(), + log_v2::bam()->info("BAM: creating new KPI {} of BA {}:{} impacting BA {}", + cfg.get_id(), cfg.get_indicator_ba_id(), cfg.get_name(), cfg.get_ba_id()); - std::shared_ptr obj( - std::make_shared(cfg.get_id(), cfg.get_ba_id())); + std::shared_ptr obj(std::make_shared( + cfg.get_id(), cfg.get_ba_id(), cfg.get_name())); obj->set_impact_critical(cfg.get_impact_critical()); obj->set_impact_unknown(cfg.get_impact_unknown()); obj->set_impact_warning(cfg.get_impact_warning()); my_kpi = std::static_pointer_cast(obj); } else if (cfg.is_boolexp()) { log_v2::bam()->info( - "BAM: creating new KPI {} of boolean expression {} impacting BA {}", - cfg.get_id(), cfg.get_boolexp_id(), cfg.get_ba_id()); - std::shared_ptr obj( - std::make_shared(cfg.get_id(), cfg.get_ba_id())); + "BAM: creating new KPI {} of boolean expression {}:{} impacting BA {}", + cfg.get_id(), cfg.get_boolexp_id(), cfg.get_name(), cfg.get_ba_id()); + std::shared_ptr obj(std::make_shared( + cfg.get_id(), cfg.get_ba_id(), cfg.get_name())); obj->set_impact(cfg.get_impact_critical()); my_kpi = std::static_pointer_cast(obj); } else diff --git a/broker/bam/src/configuration/kpi.cc b/broker/bam/src/configuration/kpi.cc index 82b844ba394..b3e3be9ddac 100644 --- a/broker/bam/src/configuration/kpi.cc +++ b/broker/bam/src/configuration/kpi.cc @@ -41,7 +41,8 @@ kpi::kpi(uint32_t id, bool ignore_acknowledgement, double warning, double critical, - double unknown) + double unknown, + const std::string& name) : _id(id), _state_type(state_type), _host_id(host_id), @@ -57,71 +58,13 @@ kpi::kpi(uint32_t id, _ignore_acknowledgement(ignore_acknowledgement), _impact_warning(warning), _impact_critical(critical), - _impact_unknown(unknown) { + _impact_unknown(unknown), + _name(name) { _event.set_kpi_id(_id); _event.set_ba_id(_ba_id); _event.set_start_time(::time(nullptr)); } -/** - * Copy constructor. - * - * @param[in] other The copy. - */ -kpi::kpi(kpi const& other) - : _id(other._id), - _state_type(other._state_type), - _host_id(other._host_id), - _service_id(other._service_id), - _ba_id(other._ba_id), - _indicator_ba_id(other._indicator_ba_id), - _meta_id(other._meta_id), - _boolexp_id(other._boolexp_id), - _status(other._status), - _downtimed(other._downtimed), - _acknowledged(other._acknowledged), - _ignore_downtime(other._ignore_downtime), - _ignore_acknowledgement(other._ignore_acknowledgement), - _impact_warning(other._impact_warning), - _impact_critical(other._impact_critical), - _impact_unknown(other._impact_unknown), - _event(other._event) {} - -/** - * Destructor. - */ -kpi::~kpi() {} - -/** - * Assignment operator. - * - * @param[in] other The copy. - * - * @return This object. - */ -kpi& kpi::operator=(kpi const& other) { - if (&other != this) { - _id = other._id; - _state_type = other._state_type; - _host_id = other._host_id; - _service_id = other._service_id; - _ba_id = other._ba_id; - _indicator_ba_id = other._indicator_ba_id; - _meta_id = other._meta_id; - _boolexp_id = other._boolexp_id; - _status = other._status; - _downtimed = other._downtimed; - _acknowledged = other._acknowledged; - _ignore_downtime = other._ignore_downtime; - _ignore_acknowledgement = other._ignore_acknowledgement; - _impact_warning = other._impact_warning; - _impact_critical = other._impact_critical; - _impact_unknown = other._impact_unknown; - _event = other._event; - } - return *this; -} - /** * @brief more efficient than MessageDifferencier * diff --git a/broker/bam/src/configuration/reader_v2.cc b/broker/bam/src/configuration/reader_v2.cc index ceb49a5d01c..e5409f122da 100644 --- a/broker/bam/src/configuration/reader_v2.cc +++ b/broker/bam/src/configuration/reader_v2.cc @@ -90,7 +90,10 @@ void reader_v2::_load(state::kpis& kpis) { "g.average_impact)," " COALESCE(COALESCE(k.drop_unknown, uu.impact), " "g.average_impact)," - " k.last_state_change, k.in_downtime, k.last_impact" + " k.last_state_change, k.in_downtime, k.last_impact," + " kpiba.name AS ba_name, mbb.name AS boolean_name, " + " CONCAT(hst.host_name, '/', serv.service_description) AS " + "service_name" " FROM mod_bam_kpi AS k" " INNER JOIN mod_bam AS mb" " ON k.id_ba = mb.ba_id" @@ -107,6 +110,14 @@ void reader_v2::_load(state::kpis& kpis) { " WHERE activate='1'" " GROUP BY id_ba) AS g" " ON k.id_ba=g.id_ba" + " LEFT JOIN mod_bam as kpiba" + " ON k.id_indicator_ba=kpiba.ba_id" + " LEFT JOIN mod_bam_boolean AS mbb" + " ON mbb.boolean_id= k.boolean_id" + " LEFT JOIN service as serv" + " ON k.service_id = serv.service_id" + " LEFT JOIN host as hst" + " ON k.host_id = hst.host_id" " WHERE k.activate='1'" " AND mb.activate='1'" " AND pr.poller_id={}", @@ -117,16 +128,28 @@ void reader_v2::_load(state::kpis& kpis) { try { database::mysql_result res(future.get()); while (_mysql.fetch_row(res)) { + std::string kpi_name; + uint32_t service_id = res.value_as_u32(3); + uint32_t boolean_id = res.value_as_u32(7); + uint32_t id_indicator_ba = res.value_as_u32(5); + + if (service_id > 0) + kpi_name = "Service " + res.value_as_str(21); + else if (boolean_id > 0) + kpi_name = "Boolean rule " + res.value_as_str(20); + else + kpi_name = "Business Activity " + res.value_as_str(19); + // KPI object. uint32_t kpi_id(res.value_as_u32(0)); kpis[kpi_id] = kpi(kpi_id, // ID. res.value_as_i32(1), // State type. res.value_as_u32(2), // Host ID. - res.value_as_u32(3), // Service ID. + service_id, // Service ID. res.value_as_u32(4), // BA ID. - res.value_as_u32(5), // BA indicator ID. + id_indicator_ba, // BA indicator ID. res.value_as_u32(6), // Meta-service ID. - res.value_as_u32(7), // Boolean expression ID. + boolean_id, // Boolean expression ID. res.value_as_i32(8), // Status. res.value_as_f32(9), // Downtimed. res.value_as_f32(10), // Acknowledged. @@ -134,7 +157,8 @@ void reader_v2::_load(state::kpis& kpis) { res.value_as_bool(12), // Ignore acknowledgement. res.value_as_f64(13), // Warning. res.value_as_f64(14), // Critical. - res.value_as_f64(15)); // Unknown. + res.value_as_f64(15), // Unknown. + kpi_name); // KPI state. if (!res.value_is_null(16)) { diff --git a/broker/bam/src/kpi.cc b/broker/bam/src/kpi.cc index 02ad2d7d725..eaa63c84936 100644 --- a/broker/bam/src/kpi.cc +++ b/broker/bam/src/kpi.cc @@ -29,7 +29,8 @@ static constexpr double eps = 0.000001; /** * Constructor. */ -kpi::kpi(uint32_t kpi_id, uint32_t ba_id) : _id(kpi_id), _ba_id(ba_id) {} +kpi::kpi(uint32_t kpi_id, uint32_t ba_id, const std::string& name) + : _id(kpi_id), _ba_id(ba_id), _name(name) {} /** * Get KPI ID. diff --git a/broker/bam/src/kpi_ba.cc b/broker/bam/src/kpi_ba.cc index 6a154db3867..524396b1fc1 100644 --- a/broker/bam/src/kpi_ba.cc +++ b/broker/bam/src/kpi_ba.cc @@ -27,7 +27,8 @@ using namespace com::centreon::broker::bam; /** * Default constructor. */ -kpi_ba::kpi_ba(uint32_t kpi_id, uint32_t ba_id) : kpi(kpi_id, ba_id) {} +kpi_ba::kpi_ba(uint32_t kpi_id, uint32_t ba_id, const std::string& ba_name) + : kpi(kpi_id, ba_id, ba_name) {} /** * Get the impact introduced by a CRITICAL state of the BA. diff --git a/broker/bam/src/kpi_boolexp.cc b/broker/bam/src/kpi_boolexp.cc index 4bd64f53af1..7731ac4ac2e 100644 --- a/broker/bam/src/kpi_boolexp.cc +++ b/broker/bam/src/kpi_boolexp.cc @@ -28,8 +28,10 @@ using namespace com::centreon::broker::bam; /** * Default constructor. */ -kpi_boolexp::kpi_boolexp(uint32_t kpi_id, uint32_t ba_id) - : kpi(kpi_id, ba_id) {} +kpi_boolexp::kpi_boolexp(uint32_t kpi_id, + uint32_t ba_id, + const std::string& bool_name) + : kpi(kpi_id, ba_id, bool_name) {} /** * Return true if in downtime. diff --git a/broker/bam/src/kpi_service.cc b/broker/bam/src/kpi_service.cc index 3fe4326aa87..7b1b2e557d9 100644 --- a/broker/bam/src/kpi_service.cc +++ b/broker/bam/src/kpi_service.cc @@ -42,8 +42,9 @@ static bool time_is_undefined(uint64_t t) { kpi_service::kpi_service(uint32_t kpi_id, uint32_t ba_id, uint32_t host_id, - uint32_t service_id) - : kpi(kpi_id, ba_id), + uint32_t service_id, + const std::string& host_serv) + : kpi(kpi_id, ba_id, host_serv), _host_id(host_id), _service_id(service_id), _acknowledged(false), diff --git a/broker/bam/test/ba/kpi_ba.cc b/broker/bam/test/ba/kpi_ba.cc index e3cae43916b..dae1cf29e50 100644 --- a/broker/bam/test/ba/kpi_ba.cc +++ b/broker/bam/test/ba/kpi_ba.cc @@ -80,7 +80,8 @@ TEST_F(KpiBA, KpiBa) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -94,11 +95,11 @@ TEST_F(KpiBA, KpiBa) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); @@ -158,7 +159,7 @@ TEST_F(KpiBA, KpiBa) { ASSERT_EQ(it->end_time, -1); ASSERT_EQ(test_ba->get_output(), "Status is CRITICAL - At least one KPI is in a CRITICAL state: " - "KPI3 is in CRITICAL state"); + "KPI ba 2 is in CRITICAL state"); /* No perfdata on Worst BA */ ASSERT_EQ(test_ba->get_perfdata(), ""); } @@ -187,7 +188,8 @@ TEST_F(KpiBA, KpiBaPb) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -201,11 +203,11 @@ TEST_F(KpiBA, KpiBaPb) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); @@ -289,7 +291,8 @@ TEST_F(KpiBA, KpiBaDt) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -303,11 +306,11 @@ TEST_F(KpiBA, KpiBaDt) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); @@ -399,7 +402,8 @@ TEST_F(KpiBA, KpiBaDtPb) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -413,11 +417,11 @@ TEST_F(KpiBA, KpiBaDtPb) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); @@ -510,7 +514,8 @@ TEST_F(KpiBA, KpiBaDtOff) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -524,11 +529,11 @@ TEST_F(KpiBA, KpiBaDtOff) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); @@ -630,7 +635,8 @@ TEST_F(KpiBA, KpiBaDtOffPb) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -644,11 +650,11 @@ TEST_F(KpiBA, KpiBaDtOffPb) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); @@ -756,7 +762,8 @@ TEST_F(KpiBA, KpiBaOkDtOff) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -770,11 +777,11 @@ TEST_F(KpiBA, KpiBaOkDtOff) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); @@ -860,7 +867,8 @@ TEST_F(KpiBA, KpiBaOkDtOffPb) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -874,11 +882,11 @@ TEST_F(KpiBA, KpiBaOkDtOffPb) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); @@ -974,7 +982,8 @@ TEST_F(KpiBA, KpiBaWorstImpact) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -986,12 +995,12 @@ TEST_F(KpiBA, KpiBaWorstImpact) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); kpi_ba_child->set_impact_unknown(27); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); @@ -1070,7 +1079,8 @@ TEST_F(KpiBA, KpiBaWorstImpactPb) { /* Construction of kpi_services */ for (int i = 0; i < 2; i++) { - auto s = std::make_shared(i + 1, 2, 3, 1 + i); + auto s = std::make_shared(i + 1, 2, 3, 1 + i, + fmt::format("service {}", i)); s->set_downtimed(false); s->set_impact_critical(100); s->set_impact_unknown(0); @@ -1082,12 +1092,12 @@ TEST_F(KpiBA, KpiBaWorstImpactPb) { } /* Construction of kpi_ba */ - auto kpi_ba_child = std::make_shared(3, 2); + auto kpi_ba_child = std::make_shared(3, 2, "ba 2"); kpi_ba_child->set_impact_critical(100); kpi_ba_child->set_impact_warning(75); kpi_ba_child->set_impact_unknown(27); - auto kpi_ba = std::make_shared(4, 1); + auto kpi_ba = std::make_shared(4, 1, "ba 1"); kpi_ba->set_impact_critical(100); kpi_ba->set_impact_warning(75); diff --git a/broker/bam/test/ba/kpi_service.cc b/broker/bam/test/ba/kpi_service.cc index 7954c41ac00..3b38f6275f5 100644 --- a/broker/bam/test/ba/kpi_service.cc +++ b/broker/bam/test/ba/kpi_service.cc @@ -73,7 +73,7 @@ TEST_F(BamBA, KpiServiceRecompute) { test_ba->set_level_warning(25); std::shared_ptr kpi{ - std::make_shared(1, 1, 1, 1)}; + std::make_shared(1, 1, 1, 1, "host_1/serv_1")}; kpi->set_impact_critical(100.0); kpi->set_state_hard(bam::state_ok); @@ -97,7 +97,7 @@ TEST_F(BamBA, KpiServiceRecompute) { /* Here is an occasion to checkout output from ba when it is critical */ ASSERT_EQ(test_ba->get_output(), "Status is CRITICAL - Level = 0 - 1 KPI out of 1 impacts the " - "BA for 100 points - KPI1 (impact: 100)"); + "BA for 100 points - KPI host_1/serv_1 (impact: 100)"); ASSERT_EQ(test_ba->get_perfdata(), "BA_Level=0;25;0;0;100"); } } @@ -128,7 +128,8 @@ TEST_F(BamBA, KpiServiceImpactState) { std::vector results{0, 0, 1, 1, 1, 2}; for (int i = 0; i < 3; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared( + i + 1, 1, i + 1, 1, fmt::format("host_{}/serv_1", i + 1)); s->set_impact_warning(10); s->set_impact_critical(20); s->set_state_hard(bam::state_ok); @@ -165,14 +166,14 @@ TEST_F(BamBA, KpiServiceImpactState) { * totally */ ASSERT_EQ(test_ba->get_output(), "Status is OK - Level = 90 (warn: 70 - crit: 40) - 1 KPI " - "out of 3 impacts the BA: KPI1 (impact: 10)"); + "out of 3 impacts the BA: KPI host_1/serv_1 (impact: 10)"); ASSERT_EQ(test_ba->get_perfdata(), "BA_Level=90;70;40;0;100"); } else if (j == 2) { /* Here is an occasion to test get_output for a status WARNING */ std::regex re( "Status is WARNING - Level = 70 - 3 KPIs out of 3 impact " - "the BA for 30 points - KPI. \\(impact: 10\\), KPI. \\(impact: " - "10\\), KPI. \\(impact: 10\\)"); + "the BA for 30 points - KPI.+ \\(impact: 10\\), KPI.+ \\(impact: " + "10\\), KPI.+ \\(impact: 10\\)"); ASSERT_TRUE(std::regex_search(test_ba->get_output(), re)); ASSERT_EQ(test_ba->get_perfdata(), "BA_Level=70;70;40;0;100"); } @@ -248,7 +249,8 @@ TEST_F(BamBA, KpiServiceBestState) { std::vector results{0, 0, 1, 1, 1, 2}; for (size_t i = 0; i < 3; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_ok); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -305,7 +307,8 @@ TEST_F(BamBA, KpiServiceWorstState) { std::vector results{1, 1, 1, 2, 2, 2}; for (int i = 0; i < 3; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_impact_warning(10); s->set_impact_critical(20); s->set_state_hard(bam::state_ok); @@ -403,7 +406,8 @@ TEST_F(BamBA, KpiServiceRatioNum) { std::stack results{{2, 1, 1, 0}}; for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_ok); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -459,7 +463,8 @@ TEST_F(BamBA, KpiServiceRatioPercent) { std::stack results({2, 1, 0, 0}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_ok); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -500,7 +505,8 @@ TEST_F(BamBA, KpiServiceDtInheritAllCritical) { std::stack results({true, false, false, false}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -547,7 +553,8 @@ TEST_F(BamBA, KpiServiceDtInheritAllCriticalPb) { std::stack results({true, false, false, false}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -596,7 +603,8 @@ TEST_F(BamBA, KpiServiceDtInheritOneOK) { std::stack results({false, false, false, false}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); if (i == 0) s->set_state_hard(bam::state_ok); else @@ -651,7 +659,8 @@ TEST_F(BamBA, KpiServiceDtInheritOneOKPb) { std::stack results({false, false, false, false}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); if (i == 0) s->set_state_hard(bam::state_ok); else @@ -708,7 +717,8 @@ TEST_F(BamBA, KpiServiceIgnoreDt) { std::stack results({false, false, false, false}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -755,7 +765,8 @@ TEST_F(BamBA, KpiServiceIgnoreDtPb) { std::stack results({false, false, false, false}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -805,7 +816,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpi) { std::stack results({false, false, false, false}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -852,7 +864,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpiPb) { std::stack results({false, false, false, false}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -907,7 +920,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpiImpact) { results.push(2); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); if (i == 3) s->set_state_hard(bam::state_ok); else @@ -961,7 +975,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpiImpactPb) { std::stack results({0, 0, 1, 2}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); if (i == 3) s->set_state_hard(bam::state_ok); else @@ -1016,7 +1031,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpiBest) { std::stack results({0, 2, 1, 0}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); switch (i) { case 0: case 1: @@ -1072,7 +1088,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpiBestPb) { std::stack results({0, 2, 1, 0}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); switch (i) { case 0: case 1: @@ -1132,7 +1149,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpiWorst) { std::stack results({0, 0, 1, 2}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); switch (i) { case 0: case 1: @@ -1188,7 +1206,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpiWorstPb) { std::stack results({0, 0, 1, 2}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); switch (i) { case 0: case 1: @@ -1249,7 +1268,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpiRatio) { std::stack results({0, 1, 2, 2}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -1296,7 +1316,8 @@ TEST_F(BamBA, KpiServiceDtIgnoreKpiRatioPb) { std::stack results({0, 1, 2, 2}); for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -1347,7 +1368,8 @@ TEST_F(BamBA, KpiServiceDt) { std::vector results{false, false, false, true}; for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -1507,7 +1529,8 @@ TEST_F(BamBA, KpiServiceDtPb) { std::vector results{false, false, false, true}; for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -1670,7 +1693,8 @@ TEST_F(BamBA, KpiServiceDtInherited_set) { std::vector results{false, false, false, true}; for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -1728,7 +1752,8 @@ TEST_F(BamBA, KpiServiceDtInherited_setPb) { std::vector results{false, false, false, true}; for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -1788,7 +1813,8 @@ TEST_F(BamBA, KpiServiceDtInherited_unset) { std::vector> kpis; for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -1833,7 +1859,8 @@ TEST_F(BamBA, KpiServiceDtInherited_unsetPb) { std::vector> kpis; for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -1879,7 +1906,8 @@ TEST_F(BamBA, KpiServiceAcknowledgement) { std::vector> kpis; for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); @@ -1926,7 +1954,8 @@ TEST_F(BamBA, KpiServiceAcknowledgementPb) { std::vector> kpis; for (int i = 0; i < 4; i++) { - auto s = std::make_shared(i + 1, 1, i + 1, 1); + auto s = std::make_shared(i + 1, 1, i + 1, 1, + fmt::format("service {}", i)); s->set_state_hard(bam::state_critical); s->set_state_soft(s->get_state_hard()); test_ba->add_impact(s); diff --git a/broker/bam/test/exp_builder/exp_builder.cc b/broker/bam/test/exp_builder/exp_builder.cc index b9c9e186605..17962d5f824 100644 --- a/broker/bam/test/exp_builder/exp_builder.cc +++ b/broker/bam/test/exp_builder/exp_builder.cc @@ -638,7 +638,7 @@ TEST_F(BamExpBuilder, KpiBoolexpWithService) { exp->set_expression(b); b->add_parent(exp); - auto kpi = std::make_shared(1, 1); + auto kpi = std::make_shared(1, 1, "test_boool_exp"); kpi->link_boolexp(exp); exp->add_parent(kpi); @@ -682,7 +682,7 @@ TEST_F(BamExpBuilder, KpiBoolexpReversedImpactWithService) { exp->set_expression(b); b->add_parent(exp); - auto kpi = std::make_shared(1, 1); + auto kpi = std::make_shared(1, 1, "test_boool_exp"); kpi->link_boolexp(exp); exp->add_parent(kpi); @@ -902,7 +902,7 @@ TEST_F(BamExpBuilder, BoolexpKpiServiceAndBoolExpression) { exp->set_expression(b); b->add_parent(exp); - auto kpi = std::make_shared(1, 1); + auto kpi = std::make_shared(1, 1, "test_boool_exp"); kpi->set_impact(100); kpi->link_boolexp(exp); exp->add_parent(kpi); @@ -1008,7 +1008,7 @@ TEST_F(BamExpBuilder, BoolexpKpiServiceAndBoolExpressionAndOperator) { exp->set_expression(b); b->add_parent(exp); - auto kpi = std::make_shared(1, 1); + auto kpi = std::make_shared(1, 1, "test_boool_exp"); kpi->set_impact(100); kpi->link_boolexp(exp); exp->add_parent(kpi); diff --git a/tests/bam/bam_pb.robot b/tests/bam/bam_pb.robot index 8ca5d43f345..828862b17f4 100644 --- a/tests/bam/bam_pb.robot +++ b/tests/bam/bam_pb.robot @@ -57,7 +57,7 @@ BAWORST ${result} Check Ba Output With Timeout ... test - ... Status is UNKNOWN - At least one KPI is in an UNKNOWN state: KPI2 is in UNKNOWN state + ... Status is UNKNOWN - At least one KPI is in an UNKNOWN state: KPI Service host_16/service_303 is in UNKNOWN state ... 60 Should Be True ${result} The BA test has not the expected output @@ -74,7 +74,7 @@ BAWORST ${result} Check Ba Output With Timeout ... test - ... Status is WARNING - At least one KPI is in a WARNING state: KPI2 is in WARNING state + ... Status is WARNING - At least one KPI is in a WARNING state: KPI Service host_16/service_303 is in WARNING state ... 60 Should Be True ${result} The BA test has not the expected output @@ -96,12 +96,105 @@ BAWORST ${result} Check Ba Output With Timeout ... test - ... Status is CRITICAL - At least one KPI is in a CRITICAL state: KPI2 is in WARNING state, KPI1 is in CRITICAL state + ... Status is CRITICAL - At least one KPI is in a CRITICAL state: KPI Service host_16/service_303 is in WARNING state, KPI Service host_16/service_314 is in CRITICAL state ... 60 Should Be True ${result} The BA test has not the expected output [Teardown] Run Keywords Stop Engine AND Kindly Stop Broker +BAWORST2 + [Documentation] a worst ba with a boolean kpi and a ba kpi + [Tags] broker engine bam + BAM Init + + ${id_ba__sid} Create Ba test worst 100 100 + Add Boolean Kpi + ... ${id_ba__sid[0]} + ... {host_16 service_302} {IS} {OK} + ... False + ... 100 + + # ba kpi + @{svc} Set Variable ${{ [("host_16", "service_314")] }} + ${id_ba__sid__child} Create Ba With Services test_child worst ${svc} + Add Ba Kpi ${id_ba__sid__child[0]} ${id_ba__sid[0]} 1 2 3 + + Start Broker + ${start} Get Current Date + Start Engine + # Let's wait for the external command check start + ${content} Create List check_for_external_commands() + ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 + Should Be True ${result} A message telling check_for_external_commands() should be available. + + ${result} Check Ba Status With Timeout test 0 60 + Dump Ba On Error ${result} ${id_ba__sid[0]} + Should Be True ${result} The BA test is not OK as expected + ${result} Check Ba Output With Timeout + ... test + ... Status is OK - All KPIs are in an OK state + ... 10 + Should Be True ${result} The BA test has not the expected output + + # boolean critical => ba test critical + Process Service Result Hard + ... host_16 + ... service_302 + ... 2 + ... output critical for service_302 + ${result} Check Service Status With Timeout host_16 service_302 2 60 HARD + Should Be True ${result} The service (host_16,service_302) is not CRITICAL as expected + Sleep 2s + ${result} Check Ba Status With Timeout test 2 60 + Dump Ba On Error ${result} ${id_ba__sid[0]} + Should Be True ${result} The BA test is not CRITICAL as expected + ${result} Check Ba Output With Timeout + ... test + ... Status is CRITICAL - At least one KPI is in a CRITICAL state: KPI Boolean rule bool test is in CRITICAL state + ... 10 + Should Be True ${result} The BA test has not the expected output + + # child ba critical + Process Service Result Hard + ... host_16 + ... service_314 + ... 2 + ... output critical for service_314 + ${result} Check Service Status With Timeout host_16 service_314 2 60 HARD + Should Be True ${result} The service (host_16,service_314) is not CRITICAL as expected + Sleep 2s + ${result} Check Ba Status With Timeout test_child 2 60 + Dump Ba On Error ${result} ${id_ba__sid[0]} + Should Be True ${result} The BA test_child is not CRITICAL as expected + ${result} Check Ba Status With Timeout test 2 60 + Dump Ba On Error ${result} ${id_ba__sid[0]} + Should Be True ${result} The BA test is not CRITICAL as expected + ${result} Check Ba Output With Timeout + ... test + ... Status is CRITICAL - At least one KPI is in a CRITICAL state: KPI Business Activity test_child is in CRITICAL state, KPI Boolean rule bool test is in CRITICAL state + ... 10 + Should Be True ${result} The BA test has not the expected output + + # boolean rule ok stay in critical + Process Service Result Hard + ... host_16 + ... service_302 + ... 0 + ... output OK + ${result} Check Service Status With Timeout host_16 service_302 0 60 HARD + Should Be True ${result} The service (host_16,service_302) is not OK as expected + Sleep 2s + ${result} Check Ba Status With Timeout test 2 60 + Dump Ba On Error ${result} ${id_ba__sid[0]} + Should Be True ${result} The BA test is not CRITICAL as expected + ${result} Check Ba Output With Timeout + ... test + ... Status is CRITICAL - At least one KPI is in a CRITICAL state: KPI Business Activity test_child is in CRITICAL state + ... 10 + Should Be True ${result} The BA test has not the expected output + + [Teardown] Run Keywords Stop Engine AND Kindly Stop Broker + BABEST_SERVICE_CRITICAL [Documentation] With bbdo version 3.0.1, a BA of type 'best' with 2 serv, ba is critical only if the 2 services are critical [Tags] broker engine bam @@ -235,7 +328,7 @@ BA_IMPACT_2KPI_SERVICES Should Be True ${result} The BA test is not OK as expected ${result} Check Ba Output With Timeout ... test - ... Status is OK - Level = 60 (warn: 35 - crit: 20) - 1 KPI out of 2 impacts the BA: KPI1 (impact: 40)|BA_Level=60;35;20;0;100 + ... Status is OK - Level = 60 (warn: 35 - crit: 20) - 1 KPI out of 2 impacts the BA: KPI Service host_16/service_302 (impact: 40)|BA_Level=60;35;20;0;100 ... 60 Should Be True ${result} The BA test has not the expected output @@ -247,7 +340,7 @@ BA_IMPACT_2KPI_SERVICES Should Be True ${result} The BA ba_1 is not WARNING as expected ${result} Check Ba Output With Timeout ... test - ... Status is WARNING - Level = 30 - 2 KPIs out of 2 impact the BA for 70 points - KPI2 (impact: 30), KPI1 (impact: 40)|BA_Level=30;35;20;0;100 + ... Status is WARNING - Level = 30 - 2 KPIs out of 2 impact the BA for 70 points - KPI Service host_16/service_303 (impact: 30), KPI Service host_16/service_302 (impact: 40)|BA_Level=30;35;20;0;100 ... 10 Should Be True ${result} The BA test has not the expected output @@ -269,7 +362,7 @@ BA_IMPACT_2KPI_SERVICES Should Be True ${result} The BA ba_1 is not CRITICAL as expected ${result} Check Ba Output With Timeout ... test - ... Status is CRITICAL - Level = 20 - 2 KPIs out of 2 impact the BA for 80 points - KPI2 (impact: 40), KPI1 (impact: 40)|BA_Level=20;35;20;0;100 + ... Status is CRITICAL - Level = 20 - 2 KPIs out of 2 impact the BA for 80 points - KPI Service host_16/service_303 (impact: 40), KPI Service host_16/service_302 (impact: 40)|BA_Level=20;35;20;0;100 ... 10 Should Be True ${result} The BA test has not the expected output @@ -282,7 +375,7 @@ BA_IMPACT_2KPI_SERVICES Should Be True ${result} The BA ba_1 is not OK as expected ${result} Check Ba Output With Timeout ... test - ... Status is OK - Level = 60 (warn: 35 - crit: 20) - 1 KPI out of 2 impacts the BA: KPI2 (impact: 40)|BA_Level=60;35;20;0;100 + ... Status is OK - Level = 60 (warn: 35 - crit: 20) - 1 KPI out of 2 impacts the BA: KPI Service host_16/service_303 (impact: 40)|BA_Level=60;35;20;0;100 ... 10 Should Be True ${result} The BA test has not the expected output @@ -306,7 +399,7 @@ BA_IMPACT_2KPI_SERVICES Should Be True ${result} The BA test is not OK as expected ${result} Check Ba Output With Timeout ... test - ... Status is OK - Level = 40 (warn: 35 - crit: 20) - 2 KPIs out of 2 impact the BA: KPI2 (impact: 30), KPI1 (impact: 30)|BA_Level=40;35;20;0;100 + ... Status is OK - Level = 40 (warn: 35 - crit: 20) - 2 KPIs out of 2 impact the BA: KPI Service host_16/service_303 (impact: 30), KPI Service host_16/service_302 (impact: 30)|BA_Level=40;35;20;0;100 ... 10 Should Be True ${result} The BA test has not the expected output diff --git a/tests/resources/resources.robot b/tests/resources/resources.robot index 52f2cce2010..301c24c12ed 100644 --- a/tests/resources/resources.robot +++ b/tests/resources/resources.robot @@ -95,7 +95,7 @@ Kindly Stop Broker ELSE IF ${result.rc} != 0 Save Logs - Copy Coredump In Failed Dir b1 /usr/sbin/cbd broker_central + # Copy Coredump In Failed Dir b1 /usr/sbin/cbd broker_central Coredump Info b1 /usr/sbin/cbd broker_central Should Be Equal As Integers ${result.rc} 0 Central Broker not correctly stopped END @@ -112,7 +112,7 @@ Kindly Stop Broker ELSE IF ${result.rc} != 0 Save Logs - Copy Coredump In Failed Dir b2 /usr/sbin/cbd broker_rrd + # Copy Coredump In Failed Dir b2 /usr/sbin/cbd broker_rrd Coredump Info b2 /usr/sbin/cbd broker_rrd Should Be Equal As Integers ${result.rc} 0 RRD Broker not correctly stopped END @@ -181,7 +181,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 @@ -296,7 +296,7 @@ Coredump Info Copy Coredump In Failed Dir [Arguments] ${process_name} ${binary_path} ${name} ${docker_env} Get Environment Variable RUN_ENV ${None} - IF ${docker_env} == "" + IF "${docker_env}" == "" ${pid} Get Process Id ${process_name} ${failDir} Catenate SEPARATOR= failed/ ${Test Name} Create Directory ${failDir} From a2cb6bc04f04d7f19ac6e9b580aff104ca0d3207 Mon Sep 17 00:00:00 2001 From: jean-christophe81 <98889244+jean-christophe81@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:04:18 +0100 Subject: [PATCH 07/39] Mon 21565 duplicate tests with grpc bbdo 3.1.0 (#898) * embed bbdo object in proto grpc message * bbdo give to grpc protobuf events without encoding * enh use of templated event_with_data * event_with_data with methid pointer * enh read events are not copied * fix tests * use of Config BBDO3 * fix(unified_sql): don't linked with roker_base * fix(ut_broker) session_base die after log_v2 * enh add alma9 grpc 3.10 tests * generation des packages A NE SURTOUT PAS GARDER * fix bad commit * yml lint fix * remove useless service_id in HostCheck * review comments * fix: improve tests REFS: MON-21505 REFS: MON-21565 --- .github/scripts/collect-test-robot.sh | 2 + .github/workflows/docker-builder.yml | 1 - .github/workflows/get-version.yml | 1 - .github/workflows/robot-nightly.yml | 18 +- .github/workflows/robot-test.yml | 21 +- bbdo/CMakeLists.txt | 13 + bbdo/bam.proto | 13 + bbdo/bbdo.proto | 5 +- bbdo/extcmd.proto | 1 + bbdo/neb.proto | 30 +- bbdo/rebuild_message.proto | 1 + bbdo/remove_graph_message.proto | 1 + bbdo/severity.proto | 1 + bbdo/storage.proto | 4 + bbdo/tag.proto | 1 + .../inc/com/centreon/broker/bbdo/acceptor.hh | 4 +- .../inc/com/centreon/broker/bbdo/connector.hh | 4 +- .../inc/com/centreon/broker/bbdo/stream.hh | 9 + .../inc/com/centreon/broker/io/factory.hh | 2 + .../inc/com/centreon/broker/io/protobuf.hh | 29 +- broker/core/src/bbdo/acceptor.cc | 9 +- broker/core/src/bbdo/connector.cc | 10 +- broker/core/src/bbdo/factory.cc | 59 ++-- broker/core/src/bbdo/stream.cc | 60 ++-- broker/core/src/compression/factory.cc | 3 + broker/core/src/io/factory.cc | 17 ++ broker/grpc/CMakeLists.txt | 46 ++- broker/grpc/generate_proto.py | 264 ++++++++++++++++++ broker/grpc/grpc_stream.proto | 15 - .../inc/com/centreon/broker/grpc/channel.hh | 55 +++- .../inc/com/centreon/broker/grpc/client.hh | 6 +- .../com/centreon/broker/grpc/grpc_bridge.hh | 38 +++ .../com/centreon/broker/grpc/grpc_config.hh | 37 ++- .../inc/com/centreon/broker/grpc/server.hh | 2 +- .../inc/com/centreon/broker/grpc/stream.hh | 2 + broker/grpc/src/channel.cc | 36 ++- broker/grpc/src/client.cc | 4 +- broker/grpc/src/factory.cc | 41 +-- broker/grpc/src/server.cc | 8 +- broker/grpc/src/stream.cc | 25 +- broker/grpc/test/acceptor.cc | 4 +- broker/grpc/test/channel_test.cc | 17 +- broker/grpc/test/grpc_test_include.hh | 3 +- broker/grpc/test/stream_test.cc | 16 +- .../http_client/test/http_connection_test.cc | 39 +-- .../inc/com/centreon/broker/neb/internal.hh | 4 +- broker/neb/src/broker.cc | 7 +- broker/rrd/CMakeLists.txt | 108 ++++--- broker/storage/CMakeLists.txt | 8 +- broker/test/CMakeLists.txt | 1 + broker/tls/src/factory.cc | 3 + broker/unified_sql/CMakeLists.txt | 15 +- broker/unified_sql/src/stream_sql.cc | 6 +- tests/bam/pb_inherited_downtime.robot | 12 +- tests/broker-engine/anomaly-detection.robot | 28 +- tests/broker-engine/bbdo-protobuf.robot | 19 +- tests/broker-engine/bench.robot | 4 +- tests/broker-engine/downtimes.robot | 6 +- tests/broker-engine/external-commands.robot | 60 +--- tests/broker-engine/external-commands2.robot | 60 ++-- tests/broker-engine/hostgroups.robot | 13 +- .../hosts-with-notes-and-actions.robot | 12 +- tests/broker-engine/output-tables.robot | 18 +- .../broker-engine/retention-duplicates.robot | 14 +- tests/broker-engine/rrd-from-db.robot | 7 +- tests/broker-engine/rrdcached-from-db.robot | 4 +- tests/broker-engine/servicegroups.robot | 8 +- .../services-and-bulk-stmt.robot | 43 ++- tests/broker-engine/services-increased.robot | 10 +- .../services-with-notes-and-actions.robot | 12 +- tests/broker-engine/services.robot | 4 +- tests/broker-engine/tags.robot | 53 +--- tests/broker/bbdo-server-client-ko.robot | 6 +- .../broker/bbdo-server-client-reversed.robot | 82 +++--- tests/broker/bbdo-server-client.robot | 66 ++--- tests/broker/sql.robot | 1 + tests/ccc/ccc.robot | 28 +- tests/engine/forced_checks.robot | 10 +- tests/migration/migration.robot | 6 +- tests/resources/Bench.py | 11 +- tests/resources/Broker.py | 54 +++- tests/resources/Common.py | 20 +- tests/resources/resources.robot | 8 +- tests/severities/hosts.robot | 14 +- tests/severities/severities.robot | 22 +- 85 files changed, 1134 insertions(+), 710 deletions(-) create mode 100755 broker/grpc/generate_proto.py delete mode 100644 broker/grpc/grpc_stream.proto create mode 100644 broker/grpc/inc/com/centreon/broker/grpc/grpc_bridge.hh diff --git a/.github/scripts/collect-test-robot.sh b/.github/scripts/collect-test-robot.sh index 03567ceb6b4..fae6945272a 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/docker-builder.yml b/.github/workflows/docker-builder.yml index ee224b96c10..9904e12451d 100644 --- a/.github/workflows/docker-builder.yml +++ b/.github/workflows/docker-builder.yml @@ -98,4 +98,3 @@ jobs: pull: true push: true tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ matrix.tag }} - diff --git a/.github/workflows/get-version.yml b/.github/workflows/get-version.yml index 8bdbbcab148..6e9801f8d67 100644 --- a/.github/workflows/get-version.yml +++ b/.github/workflows/get-version.yml @@ -85,4 +85,3 @@ jobs: echo "env=$VERSION-$ENV" >> $GITHUB_OUTPUT echo "GH_ENV: $VERSION-$ENV" shell: bash - diff --git a/.github/workflows/robot-nightly.yml b/.github/workflows/robot-nightly.yml index 943a326895a..638c229d865 100644 --- a/.github/workflows/robot-nightly.yml +++ b/.github/workflows/robot-nightly.yml @@ -68,17 +68,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-test 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-test 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-test + 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: @@ -90,6 +104,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 6a459989e00..130575cf3b0 100644 --- a/.github/workflows/robot-test.yml +++ b/.github/workflows/robot-test.yml @@ -25,6 +25,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 @@ -98,7 +104,7 @@ jobs: matrix: feature: ${{ fromJson(needs.robot-test-list.outputs.features) }} - name: ${{ matrix.feature }} ${{inputs.database_type}} + name: ${{ matrix.feature }} ${{inputs.test_group_name}} steps: - name: Checkout sources @@ -119,10 +125,10 @@ jobs: path: ${{ inputs.package_cache_path }} key: ${{ inputs.package_cache_key }} fail-on-cache-miss: true - + - name: load image run: | - docker load --input /tmp/${{ inputs.image }} + docker load --input /tmp/${{ inputs.image }} - name: Test ${{ matrix.feature }} run: | @@ -134,9 +140,8 @@ jobs: --workdir /test_collect \ ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image_test}} \ ./.github/scripts/collect-test-robot.sh \ - ${{ matrix.feature }} ${{inputs.database_type}} + ${{ matrix.feature }} ${{inputs.database_type}} ${{inputs.tests_params}} - env: AWS_ACCESS_KEY_ID: ${{ secrets.collect_s3_access_key }} AWS_SECRET_ACCESS_KEY: ${{ secrets.collect_s3_secret_key }} @@ -146,7 +151,7 @@ jobs: if: ${{ failure() }} 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}} if [ -d tests/failed ] ; then cp -rp tests/failed reports/$FILE_PREFIX-failed cp tests/log.html reports/$FILE_PREFIX-log.html @@ -157,7 +162,7 @@ jobs: if: ${{ failure() }} 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 @@ -172,7 +177,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/bbdo/CMakeLists.txt b/bbdo/CMakeLists.txt index a9a27c522a4..bd7c2a736c7 100644 --- a/bbdo/CMakeLists.txt +++ b/bbdo/CMakeLists.txt @@ -78,6 +78,19 @@ add_library(pb_extcmd_lib STATIC extcmd.pb.cc extcmd.pb.h) add_dependencies(pb_extcmd_lib target_extcmd target_header) set_target_properties(pb_extcmd_lib PROPERTIES POSITION_INDEPENDENT_CODE ON) +add_library(pb_rebuild_message_lib STATIC rebuild_message.pb.cc + rebuild_message.pb.h) +add_dependencies(pb_rebuild_message_lib target_rebuild_message target_header) +set_target_properties(pb_rebuild_message_lib + PROPERTIES POSITION_INDEPENDENT_CODE ON) + +add_library(pb_remove_graph_message_lib STATIC remove_graph_message.pb.cc + remove_graph_message.pb.h) +add_dependencies(pb_remove_graph_message_lib target_remove_graph_message + target_header) +set_target_properties(pb_remove_graph_message_lib + PROPERTIES POSITION_INDEPENDENT_CODE ON) + macro(get_protobuf_files name) set_source_files_properties("${CMAKE_SOURCE_DIR}/bbdo/${name}.pb.cc" PROPERTIES GENERATED TRUE) diff --git a/bbdo/bam.proto b/bbdo/bam.proto index f27498d83cd..64084f86811 100644 --- a/bbdo/bam.proto +++ b/bbdo/bam.proto @@ -29,12 +29,14 @@ enum State { UNKNOWN = 3; } +/*io::bam, bam::de_pb_inherited_downtime*/ message InheritedDowntime { BBDOHeader header = 1; uint32 ba_id = 2; bool in_downtime = 3; } +/*io::bam, bam::de_pb_ba_status*/ message BaStatus { uint32 ba_id = 2; bool in_downtime = 3; @@ -47,6 +49,7 @@ message BaStatus { string output = 10; } +/*io::bam, bam::de_pb_ba_event*/ message BaEvent { uint32 ba_id = 1; double first_level = 2; @@ -56,6 +59,7 @@ message BaEvent { State status = 6; } +/*io::bam, bam::de_pb_kpi_event*/ message KpiEvent { uint32 ba_id = 1; uint64 start_time = 2; @@ -68,17 +72,20 @@ message KpiEvent { State status = 9; } +/*io::bam, bam::de_pb_dimension_bv_event*/ message DimensionBvEvent { uint32 bv_id = 1; string bv_name = 2; string bv_description = 3; } +/*io::bam, bam::de_pb_dimension_ba_bv_relation_event*/ message DimensionBaBvRelationEvent { uint32 ba_id = 1; uint32 bv_id = 2; } +/*io::bam, bam::de_pb_dimension_timeperiod*/ message DimensionTimeperiod { uint32 id = 1; string name = 2; @@ -91,6 +98,7 @@ message DimensionTimeperiod { string sunday = 9; } +/*io::bam, bam::de_pb_dimension_ba_event*/ message DimensionBaEvent { uint32 ba_id = 1; string ba_name = 2; @@ -101,6 +109,7 @@ message DimensionBaEvent { uint32 sla_duration_warn = 7; } +/*io::bam, bam::de_pb_dimension_kpi_event*/ message DimensionKpiEvent { uint32 kpi_id = 1; uint32 ba_id = 2; @@ -120,6 +129,7 @@ message DimensionKpiEvent { double impact_unknown = 16; } +/*io::bam, bam::de_pb_kpi_status*/ message KpiStatus { uint32 kpi_id = 1; bool in_downtime = 2; @@ -136,6 +146,7 @@ message KpiStatus { bool valid = 13; } +/*io::bam, bam::de_pb_ba_duration_event*/ message BaDurationEvent { uint32 ba_id = 1; int64 real_start_time = 2; @@ -147,12 +158,14 @@ message BaDurationEvent { bool timeperiod_is_default = 8; } +/*io::bam, bam::de_pb_dimension_ba_timeperiod_relation*/ message DimensionBaTimeperiodRelation { uint32 ba_id = 1; uint32 timeperiod_id = 2; bool is_default = 3; } +/*io::bam, bam::de_pb_dimension_truncate_table_signal*/ message DimensionTruncateTableSignal { bool update_started = 1; } \ No newline at end of file diff --git a/bbdo/bbdo.proto b/bbdo/bbdo.proto index 9c676965d42..cc4aa5f6553 100644 --- a/bbdo/bbdo.proto +++ b/bbdo/bbdo.proto @@ -20,12 +20,14 @@ syntax = "proto3"; package com.centreon.broker; + message Bbdo { uint32 major = 1; uint32 minor = 2; uint32 patch = 3; } +/*io::bbdo, bbdo::de_welcome*/ message Welcome { Bbdo version = 1; string extensions = 2; @@ -33,10 +35,11 @@ message Welcome { string poller_name = 4; } - +/*io::bbdo, bbdo::de_pb_ack*/ message Ack { uint32 acknowledged_events = 1; } +/*io::bbdo, bbdo::de_pb_stop*/ message Stop { } \ No newline at end of file diff --git a/bbdo/extcmd.proto b/bbdo/extcmd.proto index efeec742e01..f0cadaf0397 100644 --- a/bbdo/extcmd.proto +++ b/bbdo/extcmd.proto @@ -36,6 +36,7 @@ message TimePoint { * from engine to dest with several timepoints (one per muxer) * */ +/*io::extcmd, extcmd::de_pb_bench*/ message Bench { uint32 id = 1; repeated TimePoint points = 2; diff --git a/bbdo/neb.proto b/bbdo/neb.proto index 65cfc597b41..ac99278bb27 100644 --- a/bbdo/neb.proto +++ b/bbdo/neb.proto @@ -41,6 +41,7 @@ enum AckType { STICKY = 2; } +/*io::neb, neb::de_pb_service*/ message Service { uint64 host_id = 1; uint64 service_id = 2; @@ -159,6 +160,7 @@ message Service { /** * @brief Message sent in BBDO 3.0.0 instead of neb::service_status */ +/*io::neb, neb::de_pb_service_status*/ message ServiceStatus { uint64 host_id = 1; uint64 service_id = 2; @@ -225,6 +227,7 @@ message ServiceStatus { * * Only used with BBDO 3.0 */ +/*io::neb, neb::de_pb_adaptive_service*/ message AdaptiveService { uint64 host_id = 1; uint64 service_id = 2; @@ -246,6 +249,7 @@ message AdaptiveService { optional string notification_period = 17; } +/*io::neb, neb::de_pb_host*/ message Host { uint64 host_id = 1; @@ -352,6 +356,7 @@ message Host { /** * @brief Message sent in BBDO 3.0.0 instead of neb::service_status */ +/*io::neb, neb::de_pb_host_status*/ message HostStatus { uint64 host_id = 1; @@ -408,6 +413,7 @@ message HostStatus { * * Only used with BBDO 3.0 */ +/*io::neb, neb::de_pb_adaptive_host*/ message AdaptiveHost { uint64 host_id = 1; @@ -428,6 +434,7 @@ message AdaptiveHost { optional string notification_period = 16; } +/*io::neb, neb::de_pb_comment*/ message Comment { BBDOHeader header = 1; @@ -470,6 +477,7 @@ message Comment { * @brief A downtime is applied on a resource when we don't want notifications * concerning bad states on this resource. */ +/*io::neb, neb::de_pb_downtime*/ message Downtime { enum DowntimeType { NOT_USED = 0; @@ -497,6 +505,7 @@ message Downtime { bool fixed = 18; } +/*io::neb, neb::de_pb_custom_variable*/ message CustomVariable { enum VarType { HOST = 0; @@ -521,7 +530,8 @@ enum CheckType { CheckPassive = 1; } -message Check { +/*io::neb, neb::de_pb_host_check*/ +message HostCheck { BBDOHeader header = 1; bool active_checks_enabled = 2; @@ -529,9 +539,21 @@ message Check { string command_line = 4; uint64 host_id = 5; uint64 next_check = 6; - uint64 service_id = 7; } +/*io::neb, neb::de_pb_service_check*/ +message ServiceCheck { + BBDOHeader header = 1; + + bool active_checks_enabled = 2; + CheckType check_type = 3; + string command_line = 4; + uint64 host_id = 5; + uint64 next_check = 6; + uint64 service_id = 7; +} + +/*io::neb, neb::de_pb_log_entry*/ message LogEntry { enum LogType { SOFT = 0; @@ -569,6 +591,7 @@ message LogEntry { int32 retry = 13; } +/*io::neb, neb::de_pb_instance_status*/ message InstanceStatus { BBDOHeader header = 1; @@ -590,6 +613,7 @@ message InstanceStatus { uint64 instance_id = 17; } +/*io::neb, neb::de_pb_instance*/ message Instance { BBDOHeader header = 1; @@ -603,6 +627,7 @@ message Instance { string version = 9; } +/*io::neb, neb::de_pb_responsive_instance*/ message ResponsiveInstance { BBDOHeader header = 1; @@ -610,6 +635,7 @@ message ResponsiveInstance { bool responsive = 3; } +/*io::neb, neb::de_pb_acknowledgement*/ message Acknowledgement { uint64 host_id = 1; uint64 service_id = 2; diff --git a/bbdo/rebuild_message.proto b/bbdo/rebuild_message.proto index 72d34775606..afc1e410747 100644 --- a/bbdo/rebuild_message.proto +++ b/bbdo/rebuild_message.proto @@ -15,6 +15,7 @@ message Timeserie { uint32 rrd_retention = 4; } +/*io::storage, storage::de_rebuild_message*/ message RebuildMessage { enum State { START = 0; diff --git a/bbdo/remove_graph_message.proto b/bbdo/remove_graph_message.proto index e8de80544bd..8c35c876890 100644 --- a/bbdo/remove_graph_message.proto +++ b/bbdo/remove_graph_message.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package com.centreon.broker; +/*io::storage, storage::de_remove_graph_message*/ message RemoveGraphMessage { repeated uint64 index_ids = 1; repeated uint64 metric_ids = 2; diff --git a/bbdo/severity.proto b/bbdo/severity.proto index 3ce06ca99bb..44781d3af1c 100644 --- a/bbdo/severity.proto +++ b/bbdo/severity.proto @@ -35,6 +35,7 @@ package com.centreon.broker; * relations between resources of our poller and this severity. And only if the * severity is no more used at all, we can remove it. */ +/*io::neb, neb::de_pb_severity*/ message Severity { uint64 id = 1; enum Action { diff --git a/bbdo/storage.proto b/bbdo/storage.proto index 294070f7bf5..9c097a3a089 100644 --- a/bbdo/storage.proto +++ b/bbdo/storage.proto @@ -20,6 +20,7 @@ syntax = "proto3"; package com.centreon.broker; +/*io::storage, storage::de_pb_metric*/ message Metric { enum ValueType { GAUGE = 0; @@ -39,6 +40,7 @@ message Metric { uint64 service_id = 12; } +/*io::storage, storage::de_pb_status*/ message Status { uint64 index_id = 1; uint32 interval = 2; @@ -49,12 +51,14 @@ message Status { uint64 service_id = 7; } +/*io::storage, storage::de_pb_index_mapping*/ message IndexMapping { uint64 index_id = 1; uint64 host_id = 2; uint64 service_id = 3; } +/*io::storage, storage::de_pb_metric_mapping*/ message MetricMapping { uint64 index_id = 1; uint64 metric_id = 2; diff --git a/bbdo/tag.proto b/bbdo/tag.proto index 2622b78db42..d12898d8470 100644 --- a/bbdo/tag.proto +++ b/bbdo/tag.proto @@ -41,6 +41,7 @@ enum TagType { HOSTCATEGORY = 3; } +/*io::neb, neb::de_pb_tag*/ message Tag { uint64 id = 1; enum Action { diff --git a/broker/core/inc/com/centreon/broker/bbdo/acceptor.hh b/broker/core/inc/com/centreon/broker/bbdo/acceptor.hh index e5e02f78a46..e75e25560e6 100644 --- a/broker/core/inc/com/centreon/broker/bbdo/acceptor.hh +++ b/broker/core/inc/com/centreon/broker/bbdo/acceptor.hh @@ -47,6 +47,7 @@ class acceptor : public io::endpoint { time_t _timeout; uint32_t _ack_limit; std::list> _extensions; + const bool _grpc_serialized; public: acceptor(std::string name, @@ -55,7 +56,8 @@ class acceptor : public io::endpoint { bool one_peer_retention_mode = false, bool coarse = false, uint32_t ack_limit = 1000, - std::list>&& extensions = {}); + std::list>&& extensions = {}, + bool grpc_serialized = false); ~acceptor() noexcept; acceptor(const acceptor&) = delete; acceptor& operator=(const acceptor&) = delete; diff --git a/broker/core/inc/com/centreon/broker/bbdo/connector.hh b/broker/core/inc/com/centreon/broker/bbdo/connector.hh index eb949126ba7..54f4d4dfea0 100644 --- a/broker/core/inc/com/centreon/broker/bbdo/connector.hh +++ b/broker/core/inc/com/centreon/broker/bbdo/connector.hh @@ -38,6 +38,7 @@ class connector : public io::endpoint { time_t _timeout; uint32_t _ack_limit; std::list> _extensions; + const bool _grpc_serialized; std::shared_ptr _open(std::shared_ptr stream); @@ -47,7 +48,8 @@ class connector : public io::endpoint { bool connector_is_input, bool coarse = false, uint32_t ack_limit = 1000, - std::list>&& extensions = {}); + std::list>&& extensions = {}, + bool grpc_serialized = false); ~connector() noexcept = default; connector(const connector&) = delete; connector& operator=(const connector&) = delete; diff --git a/broker/core/inc/com/centreon/broker/bbdo/stream.hh b/broker/core/inc/com/centreon/broker/bbdo/stream.hh index 31afbd3f7e9..54a4e3a0fca 100644 --- a/broker/core/inc/com/centreon/broker/bbdo/stream.hh +++ b/broker/core/inc/com/centreon/broker/bbdo/stream.hh @@ -137,6 +137,14 @@ class stream : public io::stream { uint32_t _ack_limit; uint32_t _events_received_since_last_ack; time_t _last_sent_ack; + const bool _grpc_serialized; + + /** + * @brief when we bypass bbdo serialization, we store object received by grpc + * layer in this queue + * + */ + std::deque> _grpc_serialized_queue; /** * It is possible to mix bbdo stream with others like tls or compression. @@ -157,6 +165,7 @@ class stream : public io::stream { enum negotiation_type { negotiate_first = 1, negotiate_second, negotiated }; stream(bool is_input, + bool grpc_serialized = false, const std::list>& extensions = {}); ~stream(); stream(const stream&) = delete; diff --git a/broker/core/inc/com/centreon/broker/io/factory.hh b/broker/core/inc/com/centreon/broker/io/factory.hh index af47da645e9..0ff18b5d2e9 100644 --- a/broker/core/inc/com/centreon/broker/io/factory.hh +++ b/broker/core/inc/com/centreon/broker/io/factory.hh @@ -63,6 +63,8 @@ class factory { std::shared_ptr substream, bool is_acceptor, const std::unordered_map& options); + + static bool direct_grpc_serialized(const config::endpoint& cfg); }; } // namespace io diff --git a/broker/core/inc/com/centreon/broker/io/protobuf.hh b/broker/core/inc/com/centreon/broker/io/protobuf.hh index 14277c9ccf9..7ae1d817e50 100644 --- a/broker/core/inc/com/centreon/broker/io/protobuf.hh +++ b/broker/core/inc/com/centreon/broker/io/protobuf.hh @@ -54,6 +54,8 @@ class protobuf_base : public data { protobuf_base(uint32_t typ, google::protobuf::Message* msg) : data(typ), _msg{msg} {} + void set_message(google::protobuf::Message* msg) { _msg = msg; } + public: enum attribute { always_valid = 0, @@ -107,6 +109,18 @@ class protobuf : public protobuf_base { */ protobuf(const T& o) : protobuf_base(Typ, &_obj), _obj(o) {} + /** + * @brief Construct a new protobuf object + * same as previous constructor except that it accepts two more parameters + * @param o + * @param src_id source_id + * @param dest_id destination_id + */ + protobuf(const T& o, uint32_t src_id, uint32_t dest_id) : protobuf(o) { + source_id = src_id; + destination_id = dest_id; + } + protobuf(const protobuf& to_clone) : protobuf_base(Typ, &_obj) { _obj.CopyFrom(to_clone._obj); } @@ -168,11 +182,11 @@ class protobuf : public protobuf_base { return retval.release(); } - const T& obj() const { return _obj; } + virtual const T& obj() const { return _obj; } - T& mut_obj() { return _obj; } + virtual T& mut_obj() { return _obj; } - void set_obj(T&& obj) { _obj = std::move(obj); } + virtual void set_obj(T&& obj) { _obj = std::move(obj); } void dump(std::ostream& s) const override; void dump_more_detail(std::ostream& s) const override; @@ -191,13 +205,14 @@ const io::event_info::event_operations protobuf::operations{ template bool protobuf::operator==(const protobuf& to_cmp) const { - return google::protobuf::util::MessageDifferencer::Equals(_obj, to_cmp._obj); + return google::protobuf::util::MessageDifferencer::Equals(this->obj(), + (&to_cmp)->obj()); } template void protobuf::dump(std::ostream& s) const { data::dump(s); - std::string dump{_obj.ShortDebugString()}; + std::string dump{this->obj().ShortDebugString()}; if (dump.size() > 200) { dump.resize(200); s << fmt::format(" content:'{}...'", dump); @@ -208,13 +223,13 @@ void protobuf::dump(std::ostream& s) const { template void protobuf::dump_more_detail(std::ostream& s) const { data::dump(s); - s << " content:'" << _obj.ShortDebugString() << '\''; + s << " content:'" << this->obj().ShortDebugString() << '\''; } template void protobuf::dump_to_json(std::ostream& s) const { std::string json_dump; - google::protobuf::util::MessageToJsonString(_obj, &json_dump); + google::protobuf::util::MessageToJsonString(this->obj(), &json_dump); s << " content:'" << json_dump << '\''; } diff --git a/broker/core/src/bbdo/acceptor.cc b/broker/core/src/bbdo/acceptor.cc index a9e2d26412b..6b221b23c27 100644 --- a/broker/core/src/bbdo/acceptor.cc +++ b/broker/core/src/bbdo/acceptor.cc @@ -52,7 +52,8 @@ acceptor::acceptor(std::string name, bool one_peer_retention_mode, bool coarse, uint32_t ack_limit, - std::list>&& extensions) + std::list>&& extensions, + bool grpc_serialized) : io::endpoint(!one_peer_retention_mode, {}), _coarse(coarse), _name(std::move(name)), @@ -60,7 +61,8 @@ acceptor::acceptor(std::string name, _is_output(one_peer_retention_mode), _timeout(timeout), _ack_limit(ack_limit), - _extensions{extensions} { + _extensions{extensions}, + _grpc_serialized(grpc_serialized) { if (_timeout == (time_t)-1 || _timeout == 0) _timeout = 3; } @@ -87,7 +89,8 @@ std::shared_ptr acceptor::open() { if (u) { assert(!_coarse); // if _is_output, the stream is an output - auto my_bbdo = std::make_unique(!_is_output, _extensions); + auto my_bbdo = std::make_unique( + !_is_output, _grpc_serialized, _extensions); my_bbdo->set_substream(std::move(u)); my_bbdo->set_coarse(_coarse); my_bbdo->set_negotiate(_negotiate); diff --git a/broker/core/src/bbdo/connector.cc b/broker/core/src/bbdo/connector.cc index 5a0dbcab959..78a2cd84d26 100644 --- a/broker/core/src/bbdo/connector.cc +++ b/broker/core/src/bbdo/connector.cc @@ -45,7 +45,8 @@ connector::connector(bool negotiate, bool connector_is_input, bool coarse, uint32_t ack_limit, - std::list>&& extensions) + std::list>&& extensions, + bool grpc_serialized) : io::endpoint{false, {}}, _is_input{connector_is_input}, _coarse{coarse}, @@ -53,7 +54,8 @@ connector::connector(bool negotiate, // FIXME DBR: why this trick? _timeout(timeout == -1 || timeout == 0 ? 3 : timeout), _ack_limit{ack_limit}, - _extensions{std::move(extensions)} {} + _extensions{std::move(extensions)}, + _grpc_serialized(grpc_serialized) {} /** * Open the connector. @@ -68,7 +70,6 @@ std::shared_ptr connector::open() { if (_from) // Open lower layer connection and add our own layer. retval = _open(_from->open()); - return retval; } @@ -82,7 +83,8 @@ std::shared_ptr connector::_open( std::unique_ptr bbdo_stream; if (stream) { // if _is_input, the stream is an input - bbdo_stream = std::make_unique(_is_input, _extensions); + bbdo_stream = std::make_unique(_is_input, _grpc_serialized, + _extensions); bbdo_stream->set_substream(stream); bbdo_stream->set_coarse(_coarse); bbdo_stream->set_negotiate(_negotiate); diff --git a/broker/core/src/bbdo/factory.cc b/broker/core/src/bbdo/factory.cc index 4a4d3947c66..2f6f02a0a9a 100644 --- a/broker/core/src/bbdo/factory.cc +++ b/broker/core/src/bbdo/factory.cc @@ -16,10 +16,12 @@ ** For more information : contact@centreon.com */ -#include "com/centreon/broker/bbdo/factory.hh" +#include #include "com/centreon/broker/bbdo/acceptor.hh" #include "com/centreon/broker/bbdo/connector.hh" +#include "com/centreon/broker/bbdo/factory.hh" +#include "com/centreon/broker/config/applier/state.hh" #include "com/centreon/broker/config/parser.hh" #include "com/centreon/broker/io/protocols.hh" #include "com/centreon/broker/log_v2.hh" @@ -78,26 +80,27 @@ io::endpoint* factory::new_endpoint( // Return value. std::unique_ptr retval; + std::map::const_iterator it; // Coarse endpoint ? bool coarse = false; - { - auto it = cfg.params.find("coarse"); - if (it != cfg.params.end()) { - if (!absl::SimpleAtob(it->second, &coarse)) { - log_v2::bbdo()->error( - "factory: cannot parse the 'coarse' boolean: the content is '{}'", - it->second); - coarse = false; - } + it = cfg.params.find("coarse"); + if (it != cfg.params.end()) { + if (!absl::SimpleAtob(it->second, &coarse)) { + log_v2::bbdo()->error( + "factory: cannot parse the 'coarse' boolean: the content is '{}'", + it->second); + coarse = false; } } + // only grpc serialization? + bool grpc_serialized = direct_grpc_serialized(cfg); + // Negotiation allowed ? bool negotiate = false; std::list> extensions; if (!coarse) { - std::map::const_iterator it( - cfg.params.find("negotiation")); + it = cfg.params.find("negotiation"); if (it == cfg.params.end() || it->second != "no") negotiate = true; extensions = _extensions(cfg); @@ -105,24 +108,19 @@ io::endpoint* factory::new_endpoint( // Ack limit. uint32_t ack_limit{1000}; - { - std::map::const_iterator it( - cfg.params.find("ack_limit")); - if (it != cfg.params.end() && !absl::SimpleAtoi(it->second, &ack_limit)) { - log_v2::bbdo()->error( - "BBDO: Bad value for ack_limit, it must be an integer."); - ack_limit = 1000; - } + it = cfg.params.find("ack_limit"); + if (it != cfg.params.end() && !absl::SimpleAtoi(it->second, &ack_limit)) { + log_v2::bbdo()->error( + "BBDO: Bad value for ack_limit, it must be an integer."); + ack_limit = 1000; } // Create object. std::string host; - { - std::map::const_iterator it{ - cfg.params.find("host")}; - if (it != cfg.params.end()) - host = it->second; - } + + it = cfg.params.find("host"); + if (it != cfg.params.end()) + host = it->second; /* The substream is an acceptor (usually the substream a TCP acceptor */ if (is_acceptor) { @@ -130,12 +128,13 @@ io::endpoint* factory::new_endpoint( // When the connection is made to the map server, no retention is needed, // otherwise we want it. bool keep_retention{false}; - auto it = cfg.params.find("retention"); + it = cfg.params.find("retention"); if (it != cfg.params.end()) { if (cfg.type == "bbdo_server") { if (!absl::SimpleAtob(it->second, &keep_retention)) { log_v2::bbdo()->error( - "BBDO: cannot parse the 'retention' boolean: its content is '{}'", + "BBDO: cannot parse the 'retention' boolean: its content is " + "'{}'", it->second); keep_retention = false; } @@ -167,7 +166,7 @@ io::endpoint* factory::new_endpoint( retval = std::make_unique( cfg.name, negotiate, cfg.read_timeout, acceptor_is_output, coarse, - ack_limit, std::move(extensions)); + ack_limit, std::move(extensions), grpc_serialized); if (acceptor_is_output && keep_retention) is_acceptor = false; log_v2::bbdo()->debug("BBDO: new acceptor {}", cfg.name); @@ -175,7 +174,7 @@ io::endpoint* factory::new_endpoint( bool connector_is_input = cfg.get_io_type() == config::endpoint::input; retval = std::make_unique( negotiate, cfg.read_timeout, connector_is_input, coarse, ack_limit, - std::move(extensions)); + std::move(extensions), grpc_serialized); log_v2::bbdo()->debug("BBDO: new connector {}", cfg.name); } return retval.release(); diff --git a/broker/core/src/bbdo/stream.cc b/broker/core/src/bbdo/stream.cc index b3dfc05e8ac..b6ea425c389 100644 --- a/broker/core/src/bbdo/stream.cc +++ b/broker/core/src/bbdo/stream.cc @@ -598,9 +598,14 @@ static io::raw* serialize(const io::data& e) { } /** - * Default constructor. + * @brief Construct a new stream::stream object + * + * @param is_input true if we receive bbdo events such as broker input + * @param grpc_serialized true if serialization is done by grpc stream only + * @param extensions */ stream::stream(bool is_input, + bool grpc_serialized, const std::list>& extensions) : io::stream("BBDO"), _skipped(0), @@ -614,7 +619,8 @@ stream::stream(bool is_input, _events_received_since_last_ack(0), _last_sent_ack(time(nullptr)), _extensions{extensions}, - _bbdo_version(config::applier::state::instance().get_bbdo_version()) { + _bbdo_version(config::applier::state::instance().get_bbdo_version()), + _grpc_serialized(grpc_serialized) { SPDLOG_LOGGER_DEBUG(log_v2::core(), "create bbdo stream {:p}", static_cast(this)); } @@ -1152,6 +1158,12 @@ bool stream::_read_any(std::shared_ptr& d, time_t deadline) { for (;;) { /* Maybe we have to complete the header. */ _read_packet(BBDO_HEADER_SIZE, deadline); + if (!_grpc_serialized_queue.empty()) { + d = _grpc_serialized_queue.front(); + SPDLOG_LOGGER_TRACE(log_v2::bbdo(), "read event: {}", *d); + _grpc_serialized_queue.pop_front(); + return true; + } // Packet size is now at least BBDO_HEADER_SIZE and maybe contains // already a full BBDO packet. @@ -1195,6 +1207,7 @@ bool stream::_read_any(std::shared_ptr& d, time_t deadline) { // It is time to finish to read the packet. _read_packet(BBDO_HEADER_SIZE + packet_size, deadline); + // Now, _packet contains at least BBDO_HEADER_SIZE + packet_size bytes. std::vector content; @@ -1324,6 +1337,8 @@ bool stream::_read_any(std::shared_ptr& d, time_t deadline) { * just not finished, and so no data are lost. Received packets are BBDO packets * or maybe pieces of BBDO packets, so we keep vectors as is because usually a * vector should just represent a packet. + * In case of event serialized only by grpc stream, we store it in + * _grpc_serialized_queue * * @param size The wanted final size * @param deadline A time_t. @@ -1334,14 +1349,20 @@ void stream::_read_packet(size_t size, time_t deadline) { std::shared_ptr d; bool timeout = !_substream->read(d, deadline); - if (d && d->type() == io::raw::static_type()) { - std::vector& new_v = std::static_pointer_cast(d)->_buffer; - if (!new_v.empty()) { - if (_packet.size() == 0) { - _packet = std::move(new_v); - new_v.clear(); - } else - _packet.insert(_packet.end(), new_v.begin(), new_v.end()); + if (d) { + if (d->type() == io::raw::static_type()) { + std::vector& new_v = + std::static_pointer_cast(d)->_buffer; + if (!new_v.empty()) { + if (_packet.size() == 0) { + _packet = std::move(new_v); + new_v.clear(); + } else + _packet.insert(_packet.end(), new_v.begin(), new_v.end()); + } + } else { + _grpc_serialized_queue.push_back(d); + return; } } if (timeout) { @@ -1407,14 +1428,17 @@ void stream::statistics(nlohmann::json& tree) const { void stream::_write(const std::shared_ptr& d) { assert(d); - // Check if data exists. - std::shared_ptr serialized(serialize(*d)); - if (serialized) { - SPDLOG_LOGGER_TRACE(log_v2::bbdo(), - "BBDO: serialized event of type {} to {} bytes", - d->type(), serialized->size()); - _substream->write(serialized); - } + if (!_grpc_serialized || !std::dynamic_pointer_cast(d)) { + // Check if data exists. + std::shared_ptr serialized(serialize(*d)); + if (serialized) { + SPDLOG_LOGGER_TRACE(log_v2::bbdo(), + "BBDO: serialized event of type {} to {} bytes", + d->type(), serialized->size()); + _substream->write(serialized); + } + } else + _substream->write(d); } /** diff --git a/broker/core/src/compression/factory.cc b/broker/core/src/compression/factory.cc index d3f5015dd47..ad8bc1c759d 100644 --- a/broker/core/src/compression/factory.cc +++ b/broker/core/src/compression/factory.cc @@ -42,6 +42,9 @@ using namespace com::centreon::broker::compression; */ bool factory::has_endpoint(config::endpoint& cfg, io::extension* ext) { if (ext) { + if (direct_grpc_serialized(cfg)) { + return false; + } if (cfg.type == "bbdo_server" || cfg.type == "bbdo_client") { auto it = cfg.params.find("transport_protocol"); if (it != cfg.params.end()) { diff --git a/broker/core/src/io/factory.cc b/broker/core/src/io/factory.cc index a4d5949635a..445ea99b9d7 100644 --- a/broker/core/src/io/factory.cc +++ b/broker/core/src/io/factory.cc @@ -16,6 +16,9 @@ ** For more information : contact@centreon.com */ +#include + +#include "com/centreon/broker/config/applier/state.hh" #include "com/centreon/broker/io/factory.hh" #include "com/centreon/broker/log_v2.hh" #include "com/centreon/exceptions/msg_fmt.hh" @@ -47,3 +50,17 @@ std::shared_ptr factory::new_stream( "negotiation"); return nullptr; } + +bool factory::direct_grpc_serialized(const config::endpoint& cfg) { + if (cfg.type == "bbdo_client" || cfg.type == "bbdo_server") { + auto it = cfg.params.find("transport_protocol"); + if (it != cfg.params.end()) { + return absl::EqualsIgnoreCase(it->second, "grpc") && + config::applier::state::instance() + .get_bbdo_version() + .total_version >= + bbdo::bbdo_version(3, 1, 0).total_version; + } + } + return false; +} \ No newline at end of file diff --git a/broker/grpc/CMakeLists.txt b/broker/grpc/CMakeLists.txt index c2090e11b23..055f6b15d2f 100644 --- a/broker/grpc/CMakeLists.txt +++ b/broker/grpc/CMakeLists.txt @@ -21,7 +21,7 @@ set(MODULE_DIR "${PROJECT_SOURCE_DIR}/grpc") set(INC_DIR "${MODULE_DIR}/inc/com/centreon/broker/grpc") set(SRC_DIR "${MODULE_DIR}/src") set(TEST_DIR "${MODULE_DIR}/test") -include_directories(${MODULE_DIR}/inc ${SRC_DIR}) +include_directories(${MODULE_DIR}/inc ${SRC_DIR} ${CMAKE_SOURCE_DIR}/bbdo) # Sources. set(SOURCES @@ -34,7 +34,8 @@ set(SOURCES "${SRC_DIR}/server.cc" "${SRC_DIR}/stream.cc" "${SRC_DIR}/grpc_stream.grpc.pb.cc" - "${SRC_DIR}/grpc_stream.pb.cc") + "${SRC_DIR}/grpc_stream.pb.cc" + "${SRC_DIR}/grpc_bridge.cc") # Headers. set(HEADERS "${INC_DIR}/acceptor.hh" @@ -54,17 +55,47 @@ set(GRPC PARENT_SCOPE) add_library(${GRPC} SHARED ${SOURCES} ${HEADERS}) set_target_properties(${GRPC} PROPERTIES PREFIX "") -target_link_libraries(${GRPC} CONAN_PKG::spdlog) +target_link_libraries( + ${GRPC} + "-Wl,--whole-archive" + pb_neb_lib + pb_storage_lib + pb_bbdo_lib + pb_severity_lib + pb_tag_lib + pb_bam_lib + pb_extcmd_lib + pb_rebuild_message_lib + pb_remove_graph_message_lib + pb_header_lib + "-Wl,--no-whole-archive" + CONAN_PKG::spdlog) target_precompile_headers(${GRPC} PRIVATE precomp_inc/precomp.hh) -# include_directories($(Boost_INCLUDE_DIRS)) + +file( + GLOB bbdo_files + LIST_DIRECTORIES false + ${CMAKE_SOURCE_DIR}/bbdo/*.proto) + +add_custom_command( + OUTPUT ${MODULE_DIR}/grpc_stream.proto ${MODULE_DIR}/src/grpc_bridge.cc + COMMENT "Generating grpc_stream.proto from bbdo protobuf files" + DEPENDS ${bbdo_files} + COMMAND + python3 ARGS ${MODULE_DIR}/generate_proto.py -f + ${MODULE_DIR}/grpc_stream.proto -c ${MODULE_DIR}/src/grpc_bridge.cc -d + ${CMAKE_SOURCE_DIR}/bbdo + VERBATIM) add_custom_command( OUTPUT "${SRC_DIR}/grpc_stream.pb.cc" "${SRC_DIR}/grpc_stream.pb.h" DEPENDS ${MODULE_DIR}/grpc_stream.proto COMMENT "Generating interface files of grpc_stream.proto" - COMMAND ${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out=${SRC_DIR} - --proto_path=${MODULE_DIR} grpc_stream.proto + COMMAND + ${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out=${SRC_DIR} + --proto_path=${MODULE_DIR} --proto_path=${CMAKE_SOURCE_DIR}/bbdo + grpc_stream.proto VERBATIM) add_custom_command( @@ -74,7 +105,8 @@ add_custom_command( COMMAND ${Protobuf_PROTOC_EXECUTABLE} ARGS --grpc_out=${SRC_DIR} --plugin=protoc-gen-grpc=${CONAN_BIN_DIRS_GRPC}/grpc_cpp_plugin - --proto_path=${MODULE_DIR} grpc_stream.proto + --proto_path=${MODULE_DIR} --proto_path=${CMAKE_SOURCE_DIR}/bbdo + grpc_stream.proto VERBATIM) # Testing. diff --git a/broker/grpc/generate_proto.py b/broker/grpc/generate_proto.py new file mode 100755 index 00000000000..b5473c7d761 --- /dev/null +++ b/broker/grpc/generate_proto.py @@ -0,0 +1,264 @@ +#!/usr/bin/python3 +""" +** Copyright 2023 Centreon +** +** Licensed under the Apache License, Version 2.0(the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +** +** For more information : contact@centreon.com +""" + +from os import listdir +from os.path import isfile, join +import re +import argparse + + +file_begin_content = """syntax = "proto3"; + +""" + +file_message_centreon_event = """ +message CentreonEvent { + oneof content { + bytes buffer = 1; + +""" + +cc_file_begin_content = """ +/* + * Copyright 2023 Centreon (https://www.centreon.com/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * For more information : contact@centreon.com + * + * + * File generated by generate_proto.py + * + */ + + + +#include "grpc_stream.pb.h" +#include "com/centreon/broker/io/protobuf.hh" + +#include "com/centreon/broker/grpc/channel.hh" + +using namespace com::centreon::broker; + +CCB_BEGIN() + +namespace grpc { + + +namespace detail { + +/** + * @brief the goal of this class is to not copy protobuf object + * event created by grpc receive layer is embedded in this object subclass of + * io::protobuf + * + * @tparam T A Protobuf message + * @tparam Typ The type to associate to this class as a BBDO type. + */ +template +class received_protobuf : public io::protobuf { + public: + typedef const T& (grpc_event_type::*const_accessor)() const; + typedef T* (grpc_event_type::*mutable_accessor)(); + + private: + event_ptr _received; + const_accessor _const_access; + mutable_accessor _mutable_access; + + public: + /** + * @brief Construct a new received protobuf object + * + * @param received object created by grpc layer + * @param const_access accessor to const T such as grpc_event_type::welcome_() + * @param mutable_access accessor to T such as + * grpc_event_type::mutable_welcome_() + */ + received_protobuf(const event_ptr received, + const_accessor const_access, + mutable_accessor mutable_access) + : _received(received), + _const_access(const_access), + _mutable_access(mutable_access) { + io::data::source_id = received->source_id(); + io::data::destination_id = received->destination_id(); + io::protobuf_base::set_message(((*_received).*_mutable_access)()); + } + + const T& obj() const override{ return ((*_received).*_const_access)(); } + + T& mut_obj() override { return *((*_received).*_mutable_access)(); } + + void set_obj(T&& obj) override { + throw com::centreon::exceptions::msg_fmt("unauthorized usage {}", + typeid(*this).name()); + } +}; + +} // namespace detail + +""" + + +cc_file_protobuf_to_event_function = """ +/** + * @brief this function creates a io::protobuf_object from grpc received message + * + * @param stream_content message received + * @return std::shared_ptr shared_ptr>, null if + * unknown content received + */ +std::shared_ptr protobuf_to_event(const event_ptr & stream_content) { + switch(stream_content->content_case()) { +""" + +cc_file_create_event_with_data_function = """ + +/** + * @brief this function create a event_with_data structure that will be send on grpc. + * stream_content don't have a copy of event, so event mustn't be + * deleted before stream_content + * + * @param event to send + * @return object used for send on the wire + */ +std::shared_ptr create_event_with_data(const std::shared_ptr & event) { + std::shared_ptr ret; + switch(event->type()) { +""" +cc_file_create_event_with_data_function_end = """ + default: + SPDLOG_LOGGER_ERROR(log_v2::grpc(), "unknown event type: {}", *event); + } + if (ret) { + ret->grpc_event.set_destination_id(event->destination_id); + ret->grpc_event.set_source_id(event->source_id); + } + return ret; +} +""" + + +parser = argparse.ArgumentParser( + prog='generate_proto.py', description='generate grpc_stream.proto file by referencing message found in protobuf files') +parser.add_argument('-f', '--proto_file', + help='outputs files use by grpc module', required=True) +parser.add_argument('-c', '--cc_file', + help='output source file that must be compiled and linked int target library', required=True) +parser.add_argument('-d', '--proto_directory', + help='directory where to find protobuf files', required=True, action='append') + +args = parser.parse_args() + +message_parser = r'^message\s+(\w+)\s+\{' +io_protobuf_parser = r'\/\*\s*(\w+::\w+\s*,\s*\w+::\w+)\s*\*\/' + +one_of_index = 2 + +for directory in args.proto_directory: + proto_files = [f for f in listdir( + directory) if f[-6:] == ".proto" and isfile(join(directory, f))] + for file in proto_files: + with open(join(directory, file)) as proto_file: + messages = [] + io_protobuf_match = None + for line in proto_file.readlines(): + m = re.match(message_parser, line) + if m is not None and io_protobuf_match is not None: + messages.append([m.group(1), io_protobuf_match.group(1)]) + io_protobuf_match = None + else: + io_protobuf_match = re.match(io_protobuf_parser, line) + + if len(messages) > 0: + file_begin_content += f"import \"{file}\";\n" + for mess, id in messages: + # proto file + file_message_centreon_event += f" {mess} {mess}_ = {one_of_index};\n" + one_of_index += 1 + lower_mess = mess.lower() + # cc file + cc_file_protobuf_to_event_function += f""" case ::stream::CentreonEvent::k{mess}: + return std::make_shared>( + stream_content, &grpc_event_type::{lower_mess}_, + &grpc_event_type::mutable_{lower_mess}_); +""" + cc_file_create_event_with_data_function += f""" case make_type({id}): + ret = std::make_shared( + event, reinterpret_cast( + &grpc_event_type::release_{lower_mess}_)); + ret->grpc_event.set_allocated_{lower_mess}_(&std::static_pointer_cast>(event)->mut_obj()); + break; + +""" + +with open(args.proto_file, 'w', encoding="utf-8") as fp: + fp.write(file_begin_content) + fp.write(""" + +package com.centreon.broker.stream; + +""") + fp.write(file_message_centreon_event) + fp.write(""" + } + uint32 destination_id = 126; + uint32 source_id = 127; +} + +service centreon_bbdo { + //emitter connect to receiver + rpc exchange(stream CentreonEvent) returns (stream CentreonEvent) {} +} + +""") + +with open(args.cc_file, 'w') as fp: + fp.write(cc_file_begin_content) + fp.write(cc_file_protobuf_to_event_function) + fp.write(""" default: + SPDLOG_LOGGER_ERROR(log_v2::grpc(), "unknown content type: {} => ignored", + stream_content->content_case()); + return std::shared_ptr(); + } +} + + +""") + fp.write(cc_file_create_event_with_data_function) + fp.write(cc_file_create_event_with_data_function_end) + fp.write(""" + +} //namespace grpc + +CCB_END() + +""") diff --git a/broker/grpc/grpc_stream.proto b/broker/grpc/grpc_stream.proto deleted file mode 100644 index ffaf13cc3df..00000000000 --- a/broker/grpc/grpc_stream.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; - -package com.centreon.broker.stream; - - -message centreon_event { - oneof content { - bytes buffer = 1; - } -} - -service centreon_bbdo { - //emitter connect to receiver - rpc exchange(stream centreon_event) returns (stream centreon_event) {} -} diff --git a/broker/grpc/inc/com/centreon/broker/grpc/channel.hh b/broker/grpc/inc/com/centreon/broker/grpc/channel.hh index bc48974e209..c3c18c7609d 100644 --- a/broker/grpc/inc/com/centreon/broker/grpc/channel.hh +++ b/broker/grpc/inc/com/centreon/broker/grpc/channel.hh @@ -29,7 +29,7 @@ struct detail_centreon_event; std::ostream& operator<<(std::ostream&, const detail_centreon_event&); } // namespace grpc namespace stream { -std::ostream& operator<<(std::ostream&, const centreon_event&); +std::ostream& operator<<(std::ostream&, const CentreonEvent&); } // namespace stream } // namespace broker } // namespace centreon @@ -37,7 +37,7 @@ std::ostream& operator<<(std::ostream&, const centreon_event&); namespace centreon_grpc = com::centreon::broker::grpc; namespace centreon_stream = com::centreon::broker::stream; -using grpc_event_type = centreon_stream::centreon_event; +using grpc_event_type = centreon_stream::CentreonEvent; using event_ptr = std::shared_ptr; CCB_BEGIN() @@ -48,9 +48,9 @@ using channel_ptr = std::shared_ptr<::grpc::Channel>; using uint64_vector = std::vector; struct detail_centreon_event { - detail_centreon_event(const centreon_stream::centreon_event& todump) + detail_centreon_event(const centreon_stream::CentreonEvent& todump) : to_dump(todump) {} - const centreon_stream::centreon_event& to_dump; + const centreon_stream::CentreonEvent& to_dump; }; const std::string authorization_header("authorization"); @@ -69,23 +69,55 @@ constexpr uint32_t calc_accept_all_compression_mask() { * */ class channel : public std::enable_shared_from_this { + public: + /** + * @brief we pass our protobuf objects to grpc_event without copy + * so we must avoid that grpc_event delete message of protobuf object + * This the goal of this struct. + * At destruction, it releases protobuf object from grpc_event. + * Destruction of protobuf object is the job of shared_ptr + */ + struct event_with_data { + using pointer = std::shared_ptr; + grpc_event_type grpc_event; + std::shared_ptr bbdo_event; + typedef google::protobuf::Message* (grpc_event_type::*releaser_type)(); + releaser_type releaser; + + event_with_data() : releaser(nullptr) {} + + event_with_data(const std::shared_ptr& bbdo_evt, + releaser_type relser) + : bbdo_event(bbdo_evt), releaser(relser) {} + + event_with_data(const event_with_data&) = delete; + event_with_data& operator=(const event_with_data&) = delete; + + ~event_with_data() { + if (releaser) { + (grpc_event.*releaser)(); + } + } + }; + private: channel& operator=(const channel&) = delete; channel(const channel&) = delete; protected: - using event_queue = std::list; + using read_queue = std::deque; + using write_queue = std::deque; const std::string _class_name; /// read section - event_queue _read_queue; + read_queue _read_queue; bool _read_pending; event_ptr _read_current; // write section - event_queue _write_queue; - event_ptr _write_current; + write_queue _write_queue; + event_with_data::pointer _write_current; bool _write_pending; bool _error; @@ -101,7 +133,7 @@ class channel : public std::enable_shared_from_this { void start_read(bool first_read); void start_write(); - virtual void start_write(const event_ptr&) = 0; + virtual void start_write(const event_with_data::pointer&) = 0; virtual void start_read(event_ptr&, bool first_read) = 0; void on_write_done(bool ok); @@ -118,6 +150,7 @@ class channel : public std::enable_shared_from_this { virtual void shutdown() = 0; bool is_down() const { return _error || _thrown; }; bool is_alive() const { return !_error && !_thrown; } + grpc_config::pointer get_conf() const { return _conf; } std::pair read(time_t deadline) { return read(system_clock::from_time_t(deadline)); @@ -127,7 +160,7 @@ class channel : public std::enable_shared_from_this { } std::pair read(const system_clock::time_point& deadline); - int write(const event_ptr&); + int write(const event_with_data::pointer&); int flush(); virtual int stop(); @@ -140,7 +173,7 @@ CCB_END() namespace fmt { // formatter specializations for fmt template <> -struct formatter : ostream_formatter {}; +struct formatter : ostream_formatter {}; template <> struct formatter : ostream_formatter {}; diff --git a/broker/grpc/inc/com/centreon/broker/grpc/client.hh b/broker/grpc/inc/com/centreon/broker/grpc/client.hh index ccaf360ca63..cdcf5ec3239 100644 --- a/broker/grpc/inc/com/centreon/broker/grpc/client.hh +++ b/broker/grpc/inc/com/centreon/broker/grpc/client.hh @@ -31,8 +31,8 @@ namespace grpc { */ class client : public channel, public ::grpc::ClientBidiReactor< - ::com::centreon::broker::stream::centreon_event, - ::com::centreon::broker::stream::centreon_event> { + ::com::centreon::broker::stream::CentreonEvent, + ::com::centreon::broker::stream::CentreonEvent> { channel_ptr _channel; std::unique_ptr _stub; std::unique_ptr<::grpc::ClientContext> _context; @@ -48,7 +48,7 @@ class client : public channel, client(const grpc_config::pointer& conf); void start_read(event_ptr& to_read, bool first_read) override; - void start_write(const event_ptr& to_send) override; + void start_write(const event_with_data::pointer& to_send) override; void remove_hold(); diff --git a/broker/grpc/inc/com/centreon/broker/grpc/grpc_bridge.hh b/broker/grpc/inc/com/centreon/broker/grpc/grpc_bridge.hh new file mode 100644 index 00000000000..64c30b9b474 --- /dev/null +++ b/broker/grpc/inc/com/centreon/broker/grpc/grpc_bridge.hh @@ -0,0 +1,38 @@ +/* +** Copyright 2022 Centreon +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +** +** For more information : contact@centreon.com +*/ + +#ifndef CCB_GRPC_BRIDGE_HH +#define CCB_GRPC_BRIDGE_HH + +#include "com/centreon/broker/io/protobuf.hh" +#include "com/centreon/broker/namespace.hh" +#include "grpc_stream.pb.h" + +CCB_BEGIN() + +namespace grpc { +std::shared_ptr protobuf_to_event(const event_ptr& stream_content); + +std::shared_ptr create_event_with_data( + const std::shared_ptr& event); + +}; // namespace grpc + +CCB_END() + +#endif diff --git a/broker/grpc/inc/com/centreon/broker/grpc/grpc_config.hh b/broker/grpc/inc/com/centreon/broker/grpc/grpc_config.hh index 2c1fc7b2181..00683ba6c19 100644 --- a/broker/grpc/inc/com/centreon/broker/grpc/grpc_config.hh +++ b/broker/grpc/inc/com/centreon/broker/grpc/grpc_config.hh @@ -27,23 +27,31 @@ class grpc_config { enum compression_active { NO = 0, AUTO = 1, YES = 2 }; private: - std::string _hostport; - bool _crypted = false; - std::string _certificate, _cert_key, _ca_cert, _authorization; - // grpc_compression_level _compress_level; - std::string _ca_name; - compression_active _compress; - int _second_keepalive_interval; + const std::string _hostport; + const bool _crypted = false; + const std::string _certificate, _cert_key, _ca_cert, _authorization; + const std::string _ca_name; + const compression_active _compress; + const int _second_keepalive_interval; + /** + * @brief when _grpc_serialized is set, bbdo events are sent on the wire + * without bbdo stream serialization + * + */ + const bool _grpc_serialized; public: using pointer = std::shared_ptr; - grpc_config() : _compress(NO), _second_keepalive_interval(30) {} + grpc_config() + : _compress(NO), + _second_keepalive_interval(30), + _grpc_serialized(false) {} grpc_config(const std::string& hostp) : _hostport(hostp), - _crypted(false), _compress(NO), - _second_keepalive_interval(30) {} + _second_keepalive_interval(30), + _grpc_serialized(false) {} grpc_config(const std::string& hostp, bool crypted, const std::string& certificate, @@ -52,7 +60,8 @@ class grpc_config { const std::string& authorization, const std::string& ca_name, compression_active compression, - int second_keepalive_interval = 30) + int second_keepalive_interval, + bool grpc_serialized) : _hostport(hostp), _crypted(crypted), _certificate(certificate), @@ -61,7 +70,8 @@ class grpc_config { _authorization(authorization), _ca_name(ca_name), _compress(compression), - _second_keepalive_interval(second_keepalive_interval) {} + _second_keepalive_interval(second_keepalive_interval), + _grpc_serialized(grpc_serialized) {} constexpr const std::string& get_hostport() const { return _hostport; } constexpr bool is_crypted() const { return _crypted; } @@ -73,12 +83,11 @@ class grpc_config { } const std::string& get_ca_name() const { return _ca_name; } constexpr compression_active get_compression() const { return _compress; } + constexpr bool get_grpc_serialized() const { return _grpc_serialized; } int get_second_keepalive_interval() const { return _second_keepalive_interval; } - - friend class factory; }; }; // namespace grpc CCB_END() diff --git a/broker/grpc/inc/com/centreon/broker/grpc/server.hh b/broker/grpc/inc/com/centreon/broker/grpc/server.hh index 41c4f761225..62f83e52119 100644 --- a/broker/grpc/inc/com/centreon/broker/grpc/server.hh +++ b/broker/grpc/inc/com/centreon/broker/grpc/server.hh @@ -52,7 +52,7 @@ class accepted_service void start(); void start_read(event_ptr&, bool first_read) override; - void start_write(const event_ptr&) override; + void start_write(const event_with_data::pointer&) override; int stop() override; void shutdown() override; diff --git a/broker/grpc/inc/com/centreon/broker/grpc/stream.hh b/broker/grpc/inc/com/centreon/broker/grpc/stream.hh index 975ea3adf21..345b59bd23f 100644 --- a/broker/grpc/inc/com/centreon/broker/grpc/stream.hh +++ b/broker/grpc/inc/com/centreon/broker/grpc/stream.hh @@ -33,6 +33,8 @@ class stream : public io::stream { std::shared_ptr _channel; + grpc_config::pointer _conf; + public: stream(const grpc_config::pointer& conf); stream(const std::shared_ptr&); diff --git a/broker/grpc/src/channel.cc b/broker/grpc/src/channel.cc index 73f3e46a0e0..634961b2193 100644 --- a/broker/grpc/src/channel.cc +++ b/broker/grpc/src/channel.cc @@ -42,12 +42,19 @@ namespace centreon { namespace broker { namespace stream { std::ostream& operator<<(std::ostream& st, - const centreon_stream::centreon_event& to_dump) { + const centreon_stream::CentreonEvent& to_dump) { if (to_dump.IsInitialized()) { if (to_dump.has_buffer()) { st << "buff: " << com::centreon::broker::misc::string::debug_buf( to_dump.buffer().data(), to_dump.buffer().length(), 20); + } else { + std::string dump{to_dump.ShortDebugString()}; + if (dump.size() > 200) { + dump.resize(200); + st << fmt::format(" content:'{}...'", dump); + } else + st << " content:'" << dump << '\''; } } return st; @@ -62,6 +69,8 @@ std::ostream& operator<<(std::ostream& st, << com::centreon::broker::misc::string::debug_buf( to_dump.to_dump.buffer().data(), to_dump.to_dump.buffer().length(), 100); + } else { + st << " content:'" << to_dump.to_dump.ShortDebugString() << '\''; } } return st; @@ -175,7 +184,7 @@ void channel::on_read_done(bool ok) { /*************************************************************** * write section ***************************************************************/ -int channel::write(const event_ptr& to_send) { +int channel::write(const event_with_data::pointer& to_send) { if (is_down()) { throw(exceptions::connection_closed("{} connection is down", __PRETTY_FUNCTION__)); @@ -189,7 +198,7 @@ int channel::write(const event_ptr& to_send) { } void channel::start_write() { - event_ptr write_current; + event_with_data::pointer write_current; { lock_guard l(_protect); if (_write_pending) { @@ -201,7 +210,12 @@ void channel::start_write() { _write_pending = true; write_current = _write_current = _write_queue.front(); } - SPDLOG_LOGGER_DEBUG(log_v2::grpc(), "write: {}", *write_current); + if (write_current->bbdo_event) + SPDLOG_LOGGER_TRACE(log_v2::grpc(), "write: {}", + *write_current->bbdo_event); + else + SPDLOG_LOGGER_TRACE(log_v2::grpc(), "write: {}", write_current->grpc_event); + start_write(write_current); } @@ -211,7 +225,12 @@ void channel::on_write_done(bool ok) { { lock_guard l(_protect); _write_pending = false; - SPDLOG_LOGGER_DEBUG(log_v2::grpc(), "write done: {}", *_write_current); + if (_write_current->bbdo_event) + SPDLOG_LOGGER_TRACE(log_v2::grpc(), "write done: {}", + *_write_current->bbdo_event); + else + SPDLOG_LOGGER_TRACE(log_v2::grpc(), "write done: {}", + _write_current->grpc_event); _write_queue.pop_front(); data_to_write = !_write_queue.empty(); @@ -222,7 +241,12 @@ void channel::on_write_done(bool ok) { } } else { lock_guard l(_protect); - SPDLOG_LOGGER_ERROR(log_v2::grpc(), "write failed: {}", *_write_current); + if (_write_current->bbdo_event) + SPDLOG_LOGGER_ERROR(log_v2::grpc(), "write failed: {}", + *_write_current->bbdo_event); + else + SPDLOG_LOGGER_ERROR(log_v2::grpc(), "write failed: {}", + _write_current->grpc_event); _error = true; } } diff --git a/broker/grpc/src/client.cc b/broker/grpc/src/client.cc index a55b8993d51..44290982895 100644 --- a/broker/grpc/src/client.cc +++ b/broker/grpc/src/client.cc @@ -134,10 +134,10 @@ void client::OnReadDone(bool ok) { on_read_done(ok); } -void client::start_write(const event_ptr& to_send) { +void client::start_write(const event_with_data::pointer& to_send) { std::lock_guard l(_hold_mutex); if (_hold_to_remove) { - StartWrite(to_send.get()); + StartWrite(&to_send->grpc_event); } } diff --git a/broker/grpc/src/factory.cc b/broker/grpc/src/factory.cc index 4d3f27018ca..2c5607c1204 100644 --- a/broker/grpc/src/factory.cc +++ b/broker/grpc/src/factory.cc @@ -219,28 +219,32 @@ io::endpoint* factory::new_endpoint( } } + std::string hostport; + if (host.empty()) { + is_acceptor = true; + hostport = fmt::format("0.0.0.0:{}", port); + } else { + is_acceptor = false; + hostport = fmt::format("{}:{}", host, port); + } + grpc_config::pointer conf(std::make_shared( - "", encrypted, certificate, certificate_key, certificate_authority, - authorization, ca_name, enable_compression, keepalive_interval)); + hostport, encrypted, certificate, certificate_key, certificate_authority, + authorization, ca_name, enable_compression, keepalive_interval, + direct_grpc_serialized(cfg))); std::unique_ptr endp; - if (host.empty()) - is_acceptor = true; - else - is_acceptor = false; // Acceptor. if (is_acceptor) { log_v2::grpc()->debug("GRPC: encryption {} on gRPC server port {}", encrypted ? "enabled" : "disabled", port); - conf->_hostport = fmt::format("0.0.0.0:{}", port); endp = std::make_unique(conf); } // Connector. else { log_v2::grpc()->debug("GRPC: encryption {} on gRPC client port {}", encrypted ? "enabled" : "disabled", port); - conf->_hostport = fmt::format("{}:{}", host, port); endp = std::make_unique(conf); } @@ -433,21 +437,25 @@ io::endpoint* factory::_new_endpoint_bbdo_cs( } } + std::string hostport; + if (cfg.type == "bbdo_server") { + is_acceptor = true; + hostport = fmt::format("0.0.0.0:{}", port); + } else { + is_acceptor = false; + hostport = fmt::format("{}:{}", host, port); + } + grpc_config::pointer conf(std::make_shared( - "", encryption, certificate, private_key, ca_certificate, authorization, - ca_name, enable_compression, keepalive_interval)); + hostport, encryption, certificate, private_key, ca_certificate, + authorization, ca_name, enable_compression, keepalive_interval, + direct_grpc_serialized(cfg))); // Acceptor. std::unique_ptr endp; - if (cfg.type == "bbdo_server") - is_acceptor = true; - else if (cfg.type == "bbdo_client") - is_acceptor = false; - if (is_acceptor) { log_v2::grpc()->debug("GRPC: encryption {} on gRPC server port {}", encryption ? "enabled" : "disabled", port); - conf->_hostport = fmt::format("{}:{}", host, port); endp = std::make_unique(conf); } @@ -455,7 +463,6 @@ io::endpoint* factory::_new_endpoint_bbdo_cs( else { log_v2::grpc()->debug("GRPC: encryption {} on gRPC client port {}", encryption ? "enabled" : "disabled", port); - conf->_hostport = fmt::format("{}:{}", host, port); endp = std::make_unique(conf); } diff --git a/broker/grpc/src/server.cc b/broker/grpc/src/server.cc index e6b76f7dcb0..8a0bc9567a5 100644 --- a/broker/grpc/src/server.cc +++ b/broker/grpc/src/server.cc @@ -75,7 +75,7 @@ void accepted_service::OnReadDone(bool ok) { on_read_done(ok); } -void accepted_service::start_write(const event_ptr& to_send) { +void accepted_service::start_write(const event_with_data::pointer& to_send) { if (*_server_finished || _thrown) { bool expected = false; if (_finished_called.compare_exchange_strong(expected, true)) { @@ -84,7 +84,7 @@ void accepted_service::start_write(const event_ptr& to_send) { Finish(::grpc::Status(::grpc::CANCELLED, "start_write server finished")); } } else { - StartWrite(to_send.get()); + StartWrite(&to_send->grpc_event); } } @@ -117,8 +117,8 @@ server::server(const grpc_config::pointer& conf) : _conf(conf) { void server::start() { ::grpc::Service::MarkMethodCallback( 0, new ::grpc::internal::CallbackBidiHandler< - ::com::centreon::broker::stream::centreon_event, - ::com::centreon::broker::stream::centreon_event>( + ::com::centreon::broker::stream::CentreonEvent, + ::com::centreon::broker::stream::CentreonEvent>( [me = shared_from_this()](::grpc::CallbackServerContext* context) { return me->exchange(context); })); diff --git a/broker/grpc/src/stream.cc b/broker/grpc/src/stream.cc index 13b5271479a..60f4c20cdba 100644 --- a/broker/grpc/src/stream.cc +++ b/broker/grpc/src/stream.cc @@ -22,6 +22,7 @@ #include "com/centreon/broker/grpc/stream.hh" #include "com/centreon/broker/grpc/client.hh" +#include "com/centreon/broker/grpc/grpc_bridge.hh" #include "com/centreon/broker/grpc/server.hh" #include "com/centreon/exceptions/msg_fmt.hh" @@ -38,13 +39,16 @@ struct formatter : ostream_formatter {}; } // namespace fmt com::centreon::broker::grpc::stream::stream(const grpc_config::pointer& conf) - : io::stream("GRPC"), _accept(false) { + : io::stream("GRPC"), _accept(false), _conf(conf) { _channel = client::create(conf); } com::centreon::broker::grpc::stream::stream( const std::shared_ptr& accepted) - : io::stream("GRPC"), _accept(true), _channel(accepted) {} + : io::stream("GRPC"), + _accept(true), + _channel(accepted), + _conf(_channel->get_conf()) {} com::centreon::broker::grpc::stream::~stream() noexcept { if (_channel) @@ -62,7 +66,8 @@ com::centreon::broker::grpc::stream::~stream() noexcept { SPDLOG_LOGGER_TRACE(log_v2::grpc(), "receive:{}", \ *std::static_pointer_cast(d)); \ } else { \ - return false; \ + d = protobuf_to_event(read_res.first); \ + return d ? true : false; \ } \ } else { \ if (_channel->is_down()) { \ @@ -92,11 +97,17 @@ int32_t com::centreon::broker::grpc::stream::write( if (_channel->is_down()) throw msg_fmt("Connection lost"); - event_ptr to_send(std::make_shared()); + channel::event_with_data::pointer to_send; - std::shared_ptr raw_src = std::static_pointer_cast(d); - to_send->mutable_buffer()->assign(raw_src->_buffer.begin(), - raw_src->_buffer.end()); + if (_conf->get_grpc_serialized() && + std::dynamic_pointer_cast(d)) { // no bbdo serialize + to_send = create_event_with_data(d); + } else { + to_send = std::make_shared(); + std::shared_ptr raw_src = std::static_pointer_cast(d); + to_send->grpc_event.mutable_buffer()->assign(raw_src->_buffer.begin(), + raw_src->_buffer.end()); + } return _channel->write(to_send); } diff --git a/broker/grpc/test/acceptor.cc b/broker/grpc/test/acceptor.cc index 28f9a66be76..0af66e31cd3 100644 --- a/broker/grpc/test/acceptor.cc +++ b/broker/grpc/test/acceptor.cc @@ -229,7 +229,7 @@ TEST_F(GrpcTlsTest, TlsStreamBadCaHostname) { auto conf{std::make_shared( "0.0.0.0:4141", true, read_file("/tmp/server.crt"), read_file("/tmp/server.key"), read_file("/tmp/client.crt"), "", - "centreon", grpc_config::NO)}; + "centreon", grpc_config::NO, 30, false)}; auto a{std::make_unique(conf)}; /* Nominal case, cbd is acceptor and read on the socket */ @@ -246,7 +246,7 @@ TEST_F(GrpcTlsTest, TlsStreamBadCaHostname) { auto conf{std::make_shared( "localhost:4141", true, read_file("/tmp/client.crt"), read_file("/tmp/client.key"), read_file("/tmp/server.crt"), "", - "bad_name", grpc_config::NO)}; + "bad_name", grpc_config::NO, 30, false)}; auto c{std::make_unique(conf)}; /* Nominal case, centengine is connector and write on the socket */ diff --git a/broker/grpc/test/channel_test.cc b/broker/grpc/test/channel_test.cc index 5c197c05352..443dae7a861 100644 --- a/broker/grpc/test/channel_test.cc +++ b/broker/grpc/test/channel_test.cc @@ -41,11 +41,13 @@ static com::centreon::broker::grpc::grpc_config::pointer conf1( class channel_test : public channel { public: - using event_cont = std::multimap; - event_cont sent; + using event_send_cont = std::multimap; + event_send_cont sent; std::queue to_read; - event_cont readen; + using event_read_cont = std::multimap; + event_read_cont readen; using pointer = std::shared_ptr; pointer shared_from_this() { @@ -55,7 +57,7 @@ class channel_test : public channel { channel_test(const grpc_config::pointer& conf) : channel("channel_test", conf) {} - void start_write(const event_ptr& to_send) override { + void start_write(const channel::event_with_data::pointer& to_send) override { pool::io_context().post( [me = shared_from_this()]() { me->simul_on_write(); }); } @@ -94,7 +96,7 @@ TEST_F(grpc_channel_tester, write_all) { channel->start(); for (int ii = 0; ii < 100; ++ii) { - channel->write(std::make_shared()); + channel->write(std::make_shared()); } std::this_thread::sleep_for(std::chrono::milliseconds(10)); ASSERT_EQ((channel->sent.size()), 100); @@ -182,10 +184,11 @@ TEST_F(grpc_channel_tester, throw_write_after_failure) { int failure_ind = channel->failure_ind = rand() % 100 + 10; for (int32_t ii = 0; ii <= failure_ind; ++ii) { - channel->write(std::make_shared()); + channel->write(std::make_shared()); } std::this_thread::sleep_for(std::chrono::milliseconds(20)); - ASSERT_THROW(channel->write(std::make_shared()), msg_fmt); + ASSERT_THROW(channel->write(std::make_shared()), + msg_fmt); ASSERT_THROW(channel->read(std::chrono::milliseconds(1)), msg_fmt); } diff --git a/broker/grpc/test/grpc_test_include.hh b/broker/grpc/test/grpc_test_include.hh index 1f077d03027..06fa88476da 100644 --- a/broker/grpc/test/grpc_test_include.hh +++ b/broker/grpc/test/grpc_test_include.hh @@ -43,10 +43,11 @@ using time_point = system_clock::time_point; using duration = system_clock::duration; using unique_lock = std::unique_lock; +#include "com/centreon/broker/log_v2.hh" + #include "com/centreon/broker/grpc/acceptor.hh" #include "com/centreon/broker/grpc/stream.hh" #include "com/centreon/broker/io/raw.hh" -#include "com/centreon/broker/log_v2.hh" #include "com/centreon/broker/pool.hh" #include "com/centreon/exceptions/msg_fmt.hh" diff --git a/broker/grpc/test/stream_test.cc b/broker/grpc/test/stream_test.cc index 9633b5953f3..8594295e9b9 100644 --- a/broker/grpc/test/stream_test.cc +++ b/broker/grpc/test/stream_test.cc @@ -34,7 +34,9 @@ com::centreon::broker::grpc::grpc_config::pointer conf( "", "my_aut", "", - com::centreon::broker::grpc::grpc_config::NO)); + com::centreon::broker::grpc::grpc_config::NO, + 30, + false)); static constexpr unsigned relay_listen_port = 5123u; static constexpr unsigned server_listen_port = 5124u; @@ -344,7 +346,9 @@ com::centreon::broker::grpc::grpc_config::pointer conf_crypted_server1234( read_file("tests/grpc_test_keys/ca_1234.crt"), "my_auth", "", - com::centreon::broker::grpc::grpc_config::NO)); + com::centreon::broker::grpc::grpc_config::NO, + 30, + false)); com::centreon::broker::grpc::grpc_config::pointer conf_crypted_client1234( std::make_shared( @@ -355,7 +359,9 @@ com::centreon::broker::grpc::grpc_config::pointer conf_crypted_client1234( read_file("tests/grpc_test_keys/ca_1234.crt"), "my_auth", "", - com::centreon::broker::grpc::grpc_config::NO)); + com::centreon::broker::grpc::grpc_config::NO, + 30, + false)); class grpc_test_server_crypted : public ::testing::TestWithParam { protected: @@ -418,7 +424,9 @@ com::centreon::broker::grpc::grpc_config::pointer read_file("tests/grpc_test_keys/ca_1234.crt"), "my_auth_pasbon", "", - com::centreon::broker::grpc::grpc_config::NO)); + com::centreon::broker::grpc::grpc_config::NO, + 30, + false)); TEST_P(grpc_test_server_crypted, ServerToClientWithKeyAndBadAuthorization) { com::centreon::broker::grpc::stream client(conf_crypted_client1234_bad_auth); diff --git a/broker/http_client/test/http_connection_test.cc b/broker/http_client/test/http_connection_test.cc index 74732dbf857..28174711a93 100644 --- a/broker/http_client/test/http_connection_test.cc +++ b/broker/http_client/test/http_connection_test.cc @@ -252,9 +252,14 @@ TEST(http_keepalive_test, KeepAliveWithTimeout) { *********************************************************************/ class session_base : public std::enable_shared_from_this { + protected: + std::shared_ptr _logger; + public: using pointer = std::shared_ptr; - virtual ~session_base() { SPDLOG_LOGGER_TRACE(log_v2::tcp(), "end session"); } + + session_base() : _logger(log_v2::tcp()) {} + virtual ~session_base() { SPDLOG_LOGGER_TRACE(_logger, "end session"); } virtual void on_receive(const beast::error_code& err, const request_ptr& request) = 0; @@ -281,10 +286,10 @@ class http_session : public session_base { [me = shared_from_this(), request](const beast::error_code& err, std::size_t bytes_received) { if (err) { - SPDLOG_LOGGER_ERROR(log_v2::tcp(), "fail recv {}", err.message()); + SPDLOG_LOGGER_ERROR(me->_logger, "fail recv {}", err.message()); me->shutdown(); } else { - SPDLOG_LOGGER_TRACE(log_v2::tcp(), "recv {} bytes", bytes_received); + SPDLOG_LOGGER_TRACE(me->_logger, "recv {} bytes", bytes_received); me->on_receive(err, request); me->start_recv(); } @@ -302,18 +307,18 @@ class http_session : public session_base { } void start() override { - SPDLOG_LOGGER_TRACE(log_v2::tcp(), "start a session"); + SPDLOG_LOGGER_TRACE(_logger, "start a session"); start_recv(); } void send_response(const response_ptr& resp) override { - SPDLOG_LOGGER_TRACE(log_v2::tcp(), "send response"); + SPDLOG_LOGGER_TRACE(_logger, "send response"); beast::http::async_write( _stream, *resp, [me = shared_from_this(), resp](const beast::error_code& err, std::size_t bytes_sent) { if (err) { - SPDLOG_LOGGER_ERROR(log_v2::tcp(), "fail send response"); + SPDLOG_LOGGER_ERROR(me->_logger, "fail send response"); me->shutdown(); } }); @@ -336,10 +341,10 @@ class https_session : public session_base { [me = shared_from_this(), request](const beast::error_code& err, std::size_t bytes_received) { if (err) { - SPDLOG_LOGGER_ERROR(log_v2::tcp(), "fail recv {}", err.message()); + SPDLOG_LOGGER_ERROR(me->_logger, "fail recv {}", err.message()); me->shutdown(); } else { - SPDLOG_LOGGER_TRACE(log_v2::tcp(), "recv {} bytes", bytes_received); + SPDLOG_LOGGER_TRACE(me->_logger, "recv {} bytes", bytes_received); me->on_receive(err, request); me->start_recv(); } @@ -357,7 +362,7 @@ class https_session : public session_base { } void start() override { - SPDLOG_LOGGER_TRACE(log_v2::tcp(), "start a session"); + SPDLOG_LOGGER_TRACE(_logger, "start a session"); _stream.async_handshake( asio::ssl::stream_base::server, [me = shared_from_this()](const beast::error_code& err) { @@ -367,23 +372,23 @@ class https_session : public session_base { void on_handshake(const beast::error_code& err) { if (err) { - SPDLOG_LOGGER_TRACE(log_v2::tcp(), "{} fail handshake {}", __FUNCTION__, + SPDLOG_LOGGER_TRACE(_logger, "{} fail handshake {}", __FUNCTION__, err.message()); shutdown(); return; } - SPDLOG_LOGGER_TRACE(log_v2::tcp(), "handshake done"); + SPDLOG_LOGGER_TRACE(_logger, "handshake done"); start_recv(); } void send_response(const response_ptr& resp) override { - SPDLOG_LOGGER_TRACE(log_v2::tcp(), "send response"); + SPDLOG_LOGGER_TRACE(_logger, "send response"); beast::http::async_write( _stream, *resp, [me = shared_from_this(), resp](const beast::error_code& err, std::size_t bytes_sent) { if (err) { - SPDLOG_LOGGER_ERROR(log_v2::tcp(), "fail send response"); + SPDLOG_LOGGER_ERROR(me->_logger, "fail send response"); me->shutdown(); } }); @@ -399,6 +404,7 @@ class listener : public std::enable_shared_from_this { protected: std::shared_ptr _ssl_context; asio::ip::tcp::acceptor _acceptor; + std::shared_ptr _logger; void do_accept() { // The new connection gets its own strand @@ -409,10 +415,10 @@ class listener : public std::enable_shared_from_this { void on_accept(const beast::error_code& ec, asio::ip::tcp::socket socket) { if (ec) { - SPDLOG_LOGGER_ERROR(log_v2::tcp(), "fail accept"); + SPDLOG_LOGGER_ERROR(_logger, "fail accept"); return; } - SPDLOG_LOGGER_DEBUG(log_v2::tcp(), "accept a connection"); + SPDLOG_LOGGER_DEBUG(_logger, "accept a connection"); auto session = creator(std::move(socket), _ssl_context); session->start(); do_accept(); @@ -424,7 +430,8 @@ class listener : public std::enable_shared_from_this { listener(unsigned port) : _ssl_context(std::make_shared( asio::ssl::context::sslv23_server)), - _acceptor(*g_io_context, test_endpoint, true) { + _acceptor(*g_io_context, test_endpoint, true), + _logger(log_v2::tcp()) { load_server_certificate(*_ssl_context); } diff --git a/broker/neb/inc/com/centreon/broker/neb/internal.hh b/broker/neb/inc/com/centreon/broker/neb/internal.hh index 796383a3886..4a376a52ff3 100644 --- a/broker/neb/inc/com/centreon/broker/neb/internal.hh +++ b/broker/neb/inc/com/centreon/broker/neb/internal.hh @@ -78,10 +78,10 @@ using pb_custom_variable_status = make_type(io::neb, neb::de_pb_custom_variable_status)>; using pb_host_check = - io::protobuf; + io::protobuf; using pb_service_check = - io::protobuf; + io::protobuf; using pb_log_entry = io::protobuf; diff --git a/broker/neb/src/broker.cc b/broker/neb/src/broker.cc index 3338093a97b..80148de9b2f 100644 --- a/broker/neb/src/broker.cc +++ b/broker/neb/src/broker.cc @@ -175,11 +175,12 @@ void broker_module_init(void const* arg) { &neb::pb_custom_variable_status::operations, "customvariables"); - e.register_event(make_type(io::neb, neb::de_pb_host_check), "Check", + e.register_event(make_type(io::neb, neb::de_pb_host_check), "HostCheck", &neb::pb_host_check::operations, "hosts"); - e.register_event(make_type(io::neb, neb::de_pb_service_check), "Check", - &neb::pb_service_check::operations, "services"); + e.register_event(make_type(io::neb, neb::de_pb_service_check), + "ServiceCheck", &neb::pb_service_check::operations, + "services"); e.register_event(make_type(io::neb, neb::de_pb_log_entry), "LogEntry", &neb::pb_log_entry::operations, "logs"); diff --git a/broker/rrd/CMakeLists.txt b/broker/rrd/CMakeLists.txt index 29b5042f69e..a8898603b28 100644 --- a/broker/rrd/CMakeLists.txt +++ b/broker/rrd/CMakeLists.txt @@ -1,20 +1,20 @@ -# # -# # Copyright 2011-2013 Centreon -# # -# # Licensed under the Apache License, Version 2.0 (the "License"); -# # you may not use this file except in compliance with the License. -# # You may obtain a copy of the License at -# # -# # http://www.apache.org/licenses/LICENSE-2.0 -# # -# # Unless required by applicable law or agreed to in writing, software -# # distributed under the License is distributed on an "AS IS" BASIS, -# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# # See the License for the specific language governing permissions and -# # limitations under the License. -# # -# # For more information : contact@centreon.com -# # +# +# Copyright 2011-2013 Centreon +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# For more information : contact@centreon.com +# # Global options. set(INC_DIR "${PROJECT_SOURCE_DIR}/rrd/inc") @@ -24,9 +24,6 @@ include_directories("${INC_DIR}") include_directories("${CMAKE_SOURCE_DIR}") include_directories("${PROJECT_SOURCE_DIR}/neb/inc") -get_protobuf_files(rebuild_message) -get_protobuf_files(remove_graph_message) - # Find librrd. include(FindPkgConfig) @@ -35,7 +32,9 @@ if(PKG_CONFIG_FOUND) if(LIBRRD_INCLUDE_DIRS) include_directories("${LIBRRD_INCLUDE_DIRS}") - set(LIBRRD_INCLUDE_DIRS "${LIBRRD_INCLUDE_DIRS}" PARENT_SCOPE) + set(LIBRRD_INCLUDE_DIRS + "${LIBRRD_INCLUDE_DIRS}" + PARENT_SCOPE) endif() else() # Find rrd.h @@ -46,7 +45,9 @@ else() endif() include_directories("${LIBRRD_INCLUDE_DIR}") - set(LIBRRD_INCLUDE_DIRS "${LIBRRD_INCLUDE_DIR}" PARENT_SCOPE) + set(LIBRRD_INCLUDE_DIRS + "${LIBRRD_INCLUDE_DIR}" + PARENT_SCOPE) # Find librrd. find_library(LIBRRD_LDFLAGS "rrd") @@ -55,14 +56,18 @@ else() message(FATAL_ERROR "Could not find librrd's library.") endif() - set(LIBRRD_LDFLAGS "${LIBRRD_LDFLAGS}" PARENT_SCOPE) + set(LIBRRD_LDFLAGS + "${LIBRRD_LDFLAGS}" + PARENT_SCOPE) endif() # RRD module. set(RRD "70-rrd") -set(RRD "${RRD}" PARENT_SCOPE) -add_library("${RRD}" SHARED - +set(RRD + "${RRD}" + PARENT_SCOPE) +add_library( + "${RRD}" SHARED # Sources. "${SRC_DIR}/connector.cc" "${SRC_DIR}/creator.cc" @@ -70,9 +75,6 @@ add_library("${RRD}" SHARED "${SRC_DIR}/lib.cc" "${SRC_DIR}/main.cc" "${SRC_DIR}/output.cc" - ${proto_rebuild_message} - ${proto_remove_graph_message} - # Headers. "${INC_DIR}/com/centreon/broker/rrd/backend.hh" "${INC_DIR}/com/centreon/broker/rrd/connector.hh" @@ -81,51 +83,45 @@ add_library("${RRD}" SHARED "${INC_DIR}/com/centreon/broker/rrd/exceptions/update.hh" "${INC_DIR}/com/centreon/broker/rrd/factory.hh" "${INC_DIR}/com/centreon/broker/rrd/lib.hh" - "${INC_DIR}/com/centreon/broker/rrd/output.hh" -) + "${INC_DIR}/com/centreon/broker/rrd/output.hh") set_target_properties("${RRD}" PROPERTIES PREFIX "") target_precompile_headers(${RRD} PRIVATE precomp_inc/precomp.hpp) add_dependencies("${RRD}" target_rebuild_message target_remove_graph_message) # Compile with librrd flags. if(LIBRRD_CFLAGS) - get_source_file_property(RRD_SOURCE_CXXFLAGS "${SRC_DIR}/lib.cc" COMPILE_FLAGS) + get_source_file_property(RRD_SOURCE_CXXFLAGS "${SRC_DIR}/lib.cc" + COMPILE_FLAGS) if(LIBRRD_SOURCE_CXXFLAGS) - set_source_files_properties("${SRC_DIR}/lib.cc" PROPERTIES - COMPILE_FLAGS "${RRD_SOURCE_CXXFLAGS} ${LIBRRD_CFLAGS}") + set_source_files_properties( + "${SRC_DIR}/lib.cc" PROPERTIES COMPILE_FLAGS + "${RRD_SOURCE_CXXFLAGS} ${LIBRRD_CFLAGS}") else() - set_source_files_properties("${SRC_DIR}/lib.cc" PROPERTIES - COMPILE_FLAGS "${LIBRRD_CFLAGS}") + set_source_files_properties("${SRC_DIR}/lib.cc" + PROPERTIES COMPILE_FLAGS "${LIBRRD_CFLAGS}") endif() endif() -target_link_libraries("${RRD}" ${LIBRRD_LDFLAGS} +target_link_libraries( + "${RRD}" + ${LIBRRD_LDFLAGS} bbdo_storage pb_storage_lib + pb_rebuild_message_lib + pb_remove_graph_message_lib CONAN_PKG::spdlog) # Testing. if(WITH_TESTING) - set( - TESTS_SOURCES - ${TESTS_SOURCES} - "${TEST_DIR}/cached.cc" - "${TEST_DIR}/exceptions.cc" - "${TEST_DIR}/factory.cc" - "${TEST_DIR}/lib.cc" - "${TEST_DIR}/rrd.cc" - PARENT_SCOPE - ) - set( - TESTS_LIBRARIES - ${TESTS_LIBRARIES} - "${RRD}" - PARENT_SCOPE - ) + set(TESTS_SOURCES + ${TESTS_SOURCES} "${TEST_DIR}/cached.cc" "${TEST_DIR}/exceptions.cc" + "${TEST_DIR}/factory.cc" "${TEST_DIR}/lib.cc" "${TEST_DIR}/rrd.cc" + PARENT_SCOPE) + set(TESTS_LIBRARIES + ${TESTS_LIBRARIES} "${RRD}" + PARENT_SCOPE) endif() # Install rule. -install(TARGETS "${RRD}" - LIBRARY DESTINATION "${PREFIX_MODULES}" -) +install(TARGETS "${RRD}" LIBRARY DESTINATION "${PREFIX_MODULES}") diff --git a/broker/storage/CMakeLists.txt b/broker/storage/CMakeLists.txt index 75c2d0560df..34da1d4f143 100644 --- a/broker/storage/CMakeLists.txt +++ b/broker/storage/CMakeLists.txt @@ -25,9 +25,6 @@ include_directories("${PROJECT_SOURCE_DIR}/neb/inc") include_directories("${CMAKE_SOURCE_DIR}") set(INC_DIR "${INC_DIR}/com/centreon/broker/storage") -get_protobuf_files(rebuild_message) -get_protobuf_files(remove_graph_message) - # conflict_manager library. add_library( conflictmgr STATIC @@ -59,8 +56,6 @@ add_library( "${SRC_DIR}/main.cc" "${SRC_DIR}/rebuilder.cc" "${SRC_DIR}/stream.cc" - ${proto_rebuild_message} - ${proto_remove_graph_message} # Headers. "${INC_DIR}/connector.hh" "${INC_DIR}/events.hh" @@ -70,7 +65,8 @@ add_library( set_target_properties("${STORAGE}" PROPERTIES PREFIX "" COMPILE_FLAGS "-fPIC") add_dependencies("${STORAGE}" target_rebuild_message target_remove_graph_message table_max_size) -target_link_libraries(${STORAGE} conflictmgr rokerbase bbdo_storage) +target_link_libraries(${STORAGE} conflictmgr rokerbase bbdo_storage + pb_rebuild_message_lib pb_remove_graph_message_lib) target_precompile_headers(${STORAGE} REUSE_FROM conflictmgr) # Testing. diff --git a/broker/test/CMakeLists.txt b/broker/test/CMakeLists.txt index 1fcaeddaaef..ceeaf93f23a 100644 --- a/broker/test/CMakeLists.txt +++ b/broker/test/CMakeLists.txt @@ -24,6 +24,7 @@ set(BAM_TESTS_DIR ${PROJECT_SOURCE_DIR}/bam/test) set(WDOG_TESTS_DIR ${PROJECT_SOURCE_DIR}/watchdog/test) # Include directories. +include_directories(${CMAKE_SOURCE_DIR}/bbdo) include_directories(${PROJECT_SOURCE_DIR}/bam/inc) include_directories(${PROJECT_SOURCE_DIR}/bam/test) include_directories(${PROJECT_SOURCE_DIR}/storage/src) diff --git a/broker/tls/src/factory.cc b/broker/tls/src/factory.cc index a58a71c6714..f6f0f421ea1 100644 --- a/broker/tls/src/factory.cc +++ b/broker/tls/src/factory.cc @@ -45,6 +45,9 @@ bool factory::has_endpoint(config::endpoint& cfg, io::extension* ext) { bool legacy; if (ext) { + if (direct_grpc_serialized(cfg)) { + return false; + } if (cfg.type == "bbdo_client" || cfg.type == "bbdo_server") { it = cfg.params.find("transport_protocol"); if (it != cfg.params.end()) { diff --git a/broker/unified_sql/CMakeLists.txt b/broker/unified_sql/CMakeLists.txt index 91e88df946f..bfc27a134b6 100644 --- a/broker/unified_sql/CMakeLists.txt +++ b/broker/unified_sql/CMakeLists.txt @@ -25,9 +25,6 @@ include_directories("${PROJECT_SOURCE_DIR}/neb/inc") include_directories("${CMAKE_SOURCE_DIR}") set(INC_DIR "${INC_DIR}/com/centreon/broker/unified_sql") -get_protobuf_files(rebuild_message) -get_protobuf_files(remove_graph_message) - # Storage module. set(UNIFIED_SQL "20-unified_sql") set(UNIFIED_SQL @@ -46,8 +43,6 @@ add_library( ${SRC_DIR}/stream.cc ${SRC_DIR}/stream_sql.cc ${SRC_DIR}/stream_storage.cc - ${proto_rebuild_message} - ${proto_remove_graph_message} # Headers. ${INC_DIR}/bulk_queries.hh ${INC_DIR}/bulk_bind.hh @@ -63,8 +58,14 @@ set_target_properties("${UNIFIED_SQL}" PROPERTIES PREFIX "" COMPILE_FLAGS add_dependencies("${UNIFIED_SQL}" target_rebuild_message target_remove_graph_message target_neb) target_precompile_headers(${UNIFIED_SQL} PRIVATE precomp_inc/precomp.hpp) -target_link_libraries(${UNIFIED_SQL} rokerbase bbdo_storage CONAN_PKG::spdlog - CONAN_PKG::abseil pb_storage_lib) +target_link_libraries( + ${UNIFIED_SQL} + bbdo_storage + pb_storage_lib + pb_rebuild_message_lib + pb_remove_graph_message_lib + CONAN_PKG::spdlog + CONAN_PKG::abseil) # Testing. if(WITH_TESTING) diff --git a/broker/unified_sql/src/stream_sql.cc b/broker/unified_sql/src/stream_sql.cc index 132be4163aa..15bbbd1c34a 100644 --- a/broker/unified_sql/src/stream_sql.cc +++ b/broker/unified_sql/src/stream_sql.cc @@ -1083,7 +1083,7 @@ void stream::_process_pb_host_check(const std::shared_ptr& d) { // Cast object. const neb::pb_host_check& hc_obj = *static_cast(d.get()); - const Check& hc = hc_obj.obj(); + const HostCheck& hc = hc_obj.obj(); if (!_host_instance_known(hc.host_id())) { SPDLOG_LOGGER_WARN( log_v2::sql(), @@ -2480,7 +2480,7 @@ void stream::_process_pb_instance_status(const std::shared_ptr& d) { SPDLOG_LOGGER_DEBUG( log_v2::sql(), "SQL: processing poller status event (id: {}, last alive: {} {})", - is.instance_id(), is.last_alive(), is.DebugString()); + is.instance_id(), is.last_alive(), is.ShortDebugString()); // Processing. if (_is_valid_poller(is.instance_id())) { @@ -2744,7 +2744,7 @@ void stream::_process_pb_service_check(const std::shared_ptr& d) { // Cast object. const neb::pb_service_check& pb_sc( *static_cast(d.get())); - const Check& sc(pb_sc.obj()); + const ServiceCheck& sc(pb_sc.obj()); if (!_host_instance_known(sc.host_id())) { SPDLOG_LOGGER_WARN( diff --git a/tests/bam/pb_inherited_downtime.robot b/tests/bam/pb_inherited_downtime.robot index 358ca110d07..4f2dd41096d 100644 --- a/tests/bam/pb_inherited_downtime.robot +++ b/tests/bam/pb_inherited_downtime.robot @@ -85,9 +85,7 @@ BEBAMIDTU2 Config Broker rrd Broker Config Log central bam trace Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 Config Engine ${1} Clone Engine Config To DB @@ -176,9 +174,7 @@ BEBAMIGNDTU1 Broker Config Log module0 neb trace Config Broker rrd Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 Config Engine ${1} Engine Config Set Value ${0} log_legacy_enabled ${0} Engine Config Set Value ${0} log_v2_enabled ${1} @@ -287,9 +283,7 @@ BEBAMIGNDTU2 Broker Config Log central bam trace Config Broker rrd Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 Config Engine ${1} Clone Engine Config To DB diff --git a/tests/broker-engine/anomaly-detection.robot b/tests/broker-engine/anomaly-detection.robot index 7236b3fb87f..4610239e9bc 100644 --- a/tests/broker-engine/anomaly-detection.robot +++ b/tests/broker-engine/anomaly-detection.robot @@ -168,9 +168,7 @@ AOUTLU1 Config Broker module ${1} Broker Config Log central sql debug Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 ${serv_id} Create Anomaly Detection ${0} ${1} ${1} metric ${predict_data} Evaluate [[0,50,52],[2648812678,50,63]] Create Anomaly Threshold File /tmp/anomaly_threshold.json ${1} ${serv_id} metric ${predict_data} @@ -203,9 +201,7 @@ ANO_DT1 Config Broker module ${1} Broker Config Log central sql debug Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 ${serv_id} Create Anomaly Detection ${0} ${1} ${1} metric ${predict_data} Evaluate [[0,50,52],[2648812678,50,63]] Create Anomaly Threshold File /tmp/anomaly_threshold.json ${1} ${serv_id} metric ${predict_data} @@ -220,7 +216,7 @@ ANO_DT1 ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 Should Be True ${result} No check for external commands executed for 1mn. - #create dependent service downtime + # create dependent service downtime Schedule Service Fixed Downtime host_1 service_1 3600 ${result} Check Service Downtime With Timeout host_1 service_1 1 60 @@ -240,9 +236,7 @@ ANO_DT2 Config Broker module ${1} Broker Config Log central sql debug Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 ${serv_id} Create Anomaly Detection ${0} ${1} ${1} metric ${predict_data} Evaluate [[0,50,52],[2648812678,50,63]] Create Anomaly Threshold File /tmp/anomaly_threshold.json ${1} ${serv_id} metric ${predict_data} @@ -257,7 +251,7 @@ ANO_DT2 ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 Should Be True ${result} No check for external commands executed for 1mn. - #create dependent service downtime + # create dependent service downtime Schedule Service Fixed Downtime host_1 service_1 3600 ${result} Check Service Downtime With Timeout host_1 anomaly_${serv_id} 1 60 @@ -281,9 +275,7 @@ ANO_DT3 Config Broker module ${1} Broker Config Log central sql debug Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 ${serv_id} Create Anomaly Detection ${0} ${1} ${1} metric ${predict_data} Evaluate [[0,50,52],[2648812678,50,63]] Create Anomaly Threshold File /tmp/anomaly_threshold.json ${1} ${serv_id} metric ${predict_data} @@ -298,7 +290,7 @@ ANO_DT3 ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 Should Be True ${result} No check for external commands executed for 1mn. - #create dependent service downtime + # create dependent service downtime Schedule Service Fixed Downtime host_1 service_1 3600 ${result} Check Service Downtime With Timeout host_1 anomaly_${serv_id} 1 60 @@ -323,9 +315,7 @@ ANO_DT4 Config Broker module ${1} Broker Config Log central sql debug Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 ${serv_id} Create Anomaly Detection ${0} ${1} ${1} metric ${predict_data} Evaluate [[0,50,52],[2648812678,50,63]] Create Anomaly Threshold File /tmp/anomaly_threshold.json ${1} ${serv_id} metric ${predict_data} @@ -340,7 +330,7 @@ ANO_DT4 ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 Should Be True ${result} No check for external commands executed for 1mn. - #create dependent service downtime + # create dependent service downtime Schedule Service Fixed Downtime host_1 service_1 3600 Schedule Service Fixed Downtime host_1 anomaly_${serv_id} 3600 diff --git a/tests/broker-engine/bbdo-protobuf.robot b/tests/broker-engine/bbdo-protobuf.robot index e95a1152327..e0ecfc5351a 100644 --- a/tests/broker-engine/bbdo-protobuf.robot +++ b/tests/broker-engine/bbdo-protobuf.robot @@ -69,9 +69,7 @@ BEPBBEE3 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql Broker Config Add Lua Output central test-protobuf ${SCRIPTS}test-pbservicestatus.lua @@ -91,9 +89,7 @@ BEPBBEE4 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql Broker Config Add Lua Output central test-protobuf ${SCRIPTS}test-pbhoststatus.lua @@ -113,9 +109,7 @@ BEPBBEE5 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql Broker Config Add Lua Output central test-protobuf ${SCRIPTS}test-pbservice.lua @@ -134,8 +128,7 @@ BEPBRI1 Config Engine ${1} Config Broker central Config Broker module - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql read_timeout 2 @@ -157,7 +150,7 @@ BEPBRI1 Sleep 1s ${grep_res} Grep File /tmp/pbresponsiveinstance.log "_type":65582, "category":1, "element":46, ${grep_res} Get Lines Containing String ${grep_res} "poller_id":1, "responsive":false - IF len('${grep_res}') > 0 BREAK + IF len('${grep_res}') > 0 BREAK END Should Not Be Empty ${grep_res} "responsive":false not found @@ -185,7 +178,7 @@ BEPBCVS ... SELECT c.value FROM customvariables c LEFT JOIN hosts h ON c.host_id=h.host_id WHERE h.name='host_1' && c.name in ('KEY1','KEY_SERV1_1') ORDER BY service_id Log To Console ${output} Sleep 1s - IF "${output}" == "(('VAL1',), ('VAL_SERV1',))" BREAK + IF "${output}" == "(('VAL1',), ('VAL_SERV1',))" BREAK END Should Be Equal As Strings ${output} (('VAL1',), ('VAL_SERV1',)) diff --git a/tests/broker-engine/bench.robot b/tests/broker-engine/bench.robot index 66dc30aa930..9ae9c804630 100644 --- a/tests/broker-engine/bench.robot +++ b/tests/broker-engine/bench.robot @@ -34,9 +34,7 @@ BENCH_${nb_check}STATUS Broker Config Log central sql trace Broker Config Log central core info Broker Config Log central processing error - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Config Broker Sql Output central unified_sql ${start} Get Current Date Start Broker diff --git a/tests/broker-engine/downtimes.robot b/tests/broker-engine/downtimes.robot index e415ee67144..940623d376a 100644 --- a/tests/broker-engine/downtimes.robot +++ b/tests/broker-engine/downtimes.robot @@ -33,11 +33,7 @@ BEDTMASS1 Broker Config Log module1 neb debug Broker Config Log module2 neb debug - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item module2 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 3 Broker Config Log central sql debug Config Broker Sql Output central unified_sql Clear Retention diff --git a/tests/broker-engine/external-commands.robot b/tests/broker-engine/external-commands.robot index 0bceef2c0e9..cb2d5c33b93 100644 --- a/tests/broker-engine/external-commands.robot +++ b/tests/broker-engine/external-commands.robot @@ -25,9 +25,7 @@ BEEXTCMD1 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql FOR ${use_grpc} IN RANGE 0 2 @@ -103,9 +101,7 @@ BEEXTCMD3 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -180,9 +176,7 @@ BEEXTCMD5 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql FOR ${use_grpc} IN RANGE 0 2 @@ -258,9 +252,7 @@ BEEXTCMD7 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -335,9 +327,7 @@ BEEXTCMD9 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql FOR ${use_grpc} IN RANGE 0 2 @@ -423,9 +413,7 @@ BEEXTCMD11 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -510,9 +498,7 @@ BEEXTCMD13 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -589,9 +575,7 @@ BEEXTCMD15 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -668,9 +652,7 @@ BEEXTCMD17 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -751,9 +733,7 @@ BEEXTCMD19 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -834,9 +814,7 @@ BEEXTCMD21 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -955,9 +933,7 @@ BEEXTCMD23 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -1107,9 +1083,7 @@ BEEXTCMD25 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -1206,9 +1180,7 @@ BEEXTCMD27 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -1305,9 +1277,7 @@ BEEXTCMD29 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace diff --git a/tests/broker-engine/external-commands2.robot b/tests/broker-engine/external-commands2.robot index 57ab3bfc9f9..d66c0b6728e 100644 --- a/tests/broker-engine/external-commands2.robot +++ b/tests/broker-engine/external-commands2.robot @@ -74,9 +74,7 @@ BEEXTCMD31 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -242,9 +240,7 @@ BEEXTCMD33 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -349,9 +345,7 @@ BEEXTCMD35 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -466,9 +460,7 @@ BEEXTCMD37 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -591,9 +583,7 @@ BEEXTCMD39 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -690,9 +680,7 @@ BEEXTCMD41 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -797,11 +785,9 @@ BEEXTCMD_GRPC1 Config Broker rrd Config Broker central Config Broker module ${1} - Change Broker Tcp Output To Grpc module0 - Change Broker Tcp Input To Grpc central - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Change Broker tcp output to grpc module0 + Change Broker tcp input to grpc central + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql FOR ${use_grpc} IN RANGE 0 2 @@ -881,9 +867,7 @@ BEEXTCMD_GRPC3 Config Broker module ${1} Change Broker Tcp Output To Grpc module0 Change Broker Tcp Input To Grpc central - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central sql debug Broker Config Log module0 neb trace @@ -966,9 +950,7 @@ BEEXTCMD_REVERSE_GRPC1 Broker Config Output Remove central centreon-broker-master-rrd host Broker Config Input Set central central-broker-master-input host 127.0.0.1 Broker Config Input Set rrd central-rrd-master-input host 127.0.0.1 - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql FOR ${use_grpc} IN RANGE 0 2 @@ -1053,9 +1035,7 @@ BEEXTCMD_REVERSE_GRPC3 Config Broker module ${1} Change Broker Tcp Output To Grpc module0 Change Broker Tcp Input To Grpc central - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Output Remove module0 central-module-master-output host Broker Config Output Remove central centreon-broker-master-rrd host Broker Config Input Set central central-broker-master-input host 127.0.0.1 @@ -1145,9 +1125,7 @@ BEEXTCMD_COMPRESS_GRPC1 Change Broker Tcp Input To Grpc central Change Broker Compression Output module0 central-module-master-output yes Change Broker Compression Input central centreon-broker-master-input yes - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql FOR ${use_grpc} IN RANGE 0 2 @@ -1334,8 +1312,7 @@ BECUSTOMHOSTVAR Config Broker central Config Broker module ${1} Broker Config Log central sql trace - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 + Config BBDO3 1 Config Broker Sql Output central unified_sql ${start} Get Current Date Start Broker @@ -1369,8 +1346,7 @@ BECUSTOMSVCVAR Config Broker central Config Broker module ${1} Broker Config Log central sql trace - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 + Config BBDO3 1 Config Broker Sql Output central unified_sql ${start} Get Current Date Start Broker @@ -1404,8 +1380,7 @@ BESERVCHECK Config Broker central Config Broker module ${1} Broker Config Log central sql trace - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 + Config BBDO3 1 Config Broker Sql Output central unified_sql ${start} Get Current Date Start Broker @@ -1431,8 +1406,7 @@ BEHOSTCHECK Config Broker central Config Broker module ${1} Broker Config Log central sql trace - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 + Config BBDO3 1 Config Broker Sql Output central unified_sql ${start} Get Current Date Start Broker diff --git a/tests/broker-engine/hostgroups.robot b/tests/broker-engine/hostgroups.robot index 4b2eeb53f9d..e392f11a67c 100644 --- a/tests/broker-engine/hostgroups.robot +++ b/tests/broker-engine/hostgroups.robot @@ -89,11 +89,7 @@ EBNHGU2 Broker Config Log central sql info Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql connections_count 5 - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item module2 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 3 ${start} Get Current Date Start Broker Start Engine @@ -123,12 +119,7 @@ EBNHGU3 Broker Config Log central sql info Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql connections_count 5 - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item module2 bbdo_version 3.0.0 - Broker Config Add Item module3 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 4 Broker Config Log central sql debug ${start} Get Current Date diff --git a/tests/broker-engine/hosts-with-notes-and-actions.robot b/tests/broker-engine/hosts-with-notes-and-actions.robot index 5dd803c4601..af88e183b6b 100644 --- a/tests/broker-engine/hosts-with-notes-and-actions.robot +++ b/tests/broker-engine/hosts-with-notes-and-actions.robot @@ -25,9 +25,7 @@ EBSNU1 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql ${nu} Evaluate 2000*"X" @@ -59,9 +57,7 @@ EBSAU2 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql ${au} Evaluate 2000*"Y" @@ -93,9 +89,7 @@ EBSN3 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Config Broker Sql Output central unified_sql ${n} Evaluate 500*"Z" diff --git a/tests/broker-engine/output-tables.robot b/tests/broker-engine/output-tables.robot index bd5d8096ee0..453a39432c1 100644 --- a/tests/broker-engine/output-tables.robot +++ b/tests/broker-engine/output-tables.robot @@ -26,9 +26,7 @@ BERES1 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql store_in_resources yes @@ -60,9 +58,7 @@ BEHS1 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql store_in_resources no @@ -107,8 +103,7 @@ BEINSTANCESTATUS Config Broker central Config Broker module ${1} Broker Config Log central sql trace - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 + Config BBDO3 1 Config Broker Sql Output central unified_sql ${start} Get Current Date Start Broker @@ -160,13 +155,12 @@ BEINSTANCE Config Broker central Config Broker module ${1} Broker Config Log central sql trace - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 + Config BBDO3 1 Config Broker Sql Output central unified_sql Connect To Database pymysql ${DBName} ${DBUser} ${DBPass} ${DBHost} ${DBPort} Execute SQL String DELETE FROM instances - #as GetCurrent Date floor milliseconds to upper or lower integer, we substract 1s + # as GetCurrent Date floor milliseconds to upper or lower integer, we substract 1s ${start} Get Round Current Date Start Broker Start Engine @@ -282,7 +276,7 @@ BE_DEFAULT_NOTIFCATION_INTERVAL_IS_ZERO_SERVICE_RESOURCE ... SELECT s.notification_interval, h.notification_interval FROM services s, hosts h WHERE h.host_id=1 AND s.service_id=1 Log To Console ${output} Sleep 1s - IF "${output}" == "((0.0, 0.0),)" BREAK + IF "${output}" == "((0.0, 0.0),)" BREAK END Should Be Equal As Strings ${output} ((0.0, 0.0),) Stop Engine diff --git a/tests/broker-engine/retention-duplicates.robot b/tests/broker-engine/retention-duplicates.robot index 1c6292abd1c..b03e6cf7d3f 100644 --- a/tests/broker-engine/retention-duplicates.robot +++ b/tests/broker-engine/retention-duplicates.robot @@ -263,9 +263,7 @@ BERDUC3U1 Broker Config Flush Log central 0 Broker Config Flush Log module0 0 Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Clear Retention ${start} Get Current Date Start Broker @@ -306,9 +304,7 @@ BERDUC3U2 Broker Config Flush Log central 0 Broker Config Flush Log module0 0 Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 ${start} Get Current Date Start Broker Start Engine @@ -416,10 +412,10 @@ BERDUCA301 Broker Config Flush Log central 0 Broker Config Flush Log module0 0 Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 + + Config BBDO3 1 ${start} Get Current Date + Start Broker Start Engine diff --git a/tests/broker-engine/rrd-from-db.robot b/tests/broker-engine/rrd-from-db.robot index cf6d6e8e9f6..1b81b38cf16 100644 --- a/tests/broker-engine/rrd-from-db.robot +++ b/tests/broker-engine/rrd-from-db.robot @@ -14,7 +14,7 @@ Library ../resources/Common.py Suite Setup Clean Before Suite Suite Teardown Clean After Suite Test Setup Stop Processes -Test Teardown Save Logs If Failed +Test Teardown Stop Engine Broker And Save Logs *** Test Cases *** @@ -162,9 +162,7 @@ BRRDRBUDB1 Broker Config Log central sql trace Broker Config Flush Log central 0 Broker Config Flush Log rrd 0 - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 Create Metrics 3 ${start} Get Current Date exclude_millis=True @@ -211,7 +209,6 @@ BRRDUPLICATE Broker Config Log central sql trace Broker Config Flush Log central 0 Broker Config Flush Log rrd 0 - Clear Db data_bin Create Metrics 3 ${start} Get Current Date diff --git a/tests/broker-engine/rrdcached-from-db.robot b/tests/broker-engine/rrdcached-from-db.robot index 8e76a9916ac..786e97ae30b 100644 --- a/tests/broker-engine/rrdcached-from-db.robot +++ b/tests/broker-engine/rrdcached-from-db.robot @@ -166,9 +166,7 @@ BRRDCDRBUDB1 Broker Config Log central sql trace Broker Config Flush Log central 0 Broker Config Flush Log rrd 0 - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 Create Metrics 3 ${start} Get Current Date exclude_millis=True diff --git a/tests/broker-engine/servicegroups.robot b/tests/broker-engine/servicegroups.robot index 4f9dc48194a..39deb11b590 100644 --- a/tests/broker-engine/servicegroups.robot +++ b/tests/broker-engine/servicegroups.robot @@ -90,12 +90,7 @@ EBNSGU2 Broker Config Log central sql info Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql connections_count 5 - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item module2 bbdo_version 3.0.0 - Broker Config Add Item module3 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 4 Broker Config Log central sql debug Clear Retention @@ -123,6 +118,7 @@ EBNSGU2 ${result} Check Number Of Relations Between Servicegroup And Services 1 9 30 Should Be True ${result} We should get 9 relations between the servicegroup 1 and services. + *** Keywords *** Test End Stop Engine diff --git a/tests/broker-engine/services-and-bulk-stmt.robot b/tests/broker-engine/services-and-bulk-stmt.robot index 74d2bbe0240..2c9d03da7e7 100644 --- a/tests/broker-engine/services-and-bulk-stmt.robot +++ b/tests/broker-engine/services-and-bulk-stmt.robot @@ -27,9 +27,7 @@ EBBPS1 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 + Config BBDO3 1 Broker Config Log central core info Broker Config Log central tcp error Broker Config Log central sql trace @@ -112,9 +110,7 @@ EBBPS2 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 + Config BBDO3 1 Broker Config Log central core info Broker Config Log central tcp error Broker Config Log central sql trace @@ -197,8 +193,7 @@ EBMSSM Config Broker central Config Broker rrd Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 Broker Config Log central core error Broker Config Log central tcp error Broker Config Log central sql debug @@ -244,8 +239,7 @@ EBPS2 Config Broker central Config Broker rrd Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 + Config BBDO3 1 Broker Config Flush Log central 0 Broker Config Log central core error Broker Config Log central tcp error @@ -286,9 +280,7 @@ RLCode Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item central bbdo_version 3.0.1 - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 + Config BBDO3 1 Broker Config Log central tcp error Broker Config Log central sql error Broker Config Log central lua debug @@ -296,12 +288,12 @@ RLCode ${INITIAL_SCRIPT_CONTENT} Catenate ... function init(params) - ... broker_log:set_parameters(2, '/tmp/toto.log') + ... broker_log:set_parameters(2, '/tmp/toto.log') ... end ... ... function write(d) - ... broker_log:info(0, "toto") - ... return true + ... broker_log:info(0, "toto") + ... return true ... end # Create the initial LUA script file @@ -315,7 +307,6 @@ RLCode Start Broker Start Engine - ${content} Create List check_for_external_commands() ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 Should Be True ${result} A message telling check_for_external_commands() should be available. @@ -327,15 +318,14 @@ RLCode # Define the new content to take place of the first one ${new_content} Catenate ... function init(params) - ... broker_log:set_parameters(2, '/tmp/titi.log') + ... broker_log:set_parameters(2, '/tmp/titi.log') ... end ... ... function write(d) - ... broker_log:info(0, "titi") - ... return true + ... broker_log:info(0, "titi") + ... return true ... end - # Create the LUA script file from the content Create File /tmp/toto.lua ${new_content} ${start} Get Current Date @@ -367,14 +357,14 @@ metric_mapping ${new_content} Catenate ... function init(params) - ... broker_log:set_parameters(1, "/tmp/test.log") + ... broker_log:set_parameters(1, "/tmp/test.log") ... end ... ... function write(d) - ... if d._type == 196617 then - ... broker_log:info(0, "name: " .. tostring(d.name) .. " corresponds to metric id " .. tostring(d.metric_id)) - ... end - ... return true + ... if d._type == 196617 then + ... broker_log:info(0, "name: " .. tostring(d.name) .. " corresponds to metric id " .. tostring(d.metric_id)) + ... end + ... return true ... end # Create the initial LUA script file @@ -400,6 +390,7 @@ metric_mapping ${grep_res} Grep File /tmp/test.log name: metric1 corresponds to metric id Should Not Be Empty ${grep_res} metric name "metric1" not found + *** Keywords *** Test Clean Stop Engine diff --git a/tests/broker-engine/services-increased.robot b/tests/broker-engine/services-increased.robot index 01184db2e1e..b7fbc36242b 100644 --- a/tests/broker-engine/services-increased.robot +++ b/tests/broker-engine/services-increased.robot @@ -25,11 +25,7 @@ EBNSVC1 Config Broker rrd Config Broker central Config Broker module ${3} - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item module1 bbdo_version 3.0.1 - Broker Config Add Item module2 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 + Config BBDO3 3 Broker Config Log central sql debug Config Broker Sql Output central unified_sql Clear Retention @@ -65,9 +61,7 @@ Service_increased_huge_check_interval Config Broker central Config Broker module ${1} Broker Config Source Log central 1 - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 + Config BBDO3 1 Broker Config Log rrd rrd trace Broker Config Log central sql debug Broker Config Log rrd core error diff --git a/tests/broker-engine/services-with-notes-and-actions.robot b/tests/broker-engine/services-with-notes-and-actions.robot index 15342cf865f..1ee08ccb8e4 100644 --- a/tests/broker-engine/services-with-notes-and-actions.robot +++ b/tests/broker-engine/services-with-notes-and-actions.robot @@ -25,9 +25,7 @@ EBSNU1 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 + Config BBDO3 1 Broker Config Log central sql debug Broker Config Log central bbdo debug Config Broker Sql Output central unified_sql @@ -60,9 +58,7 @@ EBSAU2 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 + Config BBDO3 1 Broker Config Log central sql debug Broker Config Log central bbdo debug Config Broker Sql Output central unified_sql @@ -95,9 +91,7 @@ EBSN3 Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.1 - Broker Config Add Item central bbdo_version 3.0.1 - Broker Config Add Item rrd bbdo_version 3.0.1 + Config BBDO3 1 Broker Config Log central sql debug Broker Config Log central bbdo debug Config Broker Sql Output central unified_sql diff --git a/tests/broker-engine/services.robot b/tests/broker-engine/services.robot index cef4ea3b88b..fd1e5c7612e 100644 --- a/tests/broker-engine/services.robot +++ b/tests/broker-engine/services.robot @@ -25,9 +25,7 @@ SDER Config Broker rrd Config Broker central Config Broker module ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql debug Broker Config Log module0 neb trace Config Broker Sql Output central unified_sql diff --git a/tests/broker-engine/tags.robot b/tests/broker-engine/tags.robot index 20b3f85a5b4..b7ebaade16f 100644 --- a/tests/broker-engine/tags.robot +++ b/tests/broker-engine/tags.robot @@ -84,9 +84,7 @@ BEUTAG1 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql debug Clear Retention @@ -116,9 +114,7 @@ BEUTAG2 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Output Set central central-broker-unified-sql connections_count 1 Broker Config Output Set central central-broker-unified-sql queries_per_transaction 1 Broker Config Output Set central central-broker-unified-sql read_timeout 1 @@ -163,9 +159,7 @@ BEUTAG3 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql debug Clear Retention @@ -199,9 +193,7 @@ BEUTAG4 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql debug Clear Retention @@ -239,9 +231,7 @@ BEUTAG5 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql debug Clear Retention @@ -281,9 +271,7 @@ BEUTAG6 Config Broker rrd Config Broker module ${1} Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql debug Clear Retention @@ -326,10 +314,7 @@ BEUTAG7 Config Broker rrd Config Broker module ${2} Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 2 Broker Config Log module0 neb debug Broker Config Log module1 neb debug Broker Config Log central sql trace @@ -402,10 +387,7 @@ BEUTAG8 Config Broker rrd Config Broker module ${2} Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 2 Broker Config Log module0 neb debug Broker Config Log module1 neb debug Broker Config Log central sql trace @@ -460,10 +442,7 @@ BEUTAG9 Config Broker rrd Config Broker module ${2} Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 2 Broker Config Log module0 neb debug Broker Config Log module1 neb debug Broker Config Log central sql trace @@ -524,10 +503,7 @@ BEUTAG10 Config Broker rrd Config Broker module ${2} Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 2 Broker Config Log module0 neb debug Broker Config Log module1 neb debug Broker Config Log central sql trace @@ -596,10 +572,7 @@ BEUTAG11 Config Broker rrd Config Broker module ${2} Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 2 Broker Config Log module0 neb debug Broker Config Log module1 neb debug Broker Config Log central sql trace @@ -663,9 +636,7 @@ BEUTAG12 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql debug Clear Retention diff --git a/tests/broker/bbdo-server-client-ko.robot b/tests/broker/bbdo-server-client-ko.robot index 4ca415075d2..e2f0e246050 100644 --- a/tests/broker/bbdo-server-client-ko.robot +++ b/tests/broker/bbdo-server-client-ko.robot @@ -77,10 +77,10 @@ Start Stop Service Should Be True ${result} The connection between cbd central and rrd is not established. Send Signal To Process SIGTERM b1 - ${result} Wait Or Dump And Kill Process b1 60s + ${result} Wait Or Dump And Kill Process b1 /usr/sbin/cbd 60s Should Be True ${result.rc} == -15 or ${result.rc} == 0 Broker service badly stopped Send Signal To Process SIGTERM b2 - ${result} Wait Or Dump And Kill Process b2 60s + ${result} Wait Or Dump And Kill Process b2 /usr/sbin/cbd 60s Should Be True ${result.rc} == -15 or ${result.rc} == 0 Broker service badly stopped Start Stop Instance @@ -88,5 +88,5 @@ Start Stop Instance Start Process /usr/sbin/cbd ${EtcRoot}/centreon-broker/central-broker.json alias=b1 Sleep ${interval} Send Signal To Process SIGTERM b1 - ${result} Wait Or Dump And Kill Process b1 60s + ${result} Wait Or Dump And Kill Process b1 /usr/sbin/cbd 60s Should Be True ${result.rc} == -15 or ${result.rc} == 0 Broker instance badly stopped diff --git a/tests/broker/bbdo-server-client-reversed.robot b/tests/broker/bbdo-server-client-reversed.robot index 482f8ef1c97..c44cfa22103 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} 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} 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,16 +142,16 @@ 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 Broker Config Log central core off Broker Config Log rrd core off Broker Config Log central tls debug - Broker Config Log central grpc debug + Broker Config Log central grpc trace Create Key And Certificate ... localhost ... ${EtcRoot}/centreon-broker/server.key @@ -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 @@ -283,10 +283,10 @@ Start Stop Service Should Be True ${result} The connection between cbd central and rrd is not established. Send Signal To Process SIGTERM b1 - ${result} Wait Or Dump And Kill Process b1 60s + ${result} Wait Or Dump And Kill Process b1 /usr/sbin/cbd 60s Should Be True ${result.rc} == -15 or ${result.rc} == 0 Broker service badly stopped Send Signal To Process SIGTERM b2 - ${result} Wait Or Dump And Kill Process b2 60s + ${result} Wait Or Dump And Kill Process b2 /usr/sbin/cbd 60s Should Be True ${result.rc} == -15 or ${result.rc} == 0 Broker service badly stopped Start Stop Instance @@ -294,7 +294,7 @@ Start Stop Instance Start Process /usr/sbin/cbd ${EtcRoot}/centreon-broker/central-broker.json alias=b1 Sleep ${interval} Send Signal To Process SIGTERM b1 - ${result} Wait Or Dump And Kill Process b1 60s + ${result} Wait Or Dump And Kill Process b1 /usr/sbin/cbd 60s Should Be True ${result.rc} == -15 or ${result.rc} == 0 Broker instance badly stopped Prepare Suite diff --git a/tests/broker/bbdo-server-client.robot b/tests/broker/bbdo-server-client.robot index 3123a54fc60..985f490bd36 100644 --- a/tests/broker/bbdo-server-client.robot +++ b/tests/broker/bbdo-server-client.robot @@ -102,8 +102,8 @@ BSCSST1 Config Broker BBDO Input central bbdo_server 5669 tcp 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 Output Set central centreon-broker-master-rrd 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 @@ -121,28 +121,28 @@ BSCSST2 Config Broker BBDO Input central bbdo_server 5669 tcp 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 Output Set central centreon-broker-master-rrd 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 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 Current Date Repeat Keyword 5 times Start Stop Service 0 ${content} Create List TLS: successful handshake @@ -157,8 +157,8 @@ BSCSSTG1 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 Output Set central central-broker-master-output encryption 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 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 @@ -183,14 +183,14 @@ BSCSSTG2 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 Output Set central central-broker-master-output encryption 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 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 Broker Config Log central tls debug - Broker Config Log rrd grpc debug - Broker Config Log central grpc debug + Broker Config Log rrd grpc trace + Broker Config Log central grpc trace Create Key And Certificate ... localhost ... ${EtcRoot}/centreon-broker/server.key @@ -202,21 +202,21 @@ BSCSSTG2 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 Current Date Start Broker ${content} Create List encrypted connection write: buff: write done: buff: @@ -232,8 +232,8 @@ BSCSSTG3 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 Output Set central central-broker-master-output encryption 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 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 @@ -251,25 +251,25 @@ BSCSSTG3 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 + ... 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 @@ -285,7 +285,7 @@ BSCSSC1 Config Broker BBDO Input central bbdo_server 5669 tcp 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 compression yes + Broker Config Output Set central centreon-broker-master-rrd compression yes Broker Config Log central config off Broker Config Log central core trace Broker Config Log rrd core trace @@ -305,7 +305,7 @@ BSCSSC2 Config Broker BBDO Input central bbdo_server 5669 tcp 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 compression no + Broker Config Output Set central centreon-broker-master-rrd compression no Broker Config Log central config off Broker Config Log central core off Broker Config Log rrd core trace @@ -326,7 +326,7 @@ BSCSSCG1 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 Output Set central central-broker-master-output compression yes + Broker Config Output Set central centreon-broker-master-rrd compression yes Broker Config Log central config off Broker Config Log central core trace Broker Config Log rrd core off @@ -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,8 +372,8 @@ 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 Output Set central central-broker-master-output authorization titus + Broker Config Input Set rrd central-rrd-master-input authorization titus + Broker Config Output Set central centreon-broker-master-rrd authorization titus Broker Config Log central config trace Broker Config Log central core trace Broker Config Log rrd core off diff --git a/tests/broker/sql.robot b/tests/broker/sql.robot index 5f26e434d0d..9e620110b02 100644 --- a/tests/broker/sql.robot +++ b/tests/broker/sql.robot @@ -12,6 +12,7 @@ Library ../resources/Common.py Suite Setup Clean Before Suite Suite Teardown Clean After Suite Test Setup Stop Processes +Test Teardown Save Logs If failed *** Test Cases *** diff --git a/tests/ccc/ccc.robot b/tests/ccc/ccc.robot index 8ae9296dda7..4395002bbfe 100644 --- a/tests/ccc/ccc.robot +++ b/tests/ccc/ccc.robot @@ -48,9 +48,7 @@ BECCC2 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql store_in_resources yes @@ -83,9 +81,7 @@ BECCC3 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql store_in_resources yes @@ -117,9 +113,7 @@ BECCC4 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql store_in_resources yes @@ -150,9 +144,7 @@ BECCC5 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql store_in_resources yes @@ -183,9 +175,7 @@ BECCC6 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql store_in_resources yes @@ -230,9 +220,7 @@ BECCC7 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql store_in_resources yes @@ -265,9 +253,7 @@ BECCC8 Config Broker central Config Broker module Config Broker rrd - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log central sql trace Config Broker Sql Output central unified_sql Broker Config Output Set central central-broker-unified-sql store_in_resources yes diff --git a/tests/engine/forced_checks.robot b/tests/engine/forced_checks.robot index 61b2f2e606d..eb492cc0caf 100644 --- a/tests/engine/forced_checks.robot +++ b/tests/engine/forced_checks.robot @@ -117,12 +117,10 @@ EFHCU1 Config Broker module ${1} Engine Config Set Value ${0} log_legacy_enabled ${0} Engine Config Set Value ${0} log_v2_enabled ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 Broker Config Log module0 neb debug Config Broker Sql Output central unified_sql Broker Config Log central sql debug - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Clear Retention Clear Db resources @@ -169,12 +167,10 @@ EFHCU2 Config Broker module ${1} Engine Config Set Value ${0} log_legacy_enabled ${0} Engine Config Set Value ${0} log_v2_enabled ${1} - Broker Config Add Item module0 bbdo_version 3.0.0 Broker Config Log module0 neb debug Config Broker Sql Output central unified_sql Broker Config Log central sql debug - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Clear Retention ${start} Get Current Date @@ -253,7 +249,7 @@ EMACROS_NOTIF Engine Config Set Value ${0} log_legacy_enabled ${0} Engine Config Set Value ${0} log_v2_enabled ${1} Engine Config Set Value 0 log_level_checks trace True - Engine Config Add Value 0 cfg_file ${EtcRoot}/centreon-engine/config0/contacts.cfg + Engine Config Add Value 0 cfg_file ${EtcRoot}/centreon-engine/config0/contacts.cfg Engine Config Add Command ... 0 ... command_notif diff --git a/tests/migration/migration.robot b/tests/migration/migration.robot index 77d6d9cb269..ba2d60bc5d1 100644 --- a/tests/migration/migration.robot +++ b/tests/migration/migration.robot @@ -57,11 +57,7 @@ MIGRATION ${result} Find In Log With Timeout ${rrdLog} ${start} ${contentRRD} 30 Should Be True ${result} No metric sent to rrd cbd by unified_sql for 30s - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item module2 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 3 ${start} Get Current Date Log To Console Move to BBDO 3.0.0 with unified_sql diff --git a/tests/resources/Bench.py b/tests/resources/Bench.py index 3962aab12f8..cfa8aee4894 100644 --- a/tests/resources/Bench.py +++ b/tests/resources/Bench.py @@ -13,6 +13,7 @@ from robot.api import logger from dateutil import parser as date_parser from Common import get_version +from Common import is_using_direct_grpc class delta_process_stat: @@ -128,7 +129,7 @@ def store_result_in_unqlite(file_path: str, test_name: str, broker_or_engine: s """! store a bench result and process stat difference in an unqlite file it also stores git information @param file_path path of the unqlite file - @param test_name name of the state + @param test_name name of the state if we are using direct grpc serialization, _grpc is appended to @param broker_or_engine a string equal to engine or broker to identify stats owning @param resources_consumed a delta_process_stat object @param end_process_stat stat of the process at the end of the test @@ -146,7 +147,11 @@ def store_result_in_unqlite(file_path: str, test_name: str, broker_or_engine: s row['kernel_time'] = row['kernel_time'].seconds + \ row['kernel_time'].nanos / 1000000000.0 info = get_cpu_info() - row['cpu'] = info["brand_raw"] + if 'brand_raw' in info: + row['cpu'] = info["brand_raw"] + else: + row['cpu'] = 'unknown cpu' + logger.console(f"unable to get cpu info: {info}") row['nb_core'] = info["count"] row['memory_size'] = psutil.virtual_memory().total row['memory_used'] = end_process_stat.vm_size @@ -175,6 +180,8 @@ def store_result_in_unqlite(file_path: str, test_name: str, broker_or_engine: s row['commit'] = repo.head.commit.hexsha row['t'] = time.time() row['branch'] = repo.head.name + if is_using_direct_grpc(): + test_name += "_grpc" db = UnQLite(file_path) benchs = db.collection( f'collectbench_{test_name}_{broker_or_engine}_{bench_event_result["id"]}') diff --git a/tests/resources/Broker.py b/tests/resources/Broker.py index f61c56b11cf..25dcb980765 100755 --- a/tests/resources/Broker.py +++ b/tests/resources/Broker.py @@ -23,19 +23,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": """{{ @@ -421,7 +412,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) @@ -452,6 +443,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" @@ -464,11 +457,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): @@ -477,6 +491,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) @@ -495,6 +511,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) @@ -607,12 +625,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() @@ -620,10 +640,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, @@ -646,6 +666,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' @@ -658,7 +679,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}", @@ -908,6 +929,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)) @@ -926,6 +950,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 0606ef74a62..4efcf921a13 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,24 @@ 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 is_using_direct_grpc(): + default_bbdo_version = TESTS_PARAMS.get("default_bbdo_version") + default_transport = TESTS_PARAMS.get("default_transport") + return default_bbdo_version is not None and default_transport == "grpc" and default_bbdo_version >= "3.1.0" def check_connection(port: int, pid1: int, pid2: int): diff --git a/tests/resources/resources.robot b/tests/resources/resources.robot index 301c24c12ed..f870147b741 100644 --- a/tests/resources/resources.robot +++ b/tests/resources/resources.robot @@ -263,8 +263,8 @@ Dump Process Create Directory ${failDir} ${output} Catenate SEPARATOR= /tmp/core- ${name} ${gdb_output} Catenate SEPARATOR= ${failDir} /core- ${name} .txt - Log To Console Creation of core ${output}.${pid} to debug - Run Process gcore -o ${output} ${pid} + # Log To Console Creation of core ${output}.${pid} to debug + # Run Process gcore -o ${output} ${pid} Run Process ... gdb ... -batch @@ -304,12 +304,12 @@ Copy Coredump In Failed Dir END Wait Or Dump And Kill Process - [Arguments] ${process_name} ${timeout} + [Arguments] ${process_name} ${binary_path} ${timeout} ${result} Wait For Process ${process_name} timeout=${timeout} on_timeout=continu ${test_none} Set Variable If $result is None "not killed" "killed" IF ${test_none} == "not killed" ${pid} Get Process Id ${process_name} - Run Process gcore -o ${ENGINE_LOG}/config0/gcore_${process_name} ${pid} + Dump Process ${process_name} ${binary_path} ${process_name} ${result} Wait For Process ${process_name} timeout=1s on_timeout=kill END RETURN ${result} diff --git a/tests/severities/hosts.robot b/tests/severities/hosts.robot index 43444d9184b..8b0d534c4ed 100644 --- a/tests/severities/hosts.robot +++ b/tests/severities/hosts.robot @@ -28,9 +28,7 @@ BEUHSEV1 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql trace Clear Retention @@ -73,10 +71,7 @@ BEUHSEV2 Config Broker rrd Config Broker module ${2} Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 2 Broker Config Log module0 neb debug Broker Config Log module1 neb debug Broker Config Log central sql trace @@ -152,10 +147,7 @@ BETUHSEV1 Config Broker rrd Config Broker module ${2} Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 2 Broker Config Log module0 neb debug Broker Config Log module1 neb debug Broker Config Log central sql trace diff --git a/tests/severities/severities.robot b/tests/severities/severities.robot index cb616e9151a..e1e4f4e9a46 100644 --- a/tests/severities/severities.robot +++ b/tests/severities/severities.robot @@ -75,9 +75,7 @@ BEUSEV1 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql debug Clear Retention @@ -102,9 +100,7 @@ BEUSEV2 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql debug Clear Retention @@ -131,9 +127,7 @@ BEUSEV3 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 1 Broker Config Log module0 neb debug Broker Config Log central sql trace Clear Retention @@ -176,10 +170,7 @@ BEUSEV4 Config Broker rrd Config Broker module 2 Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 2 Broker Config Log module0 neb debug Broker Config Log central sql trace Clear Retention @@ -254,10 +245,7 @@ BETUSEV1 Config Broker rrd Config Broker module Config Broker Sql Output central unified_sql - Broker Config Add Item module0 bbdo_version 3.0.0 - Broker Config Add Item module1 bbdo_version 3.0.0 - Broker Config Add Item central bbdo_version 3.0.0 - Broker Config Add Item rrd bbdo_version 3.0.0 + Config BBDO3 2 Broker Config Log module0 neb debug Broker Config Log central sql trace Clear Retention From 8ef56ce85e36b7bb2a8b236a2b6ce385904a778c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Chapron?= <34628915+sc979@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:35:06 +0100 Subject: [PATCH 08/39] enh(chore): new code_owners (#940) --- .github/CODEOWNERS | 7 +++++++ .github/workflows/robot-test.yml | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000000..210d838b084 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,7 @@ +** @centreon/owners-cpp + +.github/** @centreon/owners-pipelines +packaging/** @centreon/owners-pipelines +selinux/** @centreon/owners-pipelines + +tests/** @centreon/owners-robot-e2e diff --git a/.github/workflows/robot-test.yml b/.github/workflows/robot-test.yml index 130575cf3b0..97fb2135046 100644 --- a/.github/workflows/robot-test.yml +++ b/.github/workflows/robot-test.yml @@ -146,7 +146,6 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.collect_s3_access_key }} AWS_SECRET_ACCESS_KEY: ${{ secrets.collect_s3_secret_key }} - - name: Move reports if: ${{ failure() }} run: | From 88cda97be49fbb72578ca214c2bfc2d624ac743e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Chapron?= <34628915+sc979@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:46:35 +0100 Subject: [PATCH 09/39] enh(chore): code owners feedbacks (#971) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 210d838b084..08a9bd35381 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ -** @centreon/owners-cpp +* @centreon/owners-cpp .github/** @centreon/owners-pipelines packaging/** @centreon/owners-pipelines From a3982e93a74b65930e261e1c0080f9956a77a3c2 Mon Sep 17 00:00:00 2001 From: jean-christophe81 <98889244+jean-christophe81@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:40:48 +0100 Subject: [PATCH 10/39] Mon 22275 make engine look for yaml configuration files for commands whitelists (#931) REFS:MON-22275 * add whitelist class * integrate whitelist to state * c++17 is now mandatory * MON-22270 whitelist filter commands * MON-22270 add some tests * improve wildcards add tests * add user centreon-engine in whitelist tests * add /usr/share/centreon-engine-whitelist directory * fix alma9 conan install * some fix * rewrite whitelist * whitelist result is stored in checkable * fix test * add some doc * fix duplicate issue --- .../docker/Dockerfile.centreon-collect-alma8 | 2 +- .../docker/Dockerfile.centreon-collect-alma9 | 4 +- ...ockerfile.centreon-collect-debian-bullseye | 2 +- .../Dockerfile.centreon-collect-mysql-alma9 | 4 +- .github/scripts/collect-unit-tests.sh | 6 +- .github/workflows/package-collect.yml | 3 +- .github/workflows/veracode-analysis.yml | 2 +- broker/core/src/bbdo/stream.cc | 4 +- cmake.sh | 13 +- conanfile.txt | 1 + engine/CMakeLists.txt | 2 + engine/Doxyfile | 2570 +++++++++++++++++ engine/doc/engine-doc.md | 32 + engine/doc/pictures/logo.jpg | Bin 0 -> 49244 bytes engine/inc/com/centreon/engine/checkable.hh | 17 + .../com/centreon/engine/commands/result.hh | 2 - .../centreon/engine/configuration/state.hh | 2 + .../engine/configuration/whitelist.hh | 114 + engine/precomp_inc/precomp.hh | 2 + engine/src/checkable.cc | 26 + engine/src/checks/checker.cc | 51 +- engine/src/configuration/CMakeLists.txt | 148 +- engine/src/configuration/applier/state.cc | 10 +- engine/src/configuration/state.cc | 1 + engine/src/configuration/whitelist.cc | 315 ++ engine/src/host.cc | 102 +- engine/src/service.cc | 129 +- engine/tests/CMakeLists.txt | 3 + engine/tests/configuration/whitelist-test.cc | 274 ++ .../services-and-bulk-stmt.robot | 10 +- tests/broker-engine/whitelist.robot | 237 ++ tests/connector_ssh/connector_ssh.robot | 164 +- tests/resources/Common.py | 17 + tests/resources/engine-scripts/check.pl | 8 +- tests/resources/resources.robot | 34 +- 35 files changed, 4027 insertions(+), 284 deletions(-) create mode 100644 engine/Doxyfile create mode 100644 engine/doc/engine-doc.md create mode 100644 engine/doc/pictures/logo.jpg create mode 100644 engine/inc/com/centreon/engine/configuration/whitelist.hh create mode 100644 engine/src/configuration/whitelist.cc create mode 100644 engine/tests/configuration/whitelist-test.cc create mode 100644 tests/broker-engine/whitelist.robot diff --git a/.github/docker/Dockerfile.centreon-collect-alma8 b/.github/docker/Dockerfile.centreon-collect-alma8 index 430b6237274..a6895101db2 100644 --- a/.github/docker/Dockerfile.centreon-collect-alma8 +++ b/.github/docker/Dockerfile.centreon-collect-alma8 @@ -65,7 +65,7 @@ COPY conanfile.txt . RUN <stop(); - /* We acknowledge peer about received events. */ log_v2::core()->info("bbdo stream stopped with {} events acknowledged", _events_received_since_last_ack); if (_events_received_since_last_ack) send_event_acknowledgement(); + _substream->stop(); + /* We return the number of events handled by our stream. */ int32_t retval = _acknowledged_events; _acknowledged_events = 0; diff --git a/cmake.sh b/cmake.sh index f1d63abb327..ef96f9ce6d5 100755 --- a/cmake.sh +++ b/cmake.sh @@ -27,7 +27,7 @@ for i in $(cat conanfile.txt) ; do fi done -STD=gnu14 +STD=gnu17 COMPILER=gcc CC=gcc CXX=g++ @@ -44,11 +44,6 @@ do force=1 shift ;; - -ng) - echo "C++17 applied on this compilation" - STD="gnu17" - shift - ;; -dr|--debug-robot) echo "DEBUG_ROBOT enabled" DR="-DDEBUG_ROBOT=ON" @@ -322,11 +317,7 @@ cd build echo "$conan install .. --build=missing" $conan install .. --build=missing -if [[ "$STD" -eq "gnu17" ]] ; then - NG="-DNG=ON" -else - NG="-DNG=OFF" -fi +NG="-DNG=ON" if [[ "$maj" == "Raspbian" ]] ; then CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra" $cmake $DR -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_TESTING=On -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF $NG $* .. diff --git a/conanfile.txt b/conanfile.txt index f0534039f18..f0d745cbe58 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -10,6 +10,7 @@ libssh2/1.10.0 mariadb-connector-c/3.3.3 nlohmann_json/3.11.2 opentelemetry-cpp/1.8.1 +rapidyaml/0.5.0 spdlog/1.11.0 zlib/1.2.13 abseil/20230125.3 diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 138a6b1a584..301780c9ed5 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -542,6 +542,8 @@ target_link_libraries( CONAN_PKG::openssl ${c-ares_LIBS} CONAN_PKG::zlib + CONAN_PKG::rapidyaml + stdc++fs dl) # centenginestats target. diff --git a/engine/Doxyfile b/engine/Doxyfile new file mode 100644 index 00000000000..36abf8da737 --- /dev/null +++ b/engine/Doxyfile @@ -0,0 +1,2570 @@ +# Doxyfile 1.8.20 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "Centreon Engine" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = doc/pictures/logo.jpg + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc/devel-doc + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = YES + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 2 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# (including Cygwin) and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: https://www.gnu.org/software/libiconv/) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen +# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.h \ + *.hh \ + *.py \ + *.md \ + *.pl + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = build .git cmake + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = doc/engine-doc.md + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the +# cost of reduced performance. This can be particularly helpful with template +# rich C++ code for which doxygen's built-in parser lacks the necessary type +# information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the "-p" option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: https://developer.apple.com/xcode/), introduced with OSX +# 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2 + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /