diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..007d46654cf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: java +cache: + directories: + - $HOME/.cache +jdk: +- oraclejdk7 +notifications: + email: false +env: +- TESTS="test_affinity_groups test_deploy_vms_with_varied_deploymentplanners test_disk_offerings test_global_settings test_guest_vlan_range test_iso test_multipleips_per_nic test_network test_non_contigiousvlan test_over_provisioning" +- TESTS="test_portable_publicip test_primary_storage test_privategw_acl test_public_ip_range test_pvlan test_regions test_reset_vm_on_reboot test_resource_detail test_routers" +- TESTS="test_secondary_storage test_service_offerings test_ssvm test_templates misc/test_deploy_vm test_vm_life_cycle test_volumes test_vpc_vpn" +before_install: travis_wait 30 ./tools/travis/before_install.sh +install: ./tools/travis/install.sh +before_script: travis_wait 30 ./tools/travis/before_script.sh +script: +- mkdir -p integration-test-results/misc +- travis_wait 30 sleep 30 +- for suite in $TESTS; do travis_wait 30 nosetests --with-xunit --xunit-file=integration-test-results/$suite.xml --with-marvin --marvin-config=setup/dev/advanced.cfg test/integration/smoke/$suite.py -s -a tags=advanced,required_hardware=false --zone=Sandbox-simulator --hypervisor=simulator ; done +- python ./tools/travis/xunit-reader.py integration-test-results/ +after_success: ./tools/travis/after_success.sh +after_failure: ./tools/travis/after_failure.sh +after_script: ./tools/travis/after_script.sh diff --git a/tools/travis/after_failure.sh b/tools/travis/after_failure.sh new file mode 100755 index 00000000000..d0ea01d731a --- /dev/null +++ b/tools/travis/after_failure.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# +# As the filename suggests, this is executed on build failure +# failure. +# + diff --git a/tools/travis/after_script.sh b/tools/travis/after_script.sh new file mode 100755 index 00000000000..721de641518 --- /dev/null +++ b/tools/travis/after_script.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# +# This script should run any tear down commands required. +# + +mvn -Dsimulator -pl client jetty:stop 2>&1 diff --git a/tools/travis/after_success.sh b/tools/travis/after_success.sh new file mode 100755 index 00000000000..5ca7ff02395 --- /dev/null +++ b/tools/travis/after_success.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# +# As the filename suggests this is executed on build success. +# diff --git a/tools/travis/before_install.sh b/tools/travis/before_install.sh new file mode 100755 index 00000000000..aff3e56305d --- /dev/null +++ b/tools/travis/before_install.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# This script should be used to install additional dependencies +# This includes: installing ubuntu packages, custom services +# or internet downloads. +# + +echo -e "#### System Information ####" + +echo -e "\nJava Version: " +javac -version + +echo -e "\nMaven Version: " +mvn -v + +echo -e "\nUpdating the system: " +sudo apt-get -q -y update > /dev/null + +echo -e "\nInstalling MySQL: " + +sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password' +sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password' +sudo apt-get -q -y install mysql-server > /dev/null + +sudo /etc/init.d/mysql start + +echo -e "\nInstalling Tomcat: " +wget -q -O tomcat.tar.gz http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.33/bin/apache-tomcat-6.0.33.tar.gz +sudo mkdir -p /opt/tomcat +sudo tar xfv tomcat.tar.gz -C /opt/tomcat --strip 1 > /dev/null + +echo -e "\nInstalling Development tools: " + +sudo apt-get -q -y install uuid-runtime genisoimage python-setuptools python-pip netcat > /dev/null + +echo " + + + Central + http://repo1.maven.org/maven2 + central + + + +" > ~/.m2/settings.xml + +echo -e "\nInstalling some python packages: " + +sudo pip install lxml > /dev/null +sudo pip install texttable > /dev/null diff --git a/tools/travis/before_script.sh b/tools/travis/before_script.sh new file mode 100755 index 00000000000..607ed1b723f --- /dev/null +++ b/tools/travis/before_script.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# This script should be used to bring up the environment. +# + +export CATALINA_BASE=/opt/tomcat +export CATALINA_HOME=/opt/tomcat +export M2_HOME="/usr/local/maven-3.2.1/" +export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=500m" + +mvn -Dsimulator -pl :cloud-client-ui jetty:run 2>&1 > /dev/null & + +while ! nc -vz localhost 8096 2>&1 > /dev/null; do sleep 10; done +python -m marvin.deployDataCenter -i setup/dev/advanced.cfg 2>&1 || true \ No newline at end of file diff --git a/tools/travis/install.sh b/tools/travis/install.sh new file mode 100755 index 00000000000..f8b22d43b83 --- /dev/null +++ b/tools/travis/install.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# This should be used to create the build. +# + +export CATALINA_BASE=/opt/tomcat +export CATALINA_HOME=/opt/tomcat +export M2_HOME="/usr/local/maven-3.2.1/" +export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=500m" + +# Compile Cloudstack +mvn -q -Pimpatient -Dsimulator clean install + +# Compile API Docs +cd tools/apidoc +mvn -q clean install +cd ../../ + +# Compile marvin +cd tools/marvin +mvn -q clean install +sudo python setup.py install 2>&1 > /dev/null +cd ../../ + +# Deploy the database +mvn -q -Pdeveloper -pl developer -Ddeploydb +mvn -q -Pdeveloper -pl developer -Ddeploydb-simulator \ No newline at end of file diff --git a/tools/travis/script.sh b/tools/travis/script.sh new file mode 100755 index 00000000000..72b9ee20a23 --- /dev/null +++ b/tools/travis/script.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# +# This script should be responsible for bring up the +# test environment and executing the tests. +# \ No newline at end of file diff --git a/tools/travis/xunit-reader.py b/tools/travis/xunit-reader.py new file mode 100755 index 00000000000..8cf8fe8b33e --- /dev/null +++ b/tools/travis/xunit-reader.py @@ -0,0 +1,85 @@ +# !/usr/bin/env python +# encoding: utf-8 + +""" +This script provides parsing of xunit xml files. + +""" + +import os +import argparse + +import texttable + +import lxml.etree + + +def main(): + """ + Entry point for the parser + + """ + + args = _generate_args() + file_path_list = _generate_file_list(args) + + exit(parse_reports(file_path_list)) + + +def _generate_args(): + parser = argparse.ArgumentParser( + description='Command line utility for reading xunit xml files' + ) + + parser.add_argument( + 'path', + metavar='/path/to/folder/containing/xunit-reports', + type=str, + help='A path to a folder containing xunit reports' + ) + + args = parser.parse_args() + + return vars(args) + + +def _generate_file_list(args): + path = args.pop('path') + file_path_list = [] + for (root, dirnames, filenames) in os.walk(path): + for filename in filenames: + if filename.endswith('.xml'): + file_path_list.append(os.path.join(root, filename)) + + return file_path_list + + +def parse_reports(file_path_list): + table = texttable.Texttable() + table.header(['Test', 'Result']) + + exit_code = 0 + + for file_path in file_path_list: + data = lxml.etree.iterparse(file_path, tag='testcase') + for event, elem in data: + name = '' + status = 'Success' + if 'name' in elem.attrib: + name = elem.attrib['name'] + for children in elem.getchildren(): + if 'skipped' == children.tag: + status = 'Skipped' + elif 'failure' == children.tag: + exit_code = 1 + status = 'Failure' + + table.add_row([name, status]) + + print table.draw() + + return exit_code + + +if __name__ == "__main__": + main() \ No newline at end of file