Browse code

Merge pull request #170 from cloudbuilders/ci-tests

Add CI tests

sleepsonthefloor authored on 2011/11/15 09:12:33
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+pika
... ...
@@ -39,6 +39,10 @@ OPENSTACKX_BRANCH=diablo
39 39
 QUANTUM_REPO=https://github.com/openstack/quantum
40 40
 QUANTUM_BRANCH=stable/diablo
41 41
 
42
+# CI test suite
43
+CITEST_REPO=https://github.com/openstack/openstack-integration-tests.git
44
+CITEST_BRANCH=master
45
+
42 46
 # Specify a comma-separated list of uec images to download and install into glance.
43 47
 IMAGE_URLS=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz
44 48
 
45 49
new file mode 100755
... ...
@@ -0,0 +1,144 @@
0
+#!/usr/bin/env bash
1
+#
2
+# build_ci_config.sh - Build a config.ini for openstack-integration-tests
3
+#                      (https://github.com/openstack/openstack-integration-tests)
4
+
5
+function usage {
6
+    echo "$0 - Build config.ini for openstack-integration-tests"
7
+    echo ""
8
+    echo "Usage: $0 configfile"
9
+    exit 1
10
+}
11
+
12
+if [ ! "$#" -eq "1" ]; then
13
+    usage
14
+fi
15
+
16
+CONFIG_FILE=$1
17
+
18
+# Clean up any resources that may be in use
19
+cleanup() {
20
+    set +o errexit
21
+
22
+    # Mop up temporary files
23
+    if [ -n "$CONFIG_FILE_TMP" -a -e "$CONFIG_FILE_TMP" ]; then
24
+        rm -f $CONFIG_FILE_TMP
25
+    fi
26
+
27
+    # Kill ourselves to signal any calling process
28
+    trap 2; kill -2 $$
29
+}
30
+
31
+trap cleanup SIGHUP SIGINT SIGTERM
32
+
33
+# Keep track of the current directory
34
+TOOLS_DIR=$(cd $(dirname "$0") && pwd)
35
+TOP_DIR=`cd $TOOLS_DIR/..; pwd`
36
+
37
+# Abort if localrc is not set
38
+if [ ! -e $TOP_DIR/localrc ]; then
39
+    echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding."
40
+    echo "See stack.sh for required passwords."
41
+    exit 1
42
+fi
43
+
44
+# Source params
45
+source ./stackrc
46
+
47
+# Where Openstack code lives
48
+DEST=${DEST:-/opt/stack}
49
+
50
+DIST_NAME=${DIST_NAME:-oneiric}
51
+
52
+# Process network configuration vars
53
+GUEST_NETWORK=${GUEST_NETWORK:-1}
54
+GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
55
+
56
+GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
57
+GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
58
+GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
59
+GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
60
+GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
61
+GUEST_RAM=${GUEST_RAM:-1524288}
62
+GUEST_CORES=${GUEST_CORES:-1}
63
+
64
+# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
65
+HOST_IP=${HOST_IP:-$GUEST_IP}
66
+# Use the first IP if HOST_IP still is not set
67
+if [ ! -n "$HOST_IP" ]; then
68
+    HOST_IP=`LC_ALL=C /sbin/ifconfig  | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
69
+fi
70
+
71
+RABBIT_HOST=${RABBIT_HOST:-localhost}
72
+
73
+# Glance connection info.  Note the port must be specified.
74
+GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
75
+set `echo $GLANCE_HOSTPORT | tr ':' ' '`
76
+GLANCE_HOST=$1
77
+GLANCE_PORT=$2
78
+
79
+CONFIG_FILE_TMP=$(mktemp $CONFIG_FILE.XXXXXX)
80
+if [ "$UPLOAD_LEGACY_TTY" ]; then
81
+    cat >$CONFIG_FILE_TMP <<EOF
82
+[environment]
83
+aki_location = $DEST/devstack/files/images/aki-tty/image
84
+ari_location = $DEST/devstack/files/images/ari-tty/image
85
+ami_location = $DEST/devstack/files/images/ami-tty/image
86
+image_ref = 1
87
+flavor_ref = 1
88
+EOF
89
+else
90
+    cat >$CONFIG_FILE_TMP <<EOF
91
+[environment]
92
+aki_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-vmlinuz-virtual
93
+#ari_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-loader
94
+ami_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64.img
95
+image_ref = 1
96
+flavor_ref = 1
97
+EOF
98
+fi
99
+
100
+cat >>$CONFIG_FILE_TMP <<EOF
101
+[glance]
102
+host = $GLANCE_HOST
103
+apiver = v1
104
+port = $GLANCE_PORT
105
+image_id = 1
106
+tenant_id = 1
107
+
108
+[keystone]
109
+service_host = $HOST_IP
110
+service_port = 5000
111
+apiver = v2.0
112
+user = admin
113
+password = $ADMIN_PASSWORD
114
+tenant_id = 1
115
+
116
+[nova]
117
+host = $HOST_IP
118
+port = 8774
119
+apiver = v1.1
120
+project = admin
121
+user = admin
122
+key = $ADMIN_PASSWORD
123
+ssh_timeout = 300
124
+build_timeout = 300
125
+flavor_ref = 1
126
+flavor_ref_alt = 2
127
+
128
+[rabbitmq]
129
+host = $RABBIT_HOST
130
+user = guest
131
+password = $RABBIT_PASSWORD
132
+
133
+[swift]
134
+auth_host = $HOST_IP
135
+auth_port = 443
136
+auth_prefix = /auth/
137
+auth_ssl = yes
138
+account = system
139
+username = root
140
+password = password
141
+
142
+EOF
143
+mv $CONFIG_FILE_TMP $CONFIG_FILE
... ...
@@ -17,6 +17,11 @@ cleanup() {
17 17
     set +o errexit
18 18
     unmount_images
19 19
 
20
+    if [ -n "$COPY_DIR" ]; then
21
+        umount $COPY_DIR/dev
22
+        umount $COPY_DIR
23
+    fi
24
+
20 25
     if [ -n "$ROOTFS" ]; then
21 26
         umount $ROOTFS/dev
22 27
         umount $ROOTFS
... ...
@@ -31,7 +36,7 @@ cleanup() {
31 31
     trap 2; kill -2 $$
32 32
 }
33 33
 
34
-trap cleanup SIGHUP SIGINT SIGTERM
34
+trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
35 35
 
36 36
 # Echo commands
37 37
 set -o xtrace
... ...
@@ -127,6 +132,7 @@ DEST=${DEST:-/opt/stack}
127 127
 # Mount the file system
128 128
 # For some reason, UEC-based images want 255 heads * 63 sectors * 512 byte sectors = 8225280
129 129
 mount -t ext4 -o loop,offset=8225280 $VM_IMAGE $COPY_DIR
130
+mount -o bind /dev $COPY_DIR/dev
130 131
 
131 132
 # git clone only if directory doesn't exist already.  Since ``DEST`` might not
132 133
 # be owned by the installation user, we create the directory and change the
... ...
@@ -149,6 +155,8 @@ chroot $COPY_DIR apt-get install -y --download-only `cat files/apts/* | grep NOP
149 149
 chroot $COPY_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1`
150 150
 chroot $COPY_DIR pip install `cat files/pips/*`
151 151
 
152
+umount $COPY_DIR/dev
153
+
152 154
 # Clean out code repos if directed to do so
153 155
 if [ "$CLEAN" = "1" ]; then
154 156
     rm -rf $COPY_DIR/$DEST
... ...
@@ -165,6 +173,18 @@ git_clone $NOVACLIENT_REPO $COPY_DIR/$DEST/python-novaclient $NOVACLIENT_BRANCH
165 165
 git_clone $OPENSTACKX_REPO $COPY_DIR/$DEST/openstackx $OPENSTACKX_BRANCH
166 166
 git_clone $KEYSTONE_REPO $COPY_DIR/$DEST/keystone $KEYSTONE_BRANCH
167 167
 git_clone $NOVNC_REPO $COPY_DIR/$DEST/noVNC $NOVNC_BRANCH
168
+git_clone $CITEST_REPO $COPY_DIR/$DEST/openstack-integration-tests $CITEST_BRANCH
169
+
170
+if [ -z "$UPLOAD_LEGACY_TTY" =; then
171
+    # Pre-load an image for testing
172
+    UEC_NAME=$DIST_NAME-server-cloudimg-amd64
173
+    CIVMDIR=${COPY_DIR}${DEST}/openstack-integration-tests/include/sample_vm
174
+    if [ ! -e $CIVMDIR/$UEC_NAME.tar.gz ]; then
175
+        mkdir -p $CIVMDIR
176
+        (cd $CIVMDIR && wget -N http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME.tar.gz;
177
+            tar xzf $UEC_NAME.tar.gz;)
178
+    fi
179
+fi
168 180
 
169 181
 # Back to devstack
170 182
 cd $TOP_DIR
... ...
@@ -403,18 +423,20 @@ echo 'GRUB_DISABLE_OS_PROBER=true' >>$ROOTFS/etc/default/grub
403 403
 echo "GRUB_DEVICE_UUID=$G_DEV_UUID" >>$ROOTFS/etc/default/grub
404 404
 
405 405
 chroot $ROOTFS update-grub
406
-umount $ROOTFS/dev
407 406
 
408 407
 # Pre-generate ssh host keys and allow password login
409 408
 chroot $ROOTFS dpkg-reconfigure openssh-server
410 409
 sed -e 's/^PasswordAuthentication.*$/PasswordAuthentication yes/' -i $ROOTFS/etc/ssh/sshd_config
411 410
 
412 411
 # Unmount
412
+umount $ROOTFS/dev
413 413
 umount $ROOTFS || echo 'ok'
414 414
 ROOTFS=""
415 415
 qemu-nbd -d $NBD
416 416
 NBD=""
417 417
 
418
+trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT
419
+
418 420
 # Create the instance
419 421
 cd $VM_DIR && virsh create libvirt.xml
420 422