Skip to content

Commit

Permalink
enh(github): backport-containers-pull-removed (#981)
Browse files Browse the repository at this point in the history
* backport
* fix(tests): check.pl improved to fix an issue with the perl connector.

REFS: MON-32841
  • Loading branch information
bouda1 committed Dec 5, 2023
1 parent 9b173f5 commit e273f3d
Show file tree
Hide file tree
Showing 19 changed files with 420 additions and 119 deletions.
3 changes: 1 addition & 2 deletions .github/docker/Dockerfile.centreon-collect-alma8
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo

curl -LsS "https://r.mariadb.com/downloads/mariadb_repo_setup" | bash -s -- --os-type=rhel --os-version=8 --mariadb-server-version="mariadb-10.5"
dnf install -y cmake \
dnf --best install -y cmake \
gcc \
gcc-c++ \
gdb \
Expand All @@ -36,7 +36,6 @@ dnf install -y cmake \
MariaDB-server \
gnutls-devel \
libgcrypt-devel \
libssh2-devel \
lua-devel \
make \
perl-ExtUtils-Embed.noarch \
Expand Down
3 changes: 1 addition & 2 deletions .github/docker/Dockerfile.centreon-collect-alma9
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo

dnf install -y cmake \
dnf --best install -y cmake \
gcc \
gcc-c++ \
gdb \
Expand All @@ -31,7 +31,6 @@ dnf install -y cmake \
mariadb \
gnutls-devel \
libgcrypt-devel \
libssh2-devel \
lua-devel \
make \
perl-ExtUtils-Embed.noarch \
Expand Down
53 changes: 53 additions & 0 deletions .github/docker/Dockerfile.centreon-collect-alma9-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ARG REGISTRY_URL

FROM ${REGISTRY_URL}/almalinux:9

COPY . /tmp/collect

RUN <<EOF

# Base dnf configuration.
echo 'http_caching=none' >> /etc/yum.conf
echo 'assumeyes=1' >> /etc/yum.conf
sed -i 's/best=True/best=False/g' /etc/dnf/dnf.conf
dnf install -y dnf-plugins-core
dnf config-manager --set-enabled crb

dnf install -y epel-release

dnf --best install -y \
gcc \
gcc-c++ \
gdb \
git \
openssh-server \
mariadb-server \
mariadb \
gnutls \
libgcrypt \
lua \
perl-ExtUtils-Embed \
python3 \
python3-devel \
python3-pip \
perl-Thread-Queue \
rrdtool \
perl \
procps-ng \
zstd \
psmisc \
sudo

echo "install robot and dependencies"

pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil
pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3

cd /tmp/collect

.github/scripts/collect-prepare-test-robot.sh mariadb

/bin/rm -rf /tmp/collect

EOF

53 changes: 53 additions & 0 deletions .github/docker/Dockerfile.centreon-collect-debian-bullseye-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ARG REGISTRY_URL

FROM ${REGISTRY_URL}/debian:bullseye


COPY . /tmp/collect

RUN <<EOF

apt-get update

apt-get -y install curl \
gcc \
g++ \
gdb \
git \
mariadb-server \
openssh-server \
libmariadb3 \
librrd8 \
libgnutlsxx28 \
liblua5.3 \
python3 \
python3-dev \
python3-pip \
libperl-dev \
libgcrypt20 \
aptitude \
strace \
locales \
rrdtool \
rrdcached \
zstd \
psmisc \
sudo

localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py

pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil
pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3


cd /tmp/collect

.github/scripts/collect-prepare-test-robot.sh mariadb

/bin/rm -rf /tmp/collect

EOF

3 changes: 1 addition & 2 deletions .github/docker/Dockerfile.centreon-collect-mysql-alma9
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo

dnf install -y cmake \
dnf --best install -y cmake \
gcc \
gcc-c++ \
gdb \
Expand All @@ -32,7 +32,6 @@ dnf install -y cmake \
gnutls-devel \
iproute \
libgcrypt-devel \
libssh2-devel \
lua-devel \
make \
perl-ExtUtils-Embed.noarch \
Expand Down
52 changes: 52 additions & 0 deletions .github/docker/Dockerfile.centreon-collect-mysql-alma9-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ARG REGISTRY_URL

FROM ${REGISTRY_URL}/almalinux:9

COPY . /tmp/collect

RUN <<EOF

# Base dnf configuration.
echo 'http_caching=none' >> /etc/yum.conf
echo 'assumeyes=1' >> /etc/yum.conf
sed -i 's/best=True/best=False/g' /etc/dnf/dnf.conf
dnf install -y dnf-plugins-core
dnf config-manager --set-enabled crb

dnf install -y epel-release

dnf --best install -y gcc \
gcc-c++ \
gdb \
git \
openssh-server \
mysql-server \
mysql \
gnutls \
libgcrypt \
lua \
perl-ExtUtils-Embed \
python3 \
python3-devel \
python3-pip \
perl-Thread-Queue \
rrdtool \
perl \
procps-ng \
zstd \
psmisc \
sudo \
iproute

echo "install robot and dependencies"

pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil
pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3

cd /tmp/collect

.github/scripts/collect-prepare-test-robot.sh mysql

/bin/rm -rf /tmp/collect

EOF
95 changes: 95 additions & 0 deletions .github/scripts/collect-prepare-test-robot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash
set -e
set -x


database_type=$1

. /etc/os-release
distrib=${ID}
distrib=$(echo $distrib | tr '[:lower:]' '[:upper:]')


echo "########################### Configure sshd ###########################"
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -P "" <<<y
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -P "" <<<y
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -P "" <<<y
mkdir -p /run/sshd

if [ $database_type == 'mysql' ]; then
echo "########################### Start MySQL ######################################"
#workaround of forbidden execution of mysqld
cp /usr/libexec/mysqld /usr/libexec/mysqldtoto
/usr/libexec/mysqldtoto --user=root --initialize-insecure
/usr/libexec/mysqldtoto --user=root &

while [ ! -S /var/lib/mysql/mysql.sock ] && [ ! -S /var/run/mysqld/mysqld.sock ]; do
sleep 10
done

sleep 5
echo "########################### Init centreon database ############################"

mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED WITH mysql_native_password BY 'centreon';"
mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED WITH mysql_native_password BY 'centreon';"
else
echo "########################### Start MariaDB ######################################"
if [ "$distrib" = "ALMALINUX" ]; then
mysql_install_db --user=root --basedir=/usr --datadir=/var/lib/mysql
mariadbd --socket=/var/lib/mysql/mysql.sock --user=root > /dev/null 2>&1 &
else
mkdir -p /run/mysqld
chown mysql:mysql /run/mysqld
mariadbd --socket=/run/mysqld/mysqld.sock --user=root > /dev/null 2>&1 &
fi
sleep 5

echo "########################### Init centreon database ############################"

mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED BY 'centreon';"
mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED BY 'centreon';"
fi

mysql -e "GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,DROP,INDEX,ALTER,LOCK TABLES,CREATE TEMPORARY TABLES, EVENT,CREATE VIEW ON *.* TO 'centreon'@'localhost';"
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root_centreon'@'localhost'"

cat resources/centreon.sql | sed "s/DBNameConf/centreon/g" > /tmp/centreon.sql

mysql -u root_centreon -pcentreon < resources/centreon_storage.sql
mysql -u root_centreon -pcentreon < /tmp/centreon.sql

cd tests

if [ "$distrib" = "ALMALINUX" ]; then
dnf groupinstall -y "Development Tools"
dnf install -y python3-devel
else
apt-get update
apt-get install -y build-essential
apt-get install -y python3-dev
fi


echo "########################## Install centreon collect ###########################"
cd ..
echo "Installation..."
if [ "$distrib" = "ALMALINUX" ]; then
dnf clean all
rm -f ./*-selinux-*.rpm # avoid to install selinux packages which are dependent to centreon-common-selinux
dnf install -y ./*.rpm
else
apt-get update
# apt-get install -y ./*.deb
fi


if [ $database_type == 'mysql' ]; then
killall -w mysqldtoto
else
killall -w mariadbd
fi

cd ..

\rm -rf *

56 changes: 5 additions & 51 deletions .github/scripts/collect-test-robot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,75 +24,25 @@ if [ ${database_type} == 'mysql' ] && [ ! -f tests/${test_file}.mysql ]; then
exit 0
fi

echo "########################### Configure and start sshd ###########################"
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -P "" <<<y
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -P "" <<<y
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -P "" <<<y
mkdir -p /run/sshd
echo "########################### start sshd ###########################"
/usr/sbin/sshd -D &

if [ $database_type == 'mysql' ]; then
echo "########################### Start MySQL ######################################"
#workaround of forbidden execution of mysqld
cp /usr/libexec/mysqld /usr/libexec/mysqldtoto
/usr/libexec/mysqldtoto --user=root --initialize-insecure
/usr/libexec/mysqldtoto --user=root &

while [ ! -S /var/lib/mysql/mysql.sock ] && [ ! -S /var/run/mysqld/mysqld.sock ]; do
sleep 10
done

sleep 5
echo "########################### Init centreon database ############################"

mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED WITH mysql_native_password BY 'centreon';"
mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED WITH mysql_native_password BY 'centreon';"
else
echo "########################### Start MariaDB ######################################"
if [ "$distrib" = "ALMALINUX" ]; then
mysql_install_db --user=root --basedir=/usr --datadir=/var/lib/mysql
mariadbd --socket=/var/lib/mysql/mysql.sock --user=root > /dev/null 2>&1 &
else
mkdir -p /run/mysqld
chown mysql:mysql /run/mysqld
mariadbd --socket=/run/mysqld/mysqld.sock --user=root > /dev/null 2>&1 &
fi
sleep 5

echo "########################### Init centreon database ############################"

mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED BY 'centreon';"
mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED BY 'centreon';"
fi

mysql -e "GRANT SELECT,UPDATE,DELETE,INSERT,CREATE,DROP,INDEX,ALTER,LOCK TABLES,CREATE TEMPORARY TABLES, EVENT,CREATE VIEW ON *.* TO 'centreon'@'localhost';"
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root_centreon'@'localhost'"

cat resources/centreon.sql | sed "s/DBNameConf/centreon/g" > /tmp/centreon.sql

mysql -u root_centreon -pcentreon < resources/centreon_storage.sql
mysql -u root_centreon -pcentreon < /tmp/centreon.sql

#remove git dubious ownership
git config --global --add safe.directory $PWD

echo "########################### Install Robot Framework ###########################"
cd tests
pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil

if [ "$distrib" = "ALMALINUX" ]; then
dnf groupinstall -y "Development Tools"
dnf install -y python3-devel
else
apt-get update
apt-get install -y build-essential
apt-get install -y python3-dev
fi

pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3

echo "########################## Install centreon collect ###########################"
cd ..
echo "Installation..."
if [ "$distrib" = "ALMALINUX" ]; then
dnf clean all
Expand All @@ -103,9 +53,13 @@ else
apt-get install -y ./*.deb
fi


ulimit -c unlimited
echo '/tmp/core.%p' > /proc/sys/kernel/core_pattern

#remove git dubious ownership
/usr/bin/git config --global --add safe.directory $PWD

echo "##### Starting tests #####"
cd tests
./init-proto.sh
Expand Down
Loading

5 comments on commit e273f3d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
2 1 0 3 66.67

Failed Tests

Name Message ⏱️ Duration Suite
EBNSGU2 We should get 12 relations between the servicegroup 1 and services. 41.218 s Servicegroups

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
3 2 0 5 60.00

Failed Tests

Name Message ⏱️ Duration Suite
BRGC1 There should not exist que map files. 61.535 s Reverse-Connection
BRCTS1 Connection to map has failed 203.086 s Reverse-Connection

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
2 1 0 3 66.67

Failed Tests

Name Message ⏱️ Duration Suite
EBNSGU2 We should get 12 relations between the servicegroup 1 and services. 41.211 s Servicegroups

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
4 1 0 5 80.00

Failed Tests

Name Message ⏱️ Duration Suite
BRRDUPLICATE RRD cbd did not receive metrics to rebuild START 55.696 s Rrd-From-Db

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
6 1 0 7 85.71

Failed Tests

Name Message ⏱️ Duration Suite
BENCH_1000STATUS_100ENGINE_2 AttributeError: 'NoneType' object has no attribute 'query_read_bytes' 107.823 s Bench

Please sign in to comment.