Add the yardstick invokation script 65/4565/6
authorYunhong Jiang <yunhong.jiang@linux.intel.com>
Tue, 8 Dec 2015 04:30:30 +0000 (23:30 -0500)
committerYunhong Jiang <yunhong.jiang@linux.intel.com>
Wed, 6 Jan 2016 03:32:48 +0000 (19:32 -0800)
This script does the real yardstick works. It downloads the yardstick code,
and run the cyclictest test case.

This scripts is copied by the cyclictest.sh to the container image and
is executed from the yardstick container.

It's based on a script from QiLiang when discussing the integration with
yardstick.

Change-Id: I5920a21401a3e442d5f4fada05d9e789f2a99add
Signed-off-by: Yunhong Jiang <yunhong.jiang@linux.intel.com>
Signed-off-by: QiLiang <liangqi1@huawei.com>
tests/testexec.sh [new file with mode: 0755]

diff --git a/tests/testexec.sh b/tests/testexec.sh
new file mode 100755 (executable)
index 0000000..d83ace9
--- /dev/null
@@ -0,0 +1,148 @@
+#!/bin/bash
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+set -e
+set -o errexit
+set -o pipefail
+
+: ${YARDSTICK_REPO:='https://gerrit.opnfv.org/gerrit/yardstick'}
+: ${YARDSTICK_REPO_DIR:='/home/opnfv/repos/yardstick'}
+: ${YARDSTICK_BRANCH:='master'} # branch, tag, sha1 or refspec
+
+: ${INSTALLER_TYPE:='fuel'}
+: ${INSTALLER_IP:='10.20.0.2'}
+
+: ${POD_NAME:='opnfv-jump-2'}
+: ${EXTERNAL_NET:='net04_ext'}
+
+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 yardstick -> $YARDSTICK_BRANCH"
+if [ ! -d $YARDSTICK_REPO_DIR ]; then
+    git clone YARDSTICK_REPO $YARDSTICK_REPO_DIR
+fi
+cd $YARDSTICK_REPO_DIR
+
+
+git checkout master && git pull
+git_checkout $YARDSTICK_BRANCH $YARDSTICK_REPO
+
+export EXTERNAL_NET INSTALLER_TYPE POD_NAME
+
+# Verifiy
+
+DISPATCHER_TYPE=file
+DISPATCHER_FILE_NAME="/tmp/yardstick.out.$$"
+
+exitcode=""
+
+error_exit()
+{
+    local rc=$?
+
+    if [ -z "$exitcode" ]; then
+        # In case of recursive traps (!?)
+        exitcode=$rc
+    fi
+
+    echo "Exiting with RC=$exitcode"
+
+    exit $exitcode
+}
+
+
+install_yardstick()
+{
+    echo
+    echo "========== Installing yardstick =========="
+
+    if ! sudo -E python setup.py install; then
+        echo 'Yardstick installation failed!'
+        exit 1
+    fi
+}
+
+
+run_test()
+{
+    echo
+    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
+
+    echo "----------------------------------------------"
+    echo "Running samples/cyclictest-node-context.yaml  "
+    echo "----------------------------------------------"
+
+    if ! yardstick task start /opt/cyclictest-node-context.yaml; then
+        echo "Yardstick test FAILED"
+        exit 1
+    fi
+    echo "----------------------------------------------"
+    echo "Dump test result:                             "
+    cat ${DISPATCHER_FILE_NAME}
+    echo "----------------------------------------------"
+    rm -rf ${DISPATCHER_FILE_NAME}
+}
+
+
+verifiy()
+{
+    GITROOT=$YARDSTICK_REPO_DIR
+
+    cd $GITROOT
+
+    export YARDSTICK_VERSION=$(git rev-parse HEAD)
+
+    # fetch patch
+    git fetch https://QiLiang@gerrit.opnfv.org/gerrit/yardstick refs/changes/33/3633/1 && git checkout FETCH_HEAD
+
+    # If any change needed for yardstick, applied here.
+    if [ -e /opt/yardstick.patch ]
+    then
+        patch -p1 -i /opt/yardstick.patch
+    fi
+    # install yardstick
+    install_yardstick
+
+    trap "error_exit" EXIT SIGTERM
+
+    run_test
+}
+
+
+verifiy
+