Playing with Travis CI.

This commit is contained in:
Ramon Novoa 2016-05-19 16:27:41 +02:00
parent c7737c14d6
commit 35fcc9cd46
4 changed files with 189 additions and 0 deletions

8
.travis.yml Normal file
View File

@ -0,0 +1,8 @@
sudo: required
services:
- docker
before_install:
- docker build -t pandorafms/ci "$TRAVIS_BUILD_DIR/tests/"
- docker run --rm -v "$TRAVIS_BUILD_DIR:/tmp/pandorafms" pandorafms/ci /tmp/pandorafms/tests/test.sh

95
tests/Dockerfile Normal file
View File

@ -0,0 +1,95 @@
FROM centos:centos6
MAINTAINER Pandora FMS Team <info@pandorafms.com>
RUN { \
echo '[EPEL]'; \
echo 'name = CentOS Epel'; \
echo 'baseurl = http://dl.fedoraproject.org/pub/epel/6/x86_64'; \
echo 'enabled=1'; \
echo 'gpgcheck=0'; \
} > /etc/yum.repos.d/extra_repos.repo
RUN { \
echo '[artica_pandorafms]'; \
echo 'name=CentOS6 - PandoraFMS official repo'; \
echo 'baseurl=http://artica.es/centos6'; \
echo 'gpgcheck=0'; \
echo 'enabled=1'; \
} > /etc/yum.repos.d/pandorafms.repo
RUN yum -y update; yum clean all;
# Generic dependencies
RUN yum install -y \
firefox
python-pip
xorg-x11-server-Xvfb
RUN pip install pyvirtualdisplay
RUN pip install selenium
# Pandora FMS Console dependencies
RUN yum install -y \
git \
httpd \
cronie \
ntp \
openldap \
anytermd \
nfdump \
wget \
curl \
openldap \
plymouth \
xterm \
php \
php-gd \
graphviz \
php-mysql \
php-pear-DB \
php-pear \
php-pdo \
php-mbstring \
php-ldap \
php-snmp \
php-ldap \
php-common \
php-zip \
nmap \
xprobe2 \
mysql-server \
mysql
# Pandora FMS Server dependencies
RUN yum install -y \
git \
cronie \
ntp \
wget \
curl \
xterm \
postfix \
wmic \
perl-HTML-Tree \
perl-DBI \
perl-DBD-mysql \
perl-libwww-perl \
perl-XML-Simple \
perl-XML-SAX \
perl-NetAddr-IP \
net-snmp \
net-tools \
perl-IO-Socket-INET6 \
perl-Socket6 \
nmap \
sudo \
xprobe2 \
make \
perl-CPAN \
perl-JSON \
net-snmp-perl \
perl-Time-HiRes \
perl-XML-Twig \
perl-Encode-Locale \
net-snmp \
net-snmp-utils

36
tests/install_console.py Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python
# Script to install the Pandora FMS Console.
import os
from pyvirtualdisplay import Display
from selenium import webdriver
# Are we running headless?
if ('DISPLAY' not in os.environ):
display = Display(visible=0, size=(800, 600))
display.start()
# Go to the installation page.
browser = webdriver.Firefox()
browser.implicitly_wait(5)
browser.get('http://localhost/pandora_console/install.php')
assert("Pandora FMS - Installation Wizard" in browser.title)
# Accept the license agreement.
browser.find_element_by_xpath("//*[@id='step11']/img").click()
browser.find_element_by_xpath("//*[@id='install_box']/form/div/input").click()
# Fill-in the configuration form.
browser.find_element_by_xpath("//*[@id='step3']/img").click()
browser.find_element_by_name("pass").send_keys("pandora")
browser.find_element_by_id("step4").click()
# Complete the installation.
browser.implicitly_wait(300) # The installation is going to take a long time.
browser.find_element_by_xpath("//*[@id='step5']/img").click()
browser.implicitly_wait(5)
assert("Installation complete" in browser.page_source)
# Clean-up
browser.quit()
if ('DISPLAY' not in os.environ):
display.stop()

50
tests/test.sh Executable file
View File

@ -0,0 +1,50 @@
#!/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
}
# 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 && make test
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" $?
# 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 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" $?
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" $?
exit 0