Update automated project templates
[releng/builder.git] / jjb / ovsdb / include-raw-openstack-ci.sh
1 #!/bin/bash
2
3 export PATH=$PATH:/bin:/sbin:/usr/sbin
4 export DEVSTACKDIR=$WORKSPACE/$BUILD_TAG
5 mkdir -p $DEVSTACKDIR
6 cd $DEVSTACKDIR
7
8 cat <<EOL > firewall.sh
9 sudo iptables -I INPUT -p tcp --dport 5672 -j ACCEPT
10 sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT
11 sudo iptables -I INPUT -p tcp --dport 9292 -j ACCEPT
12 sudo iptables -I INPUT -p tcp --dport 9696 -j ACCEPT
13 sudo iptables -I INPUT -p tcp --dport 35357 -j ACCEPT
14 sudo iptables -I INPUT -p tcp --dport 6080 -j ACCEPT
15 sudo iptables -I INPUT -p tcp --dport 8773 -j ACCEPT
16 sudo iptables -I INPUT -p udp --dport 8472 -j ACCEPT
17 sudo iptables -I INPUT -p udp --dport 4789 -j ACCEPT
18
19 # For the client
20 sudo iptables -I INPUT -p tcp --dport 5000 -j ACCEPT
21 sudo iptables -I INPUT -p tcp --dport 8774 -j ACCEPT
22
23 # For ODL
24 sudo iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
25 EOL
26 chmod +x firewall.sh
27
28 env
29 cat $DEVSTACKDIR/firewall.sh
30 $DEVSTACKDIR/firewall.sh
31
32 # FIXME: update version of pip being used here
33 curl -O https://pypi.python.org/packages/source/p/pip/pip-6.0.8.tar.gz
34 tar xvfz pip-6.0.8.tar.gz
35 cd pip-6.0.8
36 sudo -E python setup.py install
37 sudo pip install testtools
38
39 sudo mkdir -p /opt/stack
40 sudo chown $(whoami) /opt/stack
41 sudo chmod 755 /opt/stack
42 cd /opt/stack
43
44 cd $DEVSTACKDIR
45
46 sudo yum -y install qemu libvirt-daemon
47 git clone https://github.com/openstack-dev/devstack.git
48 cd devstack
49
50 ####
51 # Specify changeset being worked on if it's networking-odl
52 ####
53 if [ "$GERRIT_PROJECT" == "stackforge/networking-odl" ]; then
54     cat <<EOLLC > local.conf
55 [[local|localrc]]
56 enable_plugin networking-odl https://$GERRIT_HOST/$GERRIT_PROJECT $GERRIT_REFSPEC
57 EOLLC
58 else
59     cat <<EOLLC > local.conf
60 [[local|localrc]]
61 enable_plugin networking-odl https://github.com/stackforge/networking-odl
62 EOLLC
63 fi
64
65 cat <<EOLLC >> local.conf
66 LOGFILE=stack.sh.log
67 SCREEN_LOGDIR=/opt/stack/data/log
68 VERBOSE=True
69 LOG_COLOR=False
70 RECLONE=yes
71 GIT_TIMEOUT=0
72 GIT_BASE=https://git.openstack.org
73
74 # The below is needed on Fedora/CentOS6
75 #disable_service rabbit
76 #enable_service qpid
77
78 disable_service swift
79 enable_service n-cpu
80 enable_service n-cond
81 disable_service n-net
82 enable_service q-svc
83 enable_service q-dhcp
84 enable_service q-l3
85 enable_service q-meta
86 enable_service quantum
87 enable_service tempest
88
89 API_RATE_LIMIT=False
90
91 Q_PLUGIN=ml2
92 Q_ML2_PLUGIN_MECHANISM_DRIVERS=logger,opendaylight
93 ENABLE_TENANT_TUNNELS=True
94
95 ODL_MODE=allinone
96 ODL_NETVIRT_DEBUG_LOGS=True
97 ODL_MGR_IP=$(ip addr | grep inet | grep eth0 | awk -F" " '{print $2}'| sed -e 's/\/.*$//')
98 ODL_ARGS="-Xmx1024m -XX:MaxPermSize=512m"
99 ODL_BOOT_WAIT=90
100
101 VNCSERVER_LISTEN=0.0.0.0
102
103 HOST_NAME=$(hostname)
104 SERVICE_HOST_NAME=$(hostname)
105 HOST_IP=$(ip addr | grep inet | grep eth0 | awk -F" " '{print $2}'| sed -e 's/\/.*$//')
106 SERVICE_HOST=$(hostname)
107
108 MYSQL_HOST=$(hostname)
109 RABBIT_HOST=$(hostname)
110 GLANCE_HOSTPORT=$(hostname):9292
111 KEYSTONE_AUTH_HOST=$(hostname)
112 KEYSTONE_SERVICE_HOST=$(hostname)
113
114 MYSQL_PASSWORD=mysql
115 RABBIT_PASSWORD=rabbit
116 #QPID_PASSWORD=rabbit
117 SERVICE_TOKEN=service
118 SERVICE_PASSWORD=admin
119 ADMIN_PASSWORD=admin
120 EOLLC
121
122 # Add Neutron specific config if required
123 if [ "$GERRIT_PROJECT" == "openstack/neutron" ]; then
124     cat <<EOLLC >> local.conf
125 NEUTRON_REPO=https://$GERRIT_HOST/$GERRIT_PROJECT
126 NEUTRON_BRANCH=$GERRIT_REFSPEC
127 EOLLC
128 fi
129
130 echo 'cat local.conf'
131 cat local.conf
132
133 ####
134 # Clone the changeset being worked on if it's devstack
135 ####
136 if [ "$GERRIT_PROJECT" == "openstack-dev/devstack" ]; then
137     git fetch https://$GERRIT_HOST/$GERRIT_PROJECT $GERRIT_REFSPEC && git checkout FETCH_HEAD
138 fi
139
140 # Run devstack
141 ./stack.sh
142
143 if [ "$?" != "0" ]; then
144     echo "stack.sh failed"
145     # Copy logs off
146     mkdir -p $WORKSPACE/logs/devstack
147     mkdir -p $WORKSPACE/logs/opendaylight
148     cp -r /opt/stack/data/log/* $WORKSPACE/logs/devstack
149     cp -r $DEVSTACKDIR/devstack/stack.sh.log* $WORKSPACE/logs
150     cp -r $DEVSTACKDIR/devstack/local.conf $WORKSPACE/logs
151     cp -r /opt/stack/opendaylight/*/logs $WORKSPACE/logs/opendaylight
152     cp -r /opt/stack/opendaylight/*/data/log $WORKSPACE/logs/opendaylight
153     cp -r /opt/stack/opendaylight/*/etc $WORKSPACE/logs/opendaylight
154     tar cvzf $WORKSPACE/opendaylight-full-logs.tgz $WORKSPACE/logs
155     exit 1
156 else
157     echo "stack.sh completed successfully"
158 fi
159
160 # running tempest
161 if [[ -n ${BUILD_ID} ]]; then
162     cd /opt/stack/tempest
163
164     # put all the info in the following file for processing later
165     log_for_review=odl_tempest_test_list.txt
166
167     echo "Running tempest tests:" > /tmp/${log_for_review}
168     echo "" >> /tmp/${log_for_review}
169     testr init > /dev/null 2>&1 || true
170     cmd_api="tempest.api.network.test_networks \
171              tempest.api.network.test_networks_negative \
172              tempest.api.network.test_ports tempest.api.network.test_routers"
173     cmd_net_basic="tempest.scenario.test_network_basic_ops"
174     cmd="testr run $cmd_api $cmd_net_basic"
175     echo "opendaylight-test:$ "${cmd}  >> /tmp/${log_for_review}
176     ${cmd} >> /tmp/${log_for_review}
177     echo "" >> /tmp/${log_for_review}
178     echo "" >> /tmp/${log_for_review}
179
180     x=$(grep "id=" /tmp/${log_for_review})
181     y="${x//[()=]/ }"
182     z=$(echo ${y} | awk '{print $3}' | sed 's/\,//g')
183
184     #echo "x ($x) y ($y) z ($z)"
185
186     echo "List of tempest tests ran (id="${z}"):" >> /tmp/${log_for_review}
187     echo "" >> /tmp/${log_for_review}
188
189     grep -ri successful   .testrepository/${z}  |  awk '{ gsub(/\[/, "\ ");  print $1 " " $2}' >> /tmp/${log_for_review}
190 fi
191
192
193 # Copy logs off
194 mkdir -p $WORKSPACE/logs/devstack
195 mkdir -p $WORKSPACE/logs/tempest
196 mkdir -p $WORKSPACE/logs/opendaylight
197 cp -r /opt/stack/tempest/tempest.log* $WORKSPACE/logs/tempest
198 cp -r /opt/stack/data/log/* $WORKSPACE/logs/devstack
199 cp -r /opt/stack/opendaylight/*/logs $WORKSPACE/logs/opendaylight
200 cp -r /opt/stack/opendaylight/*/data/log $WORKSPACE/logs/opendaylight
201 cp -r /opt/stack/opendaylight/*/etc $WORKSPACE/logs/opendaylight
202 cp -r /tmp/${log_for_review} $WORKSPACE/logs
203 cp -r /tmp/${log_for_review} $WORKSPACE
204 cp -r $DEVSTACKDIR/devstack/stack.sh.log* $WORKSPACE/logs
205 cp -r $DEVSTACKDIR/devstack/local.conf $WORKSPACE/logs
206 tar cvzf $WORKSPACE/opendaylight-full-logs.tgz $WORKSPACE/logs