From 6790e17eb7c1a3eaaccfe97ac90932e3c15eea6d Mon Sep 17 00:00:00 2001 From: "jose.lausuch" Date: Wed, 4 May 2016 11:47:40 +0200 Subject: Refactor improvements JIRA: FUNCTEST-190 - Deleted unnecessary old scripts - Fixed healtcheck logging - Moved config_functest.yaml to /ci/ - Created env var CONFIG_FUNCTEST_YAML pointing to that new location - Modified all scripts which open config_functest.yaml using the new env var Change-Id: Ic4f0e40a70c02ac08287a1d621956f602bdee177 Signed-off-by: jose.lausuch --- ci/config_functest.yaml | 241 +++++++++++++++ ci/exec_test.sh | 5 +- ci/prepare_env.py | 4 +- ci/run_tests.py | 25 +- ci/testcases.yaml | 57 ++-- docker/Dockerfile | 3 +- docker/common.sh | 62 ---- docker/prepare_env.sh | 133 -------- docker/run_tests.sh | 275 ----------------- docs/configguide/configguide.rst | 2 +- testcases/Controllers/ODL/CI/odlreport2db.py | 3 +- .../Controllers/ONOS/Teston/CI/onosfunctest.py | 2 +- .../VIM/OpenStack/CI/libraries/healthcheck.sh | 94 ++++-- .../VIM/OpenStack/CI/libraries/run_rally-cert.py | 2 +- .../VIM/OpenStack/CI/libraries/run_tempest.py | 2 +- testcases/config_functest.py | 334 --------------------- testcases/config_functest.yaml | 241 --------------- testcases/features/doctor.py | 3 +- testcases/features/promise.py | 2 +- testcases/vIMS/CI/vIMS.py | 2 +- testcases/vPing/CI/libraries/vPing_ssh.py | 2 +- testcases/vPing/CI/libraries/vPing_userdata.py | 2 +- utils/clean_openstack | 0 utils/clean_openstack.py | 7 +- utils/generate_defaults.py | 4 +- 25 files changed, 372 insertions(+), 1135 deletions(-) create mode 100644 ci/config_functest.yaml delete mode 100755 docker/common.sh delete mode 100755 docker/prepare_env.sh delete mode 100755 docker/run_tests.sh delete mode 100755 testcases/config_functest.py delete mode 100644 testcases/config_functest.yaml delete mode 100644 utils/clean_openstack diff --git a/ci/config_functest.yaml b/ci/config_functest.yaml new file mode 100644 index 000000000..e463df202 --- /dev/null +++ b/ci/config_functest.yaml @@ -0,0 +1,241 @@ +general: + directories: + # Relative to the path where the repo is cloned: + dir_vping: testcases/vPing/CI/libraries/ + dir_odl: testcases/Controllers/ODL/CI/ + dir_rally: testcases/VIM/OpenStack/CI/libraries/ + dir_rally_scn: testcases/VIM/OpenStack/CI/rally_cert/ + dir_tempest_cases: testcases/VIM/OpenStack/CI/custom_tests/ + dir_vIMS: testcases/vIMS/CI/ + dir_onos: testcases/Controllers/ONOS/Teston/CI/ + + # Absolute path + dir_repos: /home/opnfv/repos + dir_repo_functest: /home/opnfv/repos/functest + dir_repo_rally: /home/opnfv/repos/rally + dir_repo_tempest: /home/opnfv/repos/tempest + dir_repo_releng: /home/opnfv/repos/releng + dir_repo_vims_test: /home/opnfv/repos/vims-test + dir_repo_bgpvpn: /home/opnfv/repos/bgpvpn + dir_repo_onos: /home/opnfv/repos/onos + dir_repo_promise: /home/opnfv/repos/promise + dir_repo_doctor: /home/opnfv/repos/doctor + dir_repo_ovno: /home/opnfv/repos/ovno + dir_functest: /home/opnfv/functest + dir_results: /home/opnfv/functest/results + dir_functest_conf: /home/opnfv/functest/conf + dir_rally_res: /home/opnfv/functest/results/rally/ + dir_functest_data: /home/opnfv/functest/data + dir_vIMS_data: /home/opnfv/functest/data/vIMS + dir_rally_inst: /home/opnfv/.rally + + openstack: + image_name: functest-img + image_file_name: cirros-0.3.4-x86_64-disk.img + image_disk_format: qcow2 + + # Private network for functest. Will be created by config_functest.py + neutron_private_net_name: functest-net + neutron_private_subnet_name: functest-subnet + neutron_private_subnet_cidr: 192.168.120.0/24 + neutron_private_subnet_start: 192.168.120.2 + neutron_private_subnet_end: 192.168.120.254 + neutron_private_subnet_gateway: 192.168.120.254 + neutron_router_name: functest-router + +vping: + ping_timeout: 200 + vm_flavor: m1.small # adapt to your environment + vm_name_1: opnfv-vping-1 + vm_name_2: opnfv-vping-2 + image_name: functest-vping + vping_private_net_name: vping-net + vping_private_subnet_name: vping-subnet + vping_private_subnet_cidr: 192.168.130.0/24 + vping_router_name: vping-router + vping_sg_name: vPing-sg + vping_sg_descr: Security group for vPing test case + +tempest: + identity: + tenant_name: tempest + tenant_description: Tenant for Tempest test suite + user_name: tempest + user_password: tempest + input-scenario: + ssh_user_regex: '[["^.*[Cc]irros.*$", "cirros"], ["^.*[Tt]est[VvMm].*$", "cirros"], ["^.*rally_verify.*$", "cirros"]]' + +rally: + deployment_name: opnfv-rally + +vIMS: + general: + tenant_name: vIMS + tenant_description: vIMS Functionality Testing + images: + ubuntu: + image_url: 'http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img' + image_name: ubuntu_14.04 + centos: + image_url: 'http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1510.qcow2' + image_name: centos_7 + cloudify: + blueprint: + url: https://github.com/boucherv-orange/cloudify-manager-blueprints.git + branch: "3.3-build" + requierments: + ram_min: 3000 + os_image: centos_7 + inputs: + keystone_username: "" + keystone_password: "" + keystone_tenant_name: "" + keystone_url: "" + manager_public_key_name: 'manager-kp' + agent_public_key_name: 'agent-kp' + image_id: "" + flavor_id: "3" + external_network_name: "" + ssh_user: centos + agents_user: ubuntu + clearwater: + blueprint: + file_name: 'openstack-blueprint.yaml' + name: "clearwater-opnfv" + destination_folder: "opnfv-cloudify-clearwater" + url: 'https://github.com/Orange-OpenSource/opnfv-cloudify-clearwater.git' + branch: "stable" + deployment-name: 'clearwater-opnfv' + requierments: + ram_min: 1700 + os_image: ubuntu_14.04 + inputs: + image_id: '' + flavor_id: '' + agent_user: 'ubuntu' + external_network_name: '' + public_domain: clearwater.opnfv +ONOS: + general: + onosbench_username: 'root' + onosbench_password: 'root' + onoscli_username: 'root' + onoscli_password: 'root' + runtimeout: 300 + environment: + OCT: '10.20.0.1' + OC1: '10.20.0.7' + OC2: '10.20.0.7' + OC3: '10.20.0.7' + OCN: '10.20.0.4' + OCN2: '10.20.0.5' + installer_master: '10.20.0.2' + installer_master_username: 'root' + installer_master_password: 'r00tme' + +promise: + general: + tenant_name: promise + tenant_description: promise Functionality Testing + user_name: promiser + user_pwd: test + image_name: promise-img + flavor_name: promise-flavor + flavor_vcpus: 1 + flavor_ram: 512 + flavor_disk: 0 + +results: + test_db_url: http://testresults.opnfv.org/testapi + +# to be maintained... +# the execution order is important as some tests may be more destructive than others +# and if vPing is failing is usually not needed to continue... +test_exec_priority: + 1: healthcheck + 2: vping_ssh + 3: vping_userdata + 4: tempest + 5: odl + 6: onos + 7: ovno + 8: doctor + 9: promise + 10: odl-vpnservice + 11: bgpvpn + #11: openstack-neutron-bgpvpn-api-extension-tests + 12: vims + 13: rally + + +######################################################################## +# This part lists the dependencies of the tests +# +# it is used to manage the complexity of the possible combinations +# +# 17 projects have been declared for Brahmaputra (D Milestone) +# 89 testcases are associated with these 17 projects +# +# in B-Release, Functest deals with 6 companion projects: +# - congress +# - doctor +# - ovno +# - policyTest +# - promise +# - sdnvpn +# +# constraints may be declared at the testcase or the test project level +# +# By default we consider that all the tests can be run on any configuration +# +# we defined 2 constraints +# - installer (e.g. my test can be run only with installer Compass) +# possible values: apex, compass, fuel, joid +# +# - the scenario: it described a specif installation +# os---[-] +# With parameters: +# controller=(nosdn|odl_l3|odl_l2|onos|ocl) +# No odl_l3 today +# nfvfeature=(kvm|ovs|dpdk|nofeature) +# '_' list separated. +# mode=(ha|noha) +# extrastuff=(none) +# Optional field - Not used today# +# +# ref:https://gerrit.opnfv.org/gerrit/#/c/6323/7/jjb/joid/joid-deploy.sh (L72-82) +# e.g my test is only possible with OVS 2.3.2 on odl +# +# in functest, we indicate the regex pattern to be checked towards the scenario +# e.g. odl-vpn_service-tests can be run if and only if +# - installer is fuel +# - scenario contains the name ovs and odl +# +####################################################################### +test-dependencies: + doctor: + installer: 'apex' + functest: + vims: + scenario: '(ocl)|(nosdn)|^(os-odl)((?!bgpvpn).)*$' + healthcheck: + vping_ssh: + scenario: '^((?!bgpvpn).)*$' + vping_userdata: + tempest: + rally: + odl: + scenario: 'odl' + onos: + scenario: 'onos' + promise: + installer: '(fuel)|(joid)' + ovno: + scenario: 'ocl' + policy-test: + scenario: 'odl' + sdnvpn: + bgpvpn: + installer: '(fuel)|(apex)' + scenario: 'bgpvpn' + # this execute the tempest tests of networking-bgpvpn diff --git a/ci/exec_test.sh b/ci/exec_test.sh index c0a6841c1..f778a2fb2 100755 --- a/ci/exec_test.sh +++ b/ci/exec_test.sh @@ -149,6 +149,9 @@ bgpvpn = True" >> /etc/tempest/tempest.conf "ovno") ${repos_dir}/ovno/Testcases/RunTests.sh ;; + *) + echo "The test case '${test_name}' does not exist." + exit 1 esac } @@ -183,7 +186,7 @@ done # Source credentials -echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.." +echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the test.." source ${FUNCTEST_CONF_DIR}/openstack.creds diff --git a/ci/prepare_env.py b/ci/prepare_env.py index b462f9634..520db44ec 100644 --- a/ci/prepare_env.py +++ b/ci/prepare_env.py @@ -171,7 +171,7 @@ def source_rc_file(): logger.debug("Executing command: %s" % cmd) p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) output = p.communicate()[0] - logger.debug(output) + logger.debug("\n%s" % output) if p.returncode != 0: logger.error("Failed to fetch credentials from installer.") sys.exit(1) @@ -268,7 +268,7 @@ def main(): sys.exit() if args.action == "start": - print ("\n######### Preparing Functest environment #########\n") + logger.info("\n######### Preparing Functest environment #########\n") check_env_variables() create_directories() source_rc_file() diff --git a/ci/run_tests.py b/ci/run_tests.py index 106214400..5b9309828 100644 --- a/ci/run_tests.py +++ b/ci/run_tests.py @@ -33,7 +33,7 @@ args = parser.parse_args() """ logging configuration """ -logger = ft_logger.Logger("run_test").getLogger() +logger = ft_logger.Logger("run_tests").getLogger() """ global variables """ @@ -48,7 +48,6 @@ def print_separator(str, count=45): line = "" for i in range(0, count - 1): line += str - logger.info("%s" % line) @@ -62,16 +61,11 @@ def source_rc_file(): def cleanup(): - print_separator("+") - logger.info("Cleaning OpenStack resources...") - print_separator("+") clean_os.main() - print_separator("") def run_test(test): test_name = test.get_name() - print_separator("") print_separator("=") logger.info("Running test case '%s'..." % test_name) print_separator("=") @@ -82,7 +76,6 @@ def run_test(test): cmd = ("%s%s" % (EXEC_SCRIPT, flags)) logger.debug("Executing command '%s'" % cmd) - print_separator("") p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) @@ -90,8 +83,9 @@ def run_test(test): line = p.stdout.readline().rstrip() logger.debug(line) - if p != 0: - logger.error("The command '%s' failed. Cleaning and exiting." % cmd) + if p.returncode != 0: + logger.error("The test case '%s' failed. Cleaning and exiting." + % test_name) if CLEAN_FLAG: cleanup() sys.exit(1) @@ -100,7 +94,6 @@ def run_test(test): cleanup() - def run_tier(tier): print_separator("#") logger.info("Running tier '%s'" % tier.get_name()) @@ -111,10 +104,14 @@ def run_tier(tier): def run_all(tiers): - logger.debug("Tiers to be executed:") + summary = "" for tier in tiers.get_tiers(): - logger.info("\n - %s. %s:\n\t%s" - % (tier.get_order(), tier.get_name(), tier.get_tests())) + summary += ("\n - %s. %s:\n\t %s" + % (tier.get_order(), + tier.get_name(), + tier.get_test_names())) + + logger.info("Tiers to be executed:%s" % summary) for tier in tiers.get_tiers(): run_tier(tier) diff --git a/ci/testcases.yaml b/ci/testcases.yaml index 8dc22a640..51c43fcb1 100644 --- a/ci/testcases.yaml +++ b/ci/testcases.yaml @@ -26,44 +26,43 @@ tiers: testcases: - name: vping_ssh - description: |- - This test case verifies: - ····1) SSH to an instance using floating IPs over the public network. - ····2) Connectivity between 2 instances over a private network. + description: >- + This test case verifies: 1) SSH to an instance using floating + IPs over the public network. 2) Connectivity between 2 instances + over a private network. dependencies: installer: '' scenario: '^((?!bgpvpn).)*$' - name: vping_userdata - description: |- - This test case verifies: - ····1) Boot a VM with given userdata. - ····2) Connectivity between 2 instances over a private network. - dependencies: - installer: '' - scenario: '' - - - - name: tempest_smoke_serial - description: >- - This test case runs the smoke subset of the OpenStack - Tempest suite. The list of test cases is generated by - Tempest automatically and depend on the parameters of - the OpenStack deplopyment. - dependencies: - installer: '' - scenario: '' - - - - name: rally_sanity description: >- - This test case runs a sub group of tests of the OpenStack - Rally suite in smoke mode. + This test case verifies: 1) Boot a VM with given userdata. + 2) Connectivity between 2 instances over a private network. dependencies: installer: '' scenario: '' + #- + # name: tempest_smoke_serial + # description: >- + # This test case runs the smoke subset of the OpenStack + # Tempest suite. The list of test cases is generated by + # Tempest automatically and depend on the parameters of + # the OpenStack deplopyment. + # dependencies: + # installer: '' + # scenario: '' + # + #- + # name: rally_sanity + # description: >- + # This test case runs a sub group of tests of the OpenStack + # Rally suite in smoke mode. + # dependencies: + # installer: '' + # scenario: '' + # #- # name: security_groups # description: >- @@ -151,7 +150,7 @@ tiers: This test case runs the full set of the OpenStack Tempest suite. testcases: - - name: tempest_full_parallel + name: tempest description: >- The list of test cases is generated by Tempest automatically and depend on the parameters of @@ -168,7 +167,7 @@ tiers: Rally suite from the OpenStack community. testcases: - - name: rally_full + name: rally description: >- This test case runs the full suite of scenarios of the OpenStack Rally suite using several threads and iterations. diff --git a/docker/Dockerfile b/docker/Dockerfile index b2560bef2..8d4171afb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -12,7 +12,7 @@ # $ docker run -t -i \ # -e "INSTALLER_TYPE=fuel|apex|compass|joid \ # -e "INSTALLER_IP=10.20.0.2/172.30.10.73" \ -# -v $(pwd)/config_functest.yaml:/home/opnfv/functest/conf/config_functest.yaml +# -v $(pwd)/config_functest.yaml:/home/opnfv/repos/functest/ci/config_functest.yaml # opnfv/functest /bin/bash # # NOTE: providing config_functest.yaml is optional. If not provided, it will @@ -34,6 +34,7 @@ ENV creds /home/opnfv/functest/conf/openstack.creds ENV TERM xterm ENV COLORTERM gnome-terminal ENV PYTHONPATH $PYTHONPATH:/home/opnfv/repos/ +ENV CONFIG_FUNCTEST_YAML /home/opnfv/repos/functest/ci/config_functest.yaml WORKDIR /home/opnfv # Packaged dependencies diff --git a/docker/common.sh b/docker/common.sh deleted file mode 100755 index b81dedf7e..000000000 --- a/docker/common.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# -# Author: Jose Lausuch (jose.lausuch@ericsson.com) -# -# Installs the Functest framework within the Docker container -# and run the tests automatically -# -# If config_functest.yaml is given by the docker run command, -# it must be run like this: -# -# docker run -ti \ -# -e "INSTALLER_TYPE=" \ -# -e "INSTALLER_IP=" \ -# -v $(pwd)/config_functest.yaml:/home/opnfv/functest/conf/config_functest.yaml \ -# opnfv/functest /bin/bash -# -# NOTE: $(pwd)/config_functest.yaml means that it will take the one in the -# current directory. -# -# If it is not provided, take the existing one in the functest repo -# - -# this pull is to be removed right before the B release, once we build -# a release candidate docker -# -# 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 -# - -mkdir -p /home/opnfv/functest/conf -config_file=/home/opnfv/functest/conf/config_functest.yaml -if [ ! -f ${config_file} ]; then - default_config_file=$(find /home/opnfv/repos -name config_functest.yaml) - cp $default_config_file $config_file - echo "config_functest.yaml not provided. Using default one" -fi - - -# Parse config_functest.yaml file -# TODO: this is not the best way to parse a yaml file in bash... - -# Directories -REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}') -FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}') -FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}') -FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}') -FUNCTEST_CONF_DIR=$(cat $config_file | grep -w dir_functest_conf | awk 'END {print $NF}') -FUNCTEST_DATA_DIR=$(cat $config_file | grep -w dir_functest_data | awk 'END {print $NF}') -RALLY_VENV_DIR=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}') - - -info () { - logger -s -t "FUNCTEST.info" "$*" -} - -error () { - logger -s -t "FUNCTEST.error" "$*" - exit 1 -} diff --git a/docker/prepare_env.sh b/docker/prepare_env.sh deleted file mode 100755 index 89c44e4f6..000000000 --- a/docker/prepare_env.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/bash - -# -# Author: Jose Lausuch (jose.lausuch@ericsson.com) -# -# Installs the Functest framework within the Docker container -# and run the tests automatically -# -# -# 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 -# - -usage="Script to prepare the Functest environment. - -usage: - bash $(basename "$0") [-h|--help] [-t ] - -where: - -h|--help show this help text - -examples: - $(basename "$0")" - - -# Parse parameters -while [[ $# > 0 ]] - do - key="$1" - case $key in - -h|--help) - echo "$usage" - exit 0 - shift - ;; - *) - error "unknown option $1" - exit 1 - ;; - esac - shift # past argument or value -done - -BASEDIR=`dirname $0` -source ${BASEDIR}/common.sh - -debug="" -if [[ "${CI_DEBUG,,}" == "true" ]];then - debug="--debug" -fi - - -info "######### Preparing Functest environment #########" - -# definition of available installer names -INSTALLERS=(fuel compass apex joid) - -if [ ! -f ${FUNCTEST_CONF_DIR}/openstack.creds ]; then - # If credentials file is not given, check if environment variables are set - # to get the creds using fetch_os_creds.sh later on - info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP" - if [ -z ${INSTALLER_TYPE} ]; then - error "Environment variable 'INSTALLER_TYPE' is not defined." - elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then - info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}" - else - error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}" - fi - - if [ -z ${INSTALLER_IP} ]; then - error "Environment variable 'INSTALLER_IP' is not defined." - fi - info "INSTALLER_IP env variable found: ${INSTALLER_IP}" -fi - - -# Create directories -mkdir -p ${FUNCTEST_CONF_DIR} -mkdir -p ${FUNCTEST_DATA_DIR} -mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL - - -# Create Openstack credentials file -# $creds is an env varialbe in the docker container pointing to -# /home/opnfv/functest/conf/openstack.creds -if [ ! -f ${creds} ]; then - ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${creds} \ - -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} - retval=$? - if [ $retval != 0 ]; then - error "Cannot retrieve credentials file from installation. Check logs." - exit $retval - fi -else - info "OpenStack credentials file given to the docker and stored in ${FUNCTEST_CONF_DIR}/openstack.creds." -fi - -# If we use SSL, by default use option OS_INSECURE=true which means that -# the cacert will be self-signed -if grep -Fq "OS_CACERT" ${creds}; then - echo "OS_INSECURE=true">>${creds}; -fi - -# Source credentials -source ${creds} - -# Check OpenStack -info "Checking that the basic OpenStack services are functional..." -${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/check_os.sh -RETVAL=$? -if [ $RETVAL -ne 0 ]; then - exit 1 -fi - -# Prepare Functest Environment -info "Preparing Functest environment..." -python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py $debug start -retval=$? -if [ $retval != 0 ]; then - error "Error when configuring Functest environment" - exit $retval -fi - - -# Generate OpenStack defaults -info "Generating OpenStack defaults..." -python ${FUNCTEST_REPO_DIR}/utils/generate_defaults.py $debug - -ifconfig eth0 mtu 1450 - -echo "1" > ${FUNCTEST_CONF_DIR}/env_active diff --git a/docker/run_tests.sh b/docker/run_tests.sh deleted file mode 100755 index f51c9e194..000000000 --- a/docker/run_tests.sh +++ /dev/null @@ -1,275 +0,0 @@ -#!/bin/bash - -# -# Author: Jose Lausuch (jose.lausuch@ericsson.com) -# Morgan Richomme (morgan.richomme@orange.com) -# Installs the Functest framework within the Docker container -# and run the tests automatically -# -# -# 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 -# - -usage="Script to trigger the tests automatically. - -usage: - bash $(basename "$0") [-h|--help] [-t ] - -where: - -h|--help show this help text - -r|--report push results to database (false by default) - -n|--no-clean do not clean OpenStack resources after test run - -s|--serial run Tempest tests in one thread - -t|--test run specific set of tests - one or more of the following separated by comma: - healthcheck,vping_ssh,vping_userdata,odl,onos, - tempest,rally,vims,promise,doctor - - -examples: - $(basename "$0") - $(basename "$0") --test vping_ssh,odl - $(basename "$0") -t tempest,rally" - - -BASEDIR=`dirname $0` -source ${BASEDIR}/common.sh - -report="" -clean=true -serial=false - -# Get the list of runnable tests -# Check if we are in CI mode -debug="" -if [[ "${CI_DEBUG,,}" == "true" ]];then - debug="--debug" -fi - -function clean_openstack(){ - if [ $clean == true ]; then - echo -e "\n" - info "Cleaning Openstack environment..." - python ${FUNCTEST_REPO_DIR}/utils/clean_openstack.py \ - $debug - echo -e "\n" - fi -} - -function odl_tests(){ - keystone_ip=$(openstack catalog show identity |grep publicURL| cut -f3 -d"/" | cut -f1 -d":") - # historically most of the installers use the same IP for neutron and keystone API - neutron_ip=$keystone_ip - odl_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":") - usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=') - password=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=') - odl_port=8181 - if [ $INSTALLER_TYPE == "fuel" ]; then - odl_port=8282 - elif [ $INSTALLER_TYPE == "apex" ]; then - : - elif [ $INSTALLER_TYPE == "joid" ]; then - odl_ip=$(env | grep SDN_CONTROLLER | cut -f2 -d'=') - neutron_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":") - odl_port=8080 - : - elif [ $INSTALLER_TYPE == "compass" ]; then - : - else - error "INSTALLER_TYPE not valid." - exit 1 - fi -} -function run_test(){ - test_name=$1 - echo -e "\n\n\n\n" - echo "----------------------------------------------" - echo " Running test case: $i" - echo "----------------------------------------------" - echo "" - clean_flag="" - if [ $clean == "false" ]; then - clean_flag="-n" - fi - serial_flag="" - if [ $serial == "true" ]; then - serial_flag="-s" - fi - - case $test_name in - "healthcheck") - info "Running health check test..." - ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/healthcheck.sh - ;; - "vping_ssh") - info "Running vPing-SSH test..." - python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_ssh.py \ - $debug $report - ;; - "vping_userdata") - info "Running vPing-userdata test... " - python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_userdata.py \ - $debug $report - ;; - "odl") - info "Running ODL test..." - odl_tests - ODL_PORT=$odl_port ODL_IP=$odl_ip KEYSTONE_IP=$keystone_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \ - ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh - - # push results to the DB in case of CI - if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]]; then - odl_logs="/home/opnfv/functest/results/odl/logs/2" - odl_path="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI" - node_name=$(env | grep NODE_NAME | cut -f2 -d'=') - python ${odl_path}/odlreport2db.py -x ${odl_logs}/output.xml -i ${INSTALLER_TYPE} -p ${node_name} -s ${DEPLOY_SCENARIO} - fi - ;; - "tempest") - info "Running Tempest tests..." - python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_tempest.py \ - $debug $serial_flag $clean_flag -m smoke $report - # save tempest.conf for further troubleshooting - tempest_conf="${RALLY_VENV_DIR}/tempest/for-deployment-*/tempest.conf" - if [ -f ${tempest_conf} ]; then - cp $tempest_conf ${FUNCTEST_CONF_DIR} - fi - ;; - "vims") - info "Running vIMS test..." - python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \ - $debug $clean_flag $report - ;; - "rally") - info "Running Rally benchmark suite..." - python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py \ - $debug $clean_flag all $report - - ;; - "bgpvpn") - info "Running BGPVPN Tempest test case..." - pushd ${repos_dir}/bgpvpn/ - pip install --no-deps -e . - popd - tempest_dir=$(ls -t /home/opnfv/.rally/tempest/ |grep for-deploy |tail -1) - if [[ $tempest_dir == "" ]]; then - error "Make sure tempest was running before" - fi - tempest_dir=/home/opnfv/.rally/tempest/$tempest_dir - pushd $tempest_dir - mkdir -p /etc/tempest/ - cp tempest.conf /etc/tempest/ - echo "[service_available] -bgpvpn = True" >> /etc/tempest/tempest.conf - ./run_tempest.sh -t -N -- networking_bgpvpn_tempest - rm -rf /etc/tempest/tempest.conf - popd - ;; - "onos") - info "Running ONOS test case..." - if [ $INSTALLER_TYPE == "joid" ]; then - python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py -i joid - else - python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py - fi - ;; - "promise") - info "Running PROMISE test case..." - python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py $debug $report - sleep 10 # to let the instances terminate - ;; - "doctor") - info "Running Doctor test..." - python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py - ;; - "ovno") - info "Running OpenContrail test..." - ${repos_dir}/ovno/Testcases/RunTests.sh - ;; - esac - - if [ $clean == "true" ]; then - clean_openstack - fi -} - - -# Parse parameters -while [[ $# > 0 ]] - do - key="$1" - case $key in - -h|--help) - echo "$usage" - exit 0 - shift - ;; - -r|--report) - report="-r" - ;; - -n|--no-clean) - clean=false - ;; - -s|--serial) - serial=true - ;; - -t|--test|--tests) - TEST="$2" - shift - ;; - *) - echo "unknown option $1 $2" - exit 1 - ;; - esac - shift # past argument or value -done - - -tests_file="/home/opnfv/functest/conf/testcase-list.txt" -if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]] &&\ - [[ -f $tests_file ]]; then - arr_test=($(cat $tests_file)) -else - arr_test=(healthcheck vping_ssh vping_userdata tempest vims rally) -fi - - -info "Tests to be executed: ${arr_test[@]}" - -# Check that the given tests are correct -if [ "${TEST}" != "" ]; then - arr_test_exec=(${TEST//,/ }) - for i in "${arr_test_exec[@]}"; do - if [[ " ${arr_test[*]} " != *" $i "* ]]; then - error "Unknown test: $i. Available tests are: ${arr_test[@]}" - fi - done - info "Tests to execute: ${TEST}." -fi - -# Check that the functest environment has been installed -if [ ! -f ${FUNCTEST_CONF_DIR}/env_active ]; then - error "The Functest environment is not installed. \ - Please run prepare_env.sh before running this script...." -fi - - -# Source credentials -info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.." -source ${FUNCTEST_CONF_DIR}/openstack.creds - -# Run tests -if [ "${TEST}" != "" ]; then - for i in "${arr_test_exec[@]}"; do - run_test $i - done -else - info "Executing tests..." - for i in "${arr_test[@]}"; do - run_test $i - done -fi diff --git a/docs/configguide/configguide.rst b/docs/configguide/configguide.rst index 120951c4d..c0444c6b0 100644 --- a/docs/configguide/configguide.rst +++ b/docs/configguide/configguide.rst @@ -277,7 +277,7 @@ from the repository to your current directory and run the container with a volum docker run -ti -e \ "INSTALLER_TYPE=fuel" -e "INSTALLER_IP=10.20.0.2" \ opnfv/functest:brahmaputra.1.0 \ - -v $(pwd)/config_functest.yaml:/home/opnfv/functest/conf/config_functest.yaml \ + -v $(pwd)/config_functest.yaml:/home/opnfv/repos/functest/ci/config_functest.yaml \ /bin/bash\ However, this is not recommended since most of the test cases rely on static diff --git a/testcases/Controllers/ODL/CI/odlreport2db.py b/testcases/Controllers/ODL/CI/odlreport2db.py index 9a87deac0..50c8b096e 100644 --- a/testcases/Controllers/ODL/CI/odlreport2db.py +++ b/testcases/Controllers/ODL/CI/odlreport2db.py @@ -23,6 +23,7 @@ import getopt import json +import os import sys import xmltodict import yaml @@ -116,7 +117,7 @@ def main(argv): json.dumps(data, indent=4, separators=(',', ': ')) # Only used from container, we can set up absolute path - with open("/home/opnfv/functest/conf/config_functest.yaml") as f: + with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) f.close() diff --git a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py index b9ddbf78f..1e278e6a1 100644 --- a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py +++ b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py @@ -30,7 +30,7 @@ args = parser.parse_args() """ logging configuration """ logger = ft_logger.Logger("onos").getLogger() -with open("/home/opnfv/functest/conf/config_functest.yaml") as f: +with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) f.close() diff --git a/testcases/VIM/OpenStack/CI/libraries/healthcheck.sh b/testcases/VIM/OpenStack/CI/libraries/healthcheck.sh index 9d3559b20..611c100c5 100755 --- a/testcases/VIM/OpenStack/CI/libraries/healthcheck.sh +++ b/testcases/VIM/OpenStack/CI/libraries/healthcheck.sh @@ -16,14 +16,31 @@ set -e +#Redirect all the output (stdout) to a log file and show only possible errors. +LOG_FILE=/home/opnfv/functest/results/healthcheck.log +echo "">$LOG_FILE +exec 1<>$LOG_FILE + +info () { + echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healtcheck - INFO - " "$*" | tee -a $LOG_FILE 1>&2 +} + +debug () { + if [[ "${CI_DEBUG,,}" == "true" ]]; then + echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healtcheck - DEBUG - " "$*" | tee -a $LOG_FILE 1>&2 + fi +} + +error () { + echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healtcheck - ERROR - " "$*" | tee -a $LOG_FILE 1>&2 + exit 1 +} + if [ -z $OS_AUTH_URL ]; then echo "Source credentials first." exit 1 fi -#Redirect all the output (stdout) to a log file and show only possible errors. -LOG_FILE=/home/opnfv/functest/results/healthcheck.log -exec 1<>$LOG_FILE echo "Using following credentials:" env | grep OS @@ -62,10 +79,10 @@ function wait_for_ip() { timeout=60 while [[ ${timeout} > 0 ]]; do if [[ $(nova console-log $1|grep "No lease, failing") ]]; then - echo "ERROR: The instance $1 couldn't get an IP from the DHCP agent." | tee -a $LOG_FILE 1>&2 + error "The instance $1 couldn't get an IP from the DHCP agent." | tee -a $LOG_FILE 1>&2 exit 1 elif [[ $(nova console-log $1|grep "^Lease"|grep "obtained") ]]; then - echo "The instance $1 got an IP successfully from the DHCP agent." + debug "The instance $1 got an IP successfully from the DHCP agent." | tee -a $LOG_FILE 1>&2 break fi let timeout=timeout-1 @@ -75,39 +92,47 @@ function wait_for_ip() { ################################# -echo "Testing Keystone API..." | tee -a $LOG_FILE 1>&2 +info "Testing Keystone API..." | tee -a $LOG_FILE 1>&2 ################################# openstack project create ${project_1} +debug "project '${project_1}' created." openstack project create ${project_2} - +debug "project '${project_2}' created." openstack user create ${user_1} --project ${project_1} +debug "user '${user_1}' created in project ${project_1}." openstack user create ${user_2} --project ${project_1} +debug "user '${user_2}' created in project ${project_1}." openstack user create ${user_3} --project ${project_1} +debug "user '${user_3}' created in project ${project_1}." openstack user create ${user_4} --project ${project_2} +debug "user '${user_4}' created in project ${project_2}." openstack user create ${user_5} --project ${project_2} +debug "user '${user_5}' created in project ${project_2}." openstack user create ${user_6} --project ${project_2} - -echo "...OK" | tee -a $LOG_FILE 1>&2 +debug "user '${user_6}' created in project ${project_2}." +info "...Keystone OK!" ################################# -echo "Testing Glance API..." | tee -a $LOG_FILE 1>&2 +info "Testing Glance API..." ################################# image=/home/opnfv/functest/data/cirros-0.3.4-x86_64-disk.img glance image-create --name ${image_1} --disk-format qcow2 --container-format bare < ${image} +debug "image '${image_1}' created." glance image-create --name ${image_2} --disk-format qcow2 --container-format bare < ${image} - -echo "...OK" | tee -a $LOG_FILE 1>&2 +debug "image '${image_2}' created." +info "... Glance OK!" ################################# -echo "Testing Cinder API..." | tee -a $LOG_FILE 1>&2 +info "Testing Cinder API..." ################################# cinder create --display_name ${volume_1} 1 +debug "volume '${volume_1}' created." cinder create --display_name ${volume_2} 10 - -echo "...OK" | tee -a $LOG_FILE 1>&2 +debug "volume '${volume_2}' created." +info "...Cinder OK!" ################################# -echo "Testing Neutron API..." | tee -a $LOG_FILE 1>&2 +info "Testing Neutron API..." ################################# network_ids=($(neutron net-list|grep -v "+"|grep -v name|awk '{print $2}')) @@ -115,56 +140,69 @@ for id in ${network_ids[@]}; do [[ $(neutron net-show ${id}|grep 'router:external'|grep -i "true") != "" ]] && ext_net_id=${id} done if [[ "${ext_net_id}" == "" ]]; then - echo "ERROR: No external network found. Exiting Health Check..." | tee -a $LOG_FILE 1>&2 + error "No external network found. Exiting Health Check..." exit 1 else - echo "External network found. ${ext_net_id}" + info "External network found. ${ext_net_id}" fi -echo "1. Create Networks..." +info "1. Create Networks..." neutron net-create ${net_1} +debug "net '${net_1}' created." neutron net-create ${net_2} +debug "net '${net_2}' created." net1_id=$(neutron net-list | grep ${net_1} | awk '{print $2}') net2_id=$(neutron net-list | grep ${net_2} | awk '{print $2}') -echo "2. Create subnets..." +info "2. Create subnets..." neutron subnet-create --name ${subnet_1} --allocation-pool start=10.6.0.2,end=10.6.0.253 --gateway 10.6.0.254 ${net_1} 10.6.0.0/24 +debug "subnet '${subnet_1}' created." neutron subnet-create --name ${subnet_2} --allocation-pool start=10.7.0.2,end=10.7.0.253 --gateway 10.7.0.254 ${net_2} 10.7.0.0/24 +debug "subnet '${subnet_2}' created." -echo "4. Create Routers..." +info "4. Create Routers..." neutron router-create ${router_1} +debug "router '${router_1}' created." neutron router-create ${router_2} +debug "router '${router_2}' created." neutron router-gateway-set ${router_1} ${ext_net_id} +debug "router '${router_1}' gateway set to ${ext_net_id}." neutron router-gateway-set ${router_2} ${ext_net_id} +debug "router '${router_2}' gateway set to ${ext_net_id}." neutron router-interface-add ${router_1} ${subnet_1} +debug "router '${router_1}' interface added ${subnet_1}." neutron router-interface-add ${router_2} ${subnet_2} +debug "router '${router_2}' interface added ${subnet_2}." -echo "...OK" | tee -a $LOG_FILE 1>&2 +info "...Neutron OK!" ################################# -echo "Testing Nova API..." | tee -a $LOG_FILE 1>&2 +info "Testing Nova API..." ################################# nova boot --flavor 2 --image ${image_1} --nic net-id=${net1_id} ${instance_1} +debug "nova instance '${instance_1}' booted on ${net_1}." nova boot --flavor 2 --image ${image_1} --nic net-id=${net1_id} ${instance_2} +debug "nova instance '${instance_2}' booted on ${net_1}." nova boot --flavor 2 --image ${image_2} --nic net-id=${net2_id} ${instance_3} +debug "nova instance '${instance_3}' booted on ${net_2}." nova boot --flavor 2 --image ${image_2} --nic net-id=${net2_id} ${instance_4} +debug "nova instance '${instance_4}' booted on ${net_2}." vm1_id=$(nova list | grep ${instance_1} | awk '{print $2}') vm2_id=$(nova list | grep ${instance_2} | awk '{print $2}') vm3_id=$(nova list | grep ${instance_3} | awk '{print $2}') vm4_id=$(nova list | grep ${instance_4} | awk '{print $2}') +info "...Nova OK!" -echo "...OK" | tee -a $LOG_FILE 1>&2 - -echo "Checking if instances get an IP from DHCP..." | tee -a $LOG_FILE 1>&2 - +info "Checking if instances get an IP from DHCP..." wait_for_ip ${instance_1} "10.6" wait_for_ip ${instance_2} "10.6" wait_for_ip ${instance_3} "10.7" wait_for_ip ${instance_4} "10.7" +info "...DHCP OK!" -echo "Health check passed!" | tee -a $LOG_FILE 1>&2 +info "Health check passed!" exit 0 diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py index 26e6b8c19..6aa6ee064 100755 --- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py @@ -82,7 +82,7 @@ if not os.path.exists(REPO_PATH): exit(-1) -with open("/home/opnfv/functest/conf/config_functest.yaml") as f: +with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) f.close() diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py index 3afbbffa6..d29869a04 100644 --- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py @@ -61,7 +61,7 @@ logger = ft_logger.Logger("run_tempest").getLogger() REPO_PATH = os.environ['repos_dir'] + '/functest/' -with open("/home/opnfv/functest/conf/config_functest.yaml") as f: +with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) f.close() TEST_DB = functest_yaml.get("results").get("test_db_url") diff --git a/testcases/config_functest.py b/testcases/config_functest.py deleted file mode 100755 index 649d4f7ec..000000000 --- a/testcases/config_functest.py +++ /dev/null @@ -1,334 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2015 Ericsson -# jose.lausuch@ericsson.com -# 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 argparse -import logging -import os -import shutil -import subprocess -import sys -import yaml - -from neutronclient.v2_0 import client as neutronclient - -import functest.utils.functest_utils as functest_utils -import functest.utils.openstack_utils as openstack_utils - - -actions = ['start', 'check', 'clean'] -parser = argparse.ArgumentParser() -parser.add_argument("action", help="Possible actions are: " - "'{d[0]}|{d[1]}|{d[2]}' ".format(d=actions)) -parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") -parser.add_argument("-f", "--force", help="Force", action="store_true") -args = parser.parse_args() - - -""" logging configuration """ -logger = logging.getLogger('config_functest') -logger.setLevel(logging.DEBUG) - -ch = logging.StreamHandler() -if args.debug: - ch.setLevel(logging.DEBUG) -else: - ch.setLevel(logging.INFO) - -formatter = logging.Formatter('%(asctime)s - %(name)s - ' - '%(levelname)s - %(message)s') -ch.setFormatter(formatter) -logger.addHandler(ch) - -REPOS_DIR = os.environ['repos_dir'] -FUNCTEST_REPO = REPOS_DIR + '/functest/' -if not os.path.exists(FUNCTEST_REPO): - logger.error("Functest repository directory not found '%s'" - % FUNCTEST_REPO) - exit(-1) -sys.path.append(FUNCTEST_REPO + "testcases/") - -with open("/home/opnfv/functest/conf/config_functest.yaml") as f: - functest_yaml = yaml.safe_load(f) -f.close() - - -""" global variables """ -# Directories -RALLY_DIR = FUNCTEST_REPO + functest_yaml.get("general").get( - "directories").get("dir_rally") -RALLY_REPO_DIR = functest_yaml.get("general").get( - "directories").get("dir_repo_rally") -RALLY_INSTALLATION_DIR = functest_yaml.get("general").get( - "directories").get("dir_rally_inst") -RALLY_RESULT_DIR = functest_yaml.get("general").get( - "directories").get("dir_rally_res") -TEMPEST_REPO_DIR = functest_yaml.get("general").get( - "directories").get("dir_repo_tempest") -VPING_DIR = FUNCTEST_REPO + functest_yaml.get("general").get( - "directories").get("dir_vping") -ODL_DIR = FUNCTEST_REPO + functest_yaml.get("general").get( - "directories").get("dir_odl") -DATA_DIR = functest_yaml.get("general").get( - "directories").get("dir_functest_data") - -# Tempest/Rally configuration details -DEPLOYMENT_MAME = functest_yaml.get("rally").get("deployment_name") - -# Image (cirros) -IMAGE_FILE_NAME = functest_yaml.get("general").get("openstack").get( - "image_file_name") -IMAGE_PATH = DATA_DIR + "/" + IMAGE_FILE_NAME - -# NEUTRON Private Network parameters -NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("general").get( - "openstack").get("neutron_private_net_name") -NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("general").get( - "openstack").get("neutron_private_subnet_name") -NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("general").get( - "openstack").get("neutron_private_subnet_cidr") -NEUTRON_ROUTER_NAME = functest_yaml.get("general").get( - "openstack").get("neutron_router_name") - -creds_neutron = openstack_utils.get_credentials("neutron") -neutron_client = neutronclient.Client(**creds_neutron) - - -def action_start(): - """ - Start the functest environment installation - """ - if not functest_utils.check_internet_connectivity(): - logger.info("No Internet connectivity. " - "This may affect some test case suites.") - - if action_check(): - logger.info("Functest environment already installed. Nothing to do.") - exit(0) - - else: - # Clean in case there are left overs - logger.debug("Cleaning possible functest environment leftovers.") - action_clean() - logger.info("Starting installation of functest environment") - - private_net = openstack_utils.get_private_net(neutron_client) - if private_net is None: - # If there is no private network in the deployment we create one - if not create_private_neutron_net(neutron_client): - logger.error("There has been a problem while " - "creating the functest network.") - action_clean() - exit(-1) - else: - logger.info("Private network '%s' already existing in " - "the deployment." % private_net['name']) - - logger.info("Installing Rally...") - if not install_rally(): - logger.error("There has been a problem while installing Rally.") - action_clean() - exit(-1) - - # Create result folder under functest if necessary - if not os.path.exists(RALLY_RESULT_DIR): - os.makedirs(RALLY_RESULT_DIR) - - try: - logger.info("CI: Generate the list of executable tests.") - runnable_test = functest_utils.generateTestcaseList(functest_yaml) - logger.info("List of runnable tests generated: %s" % runnable_test) - except: - logger.error("Impossible to generate the list of runnable tests") - - exit(0) - - -def action_check(): - """ - Check if the functest environment is properly installed - """ - errors_all = False - logger.info("Checking current functest configuration...") - - logger.debug("Checking script directories...") - - dirs = [RALLY_DIR, RALLY_INSTALLATION_DIR, VPING_DIR, ODL_DIR] - for dir in dirs: - if not os.path.exists(dir): - logger.debug(" %s NOT found" % dir) - errors_all = True - else: - logger.debug(" %s found" % dir) - - logger.debug("Checking Rally deployment...") - if not check_rally(): - logger.debug(" Rally deployment NOT installed.") - errors_all = True - - logger.debug("Checking Image...") - if not os.path.isfile(IMAGE_PATH): - logger.debug(" Image file '%s' NOT found." % IMAGE_PATH) - errors_all = True - else: - logger.debug(" Image file found in %s" % IMAGE_PATH) - - # TODO: check OLD environment setup - return not errors_all - - -def action_clean(): - """ - Clean the existing functest environment - """ - logger.info("Removing current functest environment...") - if os.path.exists(RALLY_INSTALLATION_DIR): - logger.debug("Removing Rally installation directory %s" - % RALLY_INSTALLATION_DIR) - shutil.rmtree(RALLY_INSTALLATION_DIR, ignore_errors=True) - - if os.path.exists(RALLY_RESULT_DIR): - logger.debug("Removing Result directory") - shutil.rmtree(RALLY_RESULT_DIR, ignore_errors=True) - - logger.info("Functest environment clean!") - - -def install_rally(): - if check_rally(): - logger.info("Rally is already installed.") - else: - logger.debug("Creating Rally environment...") - cmd = "rally deployment create --fromenv --name=" + DEPLOYMENT_MAME - functest_utils.execute_command(cmd, logger) - - logger.debug("Installing tempest from existing repo...") - cmd = ("rally verify install --source " + TEMPEST_REPO_DIR + - " --system-wide") - functest_utils.execute_command(cmd, logger) - - cmd = "rally deployment check" - functest_utils.execute_command(cmd, logger) - # TODO: check that everything is 'Available' and warn if not - - cmd = "rally show images" - functest_utils.execute_command(cmd, logger) - - cmd = "rally show flavors" - functest_utils.execute_command(cmd, logger) - - return True - - -def check_rally(): - """ - Check if Rally is installed and properly configured - """ - if os.path.exists(RALLY_INSTALLATION_DIR): - logger.debug(" Rally installation directory found in %s" - % RALLY_INSTALLATION_DIR) - FNULL = open(os.devnull, 'w') - cmd = "rally deployment list | grep " + DEPLOYMENT_MAME - logger.debug(' Executing command : {}'.format(cmd)) - p = subprocess.Popen(cmd, shell=True, - stdout=subprocess.PIPE, stderr=FNULL) - # if the command does not exist or there is no deployment - line = p.stdout.readline() - if line == "": - logger.debug(" Rally deployment NOT found") - return False - logger.debug(" Rally deployment found") - return True - else: - return False - - -def create_private_neutron_net(neutron): - neutron.format = 'json' - logger.info("Creating network '%s'..." % NEUTRON_PRIVATE_NET_NAME) - network_id = openstack_utils.create_neutron_net( - neutron, NEUTRON_PRIVATE_NET_NAME) - - if not network_id: - return False - logger.debug("Network '%s' created successfully." % network_id) - - logger.info("Updating network '%s' with shared=True..." - % NEUTRON_PRIVATE_NET_NAME) - if openstack_utils.update_neutron_net(neutron, network_id, shared=True): - logger.debug("Network '%s' updated successfully." % network_id) - else: - logger.info("Updating neutron network '%s' failed" % network_id) - - logger.info("Creating Subnet....") - subnet_id = openstack_utils.create_neutron_subnet( - neutron, NEUTRON_PRIVATE_SUBNET_NAME, NEUTRON_PRIVATE_SUBNET_CIDR, - network_id) - if not subnet_id: - return False - logger.debug("Subnet '%s' created successfully." % subnet_id) - logger.info("Creating Router...") - router_id = openstack_utils.create_neutron_router(neutron, - NEUTRON_ROUTER_NAME) - - if not router_id: - return False - - logger.debug("Router '%s' created successfully." % router_id) - logger.info("Adding router to subnet...") - - result = openstack_utils.add_interface_router(neutron, - router_id, - subnet_id) - - if not result: - return False - - logger.debug("Interface added successfully.") - return True - - -def main(): - if not (args.action in actions): - logger.error('argument not valid') - exit(-1) - - if not openstack_utils.check_credentials(): - logger.error("Please source the openrc credentials and " - "run the script again.") - # TODO: source the credentials in this script - exit(-1) - - if args.action == "start": - action_start() - - if args.action == "check": - if action_check(): - logger.info("Functest environment correctly installed") - else: - logger.info("Functest environment not found or faulty") - - if args.action == "clean": - if args.force: - action_clean() - else: - while True: - print("Are you sure? [y|n]") - answer = raw_input("") - if answer == "y": - action_clean() - break - elif answer == "n": - break - else: - print("Invalid option.") - exit(0) - - -if __name__ == '__main__': - main() diff --git a/testcases/config_functest.yaml b/testcases/config_functest.yaml deleted file mode 100644 index e463df202..000000000 --- a/testcases/config_functest.yaml +++ /dev/null @@ -1,241 +0,0 @@ -general: - directories: - # Relative to the path where the repo is cloned: - dir_vping: testcases/vPing/CI/libraries/ - dir_odl: testcases/Controllers/ODL/CI/ - dir_rally: testcases/VIM/OpenStack/CI/libraries/ - dir_rally_scn: testcases/VIM/OpenStack/CI/rally_cert/ - dir_tempest_cases: testcases/VIM/OpenStack/CI/custom_tests/ - dir_vIMS: testcases/vIMS/CI/ - dir_onos: testcases/Controllers/ONOS/Teston/CI/ - - # Absolute path - dir_repos: /home/opnfv/repos - dir_repo_functest: /home/opnfv/repos/functest - dir_repo_rally: /home/opnfv/repos/rally - dir_repo_tempest: /home/opnfv/repos/tempest - dir_repo_releng: /home/opnfv/repos/releng - dir_repo_vims_test: /home/opnfv/repos/vims-test - dir_repo_bgpvpn: /home/opnfv/repos/bgpvpn - dir_repo_onos: /home/opnfv/repos/onos - dir_repo_promise: /home/opnfv/repos/promise - dir_repo_doctor: /home/opnfv/repos/doctor - dir_repo_ovno: /home/opnfv/repos/ovno - dir_functest: /home/opnfv/functest - dir_results: /home/opnfv/functest/results - dir_functest_conf: /home/opnfv/functest/conf - dir_rally_res: /home/opnfv/functest/results/rally/ - dir_functest_data: /home/opnfv/functest/data - dir_vIMS_data: /home/opnfv/functest/data/vIMS - dir_rally_inst: /home/opnfv/.rally - - openstack: - image_name: functest-img - image_file_name: cirros-0.3.4-x86_64-disk.img - image_disk_format: qcow2 - - # Private network for functest. Will be created by config_functest.py - neutron_private_net_name: functest-net - neutron_private_subnet_name: functest-subnet - neutron_private_subnet_cidr: 192.168.120.0/24 - neutron_private_subnet_start: 192.168.120.2 - neutron_private_subnet_end: 192.168.120.254 - neutron_private_subnet_gateway: 192.168.120.254 - neutron_router_name: functest-router - -vping: - ping_timeout: 200 - vm_flavor: m1.small # adapt to your environment - vm_name_1: opnfv-vping-1 - vm_name_2: opnfv-vping-2 - image_name: functest-vping - vping_private_net_name: vping-net - vping_private_subnet_name: vping-subnet - vping_private_subnet_cidr: 192.168.130.0/24 - vping_router_name: vping-router - vping_sg_name: vPing-sg - vping_sg_descr: Security group for vPing test case - -tempest: - identity: - tenant_name: tempest - tenant_description: Tenant for Tempest test suite - user_name: tempest - user_password: tempest - input-scenario: - ssh_user_regex: '[["^.*[Cc]irros.*$", "cirros"], ["^.*[Tt]est[VvMm].*$", "cirros"], ["^.*rally_verify.*$", "cirros"]]' - -rally: - deployment_name: opnfv-rally - -vIMS: - general: - tenant_name: vIMS - tenant_description: vIMS Functionality Testing - images: - ubuntu: - image_url: 'http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img' - image_name: ubuntu_14.04 - centos: - image_url: 'http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1510.qcow2' - image_name: centos_7 - cloudify: - blueprint: - url: https://github.com/boucherv-orange/cloudify-manager-blueprints.git - branch: "3.3-build" - requierments: - ram_min: 3000 - os_image: centos_7 - inputs: - keystone_username: "" - keystone_password: "" - keystone_tenant_name: "" - keystone_url: "" - manager_public_key_name: 'manager-kp' - agent_public_key_name: 'agent-kp' - image_id: "" - flavor_id: "3" - external_network_name: "" - ssh_user: centos - agents_user: ubuntu - clearwater: - blueprint: - file_name: 'openstack-blueprint.yaml' - name: "clearwater-opnfv" - destination_folder: "opnfv-cloudify-clearwater" - url: 'https://github.com/Orange-OpenSource/opnfv-cloudify-clearwater.git' - branch: "stable" - deployment-name: 'clearwater-opnfv' - requierments: - ram_min: 1700 - os_image: ubuntu_14.04 - inputs: - image_id: '' - flavor_id: '' - agent_user: 'ubuntu' - external_network_name: '' - public_domain: clearwater.opnfv -ONOS: - general: - onosbench_username: 'root' - onosbench_password: 'root' - onoscli_username: 'root' - onoscli_password: 'root' - runtimeout: 300 - environment: - OCT: '10.20.0.1' - OC1: '10.20.0.7' - OC2: '10.20.0.7' - OC3: '10.20.0.7' - OCN: '10.20.0.4' - OCN2: '10.20.0.5' - installer_master: '10.20.0.2' - installer_master_username: 'root' - installer_master_password: 'r00tme' - -promise: - general: - tenant_name: promise - tenant_description: promise Functionality Testing - user_name: promiser - user_pwd: test - image_name: promise-img - flavor_name: promise-flavor - flavor_vcpus: 1 - flavor_ram: 512 - flavor_disk: 0 - -results: - test_db_url: http://testresults.opnfv.org/testapi - -# to be maintained... -# the execution order is important as some tests may be more destructive than others -# and if vPing is failing is usually not needed to continue... -test_exec_priority: - 1: healthcheck - 2: vping_ssh - 3: vping_userdata - 4: tempest - 5: odl - 6: onos - 7: ovno - 8: doctor - 9: promise - 10: odl-vpnservice - 11: bgpvpn - #11: openstack-neutron-bgpvpn-api-extension-tests - 12: vims - 13: rally - - -######################################################################## -# This part lists the dependencies of the tests -# -# it is used to manage the complexity of the possible combinations -# -# 17 projects have been declared for Brahmaputra (D Milestone) -# 89 testcases are associated with these 17 projects -# -# in B-Release, Functest deals with 6 companion projects: -# - congress -# - doctor -# - ovno -# - policyTest -# - promise -# - sdnvpn -# -# constraints may be declared at the testcase or the test project level -# -# By default we consider that all the tests can be run on any configuration -# -# we defined 2 constraints -# - installer (e.g. my test can be run only with installer Compass) -# possible values: apex, compass, fuel, joid -# -# - the scenario: it described a specif installation -# os---[-] -# With parameters: -# controller=(nosdn|odl_l3|odl_l2|onos|ocl) -# No odl_l3 today -# nfvfeature=(kvm|ovs|dpdk|nofeature) -# '_' list separated. -# mode=(ha|noha) -# extrastuff=(none) -# Optional field - Not used today# -# -# ref:https://gerrit.opnfv.org/gerrit/#/c/6323/7/jjb/joid/joid-deploy.sh (L72-82) -# e.g my test is only possible with OVS 2.3.2 on odl -# -# in functest, we indicate the regex pattern to be checked towards the scenario -# e.g. odl-vpn_service-tests can be run if and only if -# - installer is fuel -# - scenario contains the name ovs and odl -# -####################################################################### -test-dependencies: - doctor: - installer: 'apex' - functest: - vims: - scenario: '(ocl)|(nosdn)|^(os-odl)((?!bgpvpn).)*$' - healthcheck: - vping_ssh: - scenario: '^((?!bgpvpn).)*$' - vping_userdata: - tempest: - rally: - odl: - scenario: 'odl' - onos: - scenario: 'onos' - promise: - installer: '(fuel)|(joid)' - ovno: - scenario: 'ocl' - policy-test: - scenario: 'odl' - sdnvpn: - bgpvpn: - installer: '(fuel)|(apex)' - scenario: 'bgpvpn' - # this execute the tempest tests of networking-bgpvpn diff --git a/testcases/features/doctor.py b/testcases/features/doctor.py index e270f7e97..ac68430a9 100644 --- a/testcases/features/doctor.py +++ b/testcases/features/doctor.py @@ -14,13 +14,14 @@ # # +import os import time import yaml import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as functest_utils -with open('/home/opnfv/functest/conf/config_functest.yaml') as f: +with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) dirs = functest_yaml.get('general').get('directories') diff --git a/testcases/features/promise.py b/testcases/features/promise.py index 804cd6655..f10e054cd 100644 --- a/testcases/features/promise.py +++ b/testcases/features/promise.py @@ -33,7 +33,7 @@ parser.add_argument("-r", "--report", action="store_true") args = parser.parse_args() -with open('/home/opnfv/functest/conf/config_functest.yaml') as f: +with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) dirs = functest_yaml.get('general').get('directories') diff --git a/testcases/vIMS/CI/vIMS.py b/testcases/vIMS/CI/vIMS.py index f88494330..2430af1a1 100644 --- a/testcases/vIMS/CI/vIMS.py +++ b/testcases/vIMS/CI/vIMS.py @@ -55,7 +55,7 @@ if not os.path.exists(REPO_PATH): logger.error("Functest repository directory not found '%s'" % REPO_PATH) exit(-1) -with open("/home/opnfv/functest/conf/config_functest.yaml") as f: +with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) f.close() diff --git a/testcases/vPing/CI/libraries/vPing_ssh.py b/testcases/vPing/CI/libraries/vPing_ssh.py index 23b3d46f8..bd0b9b291 100644 --- a/testcases/vPing/CI/libraries/vPing_ssh.py +++ b/testcases/vPing/CI/libraries/vPing_ssh.py @@ -54,7 +54,7 @@ if not os.path.exists(REPO_PATH): logger.error("Functest repository directory not found '%s'" % REPO_PATH) exit(-1) -with open("/home/opnfv/functest/conf/config_functest.yaml") as f: +with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) f.close() diff --git a/testcases/vPing/CI/libraries/vPing_userdata.py b/testcases/vPing/CI/libraries/vPing_userdata.py index 3e69ddfe0..473c1f823 100644 --- a/testcases/vPing/CI/libraries/vPing_userdata.py +++ b/testcases/vPing/CI/libraries/vPing_userdata.py @@ -50,7 +50,7 @@ if not os.path.exists(REPO_PATH): logger.error("Functest repository directory not found '%s'" % REPO_PATH) exit(-1) -with open("/home/opnfv/functest/conf/config_functest.yaml") as f: +with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) f.close() diff --git a/utils/clean_openstack b/utils/clean_openstack deleted file mode 100644 index e69de29bb..000000000 diff --git a/utils/clean_openstack.py b/utils/clean_openstack.py index 3d7597e07..4ad5d5bb0 100644 --- a/utils/clean_openstack.py +++ b/utils/clean_openstack.py @@ -34,7 +34,7 @@ import functest.utils.openstack_utils as os_utils """ logging configuration """ -logger = ft_logger.Logger("run_rally").getLogger() +logger = ft_logger.Logger("clean_openstack").getLogger() REPO_PATH = os.environ['repos_dir'] + '/functest/' @@ -374,6 +374,9 @@ def remove_tenants(keystone_client): def main(): + logger.info("+++++++++++++++++++++++++++++++") + logger.info("Cleaning OpenStack resources...") + logger.info("+++++++++++++++++++++++++++++++") creds_nova = os_utils.get_credentials("nova") nova_client = novaclient.Client('2', **creds_nova) @@ -413,8 +416,6 @@ def main(): remove_tenants(keystone_client) separator() - exit(0) - if __name__ == '__main__': main() diff --git a/utils/generate_defaults.py b/utils/generate_defaults.py index 0a1e498f6..35b9ed305 100644 --- a/utils/generate_defaults.py +++ b/utils/generate_defaults.py @@ -175,8 +175,8 @@ def main(): with open(DEFAULTS_FILE, 'w+') as yaml_file: yaml_file.write(yaml.safe_dump(defaults, default_flow_style=False)) yaml_file.seek(0) - logger.debug("Openstack Defaults found in the deployment:") - print yaml_file.read() + logger.info("Openstack Defaults found in the deployment:\n%s" + % yaml_file.read()) logger.debug("NOTE: These objects will NOT be deleted after " + "running the tests.") -- cgit 1.2.3-korg