Skip to content

Commit

Permalink
pass test variables in a json
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-christophe81 committed Nov 15, 2024
1 parent 8a6be5c commit 7dbbd77
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
23 changes: 22 additions & 1 deletion .github/scripts/agent_robot_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,28 @@ Set-ItemProperty -Path HKLM:\SOFTWARE\Centreon\CentreonMonitoringAgent -Name lo

Start-Process -FilePath build_windows\agent\Release\centagent.exe -ArgumentList "--standalone" -RedirectStandardOutput reports\encrypted_reversed_centagent_stdout.log -RedirectStandardError reports\encrypted_reversed_centagent_stderr.log

wsl cd $wsl_path `&`& .github/scripts/wsl-collect-test-robot.sh broker-engine/cma.robot $my_host_name $my_ip $pwsh_path ${current_dir}.replace('\','/')
$uptime = (Get-WmiObject -Class Win32_OperatingSystem).LastBootUpTime #dtmf format
$d_uptime = [Management.ManagementDateTimeConverter]::ToDateTime($uptime) #datetime format
$ts_uptime = ([DateTimeOffset]$d_uptime).ToUnixTimeSeconds() #timestamp format

$test_param = @{
'host'= $my_host_name
'ip'= $my_ip
'wsl_path'= $wsl_path
'pwsh_path'= $pwsh_path
'drive' = @()
'current_dir' = $current_dir.replace('\','/')
'uptime' = $ts_uptime
}

Get-PSDrive -PSProvider FileSystem | Select Name, Used, Free | ForEach-Object -Process {$test_param.drive += $_}

$json_test_param = $test_param | ConvertTo-Json -Compress

Write-Host "json_test_param" $json_test_param
$quoted_json_test_param = "'" + $json_test_param + "'"

wsl cd $wsl_path `&`& .github/scripts/wsl-collect-test-robot.sh broker-engine/cma.robot $quoted_json_test_param

#something wrong in robot test => exit 1 => failure
if (Test-Path -Path 'reports\windows-cma-failed' -PathType Container) {
Expand Down
12 changes: 7 additions & 5 deletions .github/scripts/wsl-collect-test-robot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ set -x
test_file=$1

export RUN_ENV=WSL
export HOST_NAME=$2
export USED_ADDRESS=$3
export PWSH_PATH=$4
export WINDOWS_PROJECT_PATH=$5
export JSON_TEST_PARAMS=$2
export USED_ADDRESS=`echo $JSON_TEST_PARAMS | jq -r .ip`
export HOST_NAME=`echo $JSON_TEST_PARAMS | jq -r .host`
export PWSH_PATH=`echo $JSON_TEST_PARAMS | jq -r .pwsh_path`
export WINDOWS_PROJECT_PATH=`echo $JSON_TEST_PARAMS | jq -r .current_dir`



#in order to connect to windows we neeed to use windows ip
Expand All @@ -17,7 +19,7 @@ echo "${USED_ADDRESS} ${HOST_NAME}" >> /etc/hosts
echo "##### /etc/hosts: ######"
cat /etc/hosts

echo "##### Starting tests #####"
echo "##### Starting tests ##### with params: $JSON_TEST_PARAMS"
cd tests
./init-proto.sh

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows-agent-robot-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
python3
python3-pip
rrdtool
jq

- name: IP info
run: |
Expand Down

0 comments on commit 7dbbd77

Please sign in to comment.