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.
19 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
24 if ! grep -q "Defaults env_keep += \"YARD_IMG_ARCH\"" "/etc/sudoers"; then
25 echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" | sudo tee -a /etc/sudoers
28 ARCH_SCRIPT="test -f /etc/fuel_openstack_arch && grep -q arm64 /etc/fuel_openstack_arch"
29 if [ "$INSTALLER_TYPE" == "fuel" ]; then
30 sshpass -p r00tme ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root "${INSTALLER_IP}" "${ARCH_SCRIPT}" && YARD_IMG_ARCH=arm64
33 UCA_HOST="cloud-images.ubuntu.com"
34 if [ "${YARD_IMG_ARCH}"= "arm64" ]; then
35 export CLOUD_IMG_URL="http://${UCA_HOST}/${release}/current/${release}-server-cloudimg-${YARD_IMG_ARCH}.tar.gz"
36 if ! grep -q "Defaults env_keep += \"CLOUD_IMG_URL\"" "/etc/sudoers"; then
37 echo "Defaults env_keep += \"CLOUD_IMG_URL\"" | sudo tee -a /etc/sudoers
41 build_yardstick_image()
44 echo "========== Build yardstick cloud image =========="
46 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
48 cmd="sudo $(which yardstick-img-lxd-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
50 # Build the image. Retry once if the build fails
53 if [ ! -f "${RAW_IMAGE}" ]; then
54 echo "Failed building RAW image"
59 cmd="sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
61 # Build the image. Retry once if the build fails
64 if [ ! -f "${QCOW_IMAGE}" ]; then
65 echo "Failed building QCOW image"
71 load_yardstick_image()
74 echo "========== Loading yardstick cloud image =========="
76 if [[ "${YARD_IMG_ARCH}" == "arm64" && "${YARD_IMG_AKI}" == "true" ]]; then
77 CLOUD_IMAGE="/tmp/${release}-server-cloudimg-${YARD_IMG_ARCH}.tar.gz"
78 CLOUD_KERNEL="/tmp/${release}-server-cloudimg-${YARD_IMG_ARCH}-vmlinuz-generic"
80 if [ ! -f "${CLOUD_IMAGE}" ]; then
81 wget "${CLOUD_IMG_URL}"
83 if [ ! -f "${CLOUD_KERNEL}" ]; then
84 tar xf "${CLOUD_IMAGE}" "${CLOUD_KERNEL##**/}"
86 create_kernel=$(openstack image create \
89 --container-format bare \
90 --file ${CLOUD_KERNEL} \
91 yardstick-${release}-kernel)
93 GLANCE_KERNEL_ID=$(echo "$create_kernel" | awk '/ id / {print $(NF-1)}')
94 if [ -z "$GLANCE_KERNEL_ID" ]; then
95 echo 'Failed uploading kernel to cloud'.
99 command_line="root=/dev/vdb1 console=tty0 console=ttyS0 console=ttyAMA0 rw"
101 EXTRA_PARAMS="--property kernel_id=$GLANCE_KERNEL_ID --property os_command_line=\"$command_line\""
103 rm -f -- "${CLOUD_KERNEL}" "${CLOUD_IMAGE}"
104 cd "${YARDSTICK_REPO_DIR}"
107 # VPP requires guest memory to be backed by large pages
108 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
109 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
112 if [[ -n "${HW_FW_TYPE}" ]]; then
113 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_firmware_type=${HW_FW_TYPE}"
116 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
117 output=$(eval openstack image create \
119 --disk-format root-tar \
120 --container-format bare \
122 --file ${RAW_IMAGE} \
125 output=$(eval openstack image create \
127 --disk-format qcow2 \
128 --container-format bare \
130 --file ${QCOW_IMAGE} \
136 GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
138 if [ -z "$GLANCE_IMAGE_ID" ]; then
139 echo 'Failed uploading image to cloud'.
143 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
144 sudo rm -f -- "${RAW_IMAGE}"
146 sudo rm -f -- "${QCOW_IMAGE}"
149 echo "Glance image id: $GLANCE_IMAGE_ID"
155 echo "========== Loading cirros cloud image =========="
157 local image_file=/home/opnfv/images/cirros-0.3.3-x86_64-disk.img
160 # VPP requires guest memory to be backed by large pages
161 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
162 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
165 output=$(openstack image create \
166 --disk-format qcow2 \
167 --container-format bare \
169 --file ${image_file} \
173 CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
174 if [ -z "$CIRROS_IMAGE_ID" ]; then
175 echo 'Failed uploading cirros image to cloud'.
179 echo "Cirros image id: $CIRROS_IMAGE_ID"
185 echo "========== Loading ubuntu cloud image =========="
187 local ubuntu_image_file=/home/opnfv/images/trusty-server-cloudimg-amd64-disk1.img
190 # VPP requires guest memory to be backed by large pages
191 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
192 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
195 output=$(openstack image create \
196 --disk-format qcow2 \
197 --container-format bare \
199 --file $ubuntu_image_file \
203 UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
205 if [ -z "$UBUNTU_IMAGE_ID" ]; then
206 echo 'Failed uploading UBUNTU image to cloud'.
210 echo "Ubuntu image id: $UBUNTU_IMAGE_ID"
215 if ! openstack flavor list | grep -q yardstick-flavor; then
217 echo "========== Create nova flavor =========="
218 # Create the nova flavor used by some sample test cases
219 openstack flavor create --id 100 --ram 512 --disk 3 --vcpus 1 yardstick-flavor
220 # DPDK-enabled OVS requires guest memory to be backed by large pages
221 if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
222 openstack flavor set --property hw:mem_page_size=large yardstick-flavor
224 # VPP requires guest memory to be backed by large pages
225 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
226 openstack flavor set --property hw:mem_page_size=large yardstick-flavor
233 QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img"
234 RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz"
236 build_yardstick_image
238 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
239 sed -i 's/image: cirros-0.3.3/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml \
241 #We have overlapping IP with the real network
242 for filename in tests/opnfv/test_cases/*; do
243 sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" "${filename}"