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"
103 echo "========== Installing yardstick =========="
105 # uninstall previous version
106 pip uninstall -y yardstick || true
114 # Install Storper on huawei-pod1
115 if [ "$NODE_NAME" == "huawei-pod1" ]; then
117 echo "========== Installing storperf =========="
119 if ! yardstick -d plugin install plugin/CI/storperf.yaml; then
120 echo "Install storperf plugin FAILED";
129 # remove Storper from huawei-pod1
130 if [ "$NODE_NAME" == "huawei-pod1" ]; then
132 echo "========== Removing storperf =========="
134 if ! yardstick -d plugin remove plugin/CI/storperf.yaml; then
135 echo "Remove storperf plugin FAILED";
145 echo "========== Reporting Status =========="
146 curl -i -H 'content-type: application/json' -X POST -d \
147 "{\"project_name\": \"yardstick\",
148 \"case_name\": \"scenario_status\",
149 \"pod_name\":\"${NODE_NAME}\",
150 \"installer\":\"${INSTALLER_TYPE}\",
151 \"version\":\"$(basename ${YARDSTICK_BRANCH})\",
152 \"scenario\":\"${DEPLOY_SCENARIO}\",
153 \"description\": \"yardstick ci scenario status\",
154 \"criteria\":\"${1}\",
155 \"start_date\":\"${2}\",
156 \"stop_date\":\"${3}\",
158 "${REPORTING_TARGET}"
164 echo "========== Running yardstick test suites =========="
166 mkdir -p /etc/yardstick
168 cat << EOF > /etc/yardstick/yardstick.conf
171 dispatcher = ${DISPATCHER_TYPE}
174 file_name = ${DISPATCHER_FILE_NAME}
178 target = ${DISPATCHER_HTTP_TARGET}
180 [dispatcher_influxdb]
182 target = ${DISPATCHER_INFLUXDB_TARGET}
192 if [ ${#SUITE_FILES[@]} -gt 0 ]; then
194 start_date=$(date '+%Y-%m-%d %H:%M:%S')
195 for suite in ${SUITE_FILES[*]}; do
197 echo "---------------------------"
198 echo "Running test suite: $suite"
199 echo "---------------------------"
200 if ! yardstick task start --suite $suite; then
201 echo "test suite $suite FAILED";
203 # Mark the test suite failed but continue
204 # running the remaining test suites.
207 if [ ${DISPATCHER_TYPE} = file ]; then
208 echo "---------------------------"
209 echo "Dump test suite $suite result"
210 echo "---------------------------"
211 if [ -f ${DISPATCHER_FILE_NAME} ]; then
212 cat ${DISPATCHER_FILE_NAME}
214 echo "Test result file ${DISPATCHER_FILE_NAME} is not exist"
218 stop_date=$(date '+%Y-%m-%d %H:%M:%S')
222 local scenario_status="SUCCESS"
224 if [ $failed -gt 0 ]; then
225 scenario_status="FAILED"
228 report "${scenario_status}" "${start_date}" "${stop_date}"
230 if [ $failed -gt 0 ]; then
231 echo "---------------------------"
232 echo "$failed out of ${SUITE_FILES[*]} test suites FAILED"
233 echo "---------------------------"
239 echo "---------------------------"
240 echo "Running samples/ping.yaml "
241 echo "---------------------------"
243 if ! yardstick task start samples/ping.yaml; then
244 echo "Yardstick test FAILED"
248 if [ ${DISPATCHER_TYPE} = file ]; then
249 echo "---------------------------"
250 echo "Dump samples/ping.yaml test result"
251 echo "---------------------------"
252 if [ -f ${DISPATCHER_FILE_NAME} ]; then
253 cat ${DISPATCHER_FILE_NAME}
255 echo "Test result file ${DISPATCHER_FILE_NAME} is not exist"
265 GITROOT=$(cd $(dirname $0) && git rev-parse --show-toplevel)
269 export YARDSTICK_VERSION=$(git rev-parse HEAD)
273 # find the test suite files
274 for suite in $TEST_SUITES; do
275 if [ -f $suite ]; then
276 SUITE_FILES+=($suite)
278 tsdir=$GITROOT/tests/opnfv/test_suites
279 if [ ! -f $tsdir/$suite ]; then
280 echo "Test suite \"$suite\" does not exist"
283 SUITE_FILES+=($tsdir/$suite)
288 echo "========== Running Yardstick CI with following parameters =========="
289 echo "Script options: ${SCRIPT} $SCRIPT_ARGS"
290 echo "Dispatcher: ${DISPATCHER_TYPE} ${DISPATCHER_FILE_NAME}"
291 echo "YARDSTICK_VERSION: ${YARDSTICK_VERSION}"
292 echo "Number of test suites: ${#SUITE_FILES[@]}"
293 for suite in ${SUITE_FILES[*]}; do
298 # check if some necessary variables is set
299 if [ -z "$OS_AUTH_URL" ]; then
300 echo "OS_AUTH_URL is unset or empty"
304 echo "OS_AUTH_URL is $OS_AUTH_URL"
307 # check OpenStack services
308 echo "Checking OpenStack services:"
309 for cmd in "openstack image list" "openstack server list" "openstack stack list"; do
310 echo " checking ${cmd} ..."
311 if ! $cmd >/dev/null; then
312 echo "error: command \"$cmd\" failed"
318 echo "Checking for External network:"
319 for net in $(openstack network list --external -c Name -f value); do
320 echo " external network: $net"
326 source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
328 trap "error_exit" EXIT SIGTERM
330 source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh