2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB 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 ##############################################################################
12 # Set up the environment and run yardstick test suites.
14 # Example invocation: yardstick-verify -r 10.4.4.4 suite1.yaml suite2.yaml
16 # Openstack credentials must be set and the script must be run from its
17 # original location in the yardstick repo.
19 # This script is intended to be used by the CI pipeline but it may also
20 # be invoked manually.
29 usage: $0 options [TEST_SUITE ...]
31 If no test suites are given ping.yaml is run.
35 -r Http target (example: -r 213.77.62.197/results)
36 -i Influxdb target (example: -i 127.0.0.1:8086)
37 -m Reporting target (example: -m 213.77.62.197/results)
39 Default target is dump to file ($DISPATCHER_FILE_NAME)
45 DISPATCHER_FILE_NAME="/tmp/yardstick.out"
46 DISPATCHER_HTTP_TARGET="http://testresults.opnfv.org/test/api/v1/results"
47 DISPATCHER_INFLUXDB_TARGET=
48 REPORTING_TARGET="${DISPATCHER_HTTP_TARGET}"
50 while getopts "r:i:m:h" OPTION; do
58 DISPATCHER_HTTP_TARGET=http://${OPTARG}
62 DISPATCHER_TYPE=influxdb
63 DISPATCHER_INFLUXDB_TARGET=http://${OPTARG}
67 REPORTING_TARGET=http://${OPTARG}
70 echo "${OPTION} is not a valid argument"
85 if [ -z "$exitcode" ]; then
86 # In case of recursive traps (!?)
92 echo "Exiting with RC=$exitcode"
102 # Install Storper on huawei-pod1
103 if [ "$INSTALLER_TYPE" == "compass" ]; then
105 echo "========== Installing storperf =========="
107 if ! yardstick -d plugin install plugin/CI/storperf.yaml; then
108 echo "Install storperf plugin FAILED";
117 # remove Storper from huawei-pod1
118 if [ "$INSTALLER_TYPE" == "compass" ]; then
120 echo "========== Removing storperf =========="
122 if ! yardstick -d plugin remove plugin/CI/storperf.yaml; then
123 echo "Remove storperf plugin FAILED";
133 echo "========== Reporting Status =========="
134 curl -i -H 'content-type: application/json' -X POST -d \
135 "{\"project_name\": \"yardstick\",
136 \"case_name\": \"scenario_status\",
137 \"pod_name\":\"${NODE_NAME}\",
138 \"installer\":\"${INSTALLER_TYPE}\",
139 \"version\":\"$(basename ${YARDSTICK_BRANCH})\",
140 \"scenario\":\"${DEPLOY_SCENARIO}\",
141 \"description\": \"yardstick ci scenario status\",
142 \"criteria\":\"${1}\",
143 \"start_date\":\"${2}\",
144 \"stop_date\":\"${3}\",
146 "${REPORTING_TARGET}"
152 echo "========== Running yardstick test suites =========="
154 mkdir -p /etc/yardstick
156 cat << EOF > /etc/yardstick/yardstick.conf
159 dispatcher = ${DISPATCHER_TYPE}
162 file_name = ${DISPATCHER_FILE_NAME}
166 target = ${DISPATCHER_HTTP_TARGET}
168 [dispatcher_influxdb]
170 target = ${DISPATCHER_INFLUXDB_TARGET}
180 if [ ${#SUITE_FILES[@]} -gt 0 ]; then
182 start_date=$(date '+%Y-%m-%d %H:%M:%S')
183 for suite in ${SUITE_FILES[*]}; do
185 echo "---------------------------"
186 echo "Running test suite: $suite"
187 echo "---------------------------"
188 if ! yardstick task start --suite $suite; then
189 echo "test suite $suite FAILED";
191 # Mark the test suite failed but continue
192 # running the remaining test suites.
195 if [ ${DISPATCHER_TYPE} = file ]; then
196 echo "---------------------------"
197 echo "Dump test suite $suite result"
198 echo "---------------------------"
199 if [ -f ${DISPATCHER_FILE_NAME} ]; then
200 cat ${DISPATCHER_FILE_NAME}
202 echo "Test result file ${DISPATCHER_FILE_NAME} is not exist"
206 stop_date=$(date '+%Y-%m-%d %H:%M:%S')
210 local scenario_status="SUCCESS"
212 if [ $failed -gt 0 ]; then
213 scenario_status="FAILED"
216 report "${scenario_status}" "${start_date}" "${stop_date}"
218 if [ $failed -gt 0 ]; then
219 echo "---------------------------"
220 echo "$failed out of ${SUITE_FILES[*]} test suites FAILED"
221 echo "---------------------------"
227 echo "---------------------------"
228 echo "Running samples/ping.yaml "
229 echo "---------------------------"
231 if ! yardstick task start samples/ping.yaml; then
232 echo "Yardstick test FAILED"
236 if [ ${DISPATCHER_TYPE} = file ]; then
237 echo "---------------------------"
238 echo "Dump samples/ping.yaml test result"
239 echo "---------------------------"
240 if [ -f ${DISPATCHER_FILE_NAME} ]; then
241 cat ${DISPATCHER_FILE_NAME}
243 echo "Test result file ${DISPATCHER_FILE_NAME} is not exist"
253 GITROOT=$(cd $(dirname $0) && git rev-parse --show-toplevel)
257 export YARDSTICK_VERSION=$(git rev-parse HEAD)
261 # find the test suite files
262 for suite in $TEST_SUITES; do
263 if [ -f $suite ]; then
264 SUITE_FILES+=($suite)
266 tsdir=$GITROOT/tests/opnfv/test_suites
267 if [ ! -f $tsdir/$suite ]; then
268 echo "Test suite \"$suite\" does not exist"
271 SUITE_FILES+=($tsdir/$suite)
276 echo "========== Running Yardstick CI with following parameters =========="
277 echo "Script options: ${SCRIPT} $SCRIPT_ARGS"
278 echo "Dispatcher: ${DISPATCHER_TYPE} ${DISPATCHER_FILE_NAME}"
279 echo "YARDSTICK_VERSION: ${YARDSTICK_VERSION}"
280 echo "Number of test suites: ${#SUITE_FILES[@]}"
281 for suite in ${SUITE_FILES[*]}; do
286 # check if some necessary variables is set
287 if [ -z "$OS_AUTH_URL" ]; then
288 echo "OS_AUTH_URL is unset or empty"
292 echo "OS_AUTH_URL is $OS_AUTH_URL"
295 # check OpenStack services
296 echo "Checking OpenStack services:"
297 for cmd in "openstack image list" "openstack server list" "openstack stack list"; do
298 echo " checking ${cmd} ..."
299 if ! $cmd >/dev/null; then
300 echo "error: command \"$cmd\" failed"
306 echo "Checking for External network:"
307 for net in $(openstack network list --external -c Name -f value); do
308 echo " external network: $net"
311 source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
313 trap "error_exit" EXIT SIGTERM
315 source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh