diff options
Diffstat (limited to 'tests')
68 files changed, 908 insertions, 556 deletions
diff --git a/tests/ci/clean_images.sh b/tests/ci/clean_images.sh new file mode 100755 index 000000000..b1942160b --- /dev/null +++ b/tests/ci/clean_images.sh @@ -0,0 +1,29 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2015 Ericsson AB, Huawei Technologies Co.,Ltd and others. +# +# 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 +############################################################################## + +# Clean the images and flavor before running yardstick test suites. + +cleanup() +{ + echo + echo "========== Cleanup ==========" + + if ! glance image-list; then + return + fi + + for image in $(glance image-list | grep -e cirros-0.3.3 -e yardstick-image -e Ubuntu-14.04 \ + -e yardstick-vivid-kernel | awk '{print $2}'); do + echo "Deleting image $image..." + glance image-delete $image || true + done + + nova flavor-delete yardstick-flavor &> /dev/null || true +} diff --git a/tests/ci/docker/Makefile b/tests/ci/docker/Makefile deleted file mode 100644 index 036d67db3..000000000 --- a/tests/ci/docker/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Ericsson AB and others. -# -# 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 -############################################################################## - -SHELL = /bin/bash - -IMAGE = opnfv/yardstick - -DOCKER_TAG = brahmaputra.0 - -.PHONY: all -all: .docker - -.docker: - /usr/bin/docker build --rm=true --no-cache=true -t $(IMAGE):$(DOCKER_TAG) yardstick-ci - /usr/bin/docker tag -f $(IMAGE):$(DOCKER_TAG) $(IMAGE):latest - touch .docker - - -.PHONY: clean -clean: - @docker ps | grep $(IMAGE) | awk '{print $$1}' | xargs -r docker stop - @docker ps -a | grep $(IMAGE) | awk '{print $$1}' | xargs -r docker rm - @echo "Docker images to remove:" - @docker images | head -1 && docker images | grep $(IMAGE) || true - @image_tags=($$(docker images | grep $(IMAGE) | awk '{print $$2}')) ; \ - for tag in "$${image_tags[@]}"; do \ - echo "Removing docker image $(IMAGE):$$tag..." ; \ - docker rmi $(IMAGE):$$tag ; \ - done - rm -f .docker diff --git a/tests/ci/docker/yardstick-ci/Dockerfile b/tests/ci/docker/yardstick-ci/Dockerfile deleted file mode 100644 index da755d11d..000000000 --- a/tests/ci/docker/yardstick-ci/Dockerfile +++ /dev/null @@ -1,55 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Ericsson AB and others. -# -# 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 -############################################################################## - -FROM ubuntu:14.04 - -LABEL image=opnfv/yardstick - -# GIT repo directory -ENV REPOS_DIR /home/opnfv/repos - -# Yardstick repo -ENV YARDSTICK_REPO_DIR ${REPOS_DIR}/yardstick -ENV RELENG_REPO_DIR ${REPOS_DIR}/releng - -RUN apt-get update && apt-get install -y \ - wget \ - expect \ - curl \ - git \ - sshpass \ - qemu-utils \ - kpartx \ - libffi-dev \ - libssl-dev \ - python \ - python-dev \ - libxml2-dev \ - libxslt1-dev \ - python-setuptools && \ - easy_install -U setuptools - -RUN apt-get -y autoremove && \ - apt-get clean - -RUN mkdir -p ${REPOS_DIR} - -RUN git config --global http.sslVerify false -RUN git clone https://gerrit.opnfv.org/gerrit/yardstick ${YARDSTICK_REPO_DIR} -RUN git clone https://gerrit.opnfv.org/gerrit/releng ${RELENG_REPO_DIR} - -# install yardstick + dependencies -RUN cd ${YARDSTICK_REPO_DIR} && easy_install -U pip -RUN cd ${YARDSTICK_REPO_DIR} && pip install -r tests/ci/requirements.txt -RUN cd ${YARDSTICK_REPO_DIR} && pip install . - -ADD http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img /home/opnfv/images/ -ADD http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img /home/opnfv/images/ - -COPY ./exec_tests.sh /usr/local/bin/ diff --git a/tests/ci/docker/yardstick-ci/exec_tests.sh b/tests/ci/docker/yardstick-ci/exec_tests.sh deleted file mode 100755 index 9aee240da..000000000 --- a/tests/ci/docker/yardstick-ci/exec_tests.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -############################################################################## -# Copyright (c) 2015 Ericsson AB and others. -# -# 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 - -: ${YARDSTICK_REPO:='https://gerrit.opnfv.org/gerrit/yardstick'} -: ${YARDSTICK_REPO_DIR:='/home/opnfv/repos/yardstick'} -: ${YARDSTICK_BRANCH:='master'} # branch, tag, sha1 or refspec - -: ${RELENG_REPO:='https://gerrit.opnfv.org/gerrit/releng'} -: ${RELENG_REPO_DIR:='/home/opnfv/repos/releng'} -: ${RELENG_BRANCH:='master'} # branch, tag, sha1 or refspec - -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 checkout master && git pull -git_checkout $RELENG_BRANCH $RELENG_REPO - -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 - -# setup the environment -source $YARDSTICK_REPO_DIR/tests/ci/prepare_env.sh - -# execute tests -$YARDSTICK_REPO_DIR/tests/ci/yardstick-verify $@ diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh new file mode 100755 index 000000000..405d72076 --- /dev/null +++ b/tests/ci/load_images.sh @@ -0,0 +1,237 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2015 Ericsson AB, Huawei Technologies Co.,Ltd and others. +# +# 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 up the environment to run yardstick test suites. + +set -e + +YARD_IMG_ARCH=amd64 +export YARD_IMG_ARCH + +if ! grep -q "Defaults env_keep += \"YARD_IMG_ARCH\"" "/etc/sudoers"; then + sudo echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" >> /etc/sudoers +fi + +ARCH_SCRIPT="test -f /etc/fuel_openstack_arch && grep -q arm64 /etc/fuel_openstack_arch" +if [ "$INSTALLER_TYPE" == "fuel" ]; then + sshpass -p r00tme ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root $INSTALLER_IP "${ARCH_SCRIPT}" && YARD_IMG_ARCH=arm64 +fi + +UCA_HOST="cloud-images.ubuntu.com" +if [ $YARD_IMG_ARCH = "arm64" ]; then + export VIVID_IMG_URL="http://${UCA_HOST}/vivid/current/vivid-server-cloudimg-arm64.tar.gz" + if ! grep -q "Defaults env_keep += \"VIVID_IMG_URL\"" "/etc/sudoers"; then + sudo echo "Defaults env_keep += \"VIVID_IMG_URL\"" >> /etc/sudoers + fi +fi + +build_yardstick_image() +{ + echo + echo "========== Build yardstick cloud image ==========" + + if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then + local cmd="sudo $(which yardstick-img-lxd-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh" + + # Build the image. Retry once if the build fails + $cmd || $cmd + + if [ ! -f $RAW_IMAGE ]; then + echo "Failed building RAW image" + exit 1 + fi + else + 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 + fi +} + +load_yardstick_image() +{ + echo + echo "========== Loading yardstick cloud image ==========" + EXTRA_PARAMS="" + if [ $YARD_IMG_ARCH = "arm64" ]; then + VIVID_IMAGE="/tmp/vivid-server-cloudimg-arm64.tar.gz" + VIVID_KERNEL="/tmp/vivid-server-cloudimg-arm64-vmlinuz-generic" + cd /tmp + if [ ! -f $VIVID_IMAGE ]; then + wget $VIVID_IMG_URL + fi + if [ ! -f $VIVID_KERNEL ]; then + tar zxf $VIVID_IMAGE $(basename $VIVID_KERNEL) + fi + create_vivid_kernel=$(glance --os-image-api-version 1 image-create \ + --name yardstick-vivid-kernel \ + --is-public true --disk-format qcow2 \ + --container-format bare \ + --file $VIVID_KERNEL) + + GLANCE_KERNEL_ID=$(echo "$create_vivid_kernel" | grep " id " | awk '{print $(NF-1)}') + if [ -z "$GLANCE_KERNEL_ID" ]; then + echo 'Failed uploading kernel to cloud'. + exit 1 + fi + + command_line="root=/dev/vdb1 console=tty0 console=ttyS0 console=ttyAMA0 rw" + + EXTRA_PARAMS="--property kernel_id=$GLANCE_KERNEL_ID --property os_command_line=\"$command_line\"" + + rm -f $VIVID_KERNEL $VIVID_IMAGE + cd $YARDSTICK_REPO_DIR + fi + + # VPP requires guest memory to be backed by large pages + if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then + EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large" + fi + + if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then + output=$(eval glance --os-image-api-version 1 image-create \ + --name yardstick-image \ + --is-public true --disk-format root-tar \ + --container-format bare \ + $EXTRA_PARAMS \ + --file $RAW_IMAGE) + else + output=$(eval glance --os-image-api-version 1 image-create \ + --name yardstick-image \ + --is-public true --disk-format qcow2 \ + --container-format bare \ + $EXTRA_PARAMS \ + --file $QCOW_IMAGE) + fi + + echo "$output" + + GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}') + + if [ -z "$GLANCE_IMAGE_ID" ]; then + echo 'Failed uploading image to cloud'. + exit 1 + fi + + if [ "$DEPLOY_SCENARIO" == *"-lxd-"* ]; then + sudo rm -f $RAW_IMAGE + else + sudo rm -f $QCOW_IMAGE + fi + + echo "Glance image id: $GLANCE_IMAGE_ID" +} + +load_cirros_image() +{ + echo + echo "========== Loading cirros cloud image ==========" + + local image_file=/home/opnfv/images/cirros-0.3.3-x86_64-disk.img + + EXTRA_PARAMS="" + # VPP requires guest memory to be backed by large pages + if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then + EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large" + fi + + output=$(glance image-create \ + --name cirros-0.3.3 \ + --disk-format qcow2 \ + --container-format bare \ + $EXTRA_PARAMS \ + --file $image_file) + echo "$output" + + CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}') + if [ -z "$CIRROS_IMAGE_ID" ]; then + echo 'Failed uploading cirros image to cloud'. + exit 1 + fi + + echo "Cirros image id: $CIRROS_IMAGE_ID" +} + +load_ubuntu_image() +{ + echo + echo "========== Loading ubuntu cloud image ==========" + + local ubuntu_image_file=/home/opnfv/images/trusty-server-cloudimg-amd64-disk1.img + + EXTRA_PARAMS="" + # VPP requires guest memory to be backed by large pages + if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then + EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large" + fi + + output=$(glance image-create \ + --name Ubuntu-14.04 \ + --disk-format qcow2 \ + --container-format bare \ + $EXTRA_PARAMS \ + --file $ubuntu_image_file) + echo "$output" + + UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}') + + if [ -z "$UBUNTU_IMAGE_ID" ]; then + echo 'Failed uploading UBUNTU image to cloud'. + exit 1 + fi + + echo "Ubuntu image id: $UBUNTU_IMAGE_ID" +} + +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 + # DPDK-enabled OVS requires guest memory to be backed by large pages + if [[ "$DEPLOY_SCENARIO" == *"-ovs-"* ]]; then + nova flavor-key yardstick-flavor set hw:mem_page_size=large + fi + # VPP requires guest memory to be backed by large pages + if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then + nova flavor-key yardstick-flavor set hw:mem_page_size=large + fi + fi +} + +main() +{ + QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img" + RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz" + + build_yardstick_image + load_yardstick_image + if [ $YARD_IMG_ARCH = "arm64" ]; then + sed -i 's/image: cirros-0.3.3/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml \ + samples/ping.yaml + #We have overlapping IP with the real network + for filename in tests/opnfv/test_cases/*; do + sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" $filename + done + else + load_cirros_image + load_ubuntu_image + fi + create_nova_flavor +} + +main diff --git a/tests/ci/prepare_env.sh b/tests/ci/prepare_env.sh index d9f8257ae..be59b7f37 100755 --- a/tests/ci/prepare_env.sh +++ b/tests/ci/prepare_env.sh @@ -15,7 +15,6 @@ : ${NODE_NAME:='unknown'} : ${EXTERNAL_NETWORK:='admin_floating_net'} - # Extract network name from EXTERNAL_NETWORK # e.g. EXTERNAL_NETWORK='ext-net;flat;192.168.0.2;192.168.0.253;192.168.0.1;192.168.0.0/24' export EXTERNAL_NETWORK=$(echo $EXTERNAL_NETWORK | cut -f1 -d \;) @@ -83,5 +82,33 @@ if [ "$INSTALLER_TYPE" == "fuel" ]; then echo "Fetching id_rsa file from jump_server $INSTALLER_IP..." sshpass -p r00tme scp 2>/dev/null $ssh_options \ root@${INSTALLER_IP}:~/.ssh/id_rsa /root/.ssh/id_rsa &> /dev/null -fi + sshpass -p r00tme ssh 2>/dev/null $ssh_options \ + root@${INSTALLER_IP} fuel node>fuel_node + + # update fuel node id and ip info according to the CI env + controller_IDs=($(cat fuel_node|grep controller|awk '{print $1}')) + compute_IDs=($(cat fuel_node|grep compute|awk '{print $1}')) + controller_ips=($(cat fuel_node|grep controller|awk '{print $10}')) + compute_ips=($(cat fuel_node|grep compute|awk '{print $10}')) + + pod_yaml="./etc/yardstick/nodes/fuel_baremetal/pod.yaml" + node_line_num=($(grep -n node[1-5] $pod_yaml | awk -F: '{print $1}')) + + if [[ ${controller_ips[0]} ]]; then + sed -i "${node_line_num[0]}s/node1/node${controller_IDs[0]}/;s/ip1/${controller_ips[0]}/" $pod_yaml; + fi + if [[ ${controller_ips[1]} ]]; then + sed -i "${node_line_num[1]}s/node2/node${controller_IDs[1]}/;s/ip2/${controller_ips[1]}/" $pod_yaml; + fi + if [[ ${controller_ips[2]} ]]; then + sed -i "${node_line_num[2]}s/node3/node${controller_IDs[2]}/;s/ip3/${controller_ips[2]}/" $pod_yaml; + fi + if [[ ${compute_ips[0]} ]]; then + sed -i "${node_line_num[3]}s/node4/node${compute_IDs[0]}/;s/ip4/${compute_ips[0]}/" $pod_yaml; + fi + if [[ ${compute_ips[1]} ]]; then + sed -i "${node_line_num[4]}s/node5/node${compute_IDs[1]}/;s/ip5/${compute_ips[1]}/" $pod_yaml; + fi + +fi diff --git a/tests/ci/report_config.yaml b/tests/ci/report_config.yaml new file mode 100644 index 000000000..5346e608b --- /dev/null +++ b/tests/ci/report_config.yaml @@ -0,0 +1,7 @@ +reporting: + - + name: apex + scenario: + - + os-nosdn-ovs-noha + diff --git a/tests/ci/requirements.txt b/tests/ci/requirements.txt deleted file mode 100644 index 4d1a16993..000000000 --- a/tests/ci/requirements.txt +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Ericsson AB and others. -# -# 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 -############################################################################## - -appdirs==1.4.0 -Babel==2.2.0 -backport-ipaddress==0.1 -cliff==2.0.0 -cmd2==0.6.8 -coverage==4.1b2 -debtcollector==1.3.0 -ecdsa==0.13 -extras==0.0.3 -fixtures==1.4.0 -flake8==2.5.4 -funcsigs==0.4 -functools32==3.2.3.post2 -futures==3.0.5 -iso8601==0.1.11 -Jinja2==2.8 -jsonpatch==1.13 -jsonpointer==1.10 -jsonschema==2.5.1 -keystoneauth1==2.3.0 -linecache2==1.0.0 -lxml==3.5.0 -MarkupSafe==0.23 -mccabe==0.4.0 -mock==1.3.0 -monotonic==1.0 -msgpack-python==0.4.7 -netaddr==0.7.18 -netifaces==0.10.4 -nose==1.3.7 -openstacksdk==0.8.1 -os-client-config==1.16.0 -oslo.config==3.9.0 -oslo.i18n==3.4.0 -oslo.serialization==2.4.0 -oslo.utils==3.7.0 -paramiko==1.16.0 -pbr==1.8.1 -pep8==1.7.0 -positional==1.0.1 -prettytable==0.7.2 -pycrypto==2.6.1 -pyflakes==1.0.0 -pyparsing==2.1.0 -pyrsistent==0.11.12 -python-cinderclient==1.6.0 -python-glanceclient==2.0.0 -python-heatclient==1.0.0 -python-keystoneclient==2.3.1 -python-mimeparse==1.5.1 -python-neutronclient==4.1.1 -python-novaclient==3.3.0 -python-openstackclient==2.2.0 -python-subunit==1.2.0 -python-swiftclient==3.0.0 -pytz==2015.7 -PyYAML==3.11 -requests==2.9.1 -requestsexceptions==1.1.3 -scp==0.10.2 -simplejson==3.8.2 -six==1.10.0 -stevedore==1.12.0 -testrepository==0.0.20 -testtools==2.0.0 -traceback2==1.4.0 -unicodecsv==0.14.1 -unittest2==1.1.0 -warlock==1.2.0 -wrapt==1.10.6 diff --git a/tests/ci/yardstick-verify b/tests/ci/yardstick-verify index eafadf987..7644c96c4 100755 --- a/tests/ci/yardstick-verify +++ b/tests/ci/yardstick-verify @@ -71,23 +71,6 @@ done shift $[OPTIND - 1] TEST_SUITES=$@ -cleanup() -{ - echo - echo "========== Cleanup ==========" - - if ! glance image-list; then - return - fi - - for image in $(glance image-list | grep -e cirros-0.3.3 -e yardstick-trusty-server -e Ubuntu-14.04 | awk '{print $2}'); do - echo "Deleting image $image..." - glance image-delete $image || true - done - - nova flavor-delete yardstick-flavor &> /dev/null || true -} - exitcode="" error_exit() @@ -151,105 +134,23 @@ remove_storperf() fi } -build_yardstick_image() -{ - echo - echo "========== Build yardstick cloud image ==========" - - 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 - # DPDK-enabled OVS requires guest memory to be backed by large pages - if [[ "$DEPLOY_SCENARIO" == *"-ovs-"* ]]; then - nova flavor-key yardstick-flavor set hw:mem_page_size=large - fi - fi -} - -load_cirros_image() -{ - echo - echo "========== Loading cirros cloud image ==========" - - 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 $image_file) - echo "$output" - - CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}') - if [ -z "$CIRROS_IMAGE_ID" ]; then - echo 'Failed uploading cirros image to cloud'. - exit 1 - fi - - echo "Cirros image id: $CIRROS_IMAGE_ID" -} - -load_ubuntu_image() -{ - echo - echo "========== Loading ubuntu cloud image ==========" - - local ubuntu_image_file=/home/opnfv/images/trusty-server-cloudimg-amd64-disk1.img - - output=$(glance image-create \ - --name Ubuntu-14.04 \ - --disk-format qcow2 \ - --container-format bare \ - --file $ubuntu_image_file) - echo "$output" - - UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}') - - if [ -z "$UBUNTU_IMAGE_ID" ]; then - echo 'Failed uploading UBUNTU image to cloud'. - exit 1 - fi - - echo "Ubuntu image id: $UBUNTU_IMAGE_ID" -} +report(){ -load_yardstick_image() -{ echo - echo "========== Loading yardstick cloud image ==========" - - output=$(glance --os-image-api-version 1 image-create \ - --name yardstick-trusty-server \ - --is-public true --disk-format qcow2 \ - --container-format bare \ - --file $QCOW_IMAGE) - echo "$output" - - GLANCE_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}') - - if [ -z "$GLANCE_IMAGE_ID" ]; then - echo 'Failed uploading image to cloud'. - exit 1 - fi - - sudo rm -f $QCOW_IMAGE - - echo "Glance image id: $GLANCE_IMAGE_ID" + echo "========== Reporting Status ==========" + curl -i -H 'content-type: application/json' -X POST -d \ + "{\"project_name\": \"yardstick\", + \"case_name\": \"scenario_status\", + \"pod_name\":\"${NODE_NAME}\", + \"installer\":\"${INSTALLER_TYPE}\", + \"version\":\"$(basename ${YARDSTICK_BRANCH})\", + \"scenario\":\"${DEPLOY_SCENARIO}\", + \"description\": \"yardstick ci scenario status\", + \"criteria\":\"$1\", + \"start_date\":\"$2\", + \"stop_date\":\"$3\", + \"details\":\"\"}" \ + ${DISPATCHER_HTTP_TARGET} } run_test() @@ -259,9 +160,9 @@ run_test() mkdir -p /etc/yardstick - cat << EOF >> /etc/yardstick/yardstick.conf + cat << EOF > /etc/yardstick/yardstick.conf [DEFAULT] -debug = True +debug = False dispatcher = ${DISPATCHER_TYPE} [dispatcher_file] @@ -296,7 +197,7 @@ EOF # Mark the test suite failed but continue # running the remaining test suites. - (( failed++ )) + (( ++failed )) fi if [ ${DISPATCHER_TYPE} = file ]; then echo "---------------------------" @@ -313,23 +214,13 @@ EOF - local sceanrio_status="SUCCESS" + local scenario_status="SUCCESS" if [ $failed -gt 0 ]; then scenario_status="FAILED" fi - curl -i -H 'content-type: application/json' -X POST -d \ - "{\"project_name\": \"yardstick\", - \"case_name\": \"scenario_status\", - \"pod_name\":\"${NODE_NAME}\", - \"installer\":\"${INSTALLER_TYPE}\", - \"version\":\"${YARDSTICK_BRANCH}\", - \"scenario\":\"${DEPLOY_SCENARIO}\", - \"description\": \"yardstick ci scenario status\", - \"start_date\":\"${start_date}\", - \"stop_date\":\"${stop_date}\", - \"details\":\"${sceanrio_status}\"}" \ - ${DISPATCHER_HTTP_TARGET} + + report $scenario_status $start_date $stop_date if [ $failed -gt 0 ]; then echo "---------------------------" @@ -427,18 +318,13 @@ main() # install yardstick install_yardstick + source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh + cleanup trap "error_exit" EXIT SIGTERM - QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-trusty-server.img" - - build_yardstick_image - load_yardstick_image - load_cirros_image - load_ubuntu_image - create_nova_flavor - + source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh install_storperf run_test remove_storperf diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml index 899ee963c..aa2980f69 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml @@ -31,7 +31,7 @@ scenarios: context: name: yardstick - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml index 1942bb54f..3c7b988c0 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml @@ -2,6 +2,7 @@ # measure network latency using ping schema: "yardstick:task:0.1" +{% set image = image or "cirros-0.3.3" %} scenarios: {% for i in range(2) %} - @@ -23,8 +24,8 @@ scenarios: context: name: demo - image: cirros-0.3.3 - flavor: m1.tiny + image: {{image}} + flavor: yardstick-flavor user: cirros placement_groups: diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml index 6e50157fc..732d73af7 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml @@ -35,7 +35,7 @@ scenarios: context: name: yardstick-TC005 - image: yardstick-trusty-server + image: yardstick-image flavor: m1.small user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml index 1cec80ff6..a2f5f3adc 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml @@ -37,7 +37,7 @@ scenarios: context: name: yardstick-TC008 - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml index 82a55d751..f9fa1b778 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml @@ -32,7 +32,7 @@ scenarios: context: name: yardstick-TC009 - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml index aeb18543e..f64968cb1 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml @@ -25,7 +25,7 @@ scenarios: context: name: yardstick-TC010 - image: yardstick-trusty-server + image: yardstick-image flavor: m1.small user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml index 5d21e2814..4cd3119bb 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml @@ -23,7 +23,7 @@ scenarios: context: name: demo - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml index 3bdb8cb9a..a86943a51 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml @@ -26,7 +26,7 @@ scenarios: context: name: demo - image: yardstick-trusty-server + image: yardstick-image flavor: m1.small user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml index 648657f22..1ac0f2961 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml @@ -19,7 +19,7 @@ scenarios: context: name: yardstick-TC014 - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu @@ -29,4 +29,4 @@ context: networks: test: - cidr: '10.0.1.0/24'
\ No newline at end of file + cidr: '10.0.1.0/24' diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml index 544118869..5032f3de3 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml @@ -3,13 +3,18 @@ # Measure IPV6 network latency using ping6 schema: "yardstick:task:0.1" +{% set openrc = openrc or "/opt/admin-openrc.sh" %} +{% set external_network = external_network or "ext-net" %} {% set pod_info = pod_info or "etc/yardstick/nodes/compass_sclab_physical/pod.yaml" %} scenarios: - type: Ping6 options: packetsize: 56 + ping_count: 5 host: host1,host2,host3,host4,host5 + openrc: {{openrc}} + external_network: {{external_network}} nodes: host1: node1.IPV6 host2: node2.IPV6 @@ -25,14 +30,9 @@ scenarios: max_rtt: 30 action: monitor -precondition: - installer_type: compass - deploy_scenarios: os-nosdn - pod_name: huawei-pod1 context: type: Node name: IPV6 file: {{pod_info}} - diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml index 5e2177a6e..cd42098d2 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml @@ -64,7 +64,7 @@ scenarios: context: name: yardstick-TC037 - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml index 128f94045..c2e5b4028 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml @@ -64,7 +64,7 @@ scenarios: context: name: yardstick-TC038 - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml index b43e56665..54fc965c6 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml @@ -1,6 +1,13 @@ --- # Yardstick TC055 config file -# Collect hardware specification from /proc/cpuinfo +# Collect hardware specification from /proc/cpuinfo /proc/meminfo +# compute capacity and scale. + +# the results have +# number of CPUs, number of physical cores in a single CPU +# number of logical cores, total memory size +# cache size per CPU, total cache size +# HT (Hyper-Thread) support status, 1 for open, 0 for close schema: "yardstick:task:0.1" {% set host = host or "node5.yardstick-TC055" %} diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml index 9da889847..981783765 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml @@ -1,3 +1,4 @@ +--- # Yardstick TC063 config file # Measure disk size, block size and disk utilization using fdisk and iostat diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml index 637e160c6..dcc34d80d 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml @@ -25,7 +25,7 @@ scenarios: context: name: yardstick-TC069 - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml index 28b28b9ab..931587b5b 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml @@ -66,7 +66,7 @@ scenarios: context: name: yardstick-TC070 - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml index 644010916..6f006eeaf 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml @@ -64,7 +64,7 @@ scenarios: context: name: yardstick-TC071 - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml index f3e6d4c40..e1fa33173 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml @@ -66,7 +66,7 @@ scenarios: context: name: yardstick-TC072 - image: yardstick-trusty-server + image: yardstick-image flavor: yardstick-flavor user: ubuntu diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc075.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc075.yaml index d4a978c1d..fb5a12e8a 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc075.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc075.yaml @@ -1,8 +1,7 @@ --- # Yardstick TC075 config file -# Measure compute capacity and scale. -# Including number of cores, number of threads, available memory size and -# cache size. +# Measure network capacity and scale. +# Measure number of connections, number of frames received schema: "yardstick:task:0.1" {% set host = host or "node1.LF" %} diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-fdio-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-fdio-noha_daily.yaml new file mode 100644 index 000000000..187e10988 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-fdio-noha_daily.yaml @@ -0,0 +1,30 @@ +--- +# FDS suite + +schema: "yardstick:suite:0.1" + +name: "os-nosdn-fdio-noha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc001.yaml +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc006.yaml +- + file_name: opnfv_yardstick_tc007.yaml +- + file_name: opnfv_yardstick_tc008.yaml +- + file_name: opnfv_yardstick_tc009.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc020.yaml +- + file_name: opnfv_yardstick_tc021.yaml +- + file_name: opnfv_yardstick_tc037.yaml +- + file_name: opnfv_yardstick_tc038.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-ha_daily.yaml index eb1226f80..29235b6f6 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-nosdn-kvm-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-noha_daily.yaml index 02fb31e47..fd48cadb1 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-nosdn-kvm-noha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs-ha_daily.yaml index 27accf49c..b488505af 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-nosdn-kvm_ovs-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-lxd-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-lxd-ha_daily.yaml index cbb2069f9..01591b9d2 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-lxd-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-lxd-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-nosdn-lxd-ha daily task suite schema: "yardstick:suite:0.1" @@ -8,6 +8,12 @@ test_cases_dir: "tests/opnfv/test_cases/" test_cases: - file_name: opnfv_yardstick_tc002.yaml + constraint: + installer: joid + pod: intel-pod5,intel-pod6 + task_args: + intel-pod5: '{"image": "Cirros LXC 0.3"}' + intel-pod6: '{"image": "Cirros LXC 0.3"}' - file_name: opnfv_yardstick_tc005.yaml - diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-lxd-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-lxd-noha_daily.yaml index cbbf8c13e..e1f945b9c 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-lxd-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-lxd-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-nosdn-lxd-noha daily task suite schema: "yardstick:suite:0.1" @@ -8,6 +8,12 @@ test_cases_dir: "tests/opnfv/test_cases/" test_cases: - file_name: opnfv_yardstick_tc002.yaml + constraint: + installer: joid + pod: intel-pod5,intel-pod6 + task_args: + intel-pod5: '{"image": "Cirros LXC 0.3"}' + intel-pod6: '{"image": "Cirros LXC 0.3"}' - file_name: opnfv_yardstick_tc005.yaml - diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml index ebe7a0513..44c8494d1 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-nosdn-nofeature-ha daily task suite schema: "yardstick:suite:0.1" @@ -19,13 +19,6 @@ test_cases: - file_name: opnfv_yardstick_tc014.yaml - - file_name: opnfv_yardstick_tc027.yaml - constraint: - installer: compass - pod: huawei-pod1 - task_args: - huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' -- file_name: opnfv_yardstick_tc037.yaml - file_name: opnfv_yardstick_tc043.yaml @@ -111,4 +104,14 @@ test_cases: task_args: huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml", "host": "node1.LF"}' +- + file_name: opnfv_yardstick_tc027.yaml + constraint: + installer: compass,fuel + pod: huawei-pod1,lf-pod2,ericsson-pod3,ericsson-pod4 + task_args: + huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}' + ericsson-pod3: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}' + ericsson-pod4: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}' diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-noha_daily.yaml index 567e8bf73..e85a9788f 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-nosdn-nofeature-noha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-ha_daily.yaml index 6cf5b38d3..a61d8242c 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-nosdn-ovs-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-noha_daily.yaml index 9e5074fc6..6c91a3337 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-nosdn-ovs-noha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-ha_daily.yaml index 7106a1335..9ea030a40 100644 --- a/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-ocl-nofeature-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-noha_daily.yaml index 42781a841..e2f07650c 100644 --- a/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-ocl-nofeature-noha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-ha_daily.yaml index 639e18e85..cd9c29268 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-odl_l2-bgpvpn-ha daily task suite schema: "yardstick:suite:0.1" @@ -7,40 +7,10 @@ name: "os-odl_l2-bgpvpn-ha" test_cases_dir: "tests/opnfv/test_cases/" test_cases: - - file_name: opnfv_yardstick_tc002.yaml -- - file_name: opnfv_yardstick_tc005.yaml -- - file_name: opnfv_yardstick_tc010.yaml -- - file_name: opnfv_yardstick_tc011.yaml -- - file_name: opnfv_yardstick_tc012.yaml -- - file_name: opnfv_yardstick_tc014.yaml -- - file_name: opnfv_yardstick_tc037.yaml -- - file_name: opnfv_yardstick_tc055.yaml - constraint: - installer: compass - pod: huawei-pod1 - task_args: - huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml", - "host": "node5.yardstick-TC055"}' -- - file_name: opnfv_yardstick_tc063.yaml - constraint: - installer: compass - pod: huawei-pod1 - task_args: - huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml", - "host": "node5.yardstick-TC063"}' -- - file_name: opnfv_yardstick_tc075.yaml + file_name: opnfv_yardstick_tc043.yaml constraint: - installer: compass - pod: huawei-pod1 + installer: fuel + pod: ericsson-pod2 task_args: - huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml", - "host": "node1.LF"}' + ericsson-pod2: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", + "host": "node1.LF","target": "node2.LF"}' diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-noha_daily.yaml index 372041fd6..0d4113e59 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-odl_l2-bgpvpn-noha daily task suite schema: "yardstick:suite:0.1" @@ -7,32 +7,10 @@ name: "os-odl_l2-bgpvpn-noha" test_cases_dir: "tests/opnfv/test_cases/" test_cases: - - file_name: opnfv_yardstick_tc002.yaml -- - file_name: opnfv_yardstick_tc005.yaml -- - file_name: opnfv_yardstick_tc010.yaml -- - file_name: opnfv_yardstick_tc011.yaml -- - file_name: opnfv_yardstick_tc012.yaml -- - file_name: opnfv_yardstick_tc014.yaml -- - file_name: opnfv_yardstick_tc037.yaml -- - file_name: opnfv_yardstick_tc055.yaml - constraint: - installer: compass - pod: huawei-pod1 - task_args: - huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml", - "host": "node5.yardstick-TC055"}' -- - file_name: opnfv_yardstick_tc063.yaml + file_name: opnfv_yardstick_tc043.yaml constraint: - installer: compass - pod: huawei-pod1 + installer: fuel + pod: ericsson-pod2 task_args: - huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml", - "host": "node5.yardstick-TC063"}' + ericsson-pod2: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", + "host": "node1.LF","target": "node2.LF"}' diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-fdio-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-fdio-ha_daily.yaml new file mode 100644 index 000000000..2d7397a96 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-fdio-ha_daily.yaml @@ -0,0 +1,30 @@ +--- +# os-odl_l2-fdio-ha daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-odl_l2-fdio-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml +- + file_name: opnfv_yardstick_tc069.yaml +- + file_name: opnfv_yardstick_tc070.yaml +- + file_name: opnfv_yardstick_tc071.yaml +- + file_name: opnfv_yardstick_tc072.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-fdio-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-fdio-noha_daily.yaml new file mode 100644 index 000000000..3b7fe80e5 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-fdio-noha_daily.yaml @@ -0,0 +1,30 @@ +--- +# FDS suite + +schema: "yardstick:suite:0.1" + +name: "os-odl_l2-fdio-noha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc001.yaml +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc006.yaml +- + file_name: opnfv_yardstick_tc007.yaml +- + file_name: opnfv_yardstick_tc008.yaml +- + file_name: opnfv_yardstick_tc009.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc020.yaml +- + file_name: opnfv_yardstick_tc021.yaml +- + file_name: opnfv_yardstick_tc037.yaml +- + file_name: opnfv_yardstick_tc038.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-moon-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-moon-ha_daily.yaml index dadcb2f22..4a775b5bf 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-moon-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-moon-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-odl_l2-moon-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml index 1de157a37..35358bcfe 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-odl_l2-nofeature-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-noha_daily.yaml index 1661e08f1..dc8b2efd0 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-odl_l2-nofeature-noha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-ha_daily.yaml index 9e0e4186e..1899d407a 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-odl_l2-sfc-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-noha_daily.yaml index 1ebd73216..33f24e332 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-odl_l2-sfc-noha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml index 4bcf81b45..97094bf32 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-odl_l3-nofeature-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-noha_daily.yaml index c50569b69..2796dca05 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-odl_l3-nofeature-noha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-onos-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-onos-nofeature-ha_daily.yaml index 48718abb7..777565ae5 100644 --- a/tests/opnfv/test_suites/opnfv_os-onos-nofeature-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-onos-nofeature-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-onos-nofeature-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-onos-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-onos-nofeature-noha_daily.yaml index 0e9ff81d9..e6745613b 100644 --- a/tests/opnfv/test_suites/opnfv_os-onos-nofeature-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-onos-nofeature-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-onos-nofeature-noha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-onos-sfc-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-onos-sfc-ha_daily.yaml index bfb02cf48..aada4b450 100644 --- a/tests/opnfv/test_suites/opnfv_os-onos-sfc-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-onos-sfc-ha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-onos-sfc-ha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/opnfv/test_suites/opnfv_os-onos-sfc-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-onos-sfc-noha_daily.yaml index 2661e583e..a4e7c823f 100644 --- a/tests/opnfv/test_suites/opnfv_os-onos-sfc-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-onos-sfc-noha_daily.yaml @@ -1,5 +1,5 @@ --- -# Huawei US bare daily task suite +# os-onos-sfc-noha daily task suite schema: "yardstick:suite:0.1" diff --git a/tests/unit/api/utils/test_common.py b/tests/unit/api/utils/test_common.py new file mode 100644 index 000000000..5d177409e --- /dev/null +++ b/tests/unit/api/utils/test_common.py @@ -0,0 +1,65 @@ +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. +# +# 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 +############################################################################## +import unittest + +from api.utils import common + + +class TranslateToStrTestCase(unittest.TestCase): + + def test_translate_to_str_unicode(self): + input_str = u'hello' + output_str = common.translate_to_str(input_str) + + result = 'hello' + self.assertEqual(result, output_str) + + def test_translate_to_str_dict_list_unicode(self): + input_str = { + u'hello': {u'hello': [u'world']} + } + output_str = common.translate_to_str(input_str) + + result = { + 'hello': {'hello': ['world']} + } + self.assertEqual(result, output_str) + + +class GetCommandListTestCase(unittest.TestCase): + + def test_get_command_list_no_opts(self): + command_list = ['a'] + opts = {} + args = 'b' + output_list = common.get_command_list(command_list, opts, args) + + result_list = ['a', 'b'] + self.assertEqual(result_list, output_list) + + def test_get_command_list_with_opts_args(self): + command_list = ['a'] + opts = { + 'b': 'c', + 'task-args': 'd' + } + args = 'e' + + output_list = common.get_command_list(command_list, opts, args) + + result_list = ['a', 'e', '--b', '--task-args', 'd'] + self.assertEqual(result_list, output_list) + + +def main(): + unittest.main() + + +if __name__ == '__main__': + main() diff --git a/tests/unit/api/utils/test_influx.py b/tests/unit/api/utils/test_influx.py new file mode 100644 index 000000000..0852da2dd --- /dev/null +++ b/tests/unit/api/utils/test_influx.py @@ -0,0 +1,82 @@ +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. +# +# 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 +############################################################################## +import unittest +import mock +import uuid +import datetime + +from api.utils import influx + + +class GetDataDbClientTestCase(unittest.TestCase): + + @mock.patch('api.utils.influx.ConfigParser') + def test_get_data_db_client_dispatcher_not_influxdb(self, mock_parser): + mock_parser.ConfigParser().get.return_value = 'file' + try: + influx.get_data_db_client() + except Exception as e: + self.assertIsInstance(e, RuntimeError) + + +class GetIpTestCase(unittest.TestCase): + + def test_get_url(self): + url = 'http://localhost:8086/hello' + output = influx._get_ip(url) + + result = 'localhost' + self.assertEqual(result, output) + + +class WriteDataTestCase(unittest.TestCase): + + @mock.patch('api.utils.influx.get_data_db_client') + def test_write_data(self, mock_get_client): + measurement = 'tasklist' + field = {'status': 1} + timestamp = datetime.datetime.now() + tags = {'task_id': str(uuid.uuid4())} + + influx._write_data(measurement, field, timestamp, tags) + mock_get_client.assert_called_with() + + +class WriteDataTasklistTestCase(unittest.TestCase): + + @mock.patch('api.utils.influx._write_data') + def test_write_data_tasklist(self, mock_write_data): + task_id = str(uuid.uuid4()) + timestamp = datetime.datetime.now() + status = 1 + influx.write_data_tasklist(task_id, timestamp, status) + + field = {'status': status, 'error': ''} + tags = {'task_id': task_id} + mock_write_data.assert_called_with('tasklist', field, timestamp, tags) + + +class QueryTestCase(unittest.TestCase): + + @mock.patch('api.utils.influx.ConfigParser') + def test_query_dispatcher_not_influxdb(self, mock_parser): + mock_parser.ConfigParser().get.return_value = 'file' + try: + sql = 'select * form tasklist' + influx.query(sql) + except Exception as e: + self.assertIsInstance(e, RuntimeError) + + +def main(): + unittest.main() + + +if __name__ == '__main__': + main() diff --git a/tests/unit/benchmark/scenarios/compute/test_computecapacity.py b/tests/unit/benchmark/scenarios/compute/test_computecapacity.py index 660bb3391..da06b5dbb 100644 --- a/tests/unit/benchmark/scenarios/compute/test_computecapacity.py +++ b/tests/unit/benchmark/scenarios/compute/test_computecapacity.py @@ -20,7 +20,7 @@ from yardstick.benchmark.scenarios.compute import computecapacity SAMPLE_OUTPUT = '{"Cpu_number": "2", "Core_number": "24",\ "Memory_size": "263753976 kB", "Thread_number": "48",\ - "Cache_size": "30720 KB"}' + "Cache_size": "30720 KB", "HT_Open": "0"}' @mock.patch('yardstick.benchmark.scenarios.compute.computecapacity.ssh') diff --git a/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py b/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py index e3a096446..e42832f1b 100644 --- a/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py +++ b/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py @@ -1,56 +1,56 @@ -#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# 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
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.networking.networkcapacity.NetworkCapacity
-
-import mock
-import unittest
-import os
-import json
-
-from yardstick.benchmark.scenarios.networking import networkcapacity
-
-SAMPLE_OUTPUT = '{"Number of connections":"308","Number of frames received": "166503"}'
-
-@mock.patch('yardstick.benchmark.scenarios.networking.networkcapacity.ssh')
-class NetworkCapacityTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'password': "root"
- },
- }
-
- self.result = {}
-
- def test_capacity_successful_setup(self, mock_ssh):
- c = networkcapacity.NetworkCapacity({}, self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
- c.setup()
- self.assertIsNotNone(c.client)
- self.assertTrue(c.setup_done)
-
- def test_capacity_successful(self, mock_ssh):
- c = networkcapacity.NetworkCapacity({}, self.ctx)
-
- mock_ssh.SSH().execute.return_value = (0, SAMPLE_OUTPUT, '')
- c.run(self.result)
- expected_result = json.loads(SAMPLE_OUTPUT)
- self.assertEqual(self.result, expected_result)
-
- def test_capacity_unsuccessful_script_error(self, mock_ssh):
- c = networkcapacity.NetworkCapacity({}, self.ctx)
-
- mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, c.run, self.result)
+#!/usr/bin/env python + +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. +# +# 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 +############################################################################## + +# Unittest for yardstick.benchmark.scenarios.networking.networkcapacity.NetworkCapacity + +import mock +import unittest +import os +import json + +from yardstick.benchmark.scenarios.networking import networkcapacity + +SAMPLE_OUTPUT = '{"Number of connections":"308","Number of frames received": "166503"}' + +@mock.patch('yardstick.benchmark.scenarios.networking.networkcapacity.ssh') +class NetworkCapacityTestCase(unittest.TestCase): + + def setUp(self): + self.ctx = { + 'host': { + 'ip': '172.16.0.137', + 'user': 'cirros', + 'password': "root" + }, + } + + self.result = {} + + def test_capacity_successful_setup(self, mock_ssh): + c = networkcapacity.NetworkCapacity({}, self.ctx) + mock_ssh.SSH().execute.return_value = (0, '', '') + c.setup() + self.assertIsNotNone(c.client) + self.assertTrue(c.setup_done) + + def test_capacity_successful(self, mock_ssh): + c = networkcapacity.NetworkCapacity({}, self.ctx) + + mock_ssh.SSH().execute.return_value = (0, SAMPLE_OUTPUT, '') + c.run(self.result) + expected_result = json.loads(SAMPLE_OUTPUT) + self.assertEqual(self.result, expected_result) + + def test_capacity_unsuccessful_script_error(self, mock_ssh): + c = networkcapacity.NetworkCapacity({}, self.ctx) + + mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR') + self.assertRaises(RuntimeError, c.run, self.result) diff --git a/tests/unit/benchmark/scenarios/networking/test_ping6.py b/tests/unit/benchmark/scenarios/networking/test_ping6.py index b600e4103..0b8fba268 100644 --- a/tests/unit/benchmark/scenarios/networking/test_ping6.py +++ b/tests/unit/benchmark/scenarios/networking/test_ping6.py @@ -25,16 +25,33 @@ class PingTestCase(unittest.TestCase): 'host1': { 'ip': '172.16.0.137', 'user': 'cirros', + 'role': "Controller", 'key_filename': "mykey.key", 'password': "root" }, + 'host2': { + "ip": "172.16.0.138", + "key_filename": "/root/.ssh/id_rsa", + "role": "Compute", + "name": "node3.IPV6", + "user": "root" + }, } } + def test_get_controller_node(self): + args = { + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, + 'sla': {'max_rtt': 50} + } + p = ping6.Ping6(args, self.ctx) + controller_node = p._get_controller_node(['host1','host2']) + self.assertEqual(controller_node, 'host1') + @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') def test_ping_successful_setup(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, 'sla': {'max_rtt': 50} } p = ping6.Ping6(args, self.ctx) @@ -46,7 +63,7 @@ class PingTestCase(unittest.TestCase): @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') def test_ping_successful_no_sla(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, } result = {} @@ -61,7 +78,7 @@ class PingTestCase(unittest.TestCase): def test_ping_successful_sla(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, 'sla': {'max_rtt': 150} } result = {} @@ -76,7 +93,7 @@ class PingTestCase(unittest.TestCase): def test_ping_unsuccessful_sla(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, 'sla': {'max_rtt': 50} } result = {} @@ -90,7 +107,7 @@ class PingTestCase(unittest.TestCase): def test_ping_unsuccessful_script_error(self, mock_ssh): args = { - 'options': {'host': 'host1','packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, 'sla': {'max_rtt': 150} } result = {} diff --git a/tests/unit/benchmark/scenarios/networking/test_vsperf.py b/tests/unit/benchmark/scenarios/networking/test_vsperf.py index cb5c09ab3..25d52212b 100644 --- a/tests/unit/benchmark/scenarios/networking/test_vsperf.py +++ b/tests/unit/benchmark/scenarios/networking/test_vsperf.py @@ -39,17 +39,17 @@ class VsperfTestCase(unittest.TestCase): } self.args = { 'options': { - 'testname': 'rfc2544_p2p_continuous', + 'testname': 'p2p_rfc2544_continuous', 'traffic_type': 'continuous', - 'pkt_sizes': '64', + 'frame_size': '64', 'bidirectional': 'True', 'iload': 100, - 'duration': 29, 'trafficgen_port1': 'eth1', 'trafficgen_port2': 'eth3', 'external_bridge': 'br-ex', - 'conf-file': 'vsperf-yardstick.conf', - 'setup-script': 'setup_yardstick.sh', + 'conf_file': 'vsperf-yardstick.conf', + 'setup_script': 'setup_yardstick.sh', + 'test_params': 'TRAFFICGEN_DURATION=30;', }, 'sla': { 'metrics': 'throughput_rx_fps', diff --git a/tests/unit/benchmark/scenarios/storage/test_storperf.py b/tests/unit/benchmark/scenarios/storage/test_storperf.py index d87ed733c..8fc97d2ed 100644 --- a/tests/unit/benchmark/scenarios/storage/test_storperf.py +++ b/tests/unit/benchmark/scenarios/storage/test_storperf.py @@ -43,7 +43,7 @@ def mocked_requests_job_get(*args, **kwargs): self.content = json_data self.status_code = status_code - return MockResponseJobGet('{"_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}', 200) + return MockResponseJobGet('{"status": "completed", "_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}', 200) def mocked_requests_job_post(*args, **kwargs): @@ -152,7 +152,7 @@ class StorPerfTestCase(unittest.TestCase): s = storperf.StorPerf(args, self.ctx) s.setup_done = True - sample_output = '{"_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}' + sample_output = '{"status": "completed", "_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}' expected_result = json.loads(sample_output) diff --git a/tests/unit/cmd/commands/test_env.py b/tests/unit/cmd/commands/test_env.py new file mode 100644 index 000000000..af1ab8030 --- /dev/null +++ b/tests/unit/cmd/commands/test_env.py @@ -0,0 +1,29 @@ +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. +# +# 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 +############################################################################## +import unittest +import mock + +from yardstick.cmd.commands.env import EnvCommand + + +class EnvCommandTestCase(unittest.TestCase): + + @mock.patch('yardstick.cmd.commands.env.HttpClient') + def test_do_influxdb(self, mock_http_client): + env = EnvCommand() + env.do_influxdb({}) + self.assertTrue(mock_http_client().post.called) + + +def main(): + unittest.main() + + +if __name__ == '__main__': + main() diff --git a/tests/unit/common/config_sample.yaml b/tests/unit/common/config_sample.yaml new file mode 100644 index 000000000..8caa19ec6 --- /dev/null +++ b/tests/unit/common/config_sample.yaml @@ -0,0 +1,2 @@ +releng: + dir: /home/opnfv/repos/releng diff --git a/tests/unit/common/test_httpClient.py b/tests/unit/common/test_httpClient.py new file mode 100644 index 000000000..b39dc2332 --- /dev/null +++ b/tests/unit/common/test_httpClient.py @@ -0,0 +1,33 @@ +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. +# +# 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 +############################################################################## +import unittest +import mock +import json + +from yardstick.common import httpClient + + +class HttpClientTestCase(unittest.TestCase): + + @mock.patch('yardstick.common.httpClient.requests') + def test_post(self, mock_requests): + url = 'http://localhost:5000/hello' + data = {'hello': 'world'} + headers = {'Content-Type': 'application/json'} + httpClient.HttpClient().post(url, data) + mock_requests.post.assert_called_with(url, data=json.dumps(data), + headers=headers) + + +def main(): + unittest.main() + + +if __name__ == '__main__': + main() diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py index 002d0494c..a64c1f1ab 100644 --- a/tests/unit/common/test_utils.py +++ b/tests/unit/common/test_utils.py @@ -83,6 +83,33 @@ class ImportModulesFromPackageTestCase(unittest.TestCase): mock_importutils.import_module.assert_called_with('bar.baz') +class GetParaFromYaml(unittest.TestCase): + + def test_get_para_from_yaml_file_not_exist(self): + file_path = '/etc/yardstick/hello.yaml' + args = 'hello.world' + para = utils.get_para_from_yaml(file_path, args) + self.assertIsNone(para) + + def test_get_para_from_yaml_para_not_found(self): + file_path = 'config_sample.yaml' + file_path = self._get_file_abspath(file_path) + args = 'releng.file' + self.assertIsNone(utils.get_para_from_yaml(file_path, args)) + + def test_get_para_from_yaml_para_exists(self): + file_path = 'config_sample.yaml' + file_path = self._get_file_abspath(file_path) + args = 'releng.dir' + para = '/home/opnfv/repos/releng' + self.assertEqual(para, utils.get_para_from_yaml(file_path, args)) + + def _get_file_abspath(self, filename): + curr_path = os.path.dirname(os.path.abspath(__file__)) + file_path = os.path.join(curr_path, filename) + return file_path + + def main(): unittest.main() diff --git a/tests/unit/dispatcher/test_influxdb_line_protocol.py b/tests/unit/dispatcher/test_influxdb_line_protocol.py index cb05bf4d2..42553c498 100644 --- a/tests/unit/dispatcher/test_influxdb_line_protocol.py +++ b/tests/unit/dispatcher/test_influxdb_line_protocol.py @@ -4,7 +4,7 @@ # influxdb-python/influxdb/tests/test_line_protocol.py import unittest -from yardstick.dispatcher.influxdb_line_protocol import make_lines +from third_party.influxdb.influxdb_line_protocol import make_lines class TestLineProtocol(unittest.TestCase): diff --git a/tests/unit/test_ssh.py b/tests/unit/test_ssh.py index a27052462..88638a0a8 100644 --- a/tests/unit/test_ssh.py +++ b/tests/unit/test_ssh.py @@ -17,7 +17,10 @@ # rally/tests/unit/common/test_sshutils.py import os +import socket import unittest +from cStringIO import StringIO + import mock from yardstick import ssh @@ -162,10 +165,10 @@ class SSHTestCase(unittest.TestCase): def test_send_command(self, mock_paramiko): paramiko_sshclient = self.test_client._get_client() with mock.patch.object(paramiko_sshclient, "exec_command") \ - as mock_paramiko_exec_command: + as mock_paramiko_exec_command: self.test_client.send_command('cmd') mock_paramiko_exec_command.assert_called_once_with('cmd', - get_pty=True) + get_pty=True) class SSHRunTestCase(unittest.TestCase): @@ -275,6 +278,23 @@ class SSHRunTestCase(unittest.TestCase): self.assertEqual(send_calls, self.fake_session.send.mock_calls) @mock.patch("yardstick.ssh.select") + def test_run_stdin_keep_open(self, mock_select): + """Test run method with stdin. + + Third send call was called with "e2" because only 3 bytes was sent + by second call. So remainig 2 bytes of "line2" was sent by third call. + """ + mock_select.select.return_value = ([], [], []) + self.fake_session.exit_status_ready.side_effect = [0, 0, 0, True] + self.fake_session.send_ready.return_value = True + self.fake_session.send.side_effect = len + fake_stdin = StringIO("line1\nline2\n") + self.test_client.run("cmd", stdin=fake_stdin, keep_stdin_open=True) + call = mock.call + send_calls = [call("line1\nline2\n")] + self.assertEqual(send_calls, self.fake_session.send.mock_calls) + + @mock.patch("yardstick.ssh.select") def test_run_select_error(self, mock_select): self.fake_session.exit_status_ready.return_value = False mock_select.select.return_value = ([], [], [True]) @@ -288,6 +308,61 @@ class SSHRunTestCase(unittest.TestCase): self.fake_session.exit_status_ready.return_value = False self.assertRaises(ssh.SSHTimeout, self.test_client.run, "cmd") + @mock.patch("yardstick.ssh.open", create=True) + def test__put_file_shell(self, mock_open): + self.test_client.run = mock.Mock() + self.test_client._put_file_shell("localfile", "remotefile", 0o42) + + self.test_client.run.assert_called_once_with( + 'cat > "remotefile"&& chmod -- 042 "remotefile"', + stdin=mock_open.return_value.__enter__.return_value) + + @mock.patch("yardstick.ssh.os.stat") + def test__put_file_sftp(self, mock_stat): + sftp = self.fake_client.open_sftp.return_value = mock.MagicMock() + sftp.__enter__.return_value = sftp + + mock_stat.return_value = os.stat_result([0o753] + [0] * 9) + + self.test_client._put_file_sftp("localfile", "remotefile") + + sftp.put.assert_called_once_with("localfile", "remotefile") + mock_stat.assert_called_once_with("localfile") + sftp.chmod.assert_called_once_with("remotefile", 0o753) + sftp.__exit__.assert_called_once_with(None, None, None) + + def test__put_file_sftp_mode(self): + sftp = self.fake_client.open_sftp.return_value = mock.MagicMock() + sftp.__enter__.return_value = sftp + + self.test_client._put_file_sftp("localfile", "remotefile", mode=0o753) + + sftp.put.assert_called_once_with("localfile", "remotefile") + sftp.chmod.assert_called_once_with("remotefile", 0o753) + sftp.__exit__.assert_called_once_with(None, None, None) + + def test_put_file_SSHException(self): + exc = ssh.paramiko.SSHException + self.test_client._put_file_sftp = mock.Mock(side_effect=exc()) + self.test_client._put_file_shell = mock.Mock() + + self.test_client.put_file("foo", "bar", 42) + self.test_client._put_file_sftp.assert_called_once_with("foo", "bar", + mode=42) + self.test_client._put_file_shell.assert_called_once_with("foo", "bar", + mode=42) + + def test_put_file_socket_error(self): + exc = socket.error + self.test_client._put_file_sftp = mock.Mock(side_effect=exc()) + self.test_client._put_file_shell = mock.Mock() + + self.test_client.put_file("foo", "bar", 42) + self.test_client._put_file_sftp.assert_called_once_with("foo", "bar", + mode=42) + self.test_client._put_file_shell.assert_called_once_with("foo", "bar", + mode=42) + def main(): unittest.main() |