9ed1cd2881609e33cb7f70859d87c274056387f9
[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
59 # Enable ODL debug logs and set memory parameters
60 DEVSTACK_LOCAL_CONFIG=""
61 DEVSTACK_LOCAL_CONFIG+="ODL_NETVIRT_DEBUG_LOGS=True;"
62 DEVSTACK_LOCAL_CONFIG+="ODL_JAVA_MIN_MEM=512m;"
63 DEVSTACK_LOCAL_CONFIG+="ODL_JAVA_MAX_MEM=784m;"
64 DEVSTACK_LOCAL_CONFIG+="ODL_JAVA_MAX_PERM_MEM=784m;"
65
66 # And this runs devstack-gate
67 export PYTHONUNBUFFERED=true
68 export DEVSTACK_GATE_TIMEOUT=120
69 export DEVSTACK_GATE_NEUTRON=1
70 export DEVSTACK_GATE_TEMPEST=1
71 export BRANCH_OVERRIDE=master
72 if [ "$BRANCH_OVERRIDE" != "default" ] ; then
73     export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
74 fi
75 # Because we are testing a non standard project, add
76 # our project repository. This makes zuul do the right
77 # reference magic for testing changes.
78 export PROJECTS="stackforge/networking-odl $PROJECTS"
79 # Note the actual url here is somewhat irrelevant because it
80 # caches in nodepool, however make it a valid url for
81 # documentation purposes.
82 if [ "$GERRIT_PROJECT" == "stackforge/networking-odl" ]; then
83     export DEVSTACK_LOCAL_CONFIG+="enable_plugin networking-odl https://$GERRIT_HOST/$GERRIT_PROJECT $GERRIT_REFSPEC"
84 else
85     export DEVSTACK_LOCAL_CONFIG+="enable_plugin networking-odl https://git.openstack.org/stackforge/networking-odl"
86 fi
87
88
89 # Keep localrc to be able to set some vars in pre_test_hook
90 export KEEP_LOCALRC=1
91
92 # Unset this because it's set by the underlying Jenkins node ...
93 unset GIT_BASE
94
95 # Only run certain tempest tests
96 export DEVSTACK_GATE_TEMPEST_REGEX="tempest.api.network.test_networks.NetworksIpV6TestJSON \
97                                     tempest.api.network.test_networks.NetworksTestJSON \
98                                     tempest.api.network.test_networks_negative"
99
100 # Specifically set the services we want
101 #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
102
103 # Trim down the boot wait time
104 export ODL_BOOT_WAIT=30
105
106 echo "Copying devstack-vm-gate-wrap.sh"
107 cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
108 echo "Running safe-devstack-vm-gate-wrap.sh"
109 ./safe-devstack-vm-gate-wrap.sh
110 # Save the return value so we can exit with this
111 DGRET=$?
112
113 # Restore WORKSPACE
114 OS_WORKSPACE=$WORKSPACE
115 export WORKSPACE=$SAVED_WORKSPACE
116
117 # Copy all the logs
118 cp -r $OS_WORKSPACE/logs $WORKSPACE
119 cp -a /opt/stack/new/logs/q-odl-karaf* $WORKSPACE/logs
120 mkdir -p $WORKSPACE/logs/opendaylight
121 cp -a /opt/stack/new/opendaylight/distribution*/etc $WORKSPACE/logs/opendaylight
122 # Unzip the logs to make them easier to view
123 gunzip $WORKSPACE/logs/*.gz
124
125 exit $DGRET