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"
155 if [[ -n $(openstack image list | grep -e Cirros-0.3.5) ]]; then
156 echo "Cirros-0.3.5 image already exist, skip loading cirros image"
159 echo "========== Loading cirros cloud image =========="
161 local image_file=/home/opnfv/images/cirros-0.3.5-x86_64-disk.img
164 # VPP requires guest memory to be backed by large pages
165 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
166 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
169 output=$(openstack image create \
170 --disk-format qcow2 \
171 --container-format bare \
173 --file ${image_file} \
177 CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
178 if [ -z "$CIRROS_IMAGE_ID" ]; then
179 echo 'Failed uploading cirros image to cloud'.
183 echo "Cirros image id: $CIRROS_IMAGE_ID"
190 echo "========== Loading ubuntu cloud image =========="
192 local ubuntu_image_file=/home/opnfv/images/trusty-server-cloudimg-amd64-disk1.img
195 # VPP requires guest memory to be backed by large pages
196 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
197 EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
200 output=$(openstack image create \
201 --disk-format qcow2 \
202 --container-format bare \
204 --file $ubuntu_image_file \
208 UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
210 if [ -z "$UBUNTU_IMAGE_ID" ]; then
211 echo 'Failed uploading UBUNTU image to cloud'.
215 echo "Ubuntu image id: $UBUNTU_IMAGE_ID"
220 if ! openstack flavor list | grep -q yardstick-flavor; then
222 echo "========== Creating yardstick-flavor =========="
223 # Create the nova flavor used by some sample test cases
224 openstack flavor create --id 100 --ram 512 --disk 3 --vcpus 1 yardstick-flavor
225 # DPDK-enabled OVS requires guest memory to be backed by large pages
226 if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
227 openstack flavor set --property hw:mem_page_size=large yardstick-flavor
229 # VPP requires guest memory to be backed by large pages
230 if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
231 openstack flavor set --property hw:mem_page_size=large yardstick-flavor
235 if ! openstack flavor list | grep -q storperf; then
237 echo "========== Creating storperf flavor =========="
238 # Create the nova flavor used by storperf test case
239 openstack flavor create --id auto --ram 8192 --disk 4 --vcpus 2 storperf
245 QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img"
246 RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz"
248 build_yardstick_image
250 if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
251 sed -i 's/image: {{image}}/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml
252 sed -i 's/image: cirros-0.3.5/image: TestVM/g' samples/ping.yaml
253 #We have overlapping IP with the real network
254 for filename in tests/opnfv/test_cases/*; do
255 sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" "${filename}"