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)
38 Default target is dump to file ($DISPATCHER_FILE_NAME)
44 DISPATCHER_FILE_NAME="/tmp/yardstick.out"
45 DISPATCHER_HTTP_TARGET="http://testresults.opnfv.org/test/api/v1/results"
46 DISPATCHER_INFLUXDB_TARGET=
48 while getopts "r:i:h" OPTION; do
56 DISPATCHER_HTTP_TARGET=http://${OPTARG}
60 DISPATCHER_TYPE=influxdb
61 DISPATCHER_INFLUXDB_TARGET=http://${OPTARG}
65 echo "${OPTION} is not a valid argument"
80 if [ -z "$exitcode" ]; then
81 # In case of recursive traps (!?)
87 echo "Exiting with RC=$exitcode"
98 echo "========== Installing yardstick =========="
100 # uninstall previous version
101 pip uninstall -y yardstick || true
109 # Install Storper on huawei-pod1
110 if [ "$NODE_NAME" == "huawei-pod1" ]; then
112 echo "========== Installing storperf =========="
114 if ! yardstick -d plugin install plugin/CI/storperf.yaml; then
115 echo "Install storperf plugin FAILED";
124 # remove Storper from huawei-pod1
125 if [ "$NODE_NAME" == "huawei-pod1" ]; then
127 echo "========== Removing storperf =========="
129 if ! yardstick -d plugin remove plugin/CI/storperf.yaml; then
130 echo "Remove storperf plugin FAILED";
140 echo "========== Reporting Status =========="
141 curl -i -H 'content-type: application/json' -X POST -d \
142 "{\"project_name\": \"yardstick\",
143 \"case_name\": \"scenario_status\",
144 \"pod_name\":\"${NODE_NAME}\",
145 \"installer\":\"${INSTALLER_TYPE}\",
146 \"version\":\"$(basename ${YARDSTICK_BRANCH})\",
147 \"scenario\":\"${DEPLOY_SCENARIO}\",
148 \"description\": \"yardstick ci scenario status\",
150 \"start_date\":\"$2\",
151 \"stop_date\":\"$3\",
153 ${DISPATCHER_HTTP_TARGET}
159 echo "========== Running yardstick test suites =========="
161 mkdir -p /etc/yardstick
163 cat << EOF > /etc/yardstick/yardstick.conf
166 dispatcher = ${DISPATCHER_TYPE}
169 file_name = ${DISPATCHER_FILE_NAME}
173 target = ${DISPATCHER_HTTP_TARGET}
175 [dispatcher_influxdb]
177 target = ${DISPATCHER_INFLUXDB_TARGET}
187 if [ ${#SUITE_FILES[@]} -gt 0 ]; then
189 start_date=$(date '+%Y-%m-%d %H:%M:%S')
190 for suite in ${SUITE_FILES[*]}; do
192 echo "---------------------------"
193 echo "Running test suite: $suite"
194 echo "---------------------------"
195 if ! yardstick task start --suite $suite; then
196 echo "test suite $suite FAILED";
198 # Mark the test suite failed but continue
199 # running the remaining test suites.
202 if [ ${DISPATCHER_TYPE} = file ]; then
203 echo "---------------------------"
204 echo "Dump test suite $suite result"
205 echo "---------------------------"
206 if [ -f ${DISPATCHER_FILE_NAME} ]; then
207 cat ${DISPATCHER_FILE_NAME}
209 echo "Test result file ${DISPATCHER_FILE_NAME} is not exist"
213 stop_date=$(date '+%Y-%m-%d %H:%M:%S')
217 local scenario_status="SUCCESS"
219 if [ $failed -gt 0 ]; then
220 scenario_status="FAILED"
223 report $scenario_status $start_date $stop_date
225 if [ $failed -gt 0 ]; then
226 echo "---------------------------"
227 echo "$failed out of ${SUITE_FILES[*]} test suites FAILED"
228 echo "---------------------------"
234 echo "---------------------------"
235 echo "Running samples/ping.yaml "
236 echo "---------------------------"
238 if ! yardstick task start samples/ping.yaml; then
239 echo "Yardstick test FAILED"
243 if [ ${DISPATCHER_TYPE} = file ]; then
244 echo "---------------------------"
245 echo "Dump samples/ping.yaml test result"
246 echo "---------------------------"
247 if [ -f ${DISPATCHER_FILE_NAME} ]; then
248 cat ${DISPATCHER_FILE_NAME}
250 echo "Test result file ${DISPATCHER_FILE_NAME} is not exist"
260 GITROOT=$(cd $(dirname $0) && git rev-parse --show-toplevel)
264 export YARDSTICK_VERSION=$(git rev-parse HEAD)
268 # find the test suite files
269 for suite in $TEST_SUITES; do
270 if [ -f $suite ]; then
271 SUITE_FILES+=($suite)
273 tsdir=$GITROOT/tests/opnfv/test_suites
274 if [ ! -f $tsdir/$suite ]; then
275 echo "Test suite \"$suite\" does not exist"
278 SUITE_FILES+=($tsdir/$suite)
283 echo "========== Running Yardstick CI with following parameters =========="
284 echo "Script options: ${SCRIPT} $SCRIPT_ARGS"
285 echo "Dispatcher: ${DISPATCHER_TYPE} ${DISPATCHER_FILE_NAME}"
286 echo "YARDSTICK_VERSION: ${YARDSTICK_VERSION}"
287 echo "Number of test suites: ${#SUITE_FILES[@]}"
288 for suite in ${SUITE_FILES[*]}; do
293 # check if some necessary variables is set
294 if [ -z "$OS_AUTH_URL" ]; then
295 echo "OS_AUTH_URL is unset or empty"
299 echo "OS_AUTH_URL is $OS_AUTH_URL"
302 # check OpenStack services
303 echo "Checking OpenStack services:"
304 for cmd in "openstack image list" "openstack server list" "openstack stack list"; do
305 echo " checking ${cmd} ..."
306 if ! $cmd >/dev/null; then
307 echo "error: command \"$cmd\" failed"
313 echo "Checking for External network:"
314 for net in $(openstack network list --external -c Name -f value); do
315 echo " external network: $net"
321 source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
325 trap "error_exit" EXIT SIGTERM
327 source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh