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 echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" | sudo tee -a /etc/sudoers
22 # Look for a compute node, that is online, and check if it is aarch64
23 ARCH_SCRIPT="ssh \$(fuel2 node list | awk -F'|' '\$6 ~ /compute/ && \$11 ~ /rue/ {print \$7; exit;}') uname -m 2>/dev/null | grep -q aarch64"
24 if [ "$INSTALLER_TYPE" == "fuel" ]; then
25 sshpass -p r00tme ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root "${INSTALLER_IP}" "${ARCH_SCRIPT}" && YARD_IMG_ARCH=arm64
29 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
34 UCA_HOST="cloud-images.ubuntu.com"
35 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
36 export CLOUD_IMG_URL="http://${UCA_HOST}/${release}/current/${release}-server-cloudimg-${YARD_IMG_ARCH}.tar.gz"
37 if ! grep -q "Defaults env_keep += \"CLOUD_IMG_URL\"" "/etc/sudoers"; then
38 echo "Defaults env_keep += \"CLOUD_IMG_URL\"" | sudo tee -a /etc/sudoers
42 build_yardstick_image()
45 echo "========== Build yardstick cloud image =========="
47 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
49 cmd="sudo $(which yardstick-img-lxd-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
51 # Build the image. Retry once if the build fails
54 if [ ! -f "${RAW_IMAGE}" ]; then
55 echo "Failed building RAW image"
60 cmd="sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
62 # Build the image. Retry once if the build fails
65 if [ ! -f "${QCOW_IMAGE}" ]; then
66 echo "Failed building QCOW image"
72 load_yardstick_image()
75 echo "========== Loading yardstick cloud image =========="
77 if [[ "${YARD_IMG_ARCH}" == "arm64" && "${YARD_IMG_AKI}" == "true" ]]; then
78 CLOUD_IMAGE="/tmp/${release}-server-cloudimg-${YARD_IMG_ARCH}.tar.gz"
79 CLOUD_KERNEL="/tmp/${release}-server-cloudimg-${YARD_IMG_ARCH}-vmlinuz-generic"
81 if [ ! -f "${CLOUD_IMAGE}" ]; then
82 wget "${CLOUD_IMG_URL}"
84 if [ ! -f "${CLOUD_KERNEL}" ]; then
85 tar xf "${CLOUD_IMAGE}" "${CLOUD_KERNEL##**/}"
87 create_kernel=$(openstack image create \
90 --container-format bare \
91 --file ${CLOUD_KERNEL} \
92 yardstick-${release}-kernel)
94 GLANCE_KERNEL_ID=$(echo "$create_kernel" | awk '/ id / {print $(NF-1)}')
95 if [ -z "$GLANCE_KERNEL_ID" ]; then
96 echo 'Failed uploading kernel to cloud'.
100 command_line="root=/dev/vdb1 console=tty0 console=ttyS0 console=ttyAMA0 rw"
102 EXTRA_PARAMS="--property kernel_id=$GLANCE_KERNEL_ID --property os_command_line=\"$command_line\""
104 rm -f -- "${CLOUD_KERNEL}" "${CLOUD_IMAGE}"
105 cd "${YARDSTICK_REPO_DIR}"
108 # VPP requires guest memory to be backed by large pages
109 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
110 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
113 if [[ -n "${HW_FW_TYPE}" ]]; then
114 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_firmware_type=${HW_FW_TYPE}"
117 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
118 output=$(eval openstack image create \
121 --container-format bare \
123 --file ${RAW_IMAGE} \
126 output=$(eval openstack image create \
128 --disk-format qcow2 \
129 --container-format bare \
131 --file ${QCOW_IMAGE} \
137 GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
139 if [ -z "$GLANCE_IMAGE_ID" ]; then
140 echo 'Failed uploading image to cloud'.
144 if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
145 sudo rm -f -- "${RAW_IMAGE}"
147 sudo rm -f -- "${QCOW_IMAGE}"
150 echo "Glance image id: $GLANCE_IMAGE_ID"
156 echo "========== Loading cirros cloud image =========="
158 local image_file=/home/opnfv/images/cirros-0.3.3-x86_64-disk.img
161 # VPP requires guest memory to be backed by large pages
162 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
163 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
166 output=$(openstack image create \
167 --disk-format qcow2 \
168 --container-format bare \
170 --file ${image_file} \
174 CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
175 if [ -z "$CIRROS_IMAGE_ID" ]; then
176 echo 'Failed uploading cirros image to cloud'.
180 echo "Cirros image id: $CIRROS_IMAGE_ID"
186 echo "========== Loading ubuntu cloud image =========="
188 local ubuntu_image_file=/home/opnfv/images/trusty-server-cloudimg-amd64-disk1.img
191 # VPP requires guest memory to be backed by large pages
192 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
193 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
196 output=$(openstack image create \
197 --disk-format qcow2 \
198 --container-format bare \
200 --file $ubuntu_image_file \
204 UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
206 if [ -z "$UBUNTU_IMAGE_ID" ]; then
207 echo 'Failed uploading UBUNTU image to cloud'.
211 echo "Ubuntu image id: $UBUNTU_IMAGE_ID"
216 if ! openstack flavor list | grep -q yardstick-flavor; then
218 echo "========== Create nova flavor =========="
219 # Create the nova flavor used by some sample test cases
220 openstack flavor create --id 100 --ram 512 --disk 3 --vcpus 1 yardstick-flavor
221 # DPDK-enabled OVS requires guest memory to be backed by large pages
222 if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
223 openstack flavor set --property hw:mem_page_size=large yardstick-flavor
225 # VPP requires guest memory to be backed by large pages
226 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
227 openstack flavor set --property hw:mem_page_size=large yardstick-flavor
234 QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img"
235 RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz"
237 build_yardstick_image
239 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
240 sed -i 's/image: cirros-0.3.3/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml \
242 #We have overlapping IP with the real network
243 for filename in tests/opnfv/test_cases/*; do
244 sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" "${filename}"