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 (!?)
90 if [[ "${DEPLOY_SCENARIO:0:2}" == 'os' ]];then
91 source "${YARDSTICK_REPO_DIR}/tests/ci/clean_images.sh"
94 echo "Exiting with RC=$exitcode"
104 # Install Storper on huawei-pod1 and huawei-pod2
105 if [ "$NODE_NAME" == "huawei-pod1" -o "$NODE_NAME" == "huawei-pod2" ]; then
107 echo "========== Installing storperf =========="
109 if ! yardstick -d plugin install ${YARDSTICK_REPO_DIR}/plugin/CI/storperf.yaml; then
110 echo "Install storperf plugin FAILED";
119 # remove Storper from huawei-pod1 and huawei-pod2
120 if [ "$NODE_NAME" == "huawei-pod1" -o "$NODE_NAME" == "huawei-pod2" ]; then
122 echo "========== Removing storperf =========="
124 if ! yardstick -d plugin remove ${YARDSTICK_REPO_DIR}/plugin/CI/storperf.yaml; then
125 echo "Remove storperf plugin FAILED";
135 echo "========== Reporting Status =========="
136 curl -i -H 'content-type: application/json' -X POST -d \
137 "{\"project_name\": \"yardstick\",
138 \"case_name\": \"scenario_status\",
139 \"pod_name\":\"${NODE_NAME}\",
140 \"installer\":\"${INSTALLER_TYPE}\",
141 \"version\":\"$(basename ${YARDSTICK_BRANCH})\",
142 \"scenario\":\"${DEPLOY_SCENARIO}\",
143 \"description\": \"yardstick ci scenario status\",
144 \"criteria\":\"${1}\",
145 \"start_date\":\"${2}\",
146 \"stop_date\":\"${3}\",
148 "${REPORTING_TARGET}"
154 echo "========== Running yardstick test suites =========="
156 mkdir -p /etc/yardstick
158 cat << EOF > /etc/yardstick/yardstick.conf
161 dispatcher = ${DISPATCHER_TYPE}
164 file_name = ${DISPATCHER_FILE_NAME}
168 target = ${DISPATCHER_HTTP_TARGET}
170 [dispatcher_influxdb]
172 target = ${DISPATCHER_INFLUXDB_TARGET}
182 if [ ${#SUITE_FILES[@]} -gt 0 ]; then
184 start_date=$(date '+%Y-%m-%d %H:%M:%S')
185 for suite in ${SUITE_FILES[*]}; do
187 echo "---------------------------"
188 echo "Running test suite: $suite"
189 echo "---------------------------"
190 if ! yardstick task start --suite $suite; then
191 echo "test suite $suite FAILED";
193 # Mark the test suite failed but continue
194 # running the remaining test suites.
197 if [ ${DISPATCHER_TYPE} = file ]; then
198 echo "---------------------------"
199 echo "Dump test suite $suite result"
200 echo "---------------------------"
201 if [ -f ${DISPATCHER_FILE_NAME} ]; then
202 cat ${DISPATCHER_FILE_NAME}
204 echo "Test result file ${DISPATCHER_FILE_NAME} is not exist"
208 stop_date=$(date '+%Y-%m-%d %H:%M:%S')
212 local scenario_status="PASS"
214 if [ $failed -gt 0 ]; then
215 scenario_status="FAIL"
218 report "${scenario_status}" "${start_date}" "${stop_date}"
220 if [ $failed -gt 0 ]; then
221 echo "---------------------------"
222 echo "$failed out of ${SUITE_FILES[*]} test suites FAILED"
223 echo "---------------------------"
229 echo "---------------------------"
230 echo "Running samples/ping.yaml "
231 echo "---------------------------"
233 if ! yardstick task start samples/ping.yaml; then
234 echo "Yardstick test FAILED"
238 if [ ${DISPATCHER_TYPE} = file ]; then
239 echo "---------------------------"
240 echo "Dump samples/ping.yaml test result"
241 echo "---------------------------"
242 if [ -f ${DISPATCHER_FILE_NAME} ]; then
243 cat ${DISPATCHER_FILE_NAME}
245 echo "Test result file ${DISPATCHER_FILE_NAME} is not exist"
254 # check if some necessary variables is set
255 if [ -z "$OS_AUTH_URL" ]; then
256 echo "OS_AUTH_URL is unset or empty"
260 echo "OS_AUTH_URL is $OS_AUTH_URL"
263 # check OpenStack services
264 if [[ $OS_INSECURE ]] && [[ "$(echo $OS_INSECURE | tr '[:upper:]' '[:lower:]')" = "true" ]]; then
269 echo "Checking OpenStack services:"
270 for cmd in "openstack ${SECURE} image list" "openstack ${SECURE} server list" "openstack ${SECURE} stack list"; do
271 echo " checking ${cmd} ..."
272 if ! $cmd >/dev/null; then
273 echo "error: command \"$cmd\" failed"
279 echo "Checking for External network:"
280 for net in $(openstack network list --external -c Name -f value); do
281 echo " external network: $net"
287 GITROOT=$(cd $(dirname $0) && git rev-parse --show-toplevel)
291 export YARDSTICK_VERSION=$(git rev-parse HEAD)
295 # find the test suite files
296 for suite in $TEST_SUITES; do
297 if [ -f $suite ]; then
298 SUITE_FILES+=($suite)
300 tsdir=$GITROOT/tests/opnfv/test_suites
301 if [ ! -f $tsdir/$suite ]; then
302 echo "Test suite \"$suite\" does not exist"
305 SUITE_FILES+=($tsdir/$suite)
310 echo "========== Running Yardstick CI with following parameters =========="
311 echo "Script options: ${SCRIPT} $SCRIPT_ARGS"
312 echo "Dispatcher: ${DISPATCHER_TYPE} ${DISPATCHER_FILE_NAME}"
313 echo "YARDSTICK_VERSION: ${YARDSTICK_VERSION}"
314 echo "Number of test suites: ${#SUITE_FILES[@]}"
315 for suite in ${SUITE_FILES[*]}; do
320 trap "error_exit" EXIT SIGTERM
322 if [[ "${DEPLOY_SCENARIO:0:2}" == "os" ]];then
325 source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
326 source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh