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.
18 if ! grep -q "Defaults env_keep += \"YARD_IMG_ARCH\"" "/etc/sudoers"; then
19 sudo echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" >> /etc/sudoers
22 ARCH_SCRIPT="test -f /etc/fuel_openstack_arch && grep -q arm64 /etc/fuel_openstack_arch"
23 if [ "$INSTALLER_TYPE" == "fuel" ]; then
24 sshpass -p r00tme ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root $INSTALLER_IP "${ARCH_SCRIPT}" && YARD_IMG_ARCH=arm64
27 UCA_HOST="cloud-images.ubuntu.com"
28 if [ $YARD_IMG_ARCH = "arm64" ]; then
29 export VIVID_IMG_URL="http://${UCA_HOST}/vivid/current/vivid-server-cloudimg-arm64.tar.gz"
30 if ! grep -q "Defaults env_keep += \"VIVID_IMG_URL\"" "/etc/sudoers"; then
31 sudo echo "Defaults env_keep += \"VIVID_IMG_URL\"" >> /etc/sudoers
35 build_yardstick_image()
38 echo "========== Build yardstick cloud image =========="
40 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
41 local cmd="sudo $(which yardstick-img-lxd-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
43 # Build the image. Retry once if the build fails
46 if [ ! -f $RAW_IMAGE ]; then
47 echo "Failed building RAW image"
51 local cmd="sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
53 # Build the image. Retry once if the build fails
56 if [ ! -f $QCOW_IMAGE ]; then
57 echo "Failed building QCOW image"
63 load_yardstick_image()
66 echo "========== Loading yardstick cloud image =========="
68 if [ $YARD_IMG_ARCH = "arm64" ]; then
69 VIVID_IMAGE="/tmp/vivid-server-cloudimg-arm64.tar.gz"
70 VIVID_KERNEL="/tmp/vivid-server-cloudimg-arm64-vmlinuz-generic"
72 if [ ! -f $VIVID_IMAGE ]; then
75 if [ ! -f $VIVID_KERNEL ]; then
76 tar zxf $VIVID_IMAGE $(basename $VIVID_KERNEL)
78 create_vivid_kernel=$(glance --os-image-api-version 1 image-create \
79 --name yardstick-vivid-kernel \
80 --is-public true --disk-format qcow2 \
81 --container-format bare \
84 GLANCE_KERNEL_ID=$(echo "$create_vivid_kernel" | grep " id " | awk '{print $(NF-1)}')
85 if [ -z "$GLANCE_KERNEL_ID" ]; then
86 echo 'Failed uploading kernel to cloud'.
90 command_line="root=/dev/vdb1 console=tty0 console=ttyS0 console=ttyAMA0 rw"
92 EXTRA_PARAMS="--property kernel_id=$GLANCE_KERNEL_ID --property os_command_line=\"$command_line\""
94 rm -f $VIVID_KERNEL $VIVID_IMAGE
95 cd $YARDSTICK_REPO_DIR
98 # VPP requires guest memory to be backed by large pages
99 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
100 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
103 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
104 output=$(eval glance --os-image-api-version 1 image-create \
105 --name yardstick-image \
106 --is-public true --disk-format root-tar \
107 --container-format bare \
111 output=$(eval glance --os-image-api-version 1 image-create \
112 --name yardstick-image \
113 --is-public true --disk-format qcow2 \
114 --container-format bare \
121 GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
123 if [ -z "$GLANCE_IMAGE_ID" ]; then
124 echo 'Failed uploading image to cloud'.
128 if [ "$DEPLOY_SCENARIO" == *"-lxd-"* ]; then
129 sudo rm -f $RAW_IMAGE
131 sudo rm -f $QCOW_IMAGE
134 echo "Glance image id: $GLANCE_IMAGE_ID"
140 echo "========== Loading cirros cloud image =========="
142 local image_file=/home/opnfv/images/cirros-0.3.3-x86_64-disk.img
145 # VPP requires guest memory to be backed by large pages
146 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
147 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
150 output=$(glance image-create \
151 --name cirros-0.3.3 \
152 --disk-format qcow2 \
153 --container-format bare \
158 CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
159 if [ -z "$CIRROS_IMAGE_ID" ]; then
160 echo 'Failed uploading cirros image to cloud'.
164 echo "Cirros image id: $CIRROS_IMAGE_ID"
170 echo "========== Loading ubuntu cloud image =========="
172 local ubuntu_image_file=/home/opnfv/images/trusty-server-cloudimg-amd64-disk1.img
175 # VPP requires guest memory to be backed by large pages
176 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
177 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
180 output=$(glance image-create \
181 --name Ubuntu-14.04 \
182 --disk-format qcow2 \
183 --container-format bare \
185 --file $ubuntu_image_file)
188 UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
190 if [ -z "$UBUNTU_IMAGE_ID" ]; then
191 echo 'Failed uploading UBUNTU image to cloud'.
195 echo "Ubuntu image id: $UBUNTU_IMAGE_ID"
200 if ! nova flavor-list | grep -q yardstick-flavor; then
202 echo "========== Create nova flavor =========="
203 # Create the nova flavor used by some sample test cases
204 nova flavor-create yardstick-flavor 100 512 3 1
205 # DPDK-enabled OVS requires guest memory to be backed by large pages
206 if [[ "$DEPLOY_SCENARIO" == *"-ovs-"* ]]; then
207 nova flavor-key yardstick-flavor set hw:mem_page_size=large
209 # VPP requires guest memory to be backed by large pages
210 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
211 nova flavor-key yardstick-flavor set hw:mem_page_size=large
218 QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img"
219 RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz"
221 build_yardstick_image
223 if [ $YARD_IMG_ARCH = "arm64" ]; then
224 sed -i 's/image: cirros-0.3.3/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml \
226 #We have overlapping IP with the real network
227 for filename in tests/opnfv/test_cases/*; do
228 sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" $filename