diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/conf/yardstick_config.yml | 24 | ||||
-rw-r--r-- | scripts/container.py | 8 | ||||
-rwxr-xr-x | scripts/prepare_test_yard/build_flavor_image.sh | 146 | ||||
-rwxr-xr-x | scripts/prepare_test_yard/build_run_test.sh | 23 | ||||
-rwxr-xr-x | scripts/prepare_test_yard/run_test.sh | 20 | ||||
-rwxr-xr-x | scripts/prepare_test_yard/source_env.sh | 21 | ||||
-rwxr-xr-x | scripts/run.py | 22 | ||||
-rw-r--r-- | scripts/utils/dovetail_logger.py | 2 |
8 files changed, 15 insertions, 251 deletions
diff --git a/scripts/conf/yardstick_config.yml b/scripts/conf/yardstick_config.yml index 7a40dc70..f7f05bcc 100644 --- a/scripts/conf/yardstick_config.yml +++ b/scripts/conf/yardstick_config.yml @@ -1,29 +1,29 @@ yardstick: image_name: opnfv/yardstick - docker_tag: stable + docker_tag: latest envs: '-e INSTALLER_TYPE=compass -e INSTALLER_IP=192.168.200.2 -e NODE_NAME=dovetail-pod -e DEPLOY_SCENARIO=ha_nosdn -e BUILD_TAG=dovetail -e CI_DEBUG=true -e DEPLOY_TYPE=baremetal -e EXTERNAL_NETWORK=ext-net' opts: '-id --privileged=true' - result_dir: '/tmp/yardstick/result' - shell_dir: '/tmp/yardstick' - shell_dir_name: 'prepare_test_yard' pre_condition: cmds: - - 'echo test for precondition' + - 'source /home/opnfv/repos/yardstick/tests/ci/prepare_env.sh && + source /home/opnfv/repos/yardstick/tests/ci/clean_images.sh && cleanup' + - 'source /home/opnfv/repos/yardstick/tests/ci/prepare_env.sh && + cd /home/opnfv/repos/yardstick && source tests/ci/load_images.sh' testcase: - build_test_cmd: '/tmp/yardstick/build_run_test.sh %s.yaml /tmp/yardstick/result/%s.out' - test_cmd: '/tmp/yardstick/run_test.sh %s.yaml /tmp/yardstick/result/%s.out' cmds: - - '/tmp/yardstick/build_run_test.sh {{script_testcase}}.yaml /tmp/yardstick/result/{{testcase}}.out' - - '/tmp/yardstick/run_test.sh {{script_testcase}}.yaml /tmp/yardstick/result/{{testcase}}.out' + - 'mkdir -p /home/opnfv/yardstick/results/' + - 'cd /home/opnfv/repos/yardstick && source tests/ci/prepare_env.sh && + yardstick task start tests/opnfv/test_cases/{{script_testcase}}.yaml + --output-file /home/opnfv/yardstick/results/{{script_testcase}}.out &> + /home/opnfv/yardstick/results/yardstick.log' post_condition: cmds: - '' result: - dir: '/tmp/yardstick/result' + dir: '/home/opnfv/yardstick/results' store_type: 'file' + file_path: 'yardstick.log' db_url: 'http://testresults.opnfv.org/test/api/v1/results?case=%s&last=1' - file_path: '/home/opnfv/dovetail/results/yardstick.log' - diff --git a/scripts/container.py b/scripts/container.py index 3223c993..918edb33 100644 --- a/scripts/container.py +++ b/scripts/container.py @@ -17,7 +17,6 @@ class Container: container_list = {} has_pull_latest_image = {'yardstick':False, 'functest':False} - has_build_images = {'yardstick':False, 'functest':False} def __init__(cls): pass @@ -68,10 +67,3 @@ class Container: def exec_cmd(cls, container_id, sub_cmd, exit_on_error=False): cmd = 'sudo docker exec %s /bin/bash -c "%s"' % (container_id, sub_cmd) dt_utils.exec_cmd(cmd,logger,exit_on_error) - - @classmethod - def copy_file(cls, file_dir, container_id, container_dir): - for root, dirs, files in os.walk(file_dir): - for file_name in files: - cmd = 'sudo docker cp %s %s:%s' % (os.path.join(file_dir,file_name), container_id, container_dir) - dt_utils.exec_cmd(cmd, logger, exit_on_error = False) diff --git a/scripts/prepare_test_yard/build_flavor_image.sh b/scripts/prepare_test_yard/build_flavor_image.sh deleted file mode 100755 index 0802f08d..00000000 --- a/scripts/prepare_test_yard/build_flavor_image.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash -############################################################################## -# 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 -############################################################################## - -set -e - -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 \ - -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 -} - -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" -} - -QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-trusty-server.img" - -build_yardstick_image() -{ - echo - echo "========== Build yardstick cloud image ==========" - - export YARD_IMG_ARCH="amd64" - sudo echo "Defaults env_keep += \"YARD_IMG_ARCH\"" >> /etc/sudoers - 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 -} - -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" -} - -main() -{ - cleanup - create_nova_flavor - load_cirros_image - load_ubuntu_image - build_yardstick_image - load_yardstick_image -} - -main diff --git a/scripts/prepare_test_yard/build_run_test.sh b/scripts/prepare_test_yard/build_run_test.sh deleted file mode 100755 index 91ac589e..00000000 --- a/scripts/prepare_test_yard/build_run_test.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -############################################################################## -# 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 -############################################################################## - -set -e - -cd /home/opnfv/repos/yardstick - -source /tmp/yardstick/source_env.sh - -echo "========== Build the flavor and load images ==========" -source /tmp/yardstick/build_flavor_image.sh - -echo "========== Run yardstick testcase ==========" -cmd="yardstick task start /home/opnfv/repos/yardstick/tests/opnfv/test_cases/$1 \ - --output-file $2" -${cmd} diff --git a/scripts/prepare_test_yard/run_test.sh b/scripts/prepare_test_yard/run_test.sh deleted file mode 100755 index 326c637b..00000000 --- a/scripts/prepare_test_yard/run_test.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -############################################################################## -# 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 -############################################################################## - -set -e - -cd /home/opnfv/repos/yardstick - -source /tmp/yardstick/source_env.sh - -echo "========== Run yardstick testcase ==========" -cmd="yardstick task start /home/opnfv/repos/yardstick/tests/opnfv/test_cases/$1 \ - --output-file $2" -${cmd} diff --git a/scripts/prepare_test_yard/source_env.sh b/scripts/prepare_test_yard/source_env.sh deleted file mode 100755 index 80135d70..00000000 --- a/scripts/prepare_test_yard/source_env.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -############################################################################## -# 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 -############################################################################## - -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 - -source $YARDSTICK_REPO_DIR/tests/ci/prepare_env.sh diff --git a/scripts/run.py b/scripts/run.py index 2afdfc7e..85871fab 100755 --- a/scripts/run.py +++ b/scripts/run.py @@ -31,22 +31,6 @@ def load_scenario(scenario): def load_testcase(): Testcase.load() -def run_functest(testcase, container_id): - for cmd in testcase.cmds: - Container.exec_cmd(container_id, cmd) - -def run_yardstick(testcase, container_id): - type = testcase.script_type() - Container.copy_file(os.path.join(os.getcwd(), dovetail_config[type]['shell_dir_name']),\ - container_id, dovetail_config[type]['shell_dir']) - if Container.has_build_images[type] == True: - sub_cmd = dovetail_config[type]['testcase']['test_cmd'] % (testcase.script_testcase(), testcase.name()) - else: - Container.has_build_images[type] = True - sub_cmd = dovetail_config[type]['testcase']['build_test_cmd'] % (testcase.script_testcase(), testcase.name()) - Container.exec_cmd(container_id, sub_cmd) - time.sleep(5) - def run_test(scenario): for testcase_name in scenario['testcase_list']: logger.info('>>[testcase]: %s' % (testcase_name)) @@ -74,10 +58,8 @@ def run_test(scenario): if not testcase.prepare_cmd(): logger.error('failed to prepare testcase:%s' % testcase.name()) else: - if testcase.script_type() == 'functest': - run_functest(testcase, container_id) - else: - run_yardstick(testcase, container_id) + for cmd in testcase.cmds: + Container.exec_cmd(container_id, cmd) #testcase.post_condition() diff --git a/scripts/utils/dovetail_logger.py b/scripts/utils/dovetail_logger.py index 7335c0ae..9b20225c 100644 --- a/scripts/utils/dovetail_logger.py +++ b/scripts/utils/dovetail_logger.py @@ -30,7 +30,7 @@ class Logger: CI_DEBUG = os.getenv('CI_DEBUG') self.logger = logging.getLogger(logger_name) - self.logger.propagate = 0 + self.logger.propagate = 0 self.logger.setLevel(logging.DEBUG) ch = logging.StreamHandler() |