set -e
: ${YARDSTICK_REPO:='https://gerrit.opnfv.org/gerrit/yardstick'}
-: ${YARDSTICK_REPO_DIR:='/home/yardstick'}
-: ${YARDSTICK_BRANCH:='master'}
+: ${YARDSTICK_REPO_DIR:='/home/opnfv/yardstick'}
+: ${YARDSTICK_BRANCH:='master'} # branch, tag, sha1 or refspec
: ${RELENG_REPO:='https://gerrit.opnfv.org/gerrit/releng'}
-: ${RELENG_REPO_DIR:='/home/releng'}
-: ${RELENG_BRANCH:='master'}
+: ${RELENG_REPO_DIR:='/home/opnfv/repos/releng'}
+: ${RELENG_BRANCH:='master'} # branch, tag, sha1 or refspec
: ${INSTALLER_TYPE:='fuel'}
: ${INSTALLER_IP:='10.20.0.2'}
-: ${EXTERNAL_NET_ID:='net04_ext'}
+: ${POD_NAME:='opnfv-jump-2'}
+: ${EXTERNAL_NET:='net04_ext'}
-# clone releng
+git_checkout()
+{
+ if git cat-file -e $1^{commit} 2>/dev/null; then
+ # branch, tag or sha1 object
+ git checkout $1
+ else
+ # refspec / changeset
+ git fetch --tags --progress $2 $1
+ git checkout FETCH_HEAD
+ fi
+}
+
+echo
+echo "INFO: Updating releng -> $RELENG_BRANCH"
if [ ! -d $RELENG_REPO_DIR ]; then
git clone $RELENG_REPO $RELENG_REPO_DIR
fi
cd $RELENG_REPO_DIR
-git fetch --tags --progress $RELENG_REPO $RELENG_BRANCH
-git checkout FETCH_HEAD
+git checkout master && git pull
+git_checkout $RELENG_BRANCH $RELENG_REPO
-# clone yardstick
+echo
+echo "INFO: Updating yardstick -> $YARDSTICK_BRANCH"
if [ ! -d $YARDSTICK_REPO_DIR ]; then
git clone YARDSTICK_REPO $YARDSTICK_REPO_DIR
fi
cd $YARDSTICK_REPO_DIR
-git fetch --tags --progress $YARDSTICK_REPO $YARDSTICK_BRANCH
-git checkout FETCH_HEAD
+git checkout master && git pull
+git_checkout $YARDSTICK_BRANCH $YARDSTICK_REPO
+
+echo
+echo "INFO: Creating openstack credentials .."
# Create openstack credentials
$RELENG_REPO_DIR/utils/fetch_os_creds.sh \
ssh_opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
if sshpass -p r00tme ssh 2>/dev/null $ssh_opts root@${INSTALLER_IP} \
fuel environment --env 1 | grep opnfv-virt; then
+ echo "INFO: applying OPNFV playground hack"
export OS_ENDPOINT_TYPE='publicURL'
fi
fi
-export EXTERNAL_NET_ID
+export EXTERNAL_NET INSTALLER_TYPE POD_NAME
-$YARDSTICK_REPO_DIR/ci/yardstick-verify
+$YARDSTICK_REPO_DIR/ci/yardstick-verify $@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-YARDSTICK_IMAGE_ID=
-CIRROS_IMAGE_ID=
+#
+# Set up the environment and run yardstick test suites.
+#
+# Example invocation: yardstick-verify -r 10.4.4.4 suite1.yaml suite2.yaml
+#
+# Openstack credentials must be set and the script must be run from its
+# original location in the yardstick repo.
+#
+# This script is intended to be used by the CI pipeline but it may also
+# be invoked manually.
+#
-QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-trusty-server.img"
+SCRIPT=$0
+SCRIPT_ARGS=$@
+
+usage()
+{
+ cat << EOF
+usage: $0 options [TEST_SUITE ...]
+
+If no test suites are given ping.yaml is run.
+
+OPTIONS:
+ -h Show this message
+ -r IP address for Result API.
+ Default is to store the results to file ($DISPATCHER_FILE_NAME)
+ if this option is not present.
+
+EOF
+}
+
+DISPATCHER_TYPE=file
+DISPATCHER_FILE_NAME="/tmp/yardstick.out"
+DISPATCHER_HTTP_TARGET=
+
+while getopts "r:h" OPTION; do
+ case $OPTION in
+ h)
+ usage
+ exit 0
+ ;;
+ r)
+ DISPATCHER_TYPE=http
+ DISPATCHER_HTTP_TARGET=http://${OPTARG}/results
+ ;;
+ *)
+ echo "${OPTION} is not a valid argument"
+ exit 1
+ ;;
+ esac
+done
+
+shift $[OPTIND - 1]
+TEST_SUITES=$@
cleanup()
{
run_test()
{
echo
- echo "========== Running yardstick test suite =========="
+ echo "========== Running yardstick test suites =========="
+
+ mkdir -p /etc/yardstick
+
+ cat << EOF >> /etc/yardstick/yardstick.conf
+[DEFAULT]
+debug = True
+dispatcher = ${DISPATCHER_TYPE}
+
+[dispatcher_file]
+file_name = ${DISPATCHER_FILE_NAME}
+
+[dispatcher_http]
+timeout = 5
+target = ${DISPATCHER_HTTP_TARGET}
+EOF
+
+ local failed=0
+
+ if [ ${#SUITE_FILES[@]} -gt 0 ]; then
+
+ for suite in ${SUITE_FILES[*]}; do
+
+ echo "---------------------------"
+ echo "Running test suite: $suite"
+ echo "---------------------------"
+
+ if ! yardstick task start --suite $suite; then
+ echo "test suite $suite FAILED";
+
+ # Mark the test suite failed but continue
+ # running the remaining test suites.
+ (( failed++ ))
+ fi
+
+ done
+
+ if [ $failed -gt 0 ]; then
+
+ echo "---------------------------"
+ echo "$failed out of ${SUITE_FILES[*]} test suites FAILED"
+ echo "---------------------------"
+ exit 1
+ fi
+
+ else
+
+ echo "---------------------------"
+ echo "Running samples/ping.yaml "
+ echo "---------------------------"
+
+ if ! yardstick task start samples/ping.yaml; then
+ echo "Yardstick test FAILED"
+ exit 1
+ fi
- # Just run sample ping for now.
- if ! yardstick -d task start samples/ping.yaml; then
- echo "Yardstick test FAILED"
- exit 1
fi
+
}
main()
cd $GITROOT
+ export YARDSTICK_VERSION=$(git rev-parse HEAD)
+
+ SUITE_FILES=()
+
+ # find the test suite files
+ for suite in $TEST_SUITES; do
+ if [ -f $suite ]; then
+ SUITE_FILES+=($suite)
+ else
+ tsdir=$GITROOT/tests/opnfv/test_suites
+ if [ ! -f $tsdir/$suite ]; then
+ echo "Test suite \"$suite\" does not exist"
+ exit 1
+ fi
+ SUITE_FILES+=($tsdir/$suite)
+ fi
+ done
+
+ echo
+ echo "========== Running Yardstick CI with following parameters =========="
+ echo "Script options: ${SCRIPT} $SCRIPT_ARGS"
+ echo "Result API: ${DISPATCHER_HTTP_TARGET:-$DISPATCHER_FILE_NAME}"
+ echo "YARDSTICK_VERSION: ${YARDSTICK_VERSION}"
+ echo "Number of test suites: ${#SUITE_FILES[@]}"
+ for suite in ${SUITE_FILES[*]}; do
+ echo " $suite"
+ done
+
# install yardstick
install_yardstick
exit 1
fi
- # extract auth ip
- ip=$(echo $OS_AUTH_URL | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
-
- ## FIXME: temporarily disabling this because
- ## of timeout errors on LF-POD2.
- ## Maybe we need a longer timeout ??
- # check if the auth port is open
- # echo "Checking if tcp port $ip:5000 is open..."
- # nc -zv -w 10 $ip 5000; rc=$?;
- # if [ $rc -eq 0 ]; then
- # echo "$ip:5000 is open for tcp connections"
- # else
- # echo "$ip:5000 is closed"
- # exit 1
- # fi
-
# check if the api is up
echo "Checking if OS API is working..."
if ! glance image-list > /dev/null; then
trap "error_exit" EXIT SIGTERM
+ QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-trusty-server.img"
+
build_yardstick_image
load_yardstick_image
load_cirros_image
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import os
import json
import logging
import requests
self.timeout = CONF.dispatcher_http.timeout
self.target = CONF.dispatcher_http.target
self.raw_result = []
- # TODO set pod_name, installer, version based on pod info
self.result = {
"project_name": "yardstick",
"description": "yardstick test cases result",
- "pod_name": "opnfv-jump-2",
- "installer": "compass",
- "version": "Brahmaputra-dev"
+ "pod_name": os.environ.get('POD_NAME', 'unknown'),
+ "installer": os.environ.get('INSTALLER_TYPE', 'unknown'),
+ "version": os.environ.get('YARDSTICK_VERSION', 'unknown')
}
def record_result_data(self, data):