2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
14 QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-trusty-server.img"
19 echo "========== Cleanup =========="
21 if ! glance image-list; then
25 for image in $(glance image-list | grep -e cirros-0.3.3 -e yardstick-trusty-server | awk '{print $2}'); do
26 echo "Deleting image $image..."
27 glance image-delete $image || true
37 if [ -z "$exitcode" ]; then
38 # In case of recursive traps (!?)
44 echo "Exiting with RC=$exitcode"
55 echo "========== Installing yardstick =========="
57 if ! sudo python setup.py install; then
58 echo 'Yardstick installation failed!'
63 build_yardstick_image()
66 echo "========== Build yardstick cloud image =========="
68 sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh
69 if [ ! -f $QCOW_IMAGE ]; then
70 echo "Failed building QCOW image"
78 echo "========== Loading cirros cloud image =========="
82 wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img -O /tmp/cirros.img
84 output=$(glance image-create \
87 --container-format bare \
88 --file /tmp/cirros.img)
91 CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
92 if [ -z "$CIRROS_IMAGE_ID" ]; then
93 echo 'Failed uploading cirros image to cloud'.
97 echo "Cirros image id: $CIRROS_IMAGE_ID"
100 load_yardstick_image()
103 echo "========== Loading yardstick cloud image =========="
105 output=$(glance --os-image-api-version 1 image-create \
106 --name yardstick-trusty-server \
107 --is-public true --disk-format qcow2 \
108 --container-format bare \
112 GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
114 if [ -z "$GLANCE_IMAGE_ID" ]; then
115 echo 'Failed uploading image to cloud'.
119 sudo rm -f $QCOW_IMAGE
121 echo "Glance image id: $GLANCE_IMAGE_ID"
127 echo "========== Running yardstick test suite =========="
129 # Just run sample ping for now.
130 if ! yardstick -d task start samples/ping.yaml; then
131 echo "Yardstick test FAILED"
138 GITROOT=$(cd $(dirname $0) && git rev-parse --show-toplevel)
145 # check if some necessary variables is set
146 if [ -z "$OS_AUTH_URL" ]; then
147 echo "OS_AUTH_URL is unset or empty"
152 ip=$(echo $OS_AUTH_URL | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
154 ## FIXME: temporarily disabling this because
155 ## of timeout errors on LF-POD2.
156 ## Maybe we need a longer timeout ??
157 # check if the auth port is open
158 # echo "Checking if tcp port $ip:5000 is open..."
159 # nc -zv -w 10 $ip 5000; rc=$?;
160 # if [ $rc -eq 0 ]; then
161 # echo "$ip:5000 is open for tcp connections"
163 # echo "$ip:5000 is closed"
167 # check if the api is up
168 echo "Checking if OS API is working..."
169 if ! glance image-list > /dev/null; then
170 echo "OS API is down"
176 trap "error_exit" EXIT SIGTERM
178 build_yardstick_image