diff options
-rw-r--r-- | docker/Dockerfile | 3 | ||||
-rw-r--r-- | testcases/VIM/OpenStack/CI/libraries/clean_openstack.py | 82 | ||||
-rwxr-xr-x | testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py | 46 | ||||
-rw-r--r-- | testcases/config_functest.yaml | 2 | ||||
-rw-r--r-- | testcases/functest_utils.py | 13 | ||||
-rw-r--r-- | testcases/vPing/CI/libraries/vPing.py | 7 |
6 files changed, 79 insertions, 74 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index 32323e0cf..decce6812 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 @@ -71,4 +72,4 @@ ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img /home/op 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 ; rvm use 1.9.3; bundle install' +RUN bash -c 'source /etc/profile.d/rvm.sh ; cd ${repos_dir}/vims-test;rvm use system;bundle install' diff --git a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py index e76034b8b..dca188f5b 100644 --- a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py +++ b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py @@ -164,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) + + #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) - #debug information (to be removed when it works many times in a row) - print ports +def remove_ports(neutron_client, ports, network_ids): for port in ports: if port['network_id'] in network_ids: port_id = port['id'] @@ -195,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) @@ -215,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'] @@ -242,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-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py index c6e5505d7..18f91b878 100755 --- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py @@ -23,6 +23,8 @@ import yaml import requests import sys import novaclient.v2.client as novaclient +from glanceclient import client as glanceclient +from keystoneclient.v2_0 import client as keystoneclient """ tests configuration """ tests = ['authenticate', 'glance', 'cinder', 'heat', 'keystone', @@ -130,16 +132,6 @@ def get_task_id(cmd_raw): return None -def create_glance_image(path, name, disk_format): - """ - Create a glance image given the absolute path of the image, its name and the disk format - """ - cmd = ("glance image-create --name " + name + " --visibility public " - "--disk-format " + disk_format + " --container-format bare --file " + path) - functest_utils.execute_command(cmd, logger) - return True - - def task_succeed(json_raw): """ Parse JSON from rally JSON results @@ -162,7 +154,7 @@ def task_succeed(json_raw): def build_task_args(test_file_name): task_args = {'service_list': [test_file_name]} - task_args['smoke'] = False + task_args['smoke'] = False task_args['image_name'] = GLANCE_IMAGE_NAME task_args['flavor_name'] = FLAVOR_NAME task_args['glance_image_location'] = GLANCE_IMAGE_LOCATION @@ -247,20 +239,6 @@ def run_task(test_name): print 'Test KO' -def delete_glance_image(name): - cmd = ("glance image-delete $(glance image-list | grep %s " - "| awk '{print $2}' | head -1)" % name) - functest_utils.execute_command(cmd, logger) - return True - - -def cleanup(nova): - logger.info("Cleaning up...") - logger.debug("Deleting image...") - delete_glance_image(GLANCE_IMAGE_NAME) - return True - - def main(): # configure script if not (args.test_name in tests): @@ -269,11 +247,19 @@ def main(): creds_nova = functest_utils.get_credentials("nova") nova_client = novaclient.Client(**creds_nova) + creds_keystone = functest_utils.get_credentials("keystone") + keystone_client = keystoneclient.Client(**creds_keystone) + glance_endpoint = keystone_client.service_catalog.url_for(service_type='image', + endpoint_type='publicURL') + glance_client = glanceclient.Client(1, glance_endpoint, + token=keystone_client.auth_token) logger.debug("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME, GLANCE_IMAGE_PATH)) - create_glance_image(GLANCE_IMAGE_PATH, GLANCE_IMAGE_NAME, GLANCE_IMAGE_FORMAT) - - + image_id = functest_utils.create_glance_image(glance_client, + GLANCE_IMAGE_NAME,GLANCE_IMAGE_PATH) + if not image_id: + logger.error("Failed to create a Glance image...") + exit(-1) # Check if the given image exists try: nova_client.images.find(name=GLANCE_IMAGE_NAME) @@ -295,7 +281,9 @@ def main(): print(args.test_name) run_task(args.test_name) - cleanup(nova_client) + logger.debug("Deleting image...") + if not functest_utils.delete_glance_image(nova_client, image_id): + logger.error("Error deleting the glance image") if __name__ == '__main__': main() diff --git a/testcases/config_functest.yaml b/testcases/config_functest.yaml index ab75ee384..dc33f07f5 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 327608691..88c00858e 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -236,6 +236,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) diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py index cc52f5ab6..d9ceb2f6d 100644 --- a/testcases/vPing/CI/libraries/vPing.py +++ b/testcases/vPing/CI/libraries/vPing.py @@ -121,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 |