From 5fd1df4c39f2d2b170c5e56b48a52192270f3299 Mon Sep 17 00:00:00 2001 From: Evan-Adam <152897682+Evan-Adam@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:00:14 +0200 Subject: [PATCH] tests(plugins): Run all tests on arm64 architecture (#5049) Co-authored-by: Sophie Depassio --- .github/workflows/plugins.yml | 10 ++++- src/centreon/plugins/dbi.pm | 60 +++++++++++++------------- tests/resources/spellcheck/stopwords.t | 4 +- 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index fdcc7605b..e084fbc24 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -248,8 +248,9 @@ jobs: strategy: fail-fast: false matrix: - distrib: [el8, el9, jammy, bullseye, bookworm] + image: [testing-plugins-alma8, testing-plugins-alma9, testing-plugins-jammy, testing-plugins-bullseye, testing-plugins-bookworm] include: + - runner_name: ubuntu-22.04 - package_extension: rpm image: testing-plugins-alma8 distrib: el8 @@ -265,8 +266,13 @@ jobs: - package_extension: deb image: testing-plugins-jammy distrib: jammy + - package_extension: deb + image: testing-plugins-bullseye-arm64 + distrib: bullseye + arch: arm64 + runner_name: ["self-hosted", "collect-arm64"] - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.runner_name }} container: image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }} credentials: diff --git a/src/centreon/plugins/dbi.pm b/src/centreon/plugins/dbi.pm index 3c1ec57f5..479157ab3 100644 --- a/src/centreon/plugins/dbi.pm +++ b/src/centreon/plugins/dbi.pm @@ -26,11 +26,11 @@ use DBI; use Digest::MD5 qw(md5_hex); use POSIX qw(:signal_h); -my %handlers = ( ALRM => {} ); +my %handlers = (ALRM => {}); sub new { my ($class, %options) = @_; - my $self = {}; + my $self = {}; bless $self, $class; # $options{options} = options object # $options{output} = output object @@ -60,16 +60,16 @@ sub new { } $options{options}->add_help(package => __PACKAGE__, sections => 'DBI OPTIONS', once => 1); - $self->{output} = $options{output}; - $self->{sqlmode_name} = $options{sqlmode_name}; - $self->{instance} = undef; + $self->{output} = $options{output}; + $self->{sqlmode_name} = $options{sqlmode_name}; + $self->{instance} = undef; $self->{statement_handle} = undef; - $self->{version} = undef; + $self->{version} = undef; - $self->{data_source} = undef; - $self->{username} = undef; - $self->{password} = undef; - $self->{connect_options} = undef; + $self->{data_source} = undef; + $self->{username} = undef; + $self->{password} = undef; + $self->{connect_options} = undef; $self->{connect_options_hash} = {}; # Sometimes, we need to set ENV @@ -87,7 +87,7 @@ sub prepare_destroy { sub set_signal_handlers { my $self = shift; - $SIG{ALRM} = \&class_handle_ALRM; + $SIG{ALRM} = \&class_handle_ALRM; $handlers{ALRM}->{$self} = sub { $self->handle_ALRM() }; } @@ -103,7 +103,7 @@ sub handle_ALRM { $self->prepare_destroy(); $self->disconnect(); $self->{output}->output_add( - severity => $self->{sql_errors_exit}, + severity => $self->{sql_errors_exit}, short_msg => 'Timeout' ); $self->{output}->display(); @@ -136,7 +136,7 @@ sub check_options { my ($self, %options) = @_; $self->{data_source} = (defined($self->{option_results}->{data_source})) ? shift(@{$self->{option_results}->{data_source}}) : undef; - $self->{username} = undef; + $self->{username} = undef; if (defined($self->{option_results}->{username})) { $self->{username} = ref($self->{option_results}->{username}) eq 'ARRAY' ? shift(@{$self->{option_results}->{username}}) : $self->{option_results}->{username}; } @@ -144,10 +144,10 @@ sub check_options { if (defined($self->{option_results}->{password})) { $self->{password} = ref($self->{option_results}->{password}) eq 'ARRAY' ? shift(@{$self->{option_results}->{password}}) : $self->{option_results}->{password}; } - + $self->{connect_options} = (defined($self->{option_results}->{connect_options})) ? shift(@{$self->{option_results}->{connect_options}}) : undef; - $self->{connect_query} = (defined($self->{option_results}->{connect_query})) ? shift(@{$self->{option_results}->{connect_query}}) : undef; - $self->{env} = (defined($self->{option_results}->{env})) ? shift(@{$self->{option_results}->{env}}) : undef; + $self->{connect_query} = (defined($self->{option_results}->{connect_query})) ? shift(@{$self->{option_results}->{connect_query}}) : undef; + $self->{env} = (defined($self->{option_results}->{env})) ? shift(@{$self->{option_results}->{env}}) : undef; $self->{sql_errors_exit} = $self->{option_results}->{sql_errors_exit}; $self->{timeout} = 10; @@ -192,10 +192,10 @@ sub quote { sub is_version_minimum { my ($self, %options) = @_; # $options{version} = string version to check - + my @version_src = split /\./, $self->{version}; - my @versions = split /\./, $options{version}; - for (my $i = 0; $i < scalar(@versions); $i++) { + my @versions = split /\./, $options{version}; + for (my $i = 0; $i < scalar(@versions); $i++) { return 1 if ($versions[$i] eq 'x'); return 1 if (!defined($version_src[$i])); $version_src[$i] =~ /^([0-9]*)/; @@ -222,10 +222,10 @@ sub disconnect { $self->{instance} = undef; } } - + sub connect { my ($self, %options) = @_; - my $dontquit = (defined($options{dontquit}) && $options{dontquit} == 1) ? 1 : 0; + my $dontquit = (defined($options{dontquit}) && $options{dontquit} == 1) ? 1 : 0; return if (defined($self->{instance})); @@ -241,7 +241,7 @@ sub connect { eval { alarm($self->{timeout}) if (defined($self->{timeout})); $self->{instance} = DBI->connect( - "DBI:". $self->{data_source}, + "DBI:" . $self->{data_source}, $self->{username}, $self->{password}, { RaiseError => 0, PrintError => 0, AutoCommit => 1, %{$self->{connect_options_hash}} } @@ -257,8 +257,8 @@ sub connect { if (!defined($self->{instance})) { my $err_msg = sprintf( 'Cannot connect: %s', - defined($DBI::errstr) ? $DBI::errstr : - (defined($connect_error) ? $connect_error : '(no error string)') + defined($DBI::errstr) ? $DBI::errstr : + (defined($connect_error) ? $connect_error : '(no error string)') ); if ($dontquit == 0) { $self->{output}->add_option_msg(short_msg => $err_msg); @@ -306,7 +306,7 @@ sub fetchrow_hashref { sub query { my ($self, %options) = @_; - my $continue_error = defined($options{continue_error}) && $options{continue_error} == 1 ? 1 : 0; + my $continue_error = defined($options{continue_error}) && $options{continue_error} == 1 ? 1 : 0; $self->{statement_handle} = $self->{instance}->prepare($options{query}); if (!defined($self->{statement_handle})) { @@ -318,7 +318,7 @@ sub query { my $rv; if (defined($self->{exec_timeout})) { - my $mask = POSIX::SigSet->new(SIGALRM); + my $mask = POSIX::SigSet->new(SIGALRM); my $action = POSIX::SigAction->new( sub { $self->handle_ALRM() }, $mask, @@ -335,7 +335,7 @@ sub query { sigaction(SIGALRM, $oldaction); } else { $rv = $self->{statement_handle}->execute(); - } + } if (!$rv) { return 1 if ($continue_error == 1); @@ -343,7 +343,7 @@ sub query { $self->disconnect(); $self->{output}->option_exit(exit_litteral => $self->{sql_errors_exit}); } - + return 0; } @@ -357,7 +357,7 @@ DBI global =head1 SYNOPSIS -dbi class +DBI class =head1 DBI OPTIONS @@ -402,6 +402,6 @@ Timeout in seconds for query execution =head1 DESCRIPTION -B. +B. =cut diff --git a/tests/resources/spellcheck/stopwords.t b/tests/resources/spellcheck/stopwords.t index 8c3a5e0bc..babdcea47 100644 --- a/tests/resources/spellcheck/stopwords.t +++ b/tests/resources/spellcheck/stopwords.t @@ -38,6 +38,7 @@ --oid-display --oid-extra-display --oid-filter +--sql-errors-exit --urlpath --use-ucd --warning-bytesallocatedpercentage @@ -100,6 +101,7 @@ api.meraki.com cardtemperature connections-dhcp connections-dns +datasource deltaps df eth @@ -145,4 +147,4 @@ v2 VDSL2 Veeam WSMAN -Kubernetes +Kubernetes \ No newline at end of file