diff options
-rw-r--r-- | docker/Dockerfile | 8 | ||||
-rwxr-xr-x | docker/prepare_env.sh | 9 | ||||
-rwxr-xr-x | docker/run_tests.sh | 18 | ||||
-rwxr-xr-x | testcases/VIM/OpenStack/CI/libraries/check_os.sh | 49 | ||||
-rw-r--r-- | testcases/VIM/OpenStack/CI/libraries/clean_openstack.py | 111 | ||||
-rw-r--r-- | testcases/VIM/OpenStack/CI/libraries/run_rally.py | 16 | ||||
-rw-r--r-- | testcases/VIM/OpenStack/CI/libraries/run_tempest.py | 14 | ||||
-rwxr-xr-x | testcases/config_functest.py | 15 | ||||
-rw-r--r-- | testcases/config_functest.yaml | 2 | ||||
-rw-r--r-- | testcases/functest_utils.py | 22 | ||||
-rw-r--r-- | testcases/vIMS/CI/vIMS.py | 16 | ||||
-rw-r--r-- | testcases/vPing/CI/libraries/vPing.py | 24 |
12 files changed, 183 insertions, 121 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index 99d18cad..decce681 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -48,6 +48,7 @@ libgmp3-dev \ libxml2-dev \ libffi-dev \ crudini \ +ruby1.9.1-dev \ --no-install-recommends @@ -64,10 +65,11 @@ RUN git clone -b stable https://github.com/boucherv-orange/clearwater-live-test RUN git clone https://github.com/openstack/networking-bgpvpn ${repos_dir}/bgpvpn RUN pip install -r ${repos_dir}/functest/docker/requirements.pip +RUN pip install -r ${repos_dir}/rally/requirements.txt + +ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img /home/opnfv/functest/data/ RUN gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 RUN curl -L https://get.rvm.io | bash -s stable RUN bash -c 'source /etc/profile.d/rvm.sh ; rvm autolibs enable ; rvm install 1.9.3 ; rvm use 1.9.3' -RUN bash -c 'source /etc/profile.d/rvm.sh ; cd ${repos_dir}/vims-test ; bundle install' - -ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img /home/opnfv/functest/data/
\ No newline at end of file +RUN bash -c 'source /etc/profile.d/rvm.sh ; cd ${repos_dir}/vims-test;rvm use system;bundle install' diff --git a/docker/prepare_env.sh b/docker/prepare_env.sh index 0c618bff..983eefc0 100755 --- a/docker/prepare_env.sh +++ b/docker/prepare_env.sh @@ -188,10 +188,17 @@ fi # Source credentials source ${FUNCTEST_CONF_DIR}/openstack.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 "Functest: prepare Functest environment" -python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug ${FUNCTEST_REPO_DIR}/ start +python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug start retval=$? if [ $retval != 0 ]; then error "Error when configuring Functest environment" diff --git a/docker/run_tests.sh b/docker/run_tests.sh index 00d53487..898cc4ca 100755 --- a/docker/run_tests.sh +++ b/docker/run_tests.sh @@ -34,7 +34,7 @@ arr_test=(vping odl tempest vims rally) function clean_openstack(){ python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py \ - --debug ${FUNCTEST_REPO_DIR}/ + --debug } function run_test(){ @@ -46,7 +46,7 @@ function run_test(){ "vping") info "Running vPing test..." python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing.py \ - --debug ${FUNCTEST_REPO_DIR}/ ${report} + --debug ${report} ;; "odl") info "Running ODL test..." @@ -79,7 +79,7 @@ function run_test(){ "tempest") info "Running Tempest smoke tests..." python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_tempest.py \ - --debug ${FUNCTEST_REPO_DIR}/ -m smoke ${report} + --debug -m smoke ${report} # save tempest.conf for further troubleshooting tempest_conf="${RALLY_VENV_DIR}/tempest/for-deployment-*/tempest.conf" if [ -f ${tempest_conf} ]; then @@ -90,13 +90,13 @@ function run_test(){ "vims") info "Running vIMS test..." python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \ - --debug ${FUNCTEST_REPO_DIR}/ ${report} + --debug ${report} clean_openstack ;; "rally") info "Running Rally benchmark suite..." python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally.py \ - --debug ${FUNCTEST_REPO_DIR}/ all ${report} + --debug all ${report} clean_openstack ;; "bgpvpn_template") @@ -175,14 +175,6 @@ fi info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.." source ${FUNCTEST_CONF_DIR}/openstack.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 - # Run tests if [ "${TEST}" != "" ]; then for i in "${arr_test_exec[@]}"; do diff --git a/testcases/VIM/OpenStack/CI/libraries/check_os.sh b/testcases/VIM/OpenStack/CI/libraries/check_os.sh index 09d98343..3cc0ee10 100755 --- a/testcases/VIM/OpenStack/CI/libraries/check_os.sh +++ b/testcases/VIM/OpenStack/CI/libraries/check_os.sh @@ -6,31 +6,52 @@ # jose.lausuch@ericsson.com # +verify_connectivity() { + for i in $(seq 0 10); do + if nc -vz $1 $2 &>/dev/null; then + return 0 + fi + sleep 1 + done + return 1 +} + + if [ -z $OS_AUTH_URL ];then echo "ERROR: OS_AUTH_URL environment variable missing... Have you sourced the OpenStack credentials?" exit 1 fi -echo "Checking OpenStack basic services:" -ip=$(echo $OS_AUTH_URL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//') -ip='192.168.123.123' -echo ">>Pinging public keystone endpoint $ip..." -timeout=5 -for i in `seq 1 $timeout`; do - ping -q -c 1 $ip &>/dev/null - RETVAL=$? - if [ $RETVAL -eq 0 ]; then - break - fi -done -if [ $i -eq $timeout ]; then - echo "ERROR: Cannot ping the endpoint $ip defined as env variable OS_AUTH_URL." +echo "Checking OpenStack endpoints:" +publicURL=$OS_AUTH_URL +publicIP=$(echo $publicURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//') +publicPort=$(echo $publicURL|sed 's/^.*://'|sed 's/.[^\/]*$//') +echo ">>Verifying connectivity to the public endpoint $publicIP:$publicPort..." +verify_connectivity $publicIP $publicPort +RETVAL=$? +if [ $RETVAL -ne 0 ]; then + echo "ERROR: Cannot talk to the public endpoint publicIP:$publicPort ." echo "OS_AUTH_URL=$OS_AUTH_URL" exit 1 fi echo " ...OK" +adminURL=$(keystone catalog --service identity 2>/dev/null|grep adminURL|awk '{print $4}') +adminIP=$(echo $adminURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//') +adminPort=$(echo $adminURL|sed 's/^.*://'|sed 's/.[^\/]*$//') +echo ">>Verifying connectivity to the admin endpoint $adminIP:$adminPort..." +verify_connectivity $adminIP $adminPort +RETVAL=$? +if [ $RETVAL -ne 0 ]; then + echo "ERROR: Cannot talk to the admin endpoint adminIP:$adminPort ." + echo "adminURL" + exit 1 +fi +echo " ...OK" + + +echo "Checking OpenStack basic services:" commands=('keystone endpoint-list' 'nova list' 'neutron net-list' \ 'glance image-list' 'cinder list') for cmd in "${commands[@]}" diff --git a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py index bdb1f7ea..dca188f5 100644 --- a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py +++ b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py @@ -27,7 +27,6 @@ from keystoneclient.v2_0 import client as keystoneclient from cinderclient import client as cinderclient parser = argparse.ArgumentParser() -parser.add_argument("repo_path", help="Path to the repository") parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") args = parser.parse_args() @@ -42,20 +41,24 @@ if args.debug: else: ch.setLevel(logging.INFO) -sys.path.append(args.repo_path + "testcases/") -import functest_utils - formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') ch.setFormatter(formatter) logger.addHandler(ch) +REPO_PATH=os.environ['repos_dir']+'/functest/' +if not os.path.exists(REPO_PATH): + logger.error("Functest repository directory not found '%s'" % REPO_PATH) + exit(-1) +sys.path.append(REPO_PATH + "testcases/") +import functest_utils + default_images = ['TestVM'] -default_networks = ['net04', 'net04_ext', 'functest-net'] -default_routers = ['router04'] +default_networks = ['net04', 'net04_ext', 'functest-net', 'ext-net'] +default_routers = ['router04', 'functest-router'] default_users = ["heat", "heat-cfn", "cinder", "nova", "swift", "glance", "neutron", "admin", "fuel_stats_user", "quantum", "heat-cfn_heat", - "ceilometer", "cinder_cinderv2"] -default_tenants = ["admin", "services","service"] + "ceilometer", "cinder_cinderv2", "demo"] +default_tenants = ["admin", "services", "service", "demo"] default_security_groups = ['default'] def separator(): @@ -144,6 +147,16 @@ def remove_floatingips(nova_client): logger.info(" > ERROR: There has been a problem removing the " "floating IP %s..." % fip_id) + timeout = 50 + while timeout > 0: + floatingips = functest_utils.get_floating_ips(nova_client) + if floatingips is None or len(floatingips) == 0: + break + else: + logger.debug("Waiting for floating ips to be released...") + timeout -= 1 + time.sleep(1) + def remove_networks(neutron_client): logger.info("Removing Neutron objects") @@ -151,29 +164,44 @@ def remove_networks(neutron_client): networks = functest_utils.get_network_list(neutron_client) if networks == None: logger.debug("There are no networks in the deployment. ") - return - - logger.debug("Existing networks:") - for network in networks: - net_id = network['id'] - net_name = network['name'] - logger.debug(" '%s', ID=%s " %(net_name,net_id)) - if net_name not in default_networks: - logger.debug(" > this is not a default network and will be deleted.") - network_ids.append(net_id) - else: - logger.debug(" > this is a default network and will NOT be deleted.") - + else: + logger.debug("Existing networks:") + for network in networks: + net_id = network['id'] + net_name = network['name'] + logger.debug(" '%s', ID=%s " %(net_name,net_id)) + if net_name not in default_networks: + logger.debug(" > this is not a default network and will be deleted.") + network_ids.append(net_id) + else: + logger.debug(" > this is a default network and will NOT be deleted.") - #remove interfaces router and delete ports + #delete ports ports = functest_utils.get_port_list(neutron_client) if ports is None: logger.debug("There are no ports in the deployment. ") - return + else: + remove_ports(neutron_client, ports, network_ids) - #debug information (to be removed when it works many times in a row) - print ports + #remove routers + routers = functest_utils.get_router_list(neutron_client) + if routers is None: + logger.debug("There are no routers in the deployment. ") + else: + remove_routers(neutron_client, routers) + #remove networks + if network_ids != None: + for net_id in network_ids: + logger.debug("Removing network %s ..." % net_id) + if functest_utils.delete_neutron_net(neutron_client, net_id): + logger.debug(" > Done!") + else: + logger.info(" > ERROR: There has been a problem removing the " + "network %s..." % net_id) + + +def remove_ports(neutron_client, ports, network_ids): for port in ports: if port['network_id'] in network_ids: port_id = port['id'] @@ -182,7 +210,6 @@ def remove_networks(neutron_client): except: logger.info(" > WARNING: Port %s does not contain 'fixed_ips'" % port_id) print port - router_id = port['device_id'] if len(port['fixed_ips']) == 0 and router_id == '': logger.debug("Removing port %s ..." % port_id) @@ -202,21 +229,19 @@ def remove_networks(neutron_client): else: logger.info(" > ERROR: There has been a problem removing the " "interface %s from router %s..." %(subnet_id,router_id)) - #print port else: + logger.debug("Clearing device_owner for port %s ..." % port_id) + functest_utils.update_neutron_port(neutron_client, + port_id, + device_owner='clear') logger.debug("Removing port %s ..." % port_id) if functest_utils.delete_neutron_port(neutron_client, port_id): logger.debug(" > Done!") else: - logger.info(" > ERROR: There has been a problem removing the " - "port %s ..." %port_id) - #print port + logger.debug(" > Port %s could not be removed directly" % port_id) - #remove routers - routers = functest_utils.get_router_list(neutron_client) - if routers is None: - logger.debug("There are no routers in the deployment. ") - return + +def remove_routers(neutron_client, routers): for router in routers: router_id = router['id'] router_name = router['name'] @@ -229,26 +254,14 @@ def remove_networks(neutron_client): else: logger.info(" > ERROR: There has been a problem removing " "the gateway...") - #print router - else: logger.debug("Router is not connected to anything. Ready to remove...") - logger.debug("Removing router %s(%s) ..." % (router_name,router_id)) + logger.debug("Removing router %s(%s) ..." % (router_name, router_id)) if functest_utils.delete_neutron_router(neutron_client, router_id): logger.debug(" > Done!") else: logger.info(" > ERROR: There has been a problem removing the " - "router '%s'(%s)..." % (router_name,router_id)) - - - #remove networks - for net_id in network_ids: - logger.debug("Removing network %s ..." % net_id) - if functest_utils.delete_neutron_net(neutron_client, net_id): - logger.debug(" > Done!") - else: - logger.info(" > ERROR: There has been a problem removing the " - "network %s..." % net_id) + "router '%s'(%s)..." % (router_name, router_id)) def remove_security_groups(neutron_client): diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally.py b/testcases/VIM/OpenStack/CI/libraries/run_rally.py index ed52dc1e..52ca5910 100644 --- a/testcases/VIM/OpenStack/CI/libraries/run_rally.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_rally.py @@ -30,7 +30,6 @@ from glanceclient import client as glanceclient tests = ['authenticate', 'glance', 'cinder', 'ceilometer', 'heat', 'keystone', 'neutron', 'nova', 'quotas', 'requests', 'vm', 'all'] parser = argparse.ArgumentParser() -parser.add_argument("repo_path", help="Path to the repository") parser.add_argument("test_name", help="Module name to be tested" "Possible values are : " @@ -47,8 +46,7 @@ parser.add_argument("-r", "--report", args = parser.parse_args() -sys.path.append(args.repo_path + "testcases/") -import functest_utils + """ logging configuration """ logger = logging.getLogger("run_rally") @@ -65,12 +63,18 @@ formatter = logging.Formatter("%(asctime)s - %(name)s - " ch.setFormatter(formatter) logger.addHandler(ch) -with open(args.repo_path+"testcases/config_functest.yaml") as f: +REPO_PATH=os.environ['repos_dir']+'/functest/' +if not os.path.exists(REPO_PATH): + logger.error("Functest repository directory not found '%s'" % REPO_PATH) + exit(-1) +sys.path.append(REPO_PATH + "testcases/") +import functest_utils + +with open(REPO_PATH+"testcases/config_functest.yaml") as f: functest_yaml = yaml.safe_load(f) f.close() HOME = os.environ['HOME']+"/" -REPO_PATH = args.repo_path SCENARIOS_DIR = REPO_PATH + functest_yaml.get("general"). \ get("directories").get("dir_rally_scn") RESULTS_DIR = functest_yaml.get("general").get("directories"). \ @@ -90,7 +94,7 @@ def push_results_to_db(payload): url = TEST_DB + "/results" installer = functest_utils.get_installer_type(logger) - git_version = functest_utils.get_git_branch(args.repo_path) + git_version = functest_utils.get_git_branch(REPO_PATH) pod_name = functest_utils.get_pod_name(logger) # TODO pod_name hardcoded, info shall come from Jenkins params = {"project_name": "functest", "case_name": "Rally", diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py index f80f4ae3..de91bf11 100644 --- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py @@ -24,7 +24,6 @@ modes = ['full', 'smoke', 'baremetal', 'compute', 'data_processing', """ tests configuration """ parser = argparse.ArgumentParser() -parser.add_argument("repo_path", help="Path to the Functest repository") parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") parser.add_argument("-m", "--mode", help="Tempest test mode [smoke, all]", default="smoke") @@ -48,14 +47,17 @@ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(messag ch.setFormatter(formatter) logger.addHandler(ch) -with open(args.repo_path+"/testcases/config_functest.yaml") as f: +REPO_PATH=os.environ['repos_dir']+'/functest/' +if not os.path.exists(REPO_PATH): + logger.error("Functest repository directory not found '%s'" % REPO_PATH) + exit(-1) +sys.path.append(REPO_PATH + "testcases/") +import functest_utils + +with open(REPO_PATH+"testcases/config_functest.yaml") as f: functest_yaml = yaml.safe_load(f) f.close() - -REPO_PATH = args.repo_path TEST_DB = functest_yaml.get("results").get("test_db_url") -sys.path.append(args.repo_path + "/testcases/") -import functest_utils MODE = "smoke" diff --git a/testcases/config_functest.py b/testcases/config_functest.py index 1d834bb3..d0788d30 100755 --- a/testcases/config_functest.py +++ b/testcases/config_functest.py @@ -17,7 +17,6 @@ from neutronclient.v2_0 import client as neutronclient actions = ['start', 'check', 'clean'] parser = argparse.ArgumentParser() -parser.add_argument("repo_path", help="Path to the repository") 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") @@ -38,18 +37,19 @@ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(messag ch.setFormatter(formatter) logger.addHandler(ch) -if not os.path.exists(args.repo_path): - logger.error("Repo directory not found '%s'" % args.repo_path) +REPO_PATH=os.environ['repos_dir']+'/functest/' +if not os.path.exists(REPO_PATH): + logger.error("Functest repository directory not found '%s'" % REPO_PATH) exit(-1) +sys.path.append(REPO_PATH + "testcases/") -with open(args.repo_path+"testcases/config_functest.yaml") as f: +with open(REPO_PATH+"testcases/config_functest.yaml") as f: functest_yaml = yaml.safe_load(f) f.close() """ global variables """ # Directories -REPO_PATH = args.repo_path RALLY_DIR = REPO_PATH + 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") @@ -194,9 +194,8 @@ def action_clean(): shutil.rmtree(RALLY_RESULT_DIR,ignore_errors=True) logger.debug("Cleaning up the OpenStack deployment...") - cmd='python ' + args.repo_path + \ - '/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py -d ' \ - +args.repo_path + cmd='python ' + REPO_PATH + \ + '/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py -d ' functest_utils.execute_command(cmd,logger) logger.info("Functest environment clean!") diff --git a/testcases/config_functest.yaml b/testcases/config_functest.yaml index ce56517e..442ed452 100644 --- a/testcases/config_functest.yaml +++ b/testcases/config_functest.yaml @@ -30,7 +30,7 @@ general: releng_branch: master releng_commit: latest rally_branch: master - rally_commit: 3011fa6ee2de2f373afe9d17d181ad7026cd8c20 + rally_commit: 2c34d1896a7a9f2955a2a09531a9c3eb3f88517b vims_test_branch: stable vims_test_commit: latest bgpvpn_branch: master diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index a0d91357..00a7b305 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -10,6 +10,7 @@ import os +import os.path import urllib2 import subprocess import sys @@ -234,6 +235,19 @@ def create_neutron_port(neutron_client, name, network_id, ip): return False +def update_neutron_port(neutron_client, port_id, device_owner): + json_body = {'port': { + 'device_owner': device_owner, + }} + try: + port = neutron_client.update_port(port=port_id, + body=json_body) + return port['port']['id'] + except: + print "Error:", sys.exc_info()[0] + return False + + def delete_neutron_port(neutron_client, port_id): try: neutron_client.delete_port(port_id) @@ -336,16 +350,20 @@ def get_image_id(glance_client, image_name): return id -def create_glance_image(glance_client, image_name, file_path, is_public=True): +def create_glance_image(glance_client, image_name, file_path, public=True): + if not os.path.isfile(file_path): + print "Error: file "+file_path+" does not exist." + return False try: with open(file_path) as fimage: image = glance_client.images.create(name=image_name, - is_public=is_public, + is_public=public, disk_format="qcow2", container_format="bare", data=fimage) return image.id except: + print "Error:", sys.exc_info()[0] return False def delete_glance_image(nova_client, image_id): diff --git a/testcases/vIMS/CI/vIMS.py b/testcases/vIMS/CI/vIMS.py index 91bec1f0..772e070b 100644 --- a/testcases/vIMS/CI/vIMS.py +++ b/testcases/vIMS/CI/vIMS.py @@ -23,16 +23,12 @@ pp = pprint.PrettyPrinter(indent=4) parser = argparse.ArgumentParser() -parser.add_argument("repo_path", help="Path to the repository") parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") parser.add_argument("-r", "--report", help="Create json result file", action="store_true") args = parser.parse_args() -sys.path.append(args.repo_path + "testcases/") - -import functest_utils """ logging configuration """ logger = logging.getLogger('vIMS') @@ -47,14 +43,18 @@ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(messag ch.setFormatter(formatter) logger.addHandler(ch) +REPO_PATH=os.environ['repos_dir']+'/functest/' +if not os.path.exists(REPO_PATH): + logger.error("Functest repository directory not found '%s'" % REPO_PATH) + exit(-1) +sys.path.append(REPO_PATH + "testcases/") +import functest_utils -# with open(args.repo_path+"config_functest.yaml") as f: -with open(args.repo_path + "testcases/config_functest.yaml") as f: +with open(REPO_PATH + "testcases/config_functest.yaml") as f: functest_yaml = yaml.safe_load(f) f.close() # Cloudify parameters -REPO_PATH = args.repo_path VIMS_DIR = REPO_PATH + functest_yaml.get("general").get("directories").get("dir_vIMS") VIMS_DATA_DIR = functest_yaml.get("general").get("directories").get("dir_vIMS_data")+"/" VIMS_TEST_DIR = functest_yaml.get("general").get("directories").get("dir_repo_vims_test")+"/" @@ -391,7 +391,7 @@ def test_clearwater(): if vims_test_result != "" & args.report: logger.debug("Push result into DB") logger.debug("Pushing results to DB....") - git_version = functest_utils.get_git_branch(args.repo_path) + git_version = functest_utils.get_git_branch(REPO_PATH) functest_utils.push_results_to_db(db_url=TEST_DB, case_name="vIMS", logger=logger, pod_name="opnfv-jump-2", git_version=git_version, payload={'orchestrator':{'duration': CFY_DEPLOYMENT_DURATION, diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py index 1ae6593d..d9ceb2f6 100644 --- a/testcases/vPing/CI/libraries/vPing.py +++ b/testcases/vPing/CI/libraries/vPing.py @@ -31,7 +31,6 @@ pp = pprint.PrettyPrinter(indent=4) parser = argparse.ArgumentParser() -parser.add_argument("repo_path", help="Path to the repository") parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") parser.add_argument("-r", "--report", help="Create json result file", @@ -39,10 +38,6 @@ parser.add_argument("-r", "--report", args = parser.parse_args() -sys.path.append(args.repo_path + "testcases/") - -import functest_utils - """ logging configuration """ logger = logging.getLogger('vPing') @@ -61,12 +56,18 @@ formatter = logging.Formatter('%(asctime)s - %(name)s' ch.setFormatter(formatter) logger.addHandler(ch) -HOME = os.environ['HOME'] + "/" +REPO_PATH=os.environ['repos_dir']+'/functest/' +if not os.path.exists(REPO_PATH): + logger.error("Functest repository directory not found '%s'" % REPO_PATH) + exit(-1) +sys.path.append(REPO_PATH + "testcases/") +import functest_utils -with open(args.repo_path + "testcases/config_functest.yaml") as f: +with open(REPO_PATH + "testcases/config_functest.yaml") as f: functest_yaml = yaml.safe_load(f) f.close() +HOME = os.environ['HOME'] + "/" # vPing parameters VM_BOOT_TIMEOUT = 180 VM_DELETE_TIMEOUT = 100 @@ -120,9 +121,12 @@ def waitVmActive(nova, vm): logger.debug("Status: %s" % status) if status == "ACTIVE": return True - if status == "ERROR" or count == 0: + if status == "ERROR" or status == "error": return False - count -= 1 + if count == 0: + logger.debug("Booting a VM timed out...") + return False + count -= 1 time.sleep(sleep_time) return False @@ -458,7 +462,7 @@ def main(): if args.report: logger.debug("Push result into DB") # TODO check path result for the file - git_version = functest_utils.get_git_branch(args.repo_path) + git_version = functest_utils.get_git_branch(REPO_PATH) pod_name = functest_utils.get_pod_name(logger) functest_utils.push_results_to_db(TEST_DB, "vPing", |