Skip to content

Commit 5179a3e

Browse files
Merge pull request #170 from cloudbuilders/ci-tests
Add CI tests
2 parents 147913f + af95a47 commit 5179a3e

File tree

4 files changed

+173
-2
lines changed

4 files changed

+173
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pika

stackrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ OPENSTACKX_BRANCH=diablo
3939
QUANTUM_REPO=https://github.com/openstack/quantum
4040
QUANTUM_BRANCH=stable/diablo
4141

42+
# CI test suite
43+
CITEST_REPO=https://github.com/openstack/openstack-integration-tests.git
44+
CITEST_BRANCH=master
45+
4246
# Specify a comma-separated list of uec images to download and install into glance.
4347
IMAGE_URLS=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz
4448

tools/build_ci_config.sh

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/usr/bin/env bash
2+
#
3+
# build_ci_config.sh - Build a config.ini for openstack-integration-tests
4+
# (https://github.com/openstack/openstack-integration-tests)
5+
6+
function usage {
7+
echo "$0 - Build config.ini for openstack-integration-tests"
8+
echo ""
9+
echo "Usage: $0 configfile"
10+
exit 1
11+
}
12+
13+
if [ ! "$#" -eq "1" ]; then
14+
usage
15+
fi
16+
17+
CONFIG_FILE=$1
18+
19+
# Clean up any resources that may be in use
20+
cleanup() {
21+
set +o errexit
22+
23+
# Mop up temporary files
24+
if [ -n "$CONFIG_FILE_TMP" -a -e "$CONFIG_FILE_TMP" ]; then
25+
rm -f $CONFIG_FILE_TMP
26+
fi
27+
28+
# Kill ourselves to signal any calling process
29+
trap 2; kill -2 $$
30+
}
31+
32+
trap cleanup SIGHUP SIGINT SIGTERM
33+
34+
# Keep track of the current directory
35+
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
36+
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
37+
38+
# Abort if localrc is not set
39+
if [ ! -e $TOP_DIR/localrc ]; then
40+
echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding."
41+
echo "See stack.sh for required passwords."
42+
exit 1
43+
fi
44+
45+
# Source params
46+
source ./stackrc
47+
48+
# Where Openstack code lives
49+
DEST=${DEST:-/opt/stack}
50+
51+
DIST_NAME=${DIST_NAME:-oneiric}
52+
53+
# Process network configuration vars
54+
GUEST_NETWORK=${GUEST_NETWORK:-1}
55+
GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
56+
57+
GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
58+
GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
59+
GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
60+
GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
61+
GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
62+
GUEST_RAM=${GUEST_RAM:-1524288}
63+
GUEST_CORES=${GUEST_CORES:-1}
64+
65+
# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
66+
HOST_IP=${HOST_IP:-$GUEST_IP}
67+
# Use the first IP if HOST_IP still is not set
68+
if [ ! -n "$HOST_IP" ]; then
69+
HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
70+
fi
71+
72+
RABBIT_HOST=${RABBIT_HOST:-localhost}
73+
74+
# Glance connection info. Note the port must be specified.
75+
GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
76+
set `echo $GLANCE_HOSTPORT | tr ':' ' '`
77+
GLANCE_HOST=$1
78+
GLANCE_PORT=$2
79+
80+
CONFIG_FILE_TMP=$(mktemp $CONFIG_FILE.XXXXXX)
81+
if [ "$UPLOAD_LEGACY_TTY" ]; then
82+
cat >$CONFIG_FILE_TMP <<EOF
83+
[environment]
84+
aki_location = $DEST/devstack/files/images/aki-tty/image
85+
ari_location = $DEST/devstack/files/images/ari-tty/image
86+
ami_location = $DEST/devstack/files/images/ami-tty/image
87+
image_ref = 1
88+
flavor_ref = 1
89+
EOF
90+
else
91+
cat >$CONFIG_FILE_TMP <<EOF
92+
[environment]
93+
aki_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-vmlinuz-virtual
94+
#ari_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-loader
95+
ami_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64.img
96+
image_ref = 1
97+
flavor_ref = 1
98+
EOF
99+
fi
100+
101+
cat >>$CONFIG_FILE_TMP <<EOF
102+
[glance]
103+
host = $GLANCE_HOST
104+
apiver = v1
105+
port = $GLANCE_PORT
106+
image_id = 1
107+
tenant_id = 1
108+
109+
[keystone]
110+
service_host = $HOST_IP
111+
service_port = 5000
112+
apiver = v2.0
113+
user = admin
114+
password = $ADMIN_PASSWORD
115+
tenant_id = 1
116+
117+
[nova]
118+
host = $HOST_IP
119+
port = 8774
120+
apiver = v1.1
121+
project = admin
122+
user = admin
123+
key = $ADMIN_PASSWORD
124+
ssh_timeout = 300
125+
build_timeout = 300
126+
flavor_ref = 1
127+
flavor_ref_alt = 2
128+
129+
[rabbitmq]
130+
host = $RABBIT_HOST
131+
user = guest
132+
password = $RABBIT_PASSWORD
133+
134+
[swift]
135+
auth_host = $HOST_IP
136+
auth_port = 443
137+
auth_prefix = /auth/
138+
auth_ssl = yes
139+
account = system
140+
username = root
141+
password = password
142+
143+
EOF
144+
mv $CONFIG_FILE_TMP $CONFIG_FILE

tools/build_libvirt.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ cleanup() {
1717
set +o errexit
1818
unmount_images
1919

20+
if [ -n "$COPY_DIR" ]; then
21+
umount $COPY_DIR/dev
22+
umount $COPY_DIR
23+
fi
24+
2025
if [ -n "$ROOTFS" ]; then
2126
umount $ROOTFS/dev
2227
umount $ROOTFS
@@ -31,7 +36,7 @@ cleanup() {
3136
trap 2; kill -2 $$
3237
}
3338

34-
trap cleanup SIGHUP SIGINT SIGTERM
39+
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
3540

3641
# Echo commands
3742
set -o xtrace
@@ -127,6 +132,7 @@ DEST=${DEST:-/opt/stack}
127132
# Mount the file system
128133
# For some reason, UEC-based images want 255 heads * 63 sectors * 512 byte sectors = 8225280
129134
mount -t ext4 -o loop,offset=8225280 $VM_IMAGE $COPY_DIR
135+
mount -o bind /dev $COPY_DIR/dev
130136

131137
# git clone only if directory doesn't exist already. Since ``DEST`` might not
132138
# 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
149155
chroot $COPY_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1`
150156
chroot $COPY_DIR pip install `cat files/pips/*`
151157

158+
umount $COPY_DIR/dev
159+
152160
# Clean out code repos if directed to do so
153161
if [ "$CLEAN" = "1" ]; then
154162
rm -rf $COPY_DIR/$DEST
@@ -165,6 +173,18 @@ git_clone $NOVACLIENT_REPO $COPY_DIR/$DEST/python-novaclient $NOVACLIENT_BRANCH
165173
git_clone $OPENSTACKX_REPO $COPY_DIR/$DEST/openstackx $OPENSTACKX_BRANCH
166174
git_clone $KEYSTONE_REPO $COPY_DIR/$DEST/keystone $KEYSTONE_BRANCH
167175
git_clone $NOVNC_REPO $COPY_DIR/$DEST/noVNC $NOVNC_BRANCH
176+
git_clone $CITEST_REPO $COPY_DIR/$DEST/openstack-integration-tests $CITEST_BRANCH
177+
178+
if [ -z "$UPLOAD_LEGACY_TTY" =; then
179+
# Pre-load an image for testing
180+
UEC_NAME=$DIST_NAME-server-cloudimg-amd64
181+
CIVMDIR=${COPY_DIR}${DEST}/openstack-integration-tests/include/sample_vm
182+
if [ ! -e $CIVMDIR/$UEC_NAME.tar.gz ]; then
183+
mkdir -p $CIVMDIR
184+
(cd $CIVMDIR && wget -N http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME.tar.gz;
185+
tar xzf $UEC_NAME.tar.gz;)
186+
fi
187+
fi
168188

169189
# Back to devstack
170190
cd $TOP_DIR
@@ -403,18 +423,20 @@ echo 'GRUB_DISABLE_OS_PROBER=true' >>$ROOTFS/etc/default/grub
403423
echo "GRUB_DEVICE_UUID=$G_DEV_UUID" >>$ROOTFS/etc/default/grub
404424

405425
chroot $ROOTFS update-grub
406-
umount $ROOTFS/dev
407426

408427
# Pre-generate ssh host keys and allow password login
409428
chroot $ROOTFS dpkg-reconfigure openssh-server
410429
sed -e 's/^PasswordAuthentication.*$/PasswordAuthentication yes/' -i $ROOTFS/etc/ssh/sshd_config
411430

412431
# Unmount
432+
umount $ROOTFS/dev
413433
umount $ROOTFS || echo 'ok'
414434
ROOTFS=""
415435
qemu-nbd -d $NBD
416436
NBD=""
417437

438+
trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT
439+
418440
# Create the instance
419441
cd $VM_DIR && virsh create libvirt.xml
420442

0 commit comments

Comments
 (0)