Skip to content

Commit 26069aa

Browse files
committed
[CLOUDSTACK-6115] Investigate the use of TravisCI for CloudStack integration testing
1 parent 615c070 commit 26069aa

9 files changed

Lines changed: 220 additions & 0 deletions

File tree

.travis.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
language: java
2+
cache:
3+
directories:
4+
- $HOME/.cache
5+
jdk:
6+
- oraclejdk7
7+
notifications:
8+
email: false
9+
env:
10+
- 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"
11+
- 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"
12+
- TESTS="test_secondary_storage test_service_offerings test_ssvm test_templates misc/test_deploy_vm test_vm_life_cycle test_volumes test_vpc_vpn"
13+
before_install: travis_wait 30 ./tools/travis/before_install.sh
14+
install: ./tools/travis/install.sh
15+
before_script: travis_wait 30 ./tools/travis/before_script.sh
16+
script:
17+
- mkdir -p integration-test-results/misc
18+
- travis_wait 30 sleep 30
19+
- 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
20+
- python ./tools/travis/xunit-reader.py integration-test-results/
21+
after_success: ./tools/travis/after_success.sh
22+
after_failure: ./tools/travis/after_failure.sh
23+
after_script: ./tools/travis/after_script.sh

tools/travis/after_failure.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
#
3+
# As the filename suggests, this is executed on build failure
4+
# failure.
5+
#
6+

tools/travis/after_script.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
#
3+
# This script should run any tear down commands required.
4+
#
5+
6+
mvn -Dsimulator -pl client jetty:stop 2>&1

tools/travis/after_success.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
#
3+
# As the filename suggests this is executed on build success.
4+
#

tools/travis/before_install.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
#
3+
# This script should be used to install additional dependencies
4+
# This includes: installing ubuntu packages, custom services
5+
# or internet downloads.
6+
#
7+
8+
echo -e "#### System Information ####"
9+
10+
echo -e "\nJava Version: "
11+
javac -version
12+
13+
echo -e "\nMaven Version: "
14+
mvn -v
15+
16+
echo -e "\nUpdating the system: "
17+
sudo apt-get -q -y update > /dev/null
18+
19+
echo -e "\nInstalling MySQL: "
20+
21+
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
22+
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
23+
sudo apt-get -q -y install mysql-server > /dev/null
24+
25+
sudo /etc/init.d/mysql start
26+
27+
echo -e "\nInstalling Tomcat: "
28+
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
29+
sudo mkdir -p /opt/tomcat
30+
sudo tar xfv tomcat.tar.gz -C /opt/tomcat --strip 1 > /dev/null
31+
32+
echo -e "\nInstalling Development tools: "
33+
34+
sudo apt-get -q -y install uuid-runtime genisoimage python-setuptools python-pip netcat > /dev/null
35+
36+
echo "<settings>
37+
<mirrors>
38+
<mirror>
39+
<id>Central</id>
40+
<url>http://repo1.maven.org/maven2</url>
41+
<mirrorOf>central</mirrorOf>
42+
<!-- United States, St. Louis-->
43+
</mirror>
44+
</mirrors>
45+
</settings>" > ~/.m2/settings.xml
46+
47+
echo -e "\nInstalling some python packages: "
48+
49+
sudo pip install lxml > /dev/null
50+
sudo pip install texttable > /dev/null

tools/travis/before_script.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
#
3+
# This script should be used to bring up the environment.
4+
#
5+
6+
export CATALINA_BASE=/opt/tomcat
7+
export CATALINA_HOME=/opt/tomcat
8+
export M2_HOME="/usr/local/maven-3.2.1/"
9+
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=500m"
10+
11+
mvn -Dsimulator -pl :cloud-client-ui jetty:run 2>&1 > /dev/null &
12+
13+
while ! nc -vz localhost 8096 2>&1 > /dev/null; do sleep 10; done
14+
python -m marvin.deployDataCenter -i setup/dev/advanced.cfg 2>&1 || true

tools/travis/install.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
#
3+
# This should be used to create the build.
4+
#
5+
6+
export CATALINA_BASE=/opt/tomcat
7+
export CATALINA_HOME=/opt/tomcat
8+
export M2_HOME="/usr/local/maven-3.2.1/"
9+
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=500m"
10+
11+
# Compile Cloudstack
12+
mvn -q -Pimpatient -Dsimulator clean install
13+
14+
# Compile API Docs
15+
cd tools/apidoc
16+
mvn -q clean install
17+
cd ../../
18+
19+
# Compile marvin
20+
cd tools/marvin
21+
mvn -q clean install
22+
sudo python setup.py install 2>&1 > /dev/null
23+
cd ../../
24+
25+
# Deploy the database
26+
mvn -q -Pdeveloper -pl developer -Ddeploydb
27+
mvn -q -Pdeveloper -pl developer -Ddeploydb-simulator

tools/travis/script.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
#
3+
# This script should be responsible for bring up the
4+
# test environment and executing the tests.
5+
#

tools/travis/xunit-reader.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# !/usr/bin/env python
2+
# encoding: utf-8
3+
4+
"""
5+
This script provides parsing of xunit xml files.
6+
7+
"""
8+
9+
import os
10+
import argparse
11+
12+
import texttable
13+
14+
import lxml.etree
15+
16+
17+
def main():
18+
"""
19+
Entry point for the parser
20+
21+
"""
22+
23+
args = _generate_args()
24+
file_path_list = _generate_file_list(args)
25+
26+
exit(parse_reports(file_path_list))
27+
28+
29+
def _generate_args():
30+
parser = argparse.ArgumentParser(
31+
description='Command line utility for reading xunit xml files'
32+
)
33+
34+
parser.add_argument(
35+
'path',
36+
metavar='/path/to/folder/containing/xunit-reports',
37+
type=str,
38+
help='A path to a folder containing xunit reports'
39+
)
40+
41+
args = parser.parse_args()
42+
43+
return vars(args)
44+
45+
46+
def _generate_file_list(args):
47+
path = args.pop('path')
48+
file_path_list = []
49+
for (root, dirnames, filenames) in os.walk(path):
50+
for filename in filenames:
51+
if filename.endswith('.xml'):
52+
file_path_list.append(os.path.join(root, filename))
53+
54+
return file_path_list
55+
56+
57+
def parse_reports(file_path_list):
58+
table = texttable.Texttable()
59+
table.header(['Test', 'Result'])
60+
61+
exit_code = 0
62+
63+
for file_path in file_path_list:
64+
data = lxml.etree.iterparse(file_path, tag='testcase')
65+
for event, elem in data:
66+
name = ''
67+
status = 'Success'
68+
if 'name' in elem.attrib:
69+
name = elem.attrib['name']
70+
for children in elem.getchildren():
71+
if 'skipped' == children.tag:
72+
status = 'Skipped'
73+
elif 'failure' == children.tag:
74+
exit_code = 1
75+
status = 'Failure'
76+
77+
table.add_row([name, status])
78+
79+
print table.draw()
80+
81+
return exit_code
82+
83+
84+
if __name__ == "__main__":
85+
main()

0 commit comments

Comments
 (0)