[MON-22331] [Plugins] Mode sql-string not working anymore (#4746)

This commit is contained in:
Lucie Dubrunfaut 2024-01-04 14:35:30 +01:00 committed by GitHub
parent 1fa45a6c69
commit c5e5701321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 5 deletions

View File

@ -141,7 +141,7 @@ jobs:
steps:
- name: Checkout sources
if: ${{ matrix.distrib == 'el7' }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@v3 # el7 is not compatible with checkout v4 which uses node20
- name: Checkout sources
if: ${{ matrix.distrib != 'el7' }}

View File

@ -48,6 +48,11 @@ jobs:
Net::SNMP
URI::Encode
XML::LibXML
DBI
DBD::mysql
POSIX
Time::HiRes
JSON::XS
- name: Install Python
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
@ -71,3 +76,6 @@ jobs:
sudo cp -r tests/resources/snmp/* /usr/snmpsim/data/
snmpsimd --agent-udpv4-endpoint=127.0.0.1:2024 --process-user=snmp --process-group=snmp &
robot tests/functional/snmp
- name: Run Robot Framework Database tests
run: robot tests/functional/database

View File

@ -96,12 +96,13 @@ sub check_options {
$self->{printf_value} = 'value_field';
if (defined($self->{option_results}->{printf_value}) && $self->{option_results}->{printf_value} ne '') {
$self->{printf_value} = $1
if ($self->{option_results}->{printf_value} =~ /\$self->{result_values}->{(value_field|key_field)}/);
if ($self->{option_results}->{printf_value} =~ /\$self->\{result_values}->\{(value_field|key_field)}/);
$self->{printf_value} = $1
if ($self->{option_results}->{printf_value} =~ /\%{(value_field|key_field)}/);
if ($self->{option_results}->{printf_value} =~ /\%\{(value_field|key_field)}/);
$self->{printf_value} = $1
if ($self->{option_results}->{printf_value} =~ /\%\((value_field|key_field)\)/);
}
}
sub manage_selection {
@ -170,8 +171,8 @@ Specify a custom output message relying on printf formatting. If this option is
=item B<--printf-value>
Specify scalar used to replace in printf. If this option is set --printf-format is mandatory.
(can be: %{key_field}, %{value_field})
Specify variable used to replace in printf. If this option is set --printf-format is mandatory.
Can be: %{key_field} (default value) or %{value_field}
=item B<--warning-string>

View File

@ -0,0 +1,36 @@
*** Settings ***
Documentation Database Mysql plugin
Library OperatingSystem
Library Process
Library String
Test Timeout 120s
*** Variables ***
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl
${CMD} perl ${CENTREON_PLUGINS} --plugin=database::mysql::plugin
&{sql_string_test1}
... result=UNKNOWN: Need to specify data_source arguments.
@{sql_string_tests}
... &{sql_string_test1}
*** Test Cases ***
Database Mysql sql string mode
[Documentation] Mode sql string (common protocol database)
[Tags] database mysql sql-string
FOR ${sql_string_test} IN @{sql_string_tests}
${command} Catenate
... ${CMD}
... --mode=sql-string
${output} Run ${command}
${output} Strip String ${output}
Should Be Equal As Strings
... ${output}
... ${sql_string_test.result}
... Wrong output result for compliance of ${sql_string_test.result}{\n}Command output:{\n}${output}{\n}{\n}{\n}
END