ci(plugins-tests) Use docker to install and test each plugins
Co-authored-by: May <110405507+paul-oureib@users.noreply.github.com> REF:CTOR-474
This commit is contained in:
parent
45dfba82ad
commit
8e068359bd
|
@ -0,0 +1,28 @@
|
|||
name: "test-plugins"
|
||||
description: "Test plugin that are passed as parameters"
|
||||
inputs:
|
||||
cache-key:
|
||||
description: "The packaged plugin's cache key"
|
||||
required: true
|
||||
plugin-list:
|
||||
description: "List of plugins to install from the cache"
|
||||
required: true
|
||||
package-extension:
|
||||
description: "Either 'rpm' or 'deb'. Needed to determine the package manager command (dnf or apt-get)."
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
|
||||
- name: get the cached plugin
|
||||
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||
with:
|
||||
path: ./*.${{ inputs.package-extension }}
|
||||
key: ${{ inputs.cache-key }}
|
||||
fail-on-cache-miss: true
|
||||
|
||||
- name: Install, test and remove plugin
|
||||
shell: bash
|
||||
run: |
|
||||
python3 .github/scripts/test-all-plugins.py ${{ inputs.package-extension }} ${{ inputs.plugin-list }}
|
|
@ -0,0 +1,68 @@
|
|||
ARG REGISTRY_URL
|
||||
|
||||
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
|
||||
dnf clean all
|
||||
|
||||
# Install Robotframework
|
||||
dnf install -y python3.11 python3.11-pip
|
||||
pip3.11 install robotframework robotframework-examples
|
||||
# Install snmpsim
|
||||
pip3.11 install snmpsim-lextudio
|
||||
|
||||
# Install node
|
||||
curl -fsSL https://rpm.nodesource.com/setup_21.x | bash -
|
||||
yum install -y nodejs
|
||||
|
||||
# Install mockoon
|
||||
npm install -g -D @mockoon/cli
|
||||
|
||||
# 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
|
||||
|
||||
mkdir -p /var/lib/centreon/centplugins/
|
||||
chmod 777 /var/lib/centreon/centplugins/
|
||||
|
||||
dnf clean all
|
||||
|
||||
EOF
|
|
@ -0,0 +1,67 @@
|
|||
ARG REGISTRY_URL
|
||||
|
||||
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
|
||||
dnf clean all
|
||||
|
||||
# Install Robotframework
|
||||
dnf install -y python3.11 python3.11-pip
|
||||
pip3.11 install robotframework robotframework-examples
|
||||
# Install snmpsim
|
||||
pip3.11 install snmpsim-lextudio
|
||||
|
||||
# Install node
|
||||
curl -fsSL https://rpm.nodesource.com/setup_21.x | bash -
|
||||
yum install -y nodejs
|
||||
# Install mockoon
|
||||
npm install -g -D @mockoon/cli
|
||||
|
||||
# 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
|
||||
|
||||
mkdir -p /var/lib/centreon/centplugins/
|
||||
chmod 777 /var/lib/centreon/centplugins/
|
||||
|
||||
dnf clean all
|
||||
|
||||
EOF
|
|
@ -0,0 +1,48 @@
|
|||
ARG REGISTRY_URL
|
||||
|
||||
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
|
||||
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
|
||||
apt-get update
|
||||
# Install Robotframework
|
||||
apt-get install -y python3-dev python3-pip
|
||||
rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED
|
||||
pip3 install robotframework robotframework-examples
|
||||
# Install snmpsim
|
||||
pip3 install snmpsim-lextudio
|
||||
|
||||
# Install nodejs
|
||||
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - &&\
|
||||
apt-get install -y nodejs
|
||||
|
||||
# Install mockoon (needs nodejs)
|
||||
npm install -g -D @mockoon/cli
|
||||
|
||||
# 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
|
||||
|
||||
mkdir -p /var/lib/centreon/centplugins/
|
||||
chmod 777 /var/lib/centreon/centplugins/
|
||||
|
||||
apt-get clean
|
||||
|
||||
EOF
|
|
@ -0,0 +1,47 @@
|
|||
ARG REGISTRY_URL
|
||||
|
||||
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
|
||||
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
|
||||
apt-get update
|
||||
# Install Robotframework
|
||||
apt-get install -y python3 python3-dev python3-pip
|
||||
pip3 install robotframework robotframework-examples
|
||||
# Install snmpsim
|
||||
pip3 install snmpsim-lextudio
|
||||
|
||||
# Install nodejs
|
||||
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - &&\
|
||||
apt-get install -y nodejs
|
||||
# Install mockoon (needs nodejs)
|
||||
npm install -g -D @mockoon/cli
|
||||
|
||||
# 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
|
||||
|
||||
mkdir -p /var/lib/centreon/centplugins/
|
||||
chmod 777 /var/lib/centreon/centplugins/
|
||||
|
||||
apt-get clean
|
||||
|
||||
|
||||
EOF
|
|
@ -0,0 +1,45 @@
|
|||
ARG REGISTRY_URL
|
||||
|
||||
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
|
||||
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
|
||||
apt-get update
|
||||
# Install Robotframework
|
||||
apt-get install -y python3 python3-dev python3-pip
|
||||
pip3 install robotframework robotframework-examples
|
||||
# Install snmpsim
|
||||
pip3 install snmpsim-lextudio
|
||||
|
||||
# Install nodejs
|
||||
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - &&\
|
||||
apt-get install -y nodejs
|
||||
# Install mockoon (needs nodejs)
|
||||
npm install -g -D @mockoon/cli
|
||||
|
||||
# Add Centreon plugins repositories
|
||||
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
|
||||
|
||||
mkdir -p /var/lib/centreon/centplugins/
|
||||
chmod 777 /var/lib/centreon/centplugins/
|
||||
|
||||
apt-get clean
|
||||
|
||||
EOF
|
|
@ -43,7 +43,7 @@ for filepath in os.popen('find packaging -type f -name pkg.json').read().split('
|
|||
packaging_path = re.search('.*\/(centreon-plugin-.*)\/pkg.json', filepath).group(1)
|
||||
|
||||
if not packaging_path == packaging["pkg_name"]:
|
||||
packaging_path = packaging_path + "=>" + packaging["pkg_name"]
|
||||
packaging_path = packaging["pkg_name"]
|
||||
|
||||
directory_path = re.search('^(.+)\/pkg.json', filepath).group(1)
|
||||
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
|
||||
|
||||
def get_tests_folders(plugin_name):
|
||||
folder_list = []
|
||||
pkg_file = open("./packaging/" + plugin_name + "/pkg.json")
|
||||
packaging = json.load(pkg_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.
|
||||
folder_list.append("tests/robot/" + file)
|
||||
return folder_list
|
||||
|
||||
|
||||
def get_plugin_full_path(plugin_name):
|
||||
pkg_file = open("./packaging/" + plugin_name + "/pkg.json")
|
||||
packaging = json.load(pkg_file)
|
||||
return "/usr/lib/centreon/plugins/" + packaging["plugin_name"]
|
||||
|
||||
|
||||
def test_plugin(plugin_name):
|
||||
folders_list = get_tests_folders(plugin_name)
|
||||
print(f"{plugin_name} folders_list : {folders_list}")
|
||||
if len(folders_list) == 0:
|
||||
return 0 # no tests present at the moment, but we still have tested the plugin can be installed.
|
||||
robot_results = subprocess.run("robot -v ''CENTREON_PLUGINS:" + get_plugin_full_path(plugin_name) + " " + " ".join(folders_list),
|
||||
shell=True, check=False)
|
||||
return robot_results.returncode
|
||||
|
||||
|
||||
def try_command(cmd, error):
|
||||
return_obj = subprocess.run(cmd, shell=True, check=False)
|
||||
print(return_obj)
|
||||
if return_obj.returncode != 0:
|
||||
print(error)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def launch_snmp_sim():
|
||||
subprocess.run("useradd snmp", shell=True, check=False)
|
||||
# we don't want to quit if this fail because it often means the user already exist.
|
||||
|
||||
# this folder seem needed to launch snmp plugins. I didn't reproduce in my env, but without it,
|
||||
# the first snmp plugin launched by robot prepend the message "Created directory: /var/lib/snmp/cert_indexes".
|
||||
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")
|
||||
|
||||
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' &"
|
||||
try_command(cmd=snmpsim_cmd, error="can't launch snmp sim daemon.")
|
||||
|
||||
|
||||
def install_plugin(plugin, archi):
|
||||
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
|
||||
if archi == "deb":
|
||||
outfile.write("apt install -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' -y ./" + plugin.lower() + "*.deb\n")
|
||||
output_status = (subprocess.run(
|
||||
"apt install -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' -y ./" + plugin.lower() + "*.deb",
|
||||
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
|
||||
elif archi == "rpm":
|
||||
outfile.write("dnf install -y ./" + plugin + "*.rpm\n")
|
||||
output_status = (subprocess.run("dnf install -y ./" + plugin + "*.rpm", shell=True, check=False,
|
||||
stderr=subprocess.STDOUT, stdout=outfile)).returncode
|
||||
else:
|
||||
print(f"Unknown architecture, expected deb or rpm, got {archi}. Exiting.")
|
||||
exit(1)
|
||||
return output_status
|
||||
|
||||
|
||||
def remove_plugin(plugin, archi):
|
||||
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
|
||||
if archi == "deb":
|
||||
outfile.write("apt -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' autoremove -y " + plugin.lower() + "\n")
|
||||
output_status = (subprocess.run(
|
||||
"apt -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' autoremove -y " + plugin.lower(),
|
||||
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
|
||||
# -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' is an option to force apt to keep the package in
|
||||
# /var/cache/apt/archives, so it do not re download them for every installation.
|
||||
# 'autoremove', contrary to 'remove' all dependancy while removing the original package.
|
||||
|
||||
elif archi == "rpm":
|
||||
outfile.write("dnf remove -y " + plugin + "\n")
|
||||
output_status = (subprocess.run("dnf remove -y " + plugin, shell=True, check=False,
|
||||
stderr=subprocess.STDOUT, stdout=outfile)).returncode
|
||||
else:
|
||||
print(f"Unknown architecture, expected deb or rpm, got {archi}. Exiting.")
|
||||
exit(1)
|
||||
return output_status
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("starting program")
|
||||
if len(sys.argv) < 2:
|
||||
print("please provide architecture (deb or rpm) and list of plugin to test as arguments (one plugin name per "
|
||||
"argument, separated by space)")
|
||||
sys.exit(1)
|
||||
|
||||
launch_snmp_sim()
|
||||
archi = sys.argv.pop(1) # expected either deb or rpm.
|
||||
script_name = sys.argv.pop(0)
|
||||
|
||||
error_install = 0
|
||||
error_tests = 0
|
||||
error_purge = 0
|
||||
nb_plugins = 0
|
||||
list_plugin_error = []
|
||||
for plugin in sys.argv:
|
||||
print("plugin : ", plugin)
|
||||
nb_plugins += 1
|
||||
tmp = install_plugin(plugin, archi)
|
||||
if tmp > 0:
|
||||
list_plugin_error.append(plugin)
|
||||
error_install += tmp
|
||||
tmp = test_plugin(plugin)
|
||||
if tmp > 0:
|
||||
list_plugin_error.append(plugin)
|
||||
error_tests += tmp
|
||||
tmp = remove_plugin(plugin, archi)
|
||||
if tmp > 0:
|
||||
list_plugin_error.append(plugin)
|
||||
error_purge += tmp
|
||||
|
||||
print(f"{nb_plugins} plugins tested.\n there was {error_install} installation error, {error_tests} test "
|
||||
f"errors, and {error_purge} removal error list of error : {list_plugin_error}",)
|
||||
|
||||
if error_install != 0 or error_tests != 0 or error_purge != 0:
|
||||
exit(1)
|
||||
exit(0)
|
||||
# the snmpsim daemon is still runing when we exit, as this script is mainly run in a docker on CI, it will be
|
||||
# cleared up eventually.
|
||||
# to clear it up manually, use ps -ax | grep snmpsim-command-respond | cut -dp -f1 | sudo xargs kill
|
|
@ -11,11 +11,11 @@ on:
|
|||
- develop
|
||||
paths:
|
||||
- ".github/workflows/docker-builder-packaging-plugins.yml"
|
||||
- ".github/docker/*"
|
||||
- ".github/docker/packaging/*"
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/docker-builder-packaging-plugins.yml"
|
||||
- ".github/docker/*"
|
||||
- ".github/docker/packaging/*"
|
||||
|
||||
jobs:
|
||||
create-and-push-docker:
|
||||
|
@ -68,7 +68,7 @@ jobs:
|
|||
|
||||
- uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
||||
with:
|
||||
file: .github/docker/Dockerfile.${{ matrix.dockerfile }}
|
||||
file: .github/docker/packaging/Dockerfile.${{ matrix.dockerfile }}
|
||||
context: .
|
||||
build-args: "REGISTRY_URL=${{ vars.DOCKER_PROXY_REGISTRY_URL }}"
|
||||
pull: true
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
name: docker-builder-testing-plugins
|
||||
|
||||
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-testing-plugins.yml"
|
||||
- ".github/docker/testing/*"
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/docker-builder-testing-plugins.yml"
|
||||
- ".github/docker/testing/*"
|
||||
|
||||
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: ["self-hosted", "collect-arm64"]
|
||||
dockerfile: bullseye
|
||||
image: bullseye-arm64
|
||||
- runner: ubuntu-22.04
|
||||
dockerfile: bookworm
|
||||
image: bookworm
|
||||
- runner: ubuntu-22.04
|
||||
dockerfile: jammy
|
||||
image: jammy
|
||||
|
||||
runs-on: ${{ matrix.runner }}
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Login to Registry
|
||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.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@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||
with:
|
||||
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
|
||||
username: ${{ secrets.DOCKER_REGISTRY_ID }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
|
||||
|
||||
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
||||
|
||||
- uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
||||
with:
|
||||
file: .github/docker/testing/Dockerfile.testing-plugins-${{ matrix.dockerfile }}
|
||||
context: .
|
||||
build-args: "REGISTRY_URL=${{ vars.DOCKER_PROXY_REGISTRY_URL }}"
|
||||
pull: true
|
||||
push: true
|
||||
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/testing-plugins-${{ matrix.image }}:latest
|
|
@ -76,10 +76,10 @@ jobs:
|
|||
PLUGINS="$(python3 .github/scripts/process-plugins.py '${{ steps.filter.outputs.common == 'true' }}')"
|
||||
|
||||
echo "plugins=$(echo $PLUGINS)" >> $GITHUB_OUTPUT
|
||||
|
||||
if [ "$PLUGINS" == '' ]; then
|
||||
echo "::notice::There are no modifications to the plugins packages"
|
||||
fi
|
||||
|
||||
shell: bash
|
||||
|
||||
fatpacker:
|
||||
|
@ -243,8 +243,55 @@ jobs:
|
|||
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
|
||||
stability: ${{ needs.get-environment.outputs.stability }}
|
||||
|
||||
test-plugins:
|
||||
needs: [get-environment, get-plugins, package]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
distrib: [el8, el9, jammy, bullseye, bookworm]
|
||||
include:
|
||||
- package_extension: rpm
|
||||
image: testing-plugins-alma8
|
||||
distrib: el8
|
||||
- package_extension: rpm
|
||||
image: testing-plugins-alma9
|
||||
distrib: el9
|
||||
- package_extension: deb
|
||||
image: testing-plugins-bullseye
|
||||
distrib: bullseye
|
||||
- package_extension: deb
|
||||
image: testing-plugins-bookworm
|
||||
distrib: bookworm
|
||||
- package_extension: deb
|
||||
image: testing-plugins-jammy
|
||||
distrib: jammy
|
||||
|
||||
runs-on: ubuntu-22.04
|
||||
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
|
||||
|
||||
- uses: ./.github/actions/test-plugins
|
||||
with:
|
||||
cache-key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
|
||||
package-extension: ${{ matrix.package_extension }}
|
||||
plugin-list: ${{ needs.get-plugins.outputs.plugins }}
|
||||
|
||||
- name: Upload apt/dnf logs as artifacts if tests failed
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
|
||||
with:
|
||||
name: plugin-installation-${{ matrix.distrib }}
|
||||
path: /var/log/robot-plugins-installation-tests.log
|
||||
retention-days: 1
|
||||
|
||||
deliver:
|
||||
needs: [get-environment, package]
|
||||
needs: [get-environment, package, test-plugins]
|
||||
if: ${{ contains(fromJson('["stable", "testing", "unstable"]'), needs.get-environment.outputs.stability) }}
|
||||
uses: ./.github/workflows/plugin-delivery.yml
|
||||
with:
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
name: functional-tests
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/tests-functional.yml'
|
||||
- 'src/**'
|
||||
- 'tests/functional/**'
|
||||
- 'tests/resources/mockoon/**'
|
||||
- 'tests/resources/snmp/**'
|
||||
|
||||
jobs:
|
||||
functional-tests-with-robot:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: Install libs
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt-get install -y libcurl4-openssl-dev
|
||||
sudo apt-get install -qqy snmpsim
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
with:
|
||||
node-version: 21
|
||||
|
||||
- name: Install Mockoon CLI
|
||||
run: npm install -g -D @mockoon/cli@7.0.0
|
||||
|
||||
- name: Install perl dependencies
|
||||
uses: shogo82148/actions-setup-perl@28eae78d12c2bba1163aec45d123f6d9228bc307 # v1.29.0
|
||||
with:
|
||||
perl-version: '5.34'
|
||||
install-modules-with: cpm
|
||||
install-modules: |
|
||||
Alien::SNMP
|
||||
DateTime
|
||||
Net::Curl::Easy
|
||||
Paws
|
||||
Net::SNMP
|
||||
URI::Encode
|
||||
XML::LibXML
|
||||
DBI
|
||||
DBD::mysql
|
||||
POSIX
|
||||
Time::HiRes
|
||||
JSON::XS
|
||||
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install Robot Framework
|
||||
run: |
|
||||
pip3.11 install robotframework
|
||||
pip3.11 install RobotFramework-Examples
|
||||
shell: bash
|
||||
|
||||
- name: Run Robot Framework tests
|
||||
run: |
|
||||
sudo mkdir -p /var/lib/centreon/centplugins/
|
||||
sudo chmod 777 /var/lib/centreon/centplugins/
|
||||
sudo useradd snmp
|
||||
sudo mkdir -p /usr/snmpsim/data
|
||||
sudo cp -r tests/robot/* /usr/snmpsim/data/
|
||||
snmpsimd --logging-method=null --agent-udpv4-endpoint=127.0.0.1:2024 --process-user=snmp --process-group=snmp &
|
||||
robot tests/robot
|
Loading…
Reference in New Issue