From 350d5702e30ee416e3e7052c3c59b1a4e34c8ff5 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 28 Jan 2022 13:38:52 +0100 Subject: [PATCH] test-legacy --- .gitlab-ci.yml | 2 +- tests/test_legacy.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100755 tests/test_legacy.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c389f23b51..202a060749 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,4 +12,4 @@ test_php_legacy: - df -h | grep instaladores | awk '{print $NF}' |xargs umount >/dev/null 2>&1 || true script: - docker pull pandorafms/pandorafms-base:centos7 - - docker run --rm -h pandorafms -t -v "$CI_PROJECT_DIR:/tmp/pandorafms" pandorafms/pandorafms-base:centos7 /tmp/pandorafms/tests/test.sh + - docker run --rm -h pandorafms -t -v "$CI_PROJECT_DIR:/tmp/pandorafms" pandorafms/pandorafms-base:centos7 /tmp/pandorafms/tests/test_legacy.sh diff --git a/tests/test_legacy.sh b/tests/test_legacy.sh new file mode 100755 index 0000000000..cffa8d1c36 --- /dev/null +++ b/tests/test_legacy.sh @@ -0,0 +1,64 @@ +#!/bin/bash +SOURCE_DIR="/tmp/pandorafms" + +################################################ +# Check the exit status of the last run command. +# Exits if it different from 0. +################################################ +function check { + MESSAGE=$1 + RC=$2 + if [ $RC == 0 ]; then + echo ">$MESSAGE... [OK]" + else + echo ">$MESSAGE... [ERR $RC]" + exit 1 + fi +} + +# Start the required services. +service mysqld start && /usr/bin/mysqladmin -u root password 'pandora' +check "Starting the MySQL Server" $? +service httpd start +check "Starting the Apache Web Server" $? + +# Install the Pandora FMS Console. +cd /tmp/pandorafms/pandora_console && chmod +x pandora_console_install && yes | ./pandora_console_install --install +check "Installing the Pandora FMS Console" $? + +# Create the Pandora FMS database. +cd /tmp/pandorafms/tests && chmod +x install_console.py && ./install_console.py +check "Creating the Pandora FMS Database" $? + +# Build and install the Pandora FMS Server. +cd /tmp/pandorafms/pandora_server && perl Makefile.PL && make # Do not run make test now. Some tests need files created by pandora_server_installer. +check "Building the Pandora FMS Server" $? +cd /tmp/pandorafms/pandora_server && chmod +x pandora_server_installer && ./pandora_server_installer --install +check "Installing the Pandora FMS Server" $? +sed -i -e 's/^dbuser.*/dbuser root/' /etc/pandora/pandora_server.conf +cd /tmp/pandorafms/pandora_server && make test +check "Running tests for the Pandora FMS Server" $? + +# Install the Pandora FMS Agent. +cd /tmp/pandorafms/pandora_agents/unix && chmod +x pandora_agent_installer && ./pandora_agent_installer --install +check "Installing the Pandora FMS Agent" $? + +# Start Pandora FMS services. +service tentacle_serverd start +check "Starting the Tentacle Server" $? +service pandora_server start +check "Starting the Pandora FMS Server" $? +service pandora_agent_daemon start +check "Starting the Pandora FMS Agent" $? + +# Disable the initial wizards. +echo "UPDATE tconfig SET value='1' WHERE token='initial_wizard'" | mysql -u root -ppandora -Dpandora +echo "UPDATE tconfig SET value='1' WHERE token='instance_registered'" | mysql -u root -ppandora -Dpandora +echo "INSERT INTO tconfig (token, value) VALUES ('skip_login_help_dialog', '1')" | mysql -u root -ppandora -Dpandora +echo "UPDATE tusuario SET middlename='1'" | mysql -u root -ppandora -Dpandora + +# Run console tests. +#cd /tmp/pandorafms/tests && chmod +x run_console_tests.py && ./run_console_tests.py +#check "Running tests for the Pandora FMS Console" $? + +exit 0