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.
17 if ! grep -q "Defaults env_keep += \"YARD_IMG_ARCH\"" "/etc/sudoers"; then
18 echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" | sudo tee -a /etc/sudoers
21 # Look for a compute node, that is online, and check if it is aarch64
22 if [ "${INSTALLER_TYPE}" == 'fuel' ]; then
23 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
24 COMPUTE_ARCH=$(ssh -l ubuntu ${INSTALLER_IP} -i ${SSH_KEY} ${ssh_options} \
25 "sudo salt 'cmp*' grains.get cpuarch --out yaml | awk '{print \$2; exit}'")
26 if [ "${COMPUTE_ARCH}" == 'aarch64' ]; then
33 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
38 UCA_HOST="cloud-images.ubuntu.com"
39 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
40 export CLOUD_IMG_URL="http://${UCA_HOST}/${release}/current/${release}-server-cloudimg-${YARD_IMG_ARCH}.tar.gz"
41 if ! grep -q "Defaults env_keep += \"CLOUD_IMG_URL\"" "/etc/sudoers"; then
42 echo "Defaults env_keep += \"CLOUD_IMG_URL\"" | sudo tee -a /etc/sudoers
47 # try again to cleanup loopbacks in case of error
49 losetup -O NAME,BACK-FILE | awk '/yardstick/ { print $1 }' | xargs -l1 losetup -v -d || true
52 build_yardstick_image()
55 echo "========== Build yardstick cloud image =========="
57 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
58 if [ ! -f "${RAW_IMAGE}" ];then
60 cmd="sudo $(which yardstick-img-lxd-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
62 # Build the image. Retry once if the build fails
66 if [ ! -f "${RAW_IMAGE}" ]; then
67 echo "Failed building RAW image"
72 if [ ! -f "${QCOW_IMAGE}" ];then
73 ANSIBLE_SCRIPTS="${0%/*}/../../ansible"
74 cd ${ANSIBLE_SCRIPTS} &&\
76 -e img_property="normal" \
77 -e YARD_IMG_ARCH=${YARD_IMG_ARCH} \
78 -vvv -i inventory.ini build_yardstick_image.yml
81 if [ ! -f "${QCOW_IMAGE}" ]; then
82 echo "Failed building QCOW image"
86 if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
88 -e img_property="nsb" \
89 -e YARD_IMG_ARCH=${YARD_IMG_ARCH} \
90 -vvv -i inventory.ini build_yardstick_image.yml
92 if [ ! -f "${QCOW_NSB_IMAGE}" ]; then
93 echo "Failed building QCOW NSB image"
100 load_yardstick_image()
103 echo "========== Loading yardstick cloud image =========="
105 if [[ "${YARD_IMG_ARCH}" == "arm64" ]]; then
106 EXTRA_PARAMS="--property hw_video_model=vga"
109 # VPP requires guest memory to be backed by large pages
110 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
111 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
114 if [[ -n "${HW_FW_TYPE}" ]]; then
115 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_firmware_type=${HW_FW_TYPE}"
118 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
119 output=$(eval openstack ${SECURE} image create \
122 --container-format bare \
124 --file ${RAW_IMAGE} \
127 output=$(eval openstack ${SECURE} image create \
129 --disk-format qcow2 \
130 --container-format bare \
132 --file ${QCOW_IMAGE} \
134 if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
135 nsb_output=$(eval openstack ${SECURE} image create \
137 --disk-format qcow2 \
138 --container-format bare \
140 --file ${QCOW_NSB_IMAGE} \
141 yardstick-samplevnfs)
148 GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
150 if [ -z "$GLANCE_IMAGE_ID" ]; then
151 echo 'Failed uploading image to cloud'.
155 echo "Glance image id: $GLANCE_IMAGE_ID"
161 if [[ "${YARD_IMG_ARCH}" == "arm64" ]]; then
162 CIRROS_IMAGE_VERSION="cirros-d161201"
163 CIRROS_IMAGE_PATH="/home/opnfv/images/cirros-d161201-aarch64-disk.img"
164 EXTRA_PARAMS="--property hw_video_model=vga --property short_id=ubuntu16.04"
166 CIRROS_IMAGE_VERSION="cirros-0.3.5"
167 CIRROS_IMAGE_PATH="/home/opnfv/images/cirros-0.3.5-x86_64-disk.img"
170 if [[ -n $(openstack ${SECURE} image list | grep -e "${CIRROS_IMAGE_VERSION}") ]]; then
171 echo "${CIRROS_IMAGE_VERSION} image already exist, skip loading cirros image"
174 echo "========== Loading cirros cloud image =========="
176 local image_file="${CIRROS_IMAGE_PATH}"
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 if [[ -n "${HW_FW_TYPE}" ]]; then
184 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_firmware_type=${HW_FW_TYPE}"
187 output=$(openstack ${SECURE} image create \
188 --disk-format qcow2 \
189 --container-format bare \
191 --file ${image_file} \
195 CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
196 if [ -z "$CIRROS_IMAGE_ID" ]; then
197 echo 'Failed uploading cirros image to cloud'.
201 echo "Cirros image id: $CIRROS_IMAGE_ID"
208 echo "========== Loading ubuntu cloud image =========="
210 local ubuntu_image_file=/home/opnfv/images/xenial-server-cloudimg-amd64-disk1.img
213 # VPP requires guest memory to be backed by large pages
214 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
215 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
218 output=$(openstack ${SECURE} image create \
219 --disk-format qcow2 \
220 --container-format bare \
222 --file $ubuntu_image_file \
226 UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
228 if [ -z "$UBUNTU_IMAGE_ID" ]; then
229 echo 'Failed uploading UBUNTU image to cloud'.
233 echo "Ubuntu image id: $UBUNTU_IMAGE_ID"
238 if ! openstack ${SECURE} flavor list | grep -q yardstick-flavor; then
240 echo "========== Creating yardstick-flavor =========="
241 # Create the nova flavor used by some sample test cases
242 openstack ${SECURE} flavor create --id 100 --ram 1024 --disk 10 --vcpus 1 yardstick-flavor
243 # DPDK-enabled OVS requires guest memory to be backed by large pages
244 if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
245 openstack ${SECURE} flavor set --property hw:mem_page_size=large yardstick-flavor
247 # VPP requires guest memory to be backed by large pages
248 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
249 openstack ${SECURE} flavor set --property hw:mem_page_size=large yardstick-flavor
253 if ! openstack ${SECURE} flavor list | grep -q storperf; then
255 echo "========== Creating storperf flavor =========="
256 # Create the nova flavor used by storperf test case
257 openstack ${SECURE} flavor create --id auto --ram 8192 --disk 4 --vcpus 2 storperf
263 QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img"
264 QCOW_NSB_IMAGE="/tmp/workspace/yardstick/yardstick-nsb-image.img"
265 RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz"
267 if [ -f /home/opnfv/images/yardstick-image.img ];then
268 QCOW_IMAGE='/home/opnfv/images/yardstick-image.img'
270 if [ -f /home/opnfv/images/yardstick-image.tar.gz ];then
271 RAW_IMAGE='/home/opnfv/images/yardstick-image.tar.gz'
274 if [ $OS_INSECURE ] && [ "$(echo $OS_INSECURE | tr '[:upper:]' '[:lower:]')" = "true" ]; then
280 build_yardstick_image
282 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
283 #We have overlapping IP with the real network
284 for filename in ${YARDSTICK_REPO_DIR}/tests/opnfv/test_cases/*; do
285 sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" "${filename}"