Merge "Move to using devstack-gate for this job"
[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 # Save existing WORKSPACE
20 SAVED_WORKSPACE=$WORKSPACE
21 export WORKSPACE=~/workspace
22 mkdir -p $WORKSPACE
23 cd $WORKSPACE
24
25 # This is the job which checks out devstack-gate
26 if [[ ! -e devstack-gate ]]; then
27     echo "Cloning devstack-gate"
28     git clone https://git.openstack.org/openstack-infra/devstack-gate
29 else
30     echo "Fixing devstack-gate git remotes"
31     cd devstack-gate
32     git remote set-url origin https://git.openstack.org/openstack-infra/devstack-gate
33     git remote update
34     git reset --hard
35     if ! git clean -x -f ; then
36         sleep 1
37         git clean -x -f
38     fi
39     git checkout master
40     git reset --hard remotes/origin/master
41     if ! git clean -x -f ; then
42         sleep 1
43         git clean -x -f
44     fi
45     cd ..
46 fi
47
48 # Set the pieces we want to test
49 if [ "$GERRIT_PROJECT" == "openstack/neutron" ]; then
50     ZUUL_PROJECT=$GERRIT_PROJECT
51     ZUUL_BRANCH=$GERRIT_REFSPEC
52 elif [ "$GERRIT_PROJECT" == "openstack-dev/devstack" ]; then
53     ZUUL_PROJECT=$GERRIT_PROJECT
54     ZUUL_BRANCH=$GERRIT_REFSPEC
55 fi
56
57 echo "Setting environment variables"
58 # And this runs devstack-gate
59 export PYTHONUNBUFFERED=true
60 export DEVSTACK_GATE_TIMEOUT=120
61 export DEVSTACK_GATE_NEUTRON=1
62 export DEVSTACK_GATE_TEMPEST=1
63 export BRANCH_OVERRIDE=master
64 if [ "$BRANCH_OVERRIDE" != "default" ] ; then
65     export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
66 fi
67 # Because we are testing a non standard project, add
68 # our project repository. This makes zuul do the right
69 # reference magic for testing changes.
70 export PROJECTS="stackforge/networking-odl $PROJECTS"
71 # Note the actual url here is somewhat irrelevant because it
72 # caches in nodepool, however make it a valid url for
73 # documentation purposes.
74 if [ "$GERRIT_PROJECT" == "stackforge/networking-odl" ]; then
75     export DEVSTACK_LOCAL_CONFIG="enable_plugin networking-odl https://$GERRIT_HOST/$GERRIT_PROJECT $GERRIT_REFSPEC"
76 else
77     export DEVSTACK_LOCAL_CONFIG="enable_plugin networking-odl https://git.openstack.org/stackforge/networking-odl"
78 fi
79
80
81 # Keep localrc to be able to set some vars in pre_test_hook
82 export KEEP_LOCALRC=1
83
84 # Unset this because it's set by the underlying Jenkins node ...
85 unset GIT_BASE
86
87 # Only run certain tempest tests
88 export DEVSTACK_GATE_TEMPEST_REGEX="tempest.api.network.test_networks \
89                                     tempest.api.network.test_networks_negative"
90
91 # Specifically set the services we want
92 #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
93
94 # Enable ODL debug logs and set memory parameters
95 export ODL_NETVIRT_DEBUG_LOGS=True
96 export ODL_JAVA_MIN_MEM=512m
97 export ODL_JAVA_MAX_MEM=784m
98 export ODL_JAVA_MAX_PERM_MEM=784m
99
100 # Trim down the boot wait time
101 export ODL_BOOT_WAIT=30
102
103 echo "Copying devstack-vm-gate-wrap.sh"
104 cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
105 echo "Running safe-devstack-vm-gate-wrap.sh"
106 ./safe-devstack-vm-gate-wrap.sh
107 # Save the return value so we can exit with this
108 DGRET=$?
109
110 # Restore WORKSPACE
111 OS_WORKSPACE=$WORKSPACE
112 export WORKSPACE=$SAVED_WORKSPACE
113
114 # Copy all the logs
115 cp -r $OS_WORKSPACE/logs $WORKSPACE
116 cp -a /opt/stack/new/logs/q-odl-karaf* $WORKSPACE/logs
117 mkdir -p $WORKSPACE/logs/opendaylight
118 cp -a /opt/stack/new/opendaylight/distribution*/etc $WORKSPACE/logs/opendaylight
119 # Unzip the logs to make them easier to view
120 gunzip $WORKSPACE/logs/*.gz
121
122 exit $DGRET