2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB, Huawei Technologies Co.,Ltd 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 ##############################################################################
11 # Set up the environment to run yardstick test suites.
15 UCA_HOST="cloud-images.ubuntu.com"
16 if [ $YARD_IMG_ARCH = "arm64" ]; then
17 export VIVID_IMG_URL="http://${UCA_HOST}/vivid/current/vivid-server-cloudimg-arm64.tar.gz"
18 if ! grep -q "Defaults env_keep += \"VIVID_IMG_URL\"" "/etc/sudoers"; then
19 sudo echo "Defaults env_keep += \"VIVID_IMG_URL\"" >> /etc/sudoers
23 build_yardstick_image()
26 echo "========== Build yardstick cloud image =========="
28 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
29 local cmd="sudo $(which yardstick-img-lxd-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
31 # Build the image. Retry once if the build fails
34 if [ ! -f $RAW_IMAGE ]; then
35 echo "Failed building RAW image"
39 local cmd="sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
41 # Build the image. Retry once if the build fails
44 if [ ! -f $QCOW_IMAGE ]; then
45 echo "Failed building QCOW image"
51 load_yardstick_image()
54 echo "========== Loading yardstick cloud image =========="
56 if [ $YARD_IMG_ARCH = "arm64" ]; then
57 VIVID_IMAGE="/tmp/vivid-server-cloudimg-arm64.tar.gz"
58 VIVID_KERNEL="/tmp/vivid-server-cloudimg-arm64-vmlinuz-generic"
60 if [ ! -f $VIVID_IMAGE ]; then
63 if [ ! -f $VIVID_KERNEL ]; then
64 tar zxf $VIVID_IMAGE $(basename $VIVID_KERNEL)
66 create_vivid_kernel=$(glance --os-image-api-version 1 image-create \
67 --name yardstick-vivid-kernel \
68 --is-public true --disk-format qcow2 \
69 --container-format bare \
72 GLANCE_KERNEL_ID=$(echo "$create_vivid_kernel" | grep " id " | awk '{print $(NF-1)}')
73 if [ -z "$GLANCE_KERNEL_ID" ]; then
74 echo 'Failed uploading kernel to cloud'.
78 command_line="root=/dev/vdb1 console=tty0 console=ttyS0 console=ttyAMA0 rw"
80 EXTRA_PARAMS="--property kernel_id=$GLANCE_KERNEL_ID --property os_command_line=\"$command_line\""
82 rm -f $VIVID_KERNEL $VIVID_IMAGE
83 cd $YARDSTICK_REPO_DIR
86 # VPP requires guest memory to be backed by large pages
87 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
88 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
91 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
92 output=$(eval glance --os-image-api-version 1 image-create \
93 --name yardstick-trusty-server \
94 --is-public true --disk-format root-tar \
95 --container-format bare \
99 output=$(eval glance --os-image-api-version 1 image-create \
100 --name yardstick-trusty-server \
101 --is-public true --disk-format qcow2 \
102 --container-format bare \
109 GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
111 if [ -z "$GLANCE_IMAGE_ID" ]; then
112 echo 'Failed uploading image to cloud'.
116 if [ "$DEPLOY_SCENARIO" == *"-lxd-"* ]; then
117 sudo rm -f $RAW_IMAGE
119 sudo rm -f $QCOW_IMAGE
122 echo "Glance image id: $GLANCE_IMAGE_ID"
128 echo "========== Loading cirros cloud image =========="
130 local image_file=/home/opnfv/images/cirros-0.3.3-x86_64-disk.img
133 # VPP requires guest memory to be backed by large pages
134 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
135 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
138 output=$(glance image-create \
139 --name cirros-0.3.3 \
140 --disk-format qcow2 \
141 --container-format bare \
146 CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
147 if [ -z "$CIRROS_IMAGE_ID" ]; then
148 echo 'Failed uploading cirros image to cloud'.
152 echo "Cirros image id: $CIRROS_IMAGE_ID"
158 echo "========== Loading ubuntu cloud image =========="
160 local ubuntu_image_file=/home/opnfv/images/trusty-server-cloudimg-amd64-disk1.img
163 # VPP requires guest memory to be backed by large pages
164 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
165 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
168 output=$(glance image-create \
169 --name Ubuntu-14.04 \
170 --disk-format qcow2 \
171 --container-format bare \
173 --file $ubuntu_image_file)
176 UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
178 if [ -z "$UBUNTU_IMAGE_ID" ]; then
179 echo 'Failed uploading UBUNTU image to cloud'.
183 echo "Ubuntu image id: $UBUNTU_IMAGE_ID"
188 if ! nova flavor-list | grep -q yardstick-flavor; then
190 echo "========== Create nova flavor =========="
191 # Create the nova flavor used by some sample test cases
192 nova flavor-create yardstick-flavor 100 512 3 1
193 # DPDK-enabled OVS requires guest memory to be backed by large pages
194 if [[ "$DEPLOY_SCENARIO" == *"-ovs-"* ]]; then
195 nova flavor-key yardstick-flavor set hw:mem_page_size=large
197 # VPP requires guest memory to be backed by large pages
198 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
199 nova flavor-key yardstick-flavor set hw:mem_page_size=large
206 QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-trusty-server.img"
207 RAW_IMAGE="/tmp/workspace/yardstick/yardstick-trusty-server.tar.gz"
209 build_yardstick_image
211 if [ $YARD_IMG_ARCH = "arm64" ]; then
212 sed -i 's/image: cirros-0.3.3/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml \
214 #We have overlapping IP with the real network
215 for filename in tests/opnfv/test_cases/*; do
216 sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" $filename