Skip to content

Commit

Permalink
Merge branch 'dev-24.10.x' into MON-150464-get-version-24.10
Browse files Browse the repository at this point in the history
  • Loading branch information
kduret committed Nov 4, 2024
2 parents d1f4901 + 94c63c6 commit 12697ab
Show file tree
Hide file tree
Showing 36 changed files with 1,481 additions and 232 deletions.
6 changes: 1 addition & 5 deletions .github/actions/package/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ runs:
export DIST="${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }}"
else
export DIST=""
if [ "${{ inputs.stability }}" = "unstable" ] || [ "${{ inputs.stability }}" = "canary" ]; then
export RELEASE="$RELEASE${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }}"
else
export RELEASE="1${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }}"
fi
export RELEASE="$RELEASE${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }}"
fi
MAJOR_LEFT=$( echo $MAJOR_VERSION | cut -d "." -f1 )
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/promote-to-stable/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ runs:
shell: bash

- name: Promote DEB packages to stable
if: ${{ inputs.is_cloud == 'false' && contains(fromJSON('["bullseye", "bookworm"]'), inputs.distrib) }}
if: ${{ contains(fromJSON('["bullseye", "bookworm"]'), inputs.distrib) }}
run: |
set -eux
Expand Down
267 changes: 267 additions & 0 deletions .github/scripts/agent_installer_test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
#
# Copyright 2024 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 : [email protected]
#

# This script test CMA installer in silent mode


function test_args_to_registry {
<#
.SYNOPSIS
start a program and check values in registry
.PARAMETER exe_path
path of the installer to execute
.PARAMETER exe_args
installer arguments
.PARAMETER expected_registry_values
hash_table as @{'host'='host_1';'endpoint'='127.0.0.1'}
#>
param (
[string] $exe_path,
[string[]] $exe_args,
$expected_registry_values
)

Write-Host "arguments: $exe_args"

$process_info= Start-Process -PassThru $exe_path $exe_args
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 0) {
Write-Host "fail to execute $exe_path with arguments $exe_args"
Write-Host "exit status = " $process_info.ExitCode
exit 1
}

foreach ($value_name in $expected_registry_values.Keys) {
$expected_value = $($expected_registry_values[$value_name])
$real_value = (Get-ItemProperty -Path HKLM:\Software\Centreon\CentreonMonitoringAgent -Name $value_name).$value_name
if ($expected_value -ne $real_value) {
Write-Host "unexpected value for $value_name, expected: $expected_value, read: $real_value"
exit 1
}
}
}

Write-Host "############################ all install uninstall ############################"

$args = '/S','--install_cma', '--install_plugins', '--hostname', "my_host_name_1", "--endpoint","127.0.0.1:4317"
$expected = @{ 'endpoint'='127.0.0.1:4317';'host'='my_host_name_1';'log_type'='EventLog'; 'log_level' = 'error'; 'encryption' = 0;'reversed_grpc_streaming'= 0 }
test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected

if (!(Get-ItemProperty -Path HKLM:\Software\Centreon\CentreonMonitoringAgent)) {
Write-Host "no registry entry created"
exit 1
}

Get-Process | Select-Object -Property ProcessName | Select-String centagent

$info = Get-Process | Select-Object -Property ProcessName | Select-String centagent

#$info = Get-Process centagent 2>$null
if (!$info) {
Write-Host "centagent.exe not started"
exit 1
}

if (![System.Io.File]::Exists("C:\Program Files\Centreon\Plugins\centreon_plugins.exe")) {
Write-Host "centreon_plugins.exe not installed"
exit 1
}

$process_info= Start-Process -PassThru "C:\Program Files\Centreon\CentreonMonitoringAgent\uninstall.exe" "/S", "--uninstall_cma","--uninstall_plugins"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 0) {
Write-Host "bad uninstaller exit code"
exit 1
}

Start-Sleep -Seconds 5

Get-Process | Select-Object -Property ProcessName | Select-String centagent

$info = Get-Process | Select-Object -Property ProcessName | Select-String centagent
#$info = Get-Process centagent 2>$null
if ($info) {
Write-Host "centagent.exe running"
exit 1
}

if ([System.Io.File]::Exists("C:\Program Files\Centreon\Plugins\centreon_plugins.exe")) {
Write-Host "centreon_plugins.exe not removed"
exit 1
}

Write-Host "The followind command will output errors, don't take it into account"
#the only mean I have found to test key erasure under CI
#Test-Path doesn't work
$key_found = true
try {
Get-ChildItem -Path HKLM:\Software\Centreon\CentreonMonitoringAgent
}
catch {
$key_found = false
}

if ($key_found) {
Write-Host "registry entry not removed"
exit 1
}


Write-Host "############################ installer test ############################"

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--help"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 2) {
Write-Host "bad --help exit code"
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--version"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 2) {
Write-Host "bad --version exit code"
exit 1
}

#missing mandatory parameters
$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "bad no parameter exit code " $process_info.ExitCode
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "bad no endpoint exit code " $process_info.ExitCode
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","turlututu"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "bad wrong endpoint exit code " $process_info.ExitCode
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--log_type","file"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "bad no log file path " $process_info.ExitCode
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--log_type","file","--log_file","C:"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "bad log file path " $process_info.ExitCode
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--log_level","dsfsfd"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "bad log level " $process_info.ExitCode
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--reverse","--log_type","file","--log_file","C:\Users\Public\cma.log","--encryption"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "reverse mode, encryption and no private_key " $process_info.ExitCode
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--reverse","--log_type","file","--log_file","C:\Users\Public\cma.log","--encryption","--private_key","C:"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "reverse mode, encryption and bad private_key path" $process_info.ExitCode
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--reverse","--log_type","file","--log_file","C:\Users\Public\cma.log","--encryption","--private_key","C:\Users\Public\private_key.key"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "reverse mode, encryption and no certificate" $process_info.ExitCode
exit 1
}

$process_info= Start-Process -PassThru "agent/installer/centreon-monitoring-agent.exe" "/S", "--install_cma","--hostname","toto","--endpoint","127.0.0.1:4317","--reverse","--log_type","file","--log_file","C:\Users\Public\cma.log","--encryption","--private_key","C:\Users\Public\private_key.key", "--public_cert", "C:"
Wait-Process -Id $process_info.Id
if ($process_info.ExitCode -ne 1) {
Write-Host "reverse mode, encryption and bad certificate path" $process_info.ExitCode
exit 1
}


$args = '/S','--install_cma','--hostname', "my_host_name_1", "--endpoint","127.0.0.1:4317"
$expected = @{ 'endpoint'='127.0.0.1:4317';'host'='my_host_name_1';'log_type'='EventLog'; 'log_level' = 'error'; 'encryption' = 0;'reversed_grpc_streaming'= 0 }
test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected

$args = '/S','--install_cma','--hostname', "my_host_name_2", "--endpoint","127.0.0.2:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--log_max_file_size", "15", "--log_max_files", "10"
$expected = @{ 'endpoint'='127.0.0.2:4317';'host'='my_host_name_2';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma.log'; 'encryption' = 0;'reversed_grpc_streaming'= 0; 'log_max_file_size' = 15; 'log_max_files' = 10; }
test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected

$args = '/S','--install_cma','--hostname', "my_host_name_2", "--endpoint","127.0.0.3:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--encryption"
$expected = @{ 'endpoint'='127.0.0.3:4317';'host'='my_host_name_2';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma.log'; 'encryption' = 1;'reversed_grpc_streaming'= 0 }
test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected

$args = '/S','--install_cma','--hostname', "my_host_name_2", "--endpoint","127.0.0.4:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--encryption", "--private_key", "C:\Users crypto\private.key", "--public_cert", "D:\tutu\titi.crt", "--ca", "C:\Users\Public\ca.crt", "--ca_name", "tls_ca_name"
$expected = @{ 'endpoint'='127.0.0.4:4317';'host'='my_host_name_2';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma.log'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi.crt'; 'private_key'='C:\Users crypto\private.key'; 'ca_certificate' = 'C:\Users\Public\ca.crt'; 'ca_name' = 'tls_ca_name' }
test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected

$args = '/S','--install_cma','--hostname', "my_host_name_2", "--endpoint","127.0.0.5:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma_rev.log", "--log_level", "trace", "--encryption", "--reverse", "--private_key", "C:\Users crypto\private_rev.key", "--public_cert", "D:\tutu\titi_rev.crt", "--ca", "C:\Users\Public\ca_rev.crt", "--ca_name", "tls_ca_name_rev"
$expected = @{ 'endpoint'='127.0.0.5:4317';'host'='my_host_name_2';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma_rev.log'; 'encryption' = 1;'reversed_grpc_streaming'= 1; 'certificate'='D:\tutu\titi_rev.crt'; 'private_key'='C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $args $expected


Write-Host "############################ modifier test ############################"

$args = '/S','--hostname', "my_host_name_10", "--endpoint","127.0.0.10:4317", "--no_reverse"
$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='File'; 'log_level' = 'trace'; 'log_file'='C:\Users\Public\cma_rev.log'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev.crt'; 'private_key'='C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected

$args = '/S',"--log_type", "file", "--log_file", "C:\Users\Public\cma_rev2.log", "--log_level", "debug", "--log_max_file_size", "50", "--log_max_files", "20"
$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='File'; 'log_level' = 'debug'; 'log_file'='C:\Users\Public\cma_rev2.log'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev.crt'; 'log_max_file_size' = 50; 'log_max_files' = 20;'private_key'='C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected

$args = '/S',"--log_type", "EventLog", "--log_level", "error"
$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='event-log'; 'log_level' = 'error'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev.crt'; 'private_key'='C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected

$args = '/S',"--private_key", "C:\Users crypto\private_rev2.key", "--public_cert", "D:\tutu\titi_rev2.crt"
$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='event-log'; 'log_level' = 'error'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev2.crt'; 'private_key'='C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected

$args = '/S',"--ca", "C:\Users\Public\ca_rev2.crt", "--ca_name", "tls_ca_name_rev2"
$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='event-log'; 'log_level' = 'error'; 'encryption' = 1;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev2.crt'; 'private_key'='C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected

$args = '/S',"--no_encryption"
$expected = @{ 'endpoint'='127.0.0.10:4317';'host'='my_host_name_10';'log_type'='event-log'; 'log_level' = 'error'; 'encryption' = 0;'reversed_grpc_streaming'= 0; 'certificate'='D:\tutu\titi_rev2.crt'; 'private_key'='C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $args $expected



Write-Host "############################ end test ############################"

exit 0
16 changes: 7 additions & 9 deletions .github/workflows/centreon-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ jobs:
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 }}
docker_registry_id: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
docker_registry_passwd: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

unit-test:
needs: [get-environment]
Expand All @@ -146,8 +146,8 @@ jobs:
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-collect-${{ matrix.distrib }}:${{ needs.get-environment.outputs.img_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

name: unit test ${{ matrix.distrib }}

Expand Down Expand Up @@ -351,8 +351,8 @@ jobs:
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 }}
registry_username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
registry_password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
collect_s3_access_key: ${{ secrets.COLLECT_S3_ACCESS_KEY }}
collect_s3_secret_key: ${{ secrets.COLLECT_S3_SECRET_KEY }}
xray_client_id: ${{ secrets.XRAY_CLIENT_ID }}
Expand Down Expand Up @@ -431,8 +431,6 @@ jobs:
include:
- distrib: bookworm
arch: amd64
- distrib: jammy
arch: amd64

name: deliver ${{ matrix.distrib }}

Expand Down Expand Up @@ -462,7 +460,7 @@ jobs:
runs-on: [self-hosted, common]
strategy:
matrix:
distrib: [el8, el9, bookworm, jammy]
distrib: [el8, el9, bookworm]

steps:
- name: Checkout sources
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ jobs:
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

- uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-gorgone-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jobs:
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.HARBOR_GITHUB_ACTIONS_DOCKER_BUILD_USERNAME }}
password: ${{ secrets.HARBOR_GITHUB_ACTIONS_DOCKER_BUILD_TOKEN }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}

- uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1

Expand Down
Loading

0 comments on commit 12697ab

Please sign in to comment.