X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=ci%2Fyardstick-verify;h=875b01ff2ced9219c5fcecf6995581690ee0a0c9;hb=c3666affeae842e3c2d8f9191928f3ae4437bc59;hp=beb2170d35b2a1b3097ef278ef709c8375dc5a5e;hpb=7209b9b3f9aedaba4ed1ae91c78641a29d84ba0c;p=yardstick.git diff --git a/ci/yardstick-verify b/ci/yardstick-verify index beb2170d3..875b01ff2 100755 --- a/ci/yardstick-verify +++ b/ci/yardstick-verify @@ -32,9 +32,10 @@ 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. + -r Http target (example: -r 213.77.62.197/results) + -i Influxdb target (example: -i 127.0.0.1:8086) + + Default target is dump to file ($DISPATCHER_FILE_NAME) EOF } @@ -42,8 +43,9 @@ EOF DISPATCHER_TYPE=file DISPATCHER_FILE_NAME="/tmp/yardstick.out" DISPATCHER_HTTP_TARGET= +DISPATCHER_INFLUXDB_TARGET= -while getopts "r:h" OPTION; do +while getopts "r:i:h" OPTION; do case $OPTION in h) usage @@ -51,7 +53,13 @@ while getopts "r:h" OPTION; do ;; r) DISPATCHER_TYPE=http - DISPATCHER_HTTP_TARGET=http://${OPTARG}/results + DISPATCHER_HTTP_TARGET=http://${OPTARG} + DISPATCHER_FILE_NAME= + ;; + i) + DISPATCHER_TYPE=influxdb + DISPATCHER_INFLUXDB_TARGET=http://${OPTARG} + DISPATCHER_FILE_NAME= ;; *) echo "${OPTION} is not a valid argument" @@ -76,6 +84,8 @@ cleanup() echo "Deleting image $image..." glance image-delete $image || true done + + nova flavor-delete yardstick-flavor &> /dev/null || true } exitcode="" @@ -104,10 +114,11 @@ install_yardstick() echo echo "========== Installing yardstick ==========" - if ! sudo python setup.py install; then - echo 'Yardstick installation failed!' - exit 1 - fi + # uninstall previous version + pip uninstall -y yardstick || true + + # Install yardstick + pip install . } build_yardstick_image() @@ -115,27 +126,39 @@ build_yardstick_image() echo echo "========== Build yardstick cloud image ==========" - sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh + local cmd="sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh" + + # Build the image. Retry once if the build fails. + $cmd || $cmd + if [ ! -f $QCOW_IMAGE ]; then echo "Failed building QCOW image" exit 1 fi } +create_nova_flavor() +{ + if ! nova flavor-list | grep -q yardstick-flavor; then + echo + echo "========== Create nova flavor ==========" + # Create the nova flavor used by some sample test cases + nova flavor-create yardstick-flavor 100 512 3 1 + fi +} + load_cirros_image() { echo echo "========== Loading cirros cloud image ==========" - local image_file= - - wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img -O /tmp/cirros.img + local image_file=/home/opnfv/images/cirros-0.3.3-x86_64-disk.img output=$(glance image-create \ --name cirros-0.3.3 \ --disk-format qcow2 \ --container-format bare \ - --file /tmp/cirros.img) + --file $image_file) echo "$output" CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}') @@ -189,6 +212,13 @@ file_name = ${DISPATCHER_FILE_NAME} [dispatcher_http] timeout = 5 target = ${DISPATCHER_HTTP_TARGET} + +[dispatcher_influxdb] +timeout = 5 +target = ${DISPATCHER_INFLUXDB_TARGET} +db_name = yardstick +username = opnfv +password = 0pnfv2015 EOF local failed=0 @@ -201,22 +231,32 @@ EOF echo "Running test suite: $suite" echo "---------------------------" - if ! yardstick task start --suite $suite; then + 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 + # Mark the test suite failed but continue + # running the remaining test suites. + (( failed++ )) + fi + if [ ${DISPATCHER_TYPE} = file ]; then + echo "---------------------------" + echo "Dump test suite $suite result" + echo "---------------------------" + if [ -f ${DISPATCHER_FILE_NAME} ]; then + cat ${DISPATCHER_FILE_NAME} + else + echo "Test result file ${DISPATCHER_FILE_NAME} is not exist" + fi + fi - done + done - if [ $failed -gt 0 ]; then + if [ $failed -gt 0 ]; then - echo "---------------------------" - echo "$failed out of ${SUITE_FILES[*]} test suites FAILED" - echo "---------------------------" - exit 1 + echo "---------------------------" + echo "$failed out of ${SUITE_FILES[*]} test suites FAILED" + echo "---------------------------" + exit 1 fi else @@ -230,6 +270,17 @@ EOF exit 1 fi + if [ ${DISPATCHER_TYPE} = file ]; then + echo "---------------------------" + echo "Dump samples/ping.yaml test result" + echo "---------------------------" + if [ -f ${DISPATCHER_FILE_NAME} ]; then + cat ${DISPATCHER_FILE_NAME} + else + echo "Test result file ${DISPATCHER_FILE_NAME} is not exist" + fi + fi + fi } @@ -261,15 +312,13 @@ main() echo echo "========== Running Yardstick CI with following parameters ==========" echo "Script options: ${SCRIPT} $SCRIPT_ARGS" - echo "Result API: ${DISPATCHER_HTTP_TARGET:-$DISPATCHER_FILE_NAME}" + echo "Dispatcher: ${DISPATCHER_TYPE} ${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 + echo # check if some necessary variables is set if [ -z "$OS_AUTH_URL" ]; then @@ -277,12 +326,27 @@ main() exit 1 fi - # check if the api is up - echo "Checking if OS API is working..." - if ! glance image-list > /dev/null; then - echo "OS API is down" - exit 1 - fi + echo "OS_AUTH_URL is $OS_AUTH_URL" + echo + + # check OpenStack services + echo "Checking OpenStack services:" + for cmd in "glance image-list" "nova list" "heat stack-list"; do + echo " checking ${cmd/%\ */} ..." + if ! $cmd >/dev/null; then + echo "error: command \"$cmd\" failed" + exit 1 + fi + done + + echo + echo "Checking for External network:" + for net in $(neutron net-list --router:external -c name -f value); do + echo " external network: $net" + done + + # install yardstick + install_yardstick cleanup @@ -293,6 +357,7 @@ main() build_yardstick_image load_yardstick_image load_cirros_image + create_nova_flavor run_test }