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
46 build_yardstick_image()
49 echo "========== Build yardstick cloud image =========="
51 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
52 if [ ! -f "${RAW_IMAGE}" ];then
54 cmd="sudo $(which yardstick-img-lxd-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
56 # Build the image. Retry once if the build fails
59 if [ ! -f "${RAW_IMAGE}" ]; then
60 echo "Failed building RAW image"
65 if [ ! -f "${QCOW_IMAGE}" ];then
66 ANSIBLE_SCRIPTS="${0%/*}/../../ansible"
67 cd ${ANSIBLE_SCRIPTS} &&\
69 -e img_property="normal" \
70 -e YARD_IMG_ARCH=${YARD_IMG_ARCH} \
71 -vvv -i inventory.ini build_yardstick_image.yml
73 if [ ! -f "${QCOW_IMAGE}" ]; then
74 echo "Failed building QCOW image"
78 # DPDK compile is not enabled for arm64 yet so disable for now
80 if [[ ! -f "${QCOW_NSB_IMAGE}" && ${DEPLOY_SCENARIO} == *[_-]ovs_dpdk[_-]* && "${YARD_IMG_ARCH}" != "arm64" ]]; then
82 -e img_property="nsb" \
83 -e YARD_IMG_ARCH=${YARD_IMG_ARCH} \
84 -vvv -i inventory.ini build_yardstick_image.yml
85 if [ ! -f "${QCOW_NSB_IMAGE}" ]; then
86 echo "Failed building QCOW NSB image"
93 load_yardstick_image()
96 echo "========== Loading yardstick cloud image =========="
98 if [[ "${YARD_IMG_ARCH}" == "arm64" ]]; then
99 EXTRA_PARAMS="--property hw_video_model=vga"
102 # VPP requires guest memory to be backed by large pages
103 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
104 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
107 if [[ -n "${HW_FW_TYPE}" ]]; then
108 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_firmware_type=${HW_FW_TYPE}"
111 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
112 output=$(eval openstack ${SECURE} image create \
115 --container-format bare \
117 --file ${RAW_IMAGE} \
120 output=$(eval openstack ${SECURE} image create \
122 --disk-format qcow2 \
123 --container-format bare \
125 --file ${QCOW_IMAGE} \
127 if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
128 nsb_output=$(eval openstack ${SECURE} image create \
130 --disk-format qcow2 \
131 --container-format bare \
133 --file ${QCOW_NSB_IMAGE} \
134 yardstick-samplevnfs)
141 GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
143 if [ -z "$GLANCE_IMAGE_ID" ]; then
144 echo 'Failed uploading image to cloud'.
148 echo "Glance image id: $GLANCE_IMAGE_ID"
154 if [[ "${YARD_IMG_ARCH}" == "arm64" ]]; then
155 CIRROS_IMAGE_VERSION="cirros-d161201"
156 CIRROS_IMAGE_PATH="/home/opnfv/images/cirros-d161201-aarch64-disk.img"
157 EXTRA_PARAMS="--property hw_video_model=vga --property short_id=ubuntu16.04"
159 CIRROS_IMAGE_VERSION="cirros-0.3.5"
160 CIRROS_IMAGE_PATH="/home/opnfv/images/cirros-0.3.5-x86_64-disk.img"
163 if [[ -n $(openstack ${SECURE} image list | grep -e "${CIRROS_IMAGE_VERSION}") ]]; then
164 echo "${CIRROS_IMAGE_VERSION} image already exist, skip loading cirros image"
167 echo "========== Loading cirros cloud image =========="
169 local image_file="${CIRROS_IMAGE_PATH}"
171 # VPP requires guest memory to be backed by large pages
172 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
173 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
176 if [[ -n "${HW_FW_TYPE}" ]]; then
177 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_firmware_type=${HW_FW_TYPE}"
180 output=$(openstack ${SECURE} image create \
181 --disk-format qcow2 \
182 --container-format bare \
184 --file ${image_file} \
188 CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
189 if [ -z "$CIRROS_IMAGE_ID" ]; then
190 echo 'Failed uploading cirros image to cloud'.
194 echo "Cirros image id: $CIRROS_IMAGE_ID"
201 echo "========== Loading ubuntu cloud image =========="
203 local ubuntu_image_file=/home/opnfv/images/xenial-server-cloudimg-amd64-disk1.img
206 # VPP requires guest memory to be backed by large pages
207 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
208 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
211 output=$(openstack ${SECURE} image create \
212 --disk-format qcow2 \
213 --container-format bare \
215 --file $ubuntu_image_file \
219 UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
221 if [ -z "$UBUNTU_IMAGE_ID" ]; then
222 echo 'Failed uploading UBUNTU image to cloud'.
226 echo "Ubuntu image id: $UBUNTU_IMAGE_ID"
231 if ! openstack ${SECURE} flavor list | grep -q yardstick-flavor; then
233 echo "========== Creating yardstick-flavor =========="
234 # Create the nova flavor used by some sample test cases
235 openstack ${SECURE} flavor create --id 100 --ram 1024 --disk 10 --vcpus 1 yardstick-flavor
236 # DPDK-enabled OVS requires guest memory to be backed by large pages
237 if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
238 openstack ${SECURE} flavor set --property hw:mem_page_size=large yardstick-flavor
240 # VPP requires guest memory to be backed by large pages
241 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
242 openstack ${SECURE} flavor set --property hw:mem_page_size=large yardstick-flavor
246 if ! openstack ${SECURE} flavor list | grep -q storperf; then
248 echo "========== Creating storperf flavor =========="
249 # Create the nova flavor used by storperf test case
250 openstack ${SECURE} flavor create --id auto --ram 8192 --disk 4 --vcpus 2 storperf
256 QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img"
257 QCOW_NSB_IMAGE="/tmp/workspace/yardstick/yardstick-nsb-image.img"
258 RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz"
260 if [ -f /home/opnfv/images/yardstick-image.img ];then
261 QCOW_IMAGE='/home/opnfv/images/yardstick-image.img'
263 if [ -f /home/opnfv/images/yardstick-image.tar.gz ];then
264 RAW_IMAGE='/home/opnfv/images/yardstick-image.tar.gz'
267 if [ $OS_INSECURE ] && [ "$(echo $OS_INSECURE | tr '[:upper:]' '[:lower:]')" = "true" ]; then
273 build_yardstick_image
275 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
276 #We have overlapping IP with the real network
277 for filename in ${YARDSTICK_REPO_DIR}/tests/opnfv/test_cases/*; do
278 sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" "${filename}"