Update automated project templates
[releng/builder.git] / jjb / ovsdb / include-raw-openstack-ci.sh
1 #!/bin/bash
2 #
3 # NOTE: This file takes two jobs from the OpenStack infra and
4 #       puts them here. See here:
5 #
6 # https://github.com/openstack-infra/project-config/blob/master/jenkins/jobs/networking-odl.yaml
7
8 export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
9
10 # *SIGH*. This is required to get lsb_release
11 sudo yum -y install redhat-lsb-core indent python-testrepository
12
13 echo "Making /opt/stack/new jenkins:jenkins"
14 sudo /usr/sbin/groupadd jenkins
15 sudo mkdir -p /opt/stack/new
16 sudo chown -R jenkins:jenkins /opt/stack/new
17 sudo bash -c 'echo "stack ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers'
18
19 # We need to install some scripts from openstack-infra/project-config
20 cd ~
21 echo "Setting up infra scripts"
22 sudo mkdir -p /usr/local/jenkins/slave_scripts
23 git clone https://git.openstack.org/openstack-infra/project-config
24 cd project-config
25 sudo cp jenkins/scripts/subunit2html.py /usr/local/jenkins/slave_scripts
26
27 # Save existing WORKSPACE
28 SAVED_WORKSPACE=$WORKSPACE
29 export WORKSPACE=~/workspace
30 mkdir -p $WORKSPACE
31 cd $WORKSPACE
32
33 # This is the job which checks out devstack-gate
34 if [[ ! -e devstack-gate ]]; then
35     echo "Cloning devstack-gate"
36     git clone https://git.openstack.org/openstack-infra/devstack-gate
37 else
38     echo "Fixing devstack-gate git remotes"
39     cd devstack-gate
40     git remote set-url origin https://git.openstack.org/openstack-infra/devstack-gate
41     git remote update
42     git reset --hard
43     if ! git clean -x -f ; then
44         sleep 1
45         git clean -x -f
46     fi
47     git checkout master
48     git reset --hard remotes/origin/master
49     if ! git clean -x -f ; then
50         sleep 1
51         git clean -x -f
52     fi
53     cd ..
54 fi
55
56 # Set the pieces we want to test
57 if [ "$GERRIT_PROJECT" == "openstack/neutron" ]; then
58     ZUUL_PROJECT=$GERRIT_PROJECT
59     ZUUL_BRANCH=$GERRIT_REFSPEC
60 elif [ "$GERRIT_PROJECT" == "openstack-dev/devstack" ]; then
61     ZUUL_PROJECT=$GERRIT_PROJECT
62     ZUUL_BRANCH=$GERRIT_REFSPEC
63 fi
64
65 echo "Setting environment variables"
66
67 # Enable ODL debug logs and set memory parameters
68 DEVSTACK_LOCAL_CONFIG=""
69 DEVSTACK_LOCAL_CONFIG+="ODL_NETVIRT_DEBUG_LOGS=True;"
70 DEVSTACK_LOCAL_CONFIG+="ODL_JAVA_MIN_MEM=512m;"
71 DEVSTACK_LOCAL_CONFIG+="ODL_JAVA_MAX_MEM=784m;"
72 DEVSTACK_LOCAL_CONFIG+="ODL_JAVA_MAX_PERM_MEM=784m;"
73
74 # Set ODL_URL_PREFIX if "nexus proxy" is provided
75 URL_PREFIX=${ODLNEXUSPROXY:-https://nexus.opendaylight.org}
76 if [ -n "$ODLNEXUSPROXY" ] ; then
77     DEVSTACK_LOCAL_CONFIG+="ODL_URL_PREFIX=$ODLNEXUSPROXY;"
78 fi
79
80 ## # Trim down the boot wait time
81 ## export ODL_BOOT_WAIT=30
82
83 # Use Lithium build, if asked to do so
84 if [ "${ODL_VERSION}" == "lithium-latest" ] ; then
85     NEXUSPATH="${URL_PREFIX}/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-karaf"
86     BUNDLEVERSION='0.3.0-SNAPSHOT'
87
88     # Acquire the timestamp information from maven-metadata.xml
89     wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
90     BUNDLE_TIMESTAMP=`xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null`
91     echo "Nexus timestamp is ${BUNDLE_TIMESTAMP}"
92
93     DEVSTACK_LOCAL_CONFIG+="ODL_NAME=distribution-karaf-${BUNDLEVERSION};"
94     DEVSTACK_LOCAL_CONFIG+="ODL_PKG=distribution-karaf-${BUNDLE_TIMESTAMP}.zip;"
95     DEVSTACK_LOCAL_CONFIG+="ODL_URL=${NEXUSPATH}/${BUNDLEVERSION};"
96 fi
97
98 # And this runs devstack-gate
99 export PYTHONUNBUFFERED=true
100 export DEVSTACK_GATE_TIMEOUT=120
101 export DEVSTACK_GATE_NEUTRON=1
102 export DEVSTACK_GATE_TEMPEST=1
103 export BRANCH_OVERRIDE=master
104 if [ "$BRANCH_OVERRIDE" != "default" ] ; then
105     export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
106 fi
107 # Because we are testing a non standard project, add
108 # our project repository. This makes zuul do the right
109 # reference magic for testing changes.
110 export PROJECTS="stackforge/networking-odl $PROJECTS"
111 # Note the actual url here is somewhat irrelevant because it
112 # caches in nodepool, however make it a valid url for
113 # documentation purposes.
114 if [ "$GERRIT_PROJECT" == "stackforge/networking-odl" ]; then
115     export DEVSTACK_LOCAL_CONFIG+="enable_plugin networking-odl https://$GERRIT_HOST/$GERRIT_PROJECT $GERRIT_REFSPEC"
116 else
117     export DEVSTACK_LOCAL_CONFIG+="enable_plugin networking-odl https://git.openstack.org/stackforge/networking-odl"
118 fi
119
120
121 # Keep localrc to be able to set some vars in pre_test_hook
122 export KEEP_LOCALRC=1
123
124 # Unset this because it's set by the underlying Jenkins node ...
125 unset GIT_BASE
126
127 # By default, only run certain tempest tests
128 export DEVSTACK_GATE_TEMPEST_REGEX=${TEMPEST_REGEX:-"tempest.api.network.test_networks_negative tempest.api.network.test_networks.NetworksTestJSON"}
129
130 # Specifically set the services we want
131 #OVERRIDE_ENABLED_SERVICES=q-svc,q-dhcp,q-l3,q-meta,quantum,key,g-api,g-reg,n-api,n-crt,n-obj,n-cpu,n-cond,n-sch,n-xvnc,n-cauth,h-eng,h-api,h-api-cfn,h-api-cw,rabbit,tempest,mysql
132
133 echo "Copying devstack-vm-gate-wrap.sh"
134 cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
135 echo "Running safe-devstack-vm-gate-wrap.sh"
136 ./safe-devstack-vm-gate-wrap.sh
137 # Save the return value so we can exit with this
138 DGRET=$?
139
140 # Restore WORKSPACE
141 OS_WORKSPACE=$WORKSPACE
142 export WORKSPACE=$SAVED_WORKSPACE
143
144 # Copy all the logs
145 cp -r $OS_WORKSPACE/logs $WORKSPACE
146 cp -a /opt/stack/new/logs/q-odl-karaf* $WORKSPACE/logs
147 mkdir -p $WORKSPACE/logs/opendaylight
148 cp -a /opt/stack/new/opendaylight/distribution*/etc $WORKSPACE/logs/opendaylight
149 # Unzip the logs to make them easier to view
150 gunzip $WORKSPACE/logs/*.gz
151
152 exit $DGRET