From e272ceee9bb0065f8517cd67cf9ebc3931bef33f Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Mon, 20 Nov 2023 15:06:33 +0100 Subject: [PATCH 01/22] Unescaped literal '{' characters in regular expression patterns are no longer permissible --- src/centreon/common/protocols/sql/mode/sqlstring.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/centreon/common/protocols/sql/mode/sqlstring.pm b/src/centreon/common/protocols/sql/mode/sqlstring.pm index f07b64392b..364257c13e 100644 --- a/src/centreon/common/protocols/sql/mode/sqlstring.pm +++ b/src/centreon/common/protocols/sql/mode/sqlstring.pm @@ -96,9 +96,9 @@ 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)\)/); } From 8eb3e0f2d7a972594f228f44b19a4ffde3c408b8 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 14:36:42 +0100 Subject: [PATCH 02/22] Update help --- src/centreon/common/protocols/sql/mode/sqlstring.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/centreon/common/protocols/sql/mode/sqlstring.pm b/src/centreon/common/protocols/sql/mode/sqlstring.pm index 364257c13e..f95aa7a6be 100644 --- a/src/centreon/common/protocols/sql/mode/sqlstring.pm +++ b/src/centreon/common/protocols/sql/mode/sqlstring.pm @@ -102,6 +102,7 @@ sub check_options { $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> From 7d92ff258bb21c1db60b38122b26ba281e3f60f5 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 15:21:59 +0100 Subject: [PATCH 03/22] Add robot functionnal test --- .../functional/database/database-mysql.robot | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/functional/database/database-mysql.robot diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot new file mode 100644 index 0000000000..d4df98aa1b --- /dev/null +++ b/tests/functional/database/database-mysql.robot @@ -0,0 +1,33 @@ +*** Settings *** +Documentation Database Mysql plugin + +Library Database + +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} + 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} + END From 8712f1494013eddfe527914532ae91280fec5e80 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 15:28:40 +0100 Subject: [PATCH 04/22] update github action workflow --- .github/workflows/tests-functional.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests-functional.yml b/.github/workflows/tests-functional.yml index 2ca2e7589e..9fd786d676 100644 --- a/.github/workflows/tests-functional.yml +++ b/.github/workflows/tests-functional.yml @@ -71,3 +71,6 @@ jobs: sudo cp 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 \ No newline at end of file From 3165dd4ecf0af83b673371ac4f6f9571408e191d Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 15:34:54 +0100 Subject: [PATCH 05/22] Update robot functionnal test --- tests/functional/database/database-mysql.robot | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index d4df98aa1b..70bfbe5edd 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -1,8 +1,6 @@ *** Settings *** Documentation Database Mysql plugin -Library Database - Test Timeout 120s From d23d55ae14938a98cfa66c043baaa0047696a903 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 16:05:36 +0100 Subject: [PATCH 06/22] Update robot functionnal test --- tests/functional/database/database-mysql.robot | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index 70bfbe5edd..da46a30240 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -1,6 +1,8 @@ *** Settings *** Documentation Database Mysql plugin +Library OperatingSystem + Test Timeout 120s From 05b845bd3961cb9d71973c7a101dab0444bcc8e8 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 16:12:15 +0100 Subject: [PATCH 07/22] Update robot functionnal test --- tests/functional/database/database-mysql.robot | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index da46a30240..0268116fe9 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -2,6 +2,7 @@ Documentation Database Mysql plugin Library OperatingSystem +Library Process Test Timeout 120s From 5d47cd804c452d52b8ebe2506e7e1a44cde4ff3e Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 16:19:57 +0100 Subject: [PATCH 08/22] Update robot functionnal test --- tests/functional/database/database-mysql.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index 0268116fe9..87b4340316 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -2,7 +2,7 @@ Documentation Database Mysql plugin Library OperatingSystem -Library Process +Library DBI Test Timeout 120s From 3668b4048db47b78cded3f3b78fdc93061e18bce Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 16:24:27 +0100 Subject: [PATCH 09/22] Update github action workflow --- .github/workflows/tests-functional.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests-functional.yml b/.github/workflows/tests-functional.yml index 9fd786d676..d565e9df54 100644 --- a/.github/workflows/tests-functional.yml +++ b/.github/workflows/tests-functional.yml @@ -48,6 +48,10 @@ jobs: Net::SNMP URI::Encode XML::LibXML + DBI + DBD + POSIX + Time::HiRes - name: Install Python uses: actions/setup-python@v4 From c9982035981f0f79e558102f1efc00bdbb3de1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Chapron?= <34628915+sc979@users.noreply.github.com> Date: Tue, 21 Nov 2023 16:25:16 +0100 Subject: [PATCH 10/22] Update .github/workflows/tests-functional.yml --- .github/workflows/tests-functional.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-functional.yml b/.github/workflows/tests-functional.yml index 9fd786d676..0b9ad6e387 100644 --- a/.github/workflows/tests-functional.yml +++ b/.github/workflows/tests-functional.yml @@ -73,4 +73,4 @@ jobs: robot tests/functional/snmp - name: Run Robot Framework Database tests - run: robot tests/functional/database \ No newline at end of file + run: robot tests/functional/database From 7cf24d27fb459fa2716fbdbcccb50de3fa8f50c2 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 16:25:19 +0100 Subject: [PATCH 11/22] Update robot functionnal test --- tests/functional/database/database-mysql.robot | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index 87b4340316..c226085c39 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -3,6 +3,9 @@ Documentation Database Mysql plugin Library OperatingSystem Library DBI +Library DBD::mysql +Library Time::HiRes +Library POSIX Test Timeout 120s From 79e42b1c837d1824ab4a009a40731466ac957603 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 16:32:16 +0100 Subject: [PATCH 12/22] Update robot functionnal test --- tests/functional/database/database-mysql.robot | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index c226085c39..04ef4f09ce 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -6,6 +6,7 @@ Library DBI Library DBD::mysql Library Time::HiRes Library POSIX +Library JSON::XS Test Timeout 120s From f7a9831988543c9cf4c2092b413078e3adf2eb0f Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 17:04:19 +0100 Subject: [PATCH 13/22] update github action workflow --- .github/workflows/tests-functional.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests-functional.yml b/.github/workflows/tests-functional.yml index d565e9df54..257d30350b 100644 --- a/.github/workflows/tests-functional.yml +++ b/.github/workflows/tests-functional.yml @@ -52,6 +52,7 @@ jobs: DBD POSIX Time::HiRes + JSON::XS - name: Install Python uses: actions/setup-python@v4 From adfec85dc6334f629d2b3b6fe1050fde4760061a Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 17:14:31 +0100 Subject: [PATCH 14/22] wip --- .github/workflows/tests-functional.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-functional.yml b/.github/workflows/tests-functional.yml index 98a90f84e9..b0d5c1fb8e 100644 --- a/.github/workflows/tests-functional.yml +++ b/.github/workflows/tests-functional.yml @@ -49,7 +49,7 @@ jobs: URI::Encode XML::LibXML DBI - DBD + DBD::mysql POSIX Time::HiRes JSON::XS From 8eb59d775d52d2664854c045a57f15319db63c94 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Tue, 21 Nov 2023 17:20:42 +0100 Subject: [PATCH 15/22] wip --- tests/functional/database/database-mysql.robot | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index 04ef4f09ce..0268116fe9 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -2,11 +2,7 @@ Documentation Database Mysql plugin Library OperatingSystem -Library DBI -Library DBD::mysql -Library Time::HiRes -Library POSIX -Library JSON::XS +Library Process Test Timeout 120s From 32fec1cdf7d1d85b0a74872e0e29e2d5c54a97c7 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Wed, 22 Nov 2023 09:44:27 +0100 Subject: [PATCH 16/22] wip --- tests/functional/database/database-mysql.robot | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index 0268116fe9..c64a27d9f4 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -3,6 +3,7 @@ Documentation Database Mysql plugin Library OperatingSystem Library Process +Library String Test Timeout 120s From ae46ae618910bf4fb058d6c3e662fb477f23632e Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Wed, 22 Nov 2023 10:23:56 +0100 Subject: [PATCH 17/22] wip --- tests/functional/database/database-mysql.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index c64a27d9f4..feb3a951fd 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -31,5 +31,5 @@ Database Mysql sql string mode 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} + ... Wrong output result for compliance of ${sql_string_test.result.strip()}.{\n}Command output:{\n}${output.strip()} END From c3fa4c027c2c8b5ab8e75955d64695ceb6634cf7 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Wed, 22 Nov 2023 11:04:13 +0100 Subject: [PATCH 18/22] wip --- tests/functional/database/database-mysql.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index feb3a951fd..cb1c47268a 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -31,5 +31,5 @@ Database Mysql sql string mode Should Be Equal As Strings ... ${output} ... ${sql_string_test.result} - ... Wrong output result for compliance of ${sql_string_test.result.strip()}.{\n}Command output:{\n}${output.strip()} + ... Wrong output result for compliance of ${sql_string_test.result}{\n}Command output:{\n}${output}{\n}{\n}{\n} END From 2b9a1356b73a7a1619137d6ed074cadba8bd7817 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Wed, 22 Nov 2023 11:25:03 +0100 Subject: [PATCH 19/22] wip --- tests/functional/database/database-mysql.robot | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/database/database-mysql.robot b/tests/functional/database/database-mysql.robot index cb1c47268a..7f0a51dd68 100644 --- a/tests/functional/database/database-mysql.robot +++ b/tests/functional/database/database-mysql.robot @@ -28,6 +28,7 @@ Database Mysql sql string mode ... ${CMD} ... --mode=sql-string ${output} Run ${command} + ${output} Strip String ${output} Should Be Equal As Strings ... ${output} ... ${sql_string_test.result} From 0086b121889cfc69f1c7f19c32fc572a71edb526 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Wed, 22 Nov 2023 11:34:09 +0100 Subject: [PATCH 20/22] Test stdr / stdout in Robot output --- src/centreon/common/protocols/sql/mode/sqlstring.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/centreon/common/protocols/sql/mode/sqlstring.pm b/src/centreon/common/protocols/sql/mode/sqlstring.pm index f95aa7a6be..fc1696c574 100644 --- a/src/centreon/common/protocols/sql/mode/sqlstring.pm +++ b/src/centreon/common/protocols/sql/mode/sqlstring.pm @@ -96,9 +96,11 @@ 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)}/); + #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)}/); + #if ($self->{option_results}->{printf_value} =~ /\%\{(value_field|key_field)}/); $self->{printf_value} = $1 if ($self->{option_results}->{printf_value} =~ /\%\((value_field|key_field)\)/); } From c861773d1855ad1850e92300569466cfa286eab0 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Wed, 22 Nov 2023 11:38:55 +0100 Subject: [PATCH 21/22] Take the fix back --- src/centreon/common/protocols/sql/mode/sqlstring.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/centreon/common/protocols/sql/mode/sqlstring.pm b/src/centreon/common/protocols/sql/mode/sqlstring.pm index fc1696c574..f95aa7a6be 100644 --- a/src/centreon/common/protocols/sql/mode/sqlstring.pm +++ b/src/centreon/common/protocols/sql/mode/sqlstring.pm @@ -96,11 +96,9 @@ 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)}/); + 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)}/); + if ($self->{option_results}->{printf_value} =~ /\%\{(value_field|key_field)}/); $self->{printf_value} = $1 if ($self->{option_results}->{printf_value} =~ /\%\((value_field|key_field)\)/); } From f4779fe946fe3009451d31b01ac15bba37065031 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 4 Jan 2024 12:02:50 +0100 Subject: [PATCH 22/22] fix actions checkout version for el7 --- .github/workflows/plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 274f6280fe..74d80778fc 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -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' }}