new(tests): initiated unit tests (#5138)

Co-authored-by: May <110405507+mushroomempires@users.noreply.github.com>
Co-authored-by: Paul Oureib <poureib@centreon.com>

REFS: CTOR-805
This commit is contained in:
omercier 2024-08-16 09:34:33 +02:00 committed by GitHub
parent 792cefd77b
commit fe90a52295
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
91 changed files with 503 additions and 126 deletions

10
.github/actions/unit-tests/action.yml vendored Normal file
View File

@ -0,0 +1,10 @@
name: "unit-tests"
description: "Unit tests that control the code itself"
runs:
using: "composite"
steps:
- name: Recursively run all unit tests
shell: bash
run: yath -L test ./tests

View File

@ -0,0 +1,55 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/almalinux:8
RUN bash -e <<EOF
dnf install -y 'dnf-command(config-manager)' epel-release zstd jq
dnf config-manager --set-enabled powertools
# Add Centreon plugins repositories
echo -e '[centreon-plugins-stable]\n\
name=centreon plugins stable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/stable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-stable-noarch]\n\
name=centreon plugins stable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/stable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing]\n\
name=centreon plugins testing x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/testing/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing-noarch]\n\
name=centreon plugins testing noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/testing/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable]\n\
name=centreon plugins unstable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/unstable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable-noarch]\n\
name=centreon plugins unstable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/unstable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n'\
>> /etc/yum.repos.d/centreon-plugins.repo
dnf install -y gcc make cpan perl-Test2-Suite.noarch perl-Test2-Plugin-NoWarnings.noarch 'perl(Authen::Radius)' 'perl(Convert::Binary::C)' 'perl(Crypt::OpenSSL::RSA)' 'perl(Data::Dumper)' 'perl(Date::Parse)' 'perl(DateTime)' 'perl(DateTime::Duration)' 'perl(DateTime-Format-Duration-ISO8601)' 'perl(DateTime::Format::Strptime)' 'perl(DBD::mysql)' 'perl(DBD::ODBC)' 'perl(DBD::Pg)' 'perl(DBD::Sybase)' 'perl(DBI)' 'perl(Device::Modbus::RTU::Client)' 'perl(Device::Modbus::TCP::Client)' 'perl(Digest::CRC)' 'perl(Digest::MD5)' 'perl(Digest::SHA)' 'perl(Email::MIME)' 'perl(Email::Sender)' 'perl(Email::Send::SMTP::Gmail)' 'perl(Email::Simple)' 'perl(File::Basename)' 'perl(Filesys::SmbClient)' 'perl(Hash::Ordered)' 'perl(HTML::Template)' 'perl(IO::Select)' 'perl(IO::Socket)' 'perl(IO::Socket::INET)' 'perl(IO::Socket::INET6)' 'perl(IO::Socket::SSL)' 'perl(JMX::Jmx4Perl)' 'perl(JSON)' 'perl(JSON::Path)' 'perl(JSON::WebToken)' 'perl(JSON::XS)' 'perl(Libssh::Session)' 'perl-Mail-IMAPClient' 'perl(MIME::Base64)' 'perl(MongoDB)' 'perl(NetAddr::IP)' 'perl(Net::DHCP::Constants)' 'perl(Net::DHCP::Packet)' 'perl(Net::DNS)' 'perl(Net::FTP)' 'perl(Net::FTPSSL)' 'perl(Net::LDAP)' 'perl(Net::MQTT::Simple)' 'perl(Net::NTP)' 'perl(Net::SSLeay)' 'perl(Net::Subnet)' 'perl(Net::Telnet)' 'perl(Net::TFTP)' 'perl(openwsman)' 'perl(Pod::Parser)' 'perl(POSIX)' 'perl(Redis)' 'perl(RRDs)' 'perl(SNMP)' 'perl(Socket)' 'perl(Text::CSV)' 'perl(Time::HiRes)' 'perl(URI::Encode)' 'perl(URI::Escape)' 'perl(UUID)' 'perl(WWW::Selenium)' 'perl(XML::LibXML)' 'perl(XML::LibXML::Simple)' 'perl(XML::Simple)' 'perl(XML::XPath)' 'perl(ZMQ::LibZMQ4)' 'perl(Data::UUID)'
dnf clean all
mkdir -p /var/lib/centreon/centplugins/
chmod 777 /var/lib/centreon/centplugins/
NONINTERACTIVE_TESTING=1 PERL_MM_USE_DEFAULT=1 cpan Test2::Harness UUID
rm -fr /root/.cpan*
EOF

View File

@ -0,0 +1,54 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/almalinux:9
RUN bash -e <<EOF
dnf install -y 'dnf-command(config-manager)' epel-release zstd jq
dnf config-manager --set-enabled crb
# Add Centreon plugins repositories
echo -e '[centreon-plugins-stable]\n\
name=centreon plugins stable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/stable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-stable-noarch]\n\
name=centreon plugins stable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/stable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing]\n\
name=centreon plugins testing x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/testing/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing-noarch]\n\
name=centreon plugins testing noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/testing/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable]\n\
name=centreon plugins unstable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/unstable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable-noarch]\n\
name=centreon plugins unstable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/unstable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n'\
>> /etc/yum.repos.d/centreon-plugins.repo
dnf install -y make cpan perl-Test2-Suite.noarch 'perl(Authen::Radius)' 'perl(Convert::Binary::C)' 'perl(Crypt::OpenSSL::RSA)' 'perl(Data::Dumper)' 'perl(Date::Parse)' 'perl(DateTime)' 'perl(DateTime::Duration)' 'perl(DateTime-Format-Duration-ISO8601)' 'perl(DateTime::Format::Strptime)' 'perl(DBD::mysql)' 'perl(DBD::ODBC)' 'perl(DBD::Pg)' 'perl(DBD::Sybase)' 'perl(DBI)' 'perl(Device::Modbus::RTU::Client)' 'perl(Device::Modbus::TCP::Client)' 'perl(Digest::CRC)' 'perl(Digest::MD5)' 'perl(Digest::SHA)' 'perl(Email::MIME)' 'perl(Email::Sender)' 'perl(Email::Send::SMTP::Gmail)' 'perl(Email::Simple)' 'perl(File::Basename)' 'perl(Filesys::SmbClient)' 'perl(Hash::Ordered)' 'perl(HTML::Template)' 'perl(IO::Select)' 'perl(IO::Socket)' 'perl(IO::Socket::INET)' 'perl(IO::Socket::INET6)' 'perl(IO::Socket::SSL)' 'perl(JMX::Jmx4Perl)' 'perl(JSON)' 'perl(JSON::Path)' 'perl(JSON::WebToken)' 'perl(JSON::XS)' 'perl(Libssh::Session)' 'perl-Mail-IMAPClient' 'perl(MIME::Base64)' 'perl(MongoDB)' 'perl(NetAddr::IP)' 'perl(Net::DHCP::Constants)' 'perl(Net::DHCP::Packet)' 'perl(Net::DNS)' 'perl(Net::FTP)' 'perl(Net::FTPSSL)' 'perl(Net::LDAP)' 'perl(Net::MQTT::Simple)' 'perl(Net::NTP)' 'perl(Net::SSLeay)' 'perl(Net::Subnet)' 'perl(Net::Telnet)' 'perl(Net::TFTP)' 'perl(openwsman)' 'perl(Pod::Parser)' 'perl(POSIX)' 'perl(Redis)' 'perl(RRDs)' 'perl(SNMP)' 'perl(Socket)' 'perl(Text::CSV)' 'perl(Time::HiRes)' 'perl(URI::Encode)' 'perl(URI::Escape)' 'perl(UUID)' 'perl(WWW::Selenium)' 'perl(XML::LibXML)' 'perl(XML::LibXML::Simple)' 'perl(XML::Simple)' 'perl(XML::XPath)' 'perl(ZMQ::LibZMQ4)' 'perl(Data::UUID)'
dnf clean all
mkdir -p /var/lib/centreon/centplugins/
chmod 777 /var/lib/centreon/centplugins/
NONINTERACTIVE_TESTING=1 PERL_MM_USE_DEFAULT=1 cpan Test2::Harness Test2::Plugin::NoWarnings UUID
rm -fr /root/.cpan*
EOF

View File

@ -0,0 +1,30 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/debian:bookworm
ENV DEBIAN_FRONTEND noninteractive
# fix locale
RUN bash -e <<EOF
apt-get update
apt-get install -y locales libcurl4-openssl-dev curl wget zstd jq gpg
rm -rf /var/lib/apt/lists/*
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
apt-get clean
EOF
ENV LANG en_US.utf8
RUN bash -e <<EOF
# Add Centreon plugins repositories
echo "deb https://packages.centreon.com/apt-plugins-stable/ bookworm main" | tee /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-testing/ bookworm main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-unstable/ bookworm main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
apt-get update
apt-get -y install libtest2-harness-perl libtest2-plugin-nowarnings-perl libauthen-radius-perl libconvert-binary-c-perl libcrypt-openssl-rsa-perl libdata-dump-perl libdatetime-format-dateparse-perl libdatetime-format-strptime-perl libdatetime-perl libdbd-mysql-perl libdbd-odbc-perl libdbd-pg-perl libdbd-sybase-perl libdbi-perl libdigest-crc-perl libdigest-md5-perl libdigest-sha-perl libemail-mime-perl libemail-sender-perl libemail-send-smtp-gmail-perl libfilesys-smbclient-perl libhtml-template-perl libio-socket-inet6-perl libio-socket-ip-perl libjson-maybexs-perl libjson-perl libjson-webtoken-perl libmail-imapclient-perl libmime-base64-perl libmongodb-perl libnet-dhcp-perl libnet-dns-perl libnet-ldap-perl libnet-mqtt-simple-perl libnet-ntp-perl libnet-ssleay-perl libnet-subnet-perl libnet-telnet-perl libnet-tftp-perl libopenwsman-perl libredis-perl librrds-perl libsnmp-perl libsocket-perl libssh-session-perl libtest-www-selenium-perl libtext-csv-perl libtime-hires-perl libtime-parsedate-perl libuuid-perl libxml-libxml-perl libxml-libxml-simple-perl libxml-simple-perl libxml-xpath-perl perl perl-modules
apt-get clean
EOF

View File

@ -0,0 +1,29 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/debian:bullseye
ENV DEBIAN_FRONTEND noninteractive
# fix locale
RUN bash -e <<EOF
apt-get update
apt-get install -y locales libcurl4-openssl-dev curl wget zstd jq gpg
rm -rf /var/lib/apt/lists/*
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
apt-get clean
EOF
ENV LANG en_US.utf8
RUN bash -e <<EOF
# Add Centreon plugins repositories
echo "deb https://packages.centreon.com/apt-plugins-stable/ bullseye main" | tee /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-testing/ bullseye main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-unstable/ bullseye main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
apt-get update
apt-get -y install gcc make libtest2-plugin-nowarnings-perl libauthen-radius-perl libconvert-binary-c-perl libcrypt-openssl-rsa-perl libdata-dump-perl libdatetime-format-dateparse-perl libdatetime-format-strptime-perl libdatetime-perl libdbd-mysql-perl libdbd-odbc-perl libdbd-pg-perl libdbd-sybase-perl libdbi-perl libdigest-crc-perl libdigest-md5-perl libdigest-sha-perl libemail-mime-perl libemail-sender-perl libemail-send-smtp-gmail-perl libfilesys-smbclient-perl libhtml-template-perl libio-socket-inet6-perl libio-socket-ip-perl libjson-maybexs-perl libjson-perl libjson-webtoken-perl libmail-imapclient-perl libmime-base64-perl libmongodb-perl libnet-dhcp-perl libnet-dns-perl libnet-ldap-perl libnet-mqtt-simple-perl libnet-ntp-perl libnet-ssleay-perl libnet-subnet-perl libnet-telnet-perl libnet-tftp-perl libopenwsman-perl libredis-perl librrds-perl libsnmp-perl libsocket-perl libssh-session-perl libtest-www-selenium-perl libtext-csv-perl libtime-hires-perl libtime-parsedate-perl libuuid-perl libxml-libxml-perl libxml-libxml-simple-perl libxml-simple-perl libxml-xpath-perl perl perl-modules libdata-uuid-perl
apt-get clean
NONINTERACTIVE_TESTING=1 PERL_MM_USE_DEFAULT=1 cpan Test2::Harness UUID
EOF

View File

@ -0,0 +1,34 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/ubuntu:jammy
ENV DEBIAN_FRONTEND noninteractive
# fix locale
RUN bash -e <<EOF
apt-get update
apt-get install -y locales libcurl4-openssl-dev curl wget zstd jq gpg
rm -rf /var/lib/apt/lists/*
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
apt-get clean
EOF
ENV LANG en_US.utf8
RUN bash -e <<EOF
# Add Centreon plugins repositories
echo "deb https://packages.centreon.com/ubuntu-plugins-stable/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/ubuntu-plugins-testing/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/ubuntu-plugins-unstable/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
apt-get update
apt-get -y install libtest2-harness-perl libtest2-plugin-nowarnings-perl libauthen-radius-perl libconvert-binary-c-perl libcrypt-openssl-rsa-perl libdata-dump-perl libdatetime-format-dateparse-perl libdatetime-format-strptime-perl libdatetime-perl libdbd-mysql-perl libdbd-odbc-perl libdbd-pg-perl libdbd-sybase-perl libdbi-perl libdigest-crc-perl libdigest-md5-perl libdigest-sha-perl libemail-mime-perl libemail-sender-perl libemail-send-smtp-gmail-perl libfilesys-smbclient-perl libhtml-template-perl libio-socket-inet6-perl libio-socket-ip-perl libjmx4perl-perl libjson-maybexs-perl libjson-perl libjson-webtoken-perl libmail-imapclient-perl libmime-base64-perl libmongodb-perl libnet-dhcp-perl libnet-dns-perl libnet-ldap-perl libnet-mqtt-simple-perl libnet-ntp-perl libnet-ssleay-perl libnet-subnet-perl libnet-telnet-perl libnet-tftp-perl libopenwsman-perl libredis-perl librrds-perl libsnmp-perl libsocket-perl libssh-session-perl libtest-www-selenium-perl libtext-csv-perl libtime-hires-perl libtime-parsedate-perl libuuid-perl libxml-libxml-perl libxml-libxml-simple-perl libxml-simple-perl libxml-xpath-perl libzmq-libzmq4-perl perl perl-modules
apt-get clean
mkdir -p /var/lib/centreon/centplugins/
chmod 777 /var/lib/centreon/centplugins/
EOF

View File

@ -8,7 +8,7 @@ if (!@ARGV) {
die "Usage: perl pod_spell_check.t module.pm stopwords.t"; die "Usage: perl pod_spell_check.t module.pm stopwords.t";
} }
my $stopword_filename='tests/resources/spellcheck/stopwords.t'; my $stopword_filename='tests/resources/spellcheck/stopwords.txt';
if(defined($ARGV[1])){ if(defined($ARGV[1])){
$stopword_filename=$ARGV[1]; $stopword_filename=$ARGV[1];
} }

View File

@ -11,8 +11,8 @@ def get_tests_folders(plugin_name):
pkg_file = open("./packaging/" + plugin_name + "/pkg.json") pkg_file = open("./packaging/" + plugin_name + "/pkg.json")
packaging = json.load(pkg_file) packaging = json.load(pkg_file)
for file in packaging["files"]: # loop on "files" array in pkg.json file. for file in packaging["files"]: # loop on "files" array in pkg.json file.
if file.endswith("/") and os.path.exists("tests/robot/" + file): # if this is a directory and there is test for it. if file.endswith("/") and os.path.exists("tests/" + file): # if this is a directory and there is test for it.
folder_list.append("tests/robot/" + file) folder_list.append("tests/" + file)
return folder_list return folder_list
@ -49,7 +49,7 @@ def launch_snmp_sim():
try_command(cmd="mkdir -p /var/lib/snmp/cert_indexes/", error="can't create /var/lib/snmp/cert_indexes/ dir") try_command(cmd="mkdir -p /var/lib/snmp/cert_indexes/", error="can't create /var/lib/snmp/cert_indexes/ dir")
try_command(cmd="chown snmp:snmp -R /var/lib/snmp/cert_indexes/", error="can't set cert_indexes folder permissions") try_command(cmd="chown snmp:snmp -R /var/lib/snmp/cert_indexes/", error="can't set cert_indexes folder permissions")
snmpsim_cmd = "snmpsim-command-responder --logging-method=null --agent-udpv4-endpoint=127.0.0.1:2024 --process-user=snmp --process-group=snmp --data-dir='./tests/robot' &" snmpsim_cmd = "snmpsim-command-responder --logging-method=null --agent-udpv4-endpoint=127.0.0.1:2024 --process-user=snmp --process-group=snmp --data-dir='./tests' &"
try_command(cmd=snmpsim_cmd, error="can't launch snmp sim daemon.") try_command(cmd=snmpsim_cmd, error="can't launch snmp sim daemon.")
def refresh_packet_manager(archi): def refresh_packet_manager(archi):

View File

@ -0,0 +1,67 @@
name: docker-builder-unit-tests
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- ".github/workflows/docker-builder-unit-tests.yml"
- ".github/docker/unit-tests/*"
pull_request:
paths:
- ".github/workflows/docker-builder-unit-tests.yml"
- ".github/docker/unit-tests/*"
jobs:
create-and-push-docker:
strategy:
matrix:
include:
- runner: ubuntu-22.04
dockerfile: alma8
image: alma8
- runner: ubuntu-22.04
dockerfile: alma9
image: alma9
- runner: ubuntu-22.04
dockerfile: bullseye
image: bullseye
- runner: ubuntu-22.04
dockerfile: bookworm
image: bookworm
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Login to Registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
- name: Login to proxy registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
- uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- uses: docker/build-push-action@15560696de535e4014efeff63c48f16952e52dd1 # v6.2.0
with:
file: .github/docker/unit-tests/Dockerfile.unit-tests-${{ matrix.dockerfile }}
context: .
build-args: "REGISTRY_URL=${{ vars.DOCKER_PROXY_REGISTRY_URL }}"
pull: true
push: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/unit-tests-${{ matrix.image }}:latest

View File

@ -82,9 +82,51 @@ jobs:
shell: bash shell: bash
unit-tests:
needs: [get-environment, get-plugins]
strategy:
fail-fast: false
matrix:
image: [unit-tests-alma8, unit-tests-alma9, unit-tests-bullseye, unit-tests-bookworm]
include:
- runner_name: ubuntu-22.04
- package_extension: rpm
image: unit-tests-alma8
distrib: el8
- package_extension: rpm
image: unit-tests-alma9
distrib: el9
- package_extension: deb
image: unit-tests-bullseye
distrib: bullseye
- package_extension: deb
image: unit-tests-bookworm
distrib: bookworm
runs-on: ${{ matrix.runner_name }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Run unit tests
uses: ./.github/actions/unit-tests
- name: Upload logs as artifacts if tests failed
if: failure()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: plugin-installation-${{ matrix.distrib }}
path: /tmp/*.jsonl
retention-days: 1
fatpacker: fatpacker:
if: ${{ needs.get-plugins.outputs.plugins != '' }} if: ${{ needs.get-plugins.outputs.plugins != '' }}
needs: [get-environment, get-plugins] needs: [get-environment, get-plugins, unit-tests]
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- name: Checkout sources - name: Checkout sources

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Check the hosts mode with api custom mode Documentation Check the hosts mode with api custom mode
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Check the jobs mode with api custom mode Documentation Check the jobs mode with api custom mode
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Eclipse Mosquitto MQTT plugin tests Documentation Eclipse Mosquitto MQTT plugin tests
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Application Microsoft HyperV 2022 Documentation Application Microsoft HyperV 2022
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Collections of HTTP Protocol plugin testing a mock of Centreon-web API Documentation Collections of HTTP Protocol plugin testing a mock of Centreon-web API
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Hardware UPS Sputnik SNMP plugin Documentation Hardware UPS Sputnik SNMP plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s
@ -20,7 +20,7 @@ SNMP Collection - Sputnik Environment ${tc}/3
... --snmp-version=${SNMPVERSION} ... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT} ... --snmp-port=${SNMPPORT}
... --snmp-community=apps/protocols/snmp/collection-sputnik ... --snmp-community=apps/protocols/snmp/collection-sputnik
... --config=${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}src/contrib/collection/snmp/sputnik-environment.json ... --config=${CURDIR}${/}..${/}..${/}..${/}..${/}src/contrib/collection/snmp/sputnik-environment.json
Ctn Run Command And Check Result As Strings ${command} ${expected_result} Ctn Run Command And Check Result As Strings ${command} ${expected_result}

View File

@ -1,5 +1,5 @@
*** Settings *** *** Settings ***
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -0,0 +1,51 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test2::V0;
use Test2::Plugin::NoWarnings echo => 1;
use FindBin;
use lib "$FindBin::RealBin/../../../src";
use centreon::plugins::perfdata;
my $perfdata = centreon::plugins::perfdata->new();
###############################################################################
# Testing trim() #
###############################################################################
is($perfdata->trim(' toto '), 'toto');
is($perfdata->trim(' toto'), 'toto');
is($perfdata->trim('toto '), 'toto');
is($perfdata->trim('toto'), 'toto');
is($perfdata->trim(' toto '), 'toto');
is($perfdata->trim(' toto titi '), 'toto titi');
is($perfdata->trim(' toto titi'), 'toto titi');
is($perfdata->trim('toto titi '), 'toto titi');
is($perfdata->trim('toto titi'), 'toto titi');
is($perfdata->trim(' '), '');
is($perfdata->trim(' '), '');
is($perfdata->trim(''), '');
is($perfdata->trim("\ttoto\t"), "toto");
is($perfdata->trim("\t toto"), "toto");
is($perfdata->trim("toto\t "), "toto");
is($perfdata->trim("toto"), "toto");
is($perfdata->trim(" \ttoto \t"), "toto");
is($perfdata->trim("\t toto titi\t "), "toto titi");
is($perfdata->trim(" \ttoto titi"), "toto titi");
is($perfdata->trim("toto\ttiti\t"), "toto\ttiti");
is($perfdata->trim("toto\ttiti"), "toto\ttiti");
is($perfdata->trim("\t"), "");
is($perfdata->trim("\t\t\t\t\t"), "");
is($perfdata->trim(""), "");
###############################################################################
# Testing change_bytes() #
###############################################################################
#is(join('', $perfdata->change_bytes(value => 1024)), '1.00KiB');
#is(join('', $perfdata->change_bytes(value => 1024, network => 1)), '1.02Kb');
done_testing();

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Azure PolicyInsights PolicyStates plugin Documentation Azure PolicyInsights PolicyStates plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon
@ -13,7 +13,7 @@ ${MOCKOON_JSON} ${CURDIR}${/}cloud-azure-policyinsights-policystates.jso
${BASE_URL} http://${HOSTNAME}:${APIPORT} ${BASE_URL} http://${HOSTNAME}:${APIPORT}
${LOGIN_ENDPOINT} ${BASE_URL}/login ${LOGIN_ENDPOINT} ${BASE_URL}/login
${CMD} ${CENTREON_PLUGINS} --plugin=cloud::azure::policyinsights::policystates::plugin --subscription=subscription --tenant=tenant --client-id=client_id --client-secret=secret --statefile-dir=/tmp/cache/ --login-endpoint=${LOGIN_ENDPOINT} ${CMD} ${CENTREON_PLUGINS} --plugin=cloud::azure::policyinsights::policystates::plugin --subscription=subscription --tenant=tenant --client-id=client_id --client-secret=secret --statefile-dir=/dev/shm/ --login-endpoint=${LOGIN_ENDPOINT}
&{compliance_value1} &{compliance_value1}
... endpoint=${BASE_URL}/ok ... endpoint=${BASE_URL}/ok

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation VeloCloud REST API Edge Status Documentation VeloCloud REST API Edge Status
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation VeloCloud REST API Edge Status Documentation VeloCloud REST API Edge Status
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Database Mysql plugin Documentation Database Mysql plugin
Resource ${CURDIR}${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Hardware Camera Avigilon memory Documentation Hardware Camera Avigilon memory
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Hardware Camera Avigilon storage Documentation Hardware Camera Avigilon storage
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Hardware Camera Avigilon temperature Documentation Hardware Camera Avigilon temperature
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation hardware::kvm::avocent::acs::8000::snmp::plugin Documentation hardware::kvm::avocent::acs::8000::snmp::plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s
@ -15,14 +15,14 @@ Cpu-Detailed
[Documentation] cpu-detailed mode [Documentation] cpu-detailed mode
[Tags] hardware kvm avocent cpu snmp [Tags] hardware kvm avocent cpu snmp
Remove File /dev/shm/snmpstandard_127.0.0.1_2024_cpu-detailed* Remove File /dev/shm/snmpstandard_127.0.0.1_2024_cpu-detailed*
${output} Run Avocent 8000 Plugin "cpu-detailed" --statefile-dir=/tmp/cache/ ${output} Run Avocent 8000 Plugin "cpu-detailed" --statefile-dir=/dev/shm/
${output} Strip String ${output} ${output} Strip String ${output}
Should Be Equal As Strings Should Be Equal As Strings
... ${output} ... ${output}
... OK: CPU Usage: user : Buffer creation, nice : Buffer creation, system : Buffer creation, idle : Buffer creation, wait : Buffer creation, kernel : Buffer creation, interrupt : Buffer creation, softirq : Buffer creation, steal : Buffer creation, guest : Buffer creation, guestnice : Buffer creation ... OK: CPU Usage: user : Buffer creation, nice : Buffer creation, system : Buffer creation, idle : Buffer creation, wait : Buffer creation, kernel : Buffer creation, interrupt : Buffer creation, softirq : Buffer creation, steal : Buffer creation, guest : Buffer creation, guestnice : Buffer creation
... Wrong output result for command:{\n}${output}{\n}{\n}{\n} ... Wrong output result for command:{\n}${output}{\n}{\n}{\n}
${output} Run Avocent 8000 Plugin "cpu-detailed" --statefile-dir=/tmp/cache/ ${output} Run Avocent 8000 Plugin "cpu-detailed" --statefile-dir=/dev/shm/
${output} Strip String ${output} ${output} Strip String ${output}
Remove File /dev/shm/snmpstandard_127.0.0.1_2024_cpu-detailed* Remove File /dev/shm/snmpstandard_127.0.0.1_2024_cpu-detailed*
Should Be Equal As Strings Should Be Equal As Strings
@ -67,14 +67,14 @@ Serial Ports
[Documentation] serial-ports mode [Documentation] serial-ports mode
[Tags] hardware kvm avocent serial snmp [Tags] hardware kvm avocent serial snmp
Remove File /dev/shm/avocent_acs_8000_127.0.0.1_2024_serial-ports* Remove File /dev/shm/avocent_acs_8000_127.0.0.1_2024_serial-ports*
${output} Run Avocent 8000 Plugin "serial-ports" --statefile-dir=/tmp/cache/ ${output} Run Avocent 8000 Plugin "serial-ports" --statefile-dir=/dev/shm/
${output} Strip String ${output} ${output} Strip String ${output}
Should Be Equal As Strings Should Be Equal As Strings
... ${output} ... ${output}
... OK: All serial ports are ok ... OK: All serial ports are ok
... Wrong output result for command:{\n}${output}{\n}{\n}{\n} ... Wrong output result for command:{\n}${output}{\n}{\n}{\n}
${output} Run Avocent 8000 Plugin "serial-ports" --statefile-dir=/tmp/cache/ ${output} Run Avocent 8000 Plugin "serial-ports" --statefile-dir=/dev/shm/
${output} Strip String ${output} ${output} Strip String ${output}
Remove File /dev/shm/avocent_acs_8000_127.0.0.1_2024_serial-ports* Remove File /dev/shm/avocent_acs_8000_127.0.0.1_2024_serial-ports*
Should Be Equal As Strings Should Be Equal As Strings

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Hardware Sensors APC SNMP plugin Documentation Hardware Sensors APC SNMP plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Hardware UPS Sputnik SNMP plugin Documentation Hardware UPS Sputnik SNMP plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Hardware UPS Socomec Netvision SNMP plugin Documentation Hardware UPS Socomec Netvision SNMP plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Hardware UPS standard SNMP plugin Documentation Hardware UPS standard SNMP plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Network Aruba Instant SNMP plugin - AP Usage Documentation Network Aruba Instant SNMP plugin - AP Usage
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Meraki VPN Tunnels Documentation Meraki VPN Tunnels
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Network citrix netscaler health Documentation Network citrix netscaler health
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Network Fortinet Fortigate SNMP plugin Documentation Network Fortinet Fortigate SNMP plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Network Teldat SNMP plugin Documentation Network Teldat SNMP plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Network Teldat SNMP plugin Documentation Network Teldat SNMP plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Network Teldat SNMP plugin Documentation Network Teldat SNMP plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Linux Local list-systemdservices Documentation Linux Local list-systemdservices
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -2,7 +2,7 @@
Documentation Linux Local Systemd-sc-status Documentation Linux Local Systemd-sc-status
# systemd changed the output format of the command starting from version 252, so we need to check for a systemd version and use the correct parameter. # systemd changed the output format of the command starting from version 252, so we need to check for a systemd version and use the correct parameter.
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Check the list-diskio mode Documentation Check the list-diskio mode
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Network Interfaces Documentation Network Interfaces
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s
@ -13,13 +13,13 @@ ${CMD} ${CENTREON_PLUGINS}
... --hostname=${HOSTNAME} ... --hostname=${HOSTNAME}
... --snmp-port=${SNMPPORT} ... --snmp-port=${SNMPPORT}
... --snmp-community=os/linux/snmp/network-interfaces ... --snmp-community=os/linux/snmp/network-interfaces
... --statefile-dir=/tmp/cache/ ... --statefile-dir=/dev/shm/
${COND} ${PERCENT}\{sub\} =~ /exited/ && ${PERCENT}{display} =~ /network/' ${COND} ${PERCENT}\{sub\} =~ /exited/ && ${PERCENT}{display} =~ /network/'
*** Test Cases *** *** Test Cases ***
Interfaces by id ${tc}/5 Interfaces by id ${tc}
[Tags] os linux network interfaces [Tags] os linux network interfaces
${command} Catenate ${command} Catenate
... ${CMD} ... ${CMD}
@ -30,14 +30,16 @@ Interfaces by id ${tc}/5
Examples: tc filter extra_options expected_result -- Examples: tc filter extra_options expected_result --
... 1 1 ${EMPTY} OK: Interface 'lo' Status : up (admin: up) ... 1 1 ${EMPTY} OK: Interface 'lo' Status : up (admin: up)
... 2 1,3 --add-traffic OK: All interfaces are ok ... 2 1,3 ${EMPTY} OK: All interfaces are ok
... 3 1,3 --add-traffic OK: All interfaces are ok | 'traffic_in_lo'=0.00b/s;;;0;10000000 'traffic_out_lo'=0.00b/s;;;0;10000000 'traffic_in_eth1'=0.00b/s;;;0;1000000000 'traffic_out_eth1'=0.00b/s;;;0;1000000000 ... 3 1,3 --add-traffic OK: All interfaces are ok
... 4 2,3,4 --add-traffic OK: All interfaces are ok ... 4 1,3 --add-traffic OK: All interfaces are ok | 'traffic_in_lo'=0.00b/s;;;0;10000000 'traffic_out_lo'=0.00b/s;;;0;10000000 'traffic_in_eth1'=0.00b/s;;;0;1000000000 'traffic_out_eth1'=0.00b/s;;;0;1000000000
... 5 2,3,4 --add-traffic OK: All interfaces are ok | 'traffic_in_eth0'=0.00b/s;;;0;1000000000 'traffic_out_eth0'=0.00b/s;;;0;1000000000 'traffic_in_eth1'=0.00b/s;;;0;1000000000 'traffic_out_eth1'=0.00b/s;;;0;1000000000 'traffic_in_eth2'=0.00b/s;;;0;1000000000 'traffic_out_eth2'=0.00b/s;;;0;1000000000 ... 5 2,3,4 ${EMPTY} OK: All interfaces are ok
# theese test are linked together. The test 2 create the cache file in /tmp/, and the test 3 use this cache file ... 6 2,3,4 --add-traffic OK: All interfaces are ok
... 7 2,3,4 --add-traffic OK: All interfaces are ok | 'traffic_in_eth0'=0.00b/s;;;0;1000000000 'traffic_out_eth0'=0.00b/s;;;0;1000000000 'traffic_in_eth1'=0.00b/s;;;0;1000000000 'traffic_out_eth1'=0.00b/s;;;0;1000000000 'traffic_in_eth2'=0.00b/s;;;0;1000000000 'traffic_out_eth2'=0.00b/s;;;0;1000000000
# theese test are linked together. The test 3 create the cache file in /dev/shm/, and the test 4 use this cache file
# to calculate traffic throughput by second. # to calculate traffic throughput by second.
Interfaces by id regexp ${tc}/6 Interfaces by id regexp ${tc}
[Tags] os linux network interfaces [Tags] os linux network interfaces
${command} Catenate ${command} Catenate
... ${CMD} ... ${CMD}
@ -50,7 +52,9 @@ Interfaces by id regexp ${tc}/6
Examples: tc filter extra_options expected_result -- Examples: tc filter extra_options expected_result --
... 1 ^1$ ${EMPTY} OK: Interface 'lo' Status : up (admin: up) ... 1 ^1$ ${EMPTY} OK: Interface 'lo' Status : up (admin: up)
... 2 1 ${EMPTY} OK: Interface 'lo' Status : up (admin: up) ... 2 1 ${EMPTY} OK: Interface 'lo' Status : up (admin: up)
... 3 [13] --add-traffic OK: All interfaces are ok ... 3 [13] ${EMPTY} OK: All interfaces are ok
... 4 [13] --add-traffic OK: All interfaces are ok | 'traffic_in_lo'=0.00b/s;;;0;10000000 'traffic_out_lo'=0.00b/s;;;0;10000000 'traffic_in_eth1'=0.00b/s;;;0;1000000000 'traffic_out_eth1'=0.00b/s;;;0;1000000000 ... 4 [13] --add-traffic OK: All interfaces are ok
... 5 [234] --add-traffic OK: All interfaces are ok ... 5 [13] --add-traffic OK: All interfaces are ok | 'traffic_in_lo'=0.00b/s;;;0;10000000 'traffic_out_lo'=0.00b/s;;;0;10000000 'traffic_in_eth1'=0.00b/s;;;0;1000000000 'traffic_out_eth1'=0.00b/s;;;0;1000000000
... 6 [234] --add-traffic OK: All interfaces are ok | 'traffic_in_eth0'=0.00b/s;;;0;1000000000 'traffic_out_eth0'=0.00b/s;;;0;1000000000 'traffic_in_eth1'=0.00b/s;;;0;1000000000 'traffic_out_eth1'=0.00b/s;;;0;1000000000 'traffic_in_eth2'=0.00b/s;;;0;1000000000 'traffic_out_eth2'=0.00b/s;;;0;1000000000 ... 6 [234] ${EMPTY} OK: All interfaces are ok
... 7 [234] --add-traffic OK: All interfaces are ok
... 8 [234] --add-traffic OK: All interfaces are ok | 'traffic_in_eth0'=0.00b/s;;;0;1000000000 'traffic_out_eth0'=0.00b/s;;;0;1000000000 'traffic_in_eth1'=0.00b/s;;;0;1000000000 'traffic_out_eth1'=0.00b/s;;;0;1000000000 'traffic_in_eth2'=0.00b/s;;;0;1000000000 'traffic_out_eth2'=0.00b/s;;;0;1000000000

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Linux Local Systemd-sc-status Documentation Linux Local Systemd-sc-status
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s

View File

@ -1,63 +0,0 @@
*** Settings ***
Documentation datacore rest api plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}storage-datacore-api.json
${CMD} ${CENTREON_PLUGINS} --plugin=storage::datacore::restapi::plugin --password=pass --username=user --port=${APIPORT} --hostname=${HOSTNAME} --proto=http
*** Test Cases ***
Datacore check pool usage
[Documentation] Check Datacore pool usage
[Tags] storage api
${command} Catenate
... ${CMD}
... --mode=pool-usage
... --critical-oversubscribed=${critical-oversubscribed}
... --warning-oversubscribed=${warning-oversubscribed}
... --warning-bytesallocatedpercentage=${warning-bytesallocatedpercentage}
... --critical-bytesallocatedpercentage=${critical-bytesallocatedpercentage}
... --pool-id=B5C140F5-6B13-4CAD-AF9D-F7C4172B3A1D:{4dec1b5a-2577-11e5-80c3-00155d651622}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: warning-bytesallocatedpercentage critical-bytesallocatedpercentage warning-oversubscribed critical-oversubscribed expected_result --
... 2 5 -1 3 CRITICAL: Bytes Allocated : 12 % WARNING: Over subscribed bytes : 0 | 'datacore.pool.bytesallocated.percentage'=12%;0:2;0:5;0;100 'datacore.pool.oversubscribed.bytes'=0bytes;0:-1;0:3;0;
... 70 80 10 20 OK: Bytes Allocated : 12 % - Over subscribed bytes : 0 | 'datacore.pool.bytesallocated.percentage'=12%;0:70;0:80;0;100 'datacore.pool.oversubscribed.bytes'=0bytes;0:10;0:20;0;
Datacore check alert count
[Documentation] Check Datacore pool usage
[Tags] storage api
${command} Catenate
... ${CMD}
... --mode=alerts
... --warning-error=${warning-error}
... --critical-error=${critical-error}
... --warning-warning=${warning-warning}
... --critical-warning=${critical-warning}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: warning-error critical-error warning-warning critical-warning expected_result --
... 0 1 5 5 WARNING: number of error alerts : 1 | 'datacore.event.error.count'=1;0:0;0:1;0; 'datacore.alerts.warning.count'=1;0:5;0:5;0; 'datacore.alerts.info.count'=0;;;0; 'datacore.alerts.trace.count'=0;;;0;
... 5 5 5 5 OK: number of error alerts : 1, number of warning alerts : 1, number of info alerts : 0, number of trace alerts : 0 | 'datacore.event.error.count'=1;0:5;0:5;0; 'datacore.alerts.warning.count'=1;0:5;0:5;0; 'datacore.alerts.info.count'=0;;;0; 'datacore.alerts.trace.count'=0;;;0;
Datacore check status monitor
[Documentation] Check Datacore pool usage
[Tags] storage api
${command} Catenate
... ${CMD}
... --mode=status-monitor
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: expected_result --
... CRITICAL: 'State of HostVM2' status : 'Critical', message is 'Connected'

View File

@ -0,0 +1,64 @@
*** Settings ***
Documentation datacore rest api plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}storage-datacore-api.json
${CMD} ${CENTREON_PLUGINS} --plugin=storage::datacore::restapi::plugin --password=pass --username=user --port=${APIPORT} --hostname=${HOSTNAME} --proto=http
*** Test Cases ***
Datacore check pool usage ${tc}
[Documentation] Check Datacore pool usage
[Tags] storage api
${command} Catenate
... ${CMD}
... --mode=pool-usage
... --critical-oversubscribed=${critical-oversubscribed}
... --warning-oversubscribed=${warning-oversubscribed}
... --warning-bytesallocatedpercentage=${warning-bytesallocatedpercentage}
... --critical-bytesallocatedpercentage=${critical-bytesallocatedpercentage}
... --pool-id=B5C140F5-6B13-4CAD-AF9D-F7C4172B3A1D:{4dec1b5a-2577-11e5-80c3-00155d651622}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc warning-bytesallocatedpercentage critical-bytesallocatedpercentage warning-oversubscribed critical-oversubscribed expected_result --
... 1 2 5 -1 3 CRITICAL: Bytes Allocated : 12 % WARNING: Over subscribed bytes : 0 | 'datacore.pool.bytesallocated.percentage'=12%;0:2;0:5;0;100 'datacore.pool.oversubscribed.bytes'=0bytes;0:-1;0:3;0;
... 2 70 80 10 20 OK: Bytes Allocated : 12 % - Over subscribed bytes : 0 | 'datacore.pool.bytesallocated.percentage'=12%;0:70;0:80;0;100 'datacore.pool.oversubscribed.bytes'=0bytes;0:10;0:20;0;
Datacore check alert count ${tc}
[Documentation] Check Datacore pool usage
[Tags] storage api
${command} Catenate
... ${CMD}
... --mode=alerts
... --warning-error=${warning-error}
... --critical-error=${critical-error}
... --warning-warning=${warning-warning}
... --critical-warning=${critical-warning}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc warning-error critical-error warning-warning critical-warning expected_result --
... 1 0 1 5 5 WARNING: number of error alerts : 1 | 'datacore.event.error.count'=1;0:0;0:1;0; 'datacore.alerts.warning.count'=1;0:5;0:5;0; 'datacore.alerts.info.count'=0;;;0; 'datacore.alerts.trace.count'=0;;;0;
... 2 5 5 5 5 OK: number of error alerts : 1, number of warning alerts : 1, number of info alerts : 0, number of trace alerts : 0 | 'datacore.event.error.count'=1;0:5;0:5;0; 'datacore.alerts.warning.count'=1;0:5;0:5;0; 'datacore.alerts.info.count'=0;;;0; 'datacore.alerts.trace.count'=0;;;0;
Datacore check status monitor ${tc}
[Documentation] Check Datacore pool usage
[Tags] storage api
${command} Catenate
... ${CMD}
... --mode=status-monitor
... --statefile-dir=/dev/shm/
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc expected_result --
... 1 CRITICAL: 'State of HostVM2' status : 'Critical', message is 'Connected'

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation HPE Primera Storage REST API Documentation HPE Primera Storage REST API
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation HPE Primera Storage REST API Documentation HPE Primera Storage REST API
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation HPE Primera Storage REST API Documentation HPE Primera Storage REST API
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation HPE Primera Storage REST API Documentation HPE Primera Storage REST API
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation HPE Primera Storage REST API Documentation HPE Primera Storage REST API
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation HPE Primera Storage REST API Documentation HPE Primera Storage REST API
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation HPE Primera Storage REST API Documentation HPE Primera Storage REST API
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation HPE Primera Storage REST API Documentation HPE Primera Storage REST API
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON} Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon Suite Teardown Stop Mockoon

View File

@ -1,7 +1,7 @@
*** Settings *** *** Settings ***
Documentation Storage Synology SNMP Documentation Storage Synology SNMP
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s Test Timeout 120s