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=$(openstack image create \
81 --container-format bare \
82 --file $VIVID_KERNEL \
83 yardstick-vivid-kernel)
85 GLANCE_KERNEL_ID=$(echo "$create_vivid_kernel" | grep " id " | awk '{print $(NF-1)}')
86 if [ -z "$GLANCE_KERNEL_ID" ]; then
87 echo 'Failed uploading kernel to cloud'.
91 command_line="root=/dev/vdb1 console=tty0 console=ttyS0 console=ttyAMA0 rw"
93 EXTRA_PARAMS="--property kernel_id=$GLANCE_KERNEL_ID --property os_command_line=\"$command_line\""
95 rm -f $VIVID_KERNEL $VIVID_IMAGE
96 cd $YARDSTICK_REPO_DIR
99 # VPP requires guest memory to be backed by large pages
100 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
101 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
104 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
105 output=$(eval openstack image create \
107 --disk-format root-tar \
108 --container-format bare \
113 output=$(eval openstack image create \
115 --disk-format qcow2 \
116 --container-format bare \
124 GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
126 if [ -z "$GLANCE_IMAGE_ID" ]; then
127 echo 'Failed uploading image to cloud'.
131 if [ "$DEPLOY_SCENARIO" == *"-lxd-"* ]; then
132 sudo rm -f $RAW_IMAGE
134 sudo rm -f $QCOW_IMAGE
137 echo "Glance image id: $GLANCE_IMAGE_ID"
143 echo "========== Loading cirros cloud image =========="
145 local image_file=/home/opnfv/images/cirros-0.3.3-x86_64-disk.img
148 # VPP requires guest memory to be backed by large pages
149 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
150 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
153 output=$(openstack image create \
154 --disk-format qcow2 \
155 --container-format bare \
161 CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
162 if [ -z "$CIRROS_IMAGE_ID" ]; then
163 echo 'Failed uploading cirros image to cloud'.
167 echo "Cirros image id: $CIRROS_IMAGE_ID"
173 echo "========== Loading ubuntu cloud image =========="
175 local ubuntu_image_file=/home/opnfv/images/trusty-server-cloudimg-amd64-disk1.img
178 # VPP requires guest memory to be backed by large pages
179 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
180 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
183 output=$(openstack image create \
184 --disk-format qcow2 \
185 --container-format bare \
187 --file $ubuntu_image_file \
191 UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
193 if [ -z "$UBUNTU_IMAGE_ID" ]; then
194 echo 'Failed uploading UBUNTU image to cloud'.
198 echo "Ubuntu image id: $UBUNTU_IMAGE_ID"
203 if ! openstack flavor list | grep -q yardstick-flavor; then
205 echo "========== Create nova flavor =========="
206 # Create the nova flavor used by some sample test cases
207 openstack flavor create --id 100 --ram 512 --disk 3 --vcpus 1 yardstick-flavor
208 # DPDK-enabled OVS requires guest memory to be backed by large pages
209 if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
210 openstack flavor set --property hw:mem_page_size=large yardstick-flavor
212 # VPP requires guest memory to be backed by large pages
213 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
214 openstack flavor set --property hw:mem_page_size=large yardstick-flavor
221 QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img"
222 RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz"
224 build_yardstick_image
226 if [ $YARD_IMG_ARCH = "arm64" ]; then
227 sed -i 's/image: cirros-0.3.3/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml \
229 #We have overlapping IP with the real network
230 for filename in tests/opnfv/test_cases/*; do
231 sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" $filename