diff options
-rwxr-xr-x | ci/run_tests.py | 14 | ||||
-rwxr-xr-x | testcases/Controllers/ODL/OpenDaylightTesting.py | 45 | ||||
-rw-r--r-- | testcases/Controllers/ODL/__init__.py | 0 | ||||
-rw-r--r-- | testcases/Controllers/__init__.py | 0 | ||||
-rwxr-xr-x | testcases/OpenStack/rally/run_rally-cert.py | 46 | ||||
-rw-r--r-- | testcases/OpenStack/tempest/custom_tests/blacklist.txt | 14 | ||||
-rwxr-xr-x | testcases/OpenStack/tempest/run_tempest.py | 45 | ||||
-rw-r--r-- | testcases/OpenStack/vPing/vping_util.py | 23 | ||||
-rwxr-xr-x | utils/openstack_utils.py | 42 |
9 files changed, 135 insertions, 94 deletions
diff --git a/ci/run_tests.py b/ci/run_tests.py index 98256721..17481780 100755 --- a/ci/run_tests.py +++ b/ci/run_tests.py @@ -13,8 +13,10 @@ import datetime import os import re import sys + import functest.ci.generate_report as generate_report import functest.ci.tier_builder as tb +from functest.testcases.Controllers.ODL.OpenDaylightTesting import ODLTestCases import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils import functest.utils.openstack_clean as os_clean @@ -100,9 +102,15 @@ def run_test(test, tier_name): if REPORT_FLAG: flags += " -r" - cmd = ("%s%s" % (EXEC_SCRIPT, flags)) - logger.debug("Executing command '%s'" % cmd) - result = ft_utils.execute_command(cmd, exit_on_error=False) + if test_name == 'odl': + result = ODLTestCases.functest_run() + if result and REPORT_FLAG: + result = ODLTestCases.push_to_db() + result = not result + else: + cmd = ("%s%s" % (EXEC_SCRIPT, flags)) + logger.debug("Executing command '%s'" % cmd) + result = ft_utils.execute_command(cmd, exit_on_error=False) if CLEAN_FLAG: cleanup() diff --git a/testcases/Controllers/ODL/OpenDaylightTesting.py b/testcases/Controllers/ODL/OpenDaylightTesting.py index d3bc0978..22df9f66 100755 --- a/testcases/Controllers/ODL/OpenDaylightTesting.py +++ b/testcases/Controllers/ODL/OpenDaylightTesting.py @@ -6,6 +6,7 @@ import os import re import shutil import sys +import urlparse from robot import run from robot.api import ExecutionResult, ResultVisitor @@ -14,6 +15,7 @@ from robot.utils.robottime import timestamp_to_secs import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils +import functest.utils.openstack_utils as op_utils class ODLResultVisitor(ResultVisitor): @@ -60,7 +62,7 @@ class ODLTestCases: except IOError as e: cls.logger.error( "Cannot copy OPNFV's testcases to ODL directory: " - "%s" % e.strerror) + "%s" % str(e)) return False return True @@ -76,7 +78,7 @@ class ODLTestCases: line.rstrip()) return True except Exception as e: - cls.logger.error("Cannot set ODL creds: %s" % e.strerror) + cls.logger.error("Cannot set ODL creds: %s" % str(e)) return False @classmethod @@ -95,7 +97,7 @@ class ODLTestCases: 'RESTCONFPORT:' + kwargs['odlrestconfport']] except KeyError as e: cls.logger.error("Cannot run ODL testcases. Please check " - "%s" % e.strerror) + "%s" % str(e)) return False if (cls.copy_opnf_testcases() and cls.set_robotframework_vars(odlusername, odlpassword)): @@ -122,6 +124,43 @@ class ODLTestCases: return False @classmethod + def functest_run(cls): + kclient = op_utils.get_keystone_client() + keystone_url = kclient.service_catalog.url_for( + service_type='identity', endpoint_type='publicURL') + neutron_url = kclient.service_catalog.url_for( + service_type='network', endpoint_type='publicURL') + kwargs = {'keystoneip': urlparse.urlparse(keystone_url).hostname} + kwargs['neutronip'] = urlparse.urlparse(neutron_url).hostname + kwargs['odlip'] = kwargs['neutronip'] + kwargs['odlwebport'] = '8080' + kwargs['odlrestconfport'] = '8181' + kwargs['odlusername'] = 'admin' + kwargs['odlpassword'] = 'admin' + try: + installer_type = os.environ['INSTALLER_TYPE'] + kwargs['osusername'] = os.environ['OS_USERNAME'] + kwargs['ostenantname'] = os.environ['OS_TENANT_NAME'] + kwargs['ospassword'] = os.environ['OS_PASSWORD'] + if installer_type == 'fuel': + kwargs['odlwebport'] = '8282' + elif installer_type == 'apex': + kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP'] + kwargs['odlwebport'] = '8181' + elif installer_type == 'joid': + kwargs['odlip'] = os.environ['SDN_CONTROLLER'] + elif installer_type == 'compass': + kwargs['odlwebport'] = '8181' + else: + kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP'] + except KeyError as e: + cls.logger.error("Cannot run ODL testcases. Please check env var: " + "%s" % str(e)) + return False + + return cls.run(**kwargs) + + @classmethod def push_to_db(cls): try: result = ExecutionResult(cls.res_dir + 'output.xml') diff --git a/testcases/Controllers/ODL/__init__.py b/testcases/Controllers/ODL/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/testcases/Controllers/ODL/__init__.py diff --git a/testcases/Controllers/__init__.py b/testcases/Controllers/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/testcases/Controllers/__init__.py diff --git a/testcases/OpenStack/rally/run_rally-cert.py b/testcases/OpenStack/rally/run_rally-cert.py index 92dbddff..f3eb79d2 100755 --- a/testcases/OpenStack/rally/run_rally-cert.py +++ b/testcases/OpenStack/rally/run_rally-cert.py @@ -376,7 +376,6 @@ def main(): nova_client = os_utils.get_nova_client() neutron_client = os_utils.get_neutron_client() - glance_client = os_utils.get_glance_client() cinder_client = os_utils.get_cinder_client() start_time = time.time() @@ -402,44 +401,19 @@ def main(): else: logger.debug("Using existing volume type(s)...") - image_id = os_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME) - image_exists = False - - if image_id == '': - logger.debug("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME, - GLANCE_IMAGE_PATH)) - image_id = os_utils.create_glance_image(glance_client, - GLANCE_IMAGE_NAME, - GLANCE_IMAGE_PATH, - GLANCE_IMAGE_FORMAT) - if not image_id: - logger.error("Failed to create the Glance image...") - exit(-1) - else: - logger.debug("Image '%s' with ID '%s' created succesfully ." - % (GLANCE_IMAGE_NAME, image_id)) - else: - logger.debug("Using existing image '%s' with ID '%s'..." - % (GLANCE_IMAGE_NAME, image_id)) - image_exists = True + image_exists, image_id = os_utils.get_or_create_image(GLANCE_IMAGE_NAME, + GLANCE_IMAGE_PATH, + GLANCE_IMAGE_FORMAT) + if not image_id: + exit(-1) logger.debug("Creating network '%s'..." % PRIVATE_NET_NAME) - network_dict = os_utils.create_network_full(neutron_client, - PRIVATE_NET_NAME, - PRIVATE_SUBNET_NAME, - ROUTER_NAME, - PRIVATE_SUBNET_CIDR) + network_dict = os_utils.create_shared_network_full(PRIVATE_NET_NAME, + PRIVATE_SUBNET_NAME, + ROUTER_NAME, + PRIVATE_SUBNET_CIDR) if not network_dict: - logger.error("Failed to create network...") - exit(-1) - else: - if not os_utils.update_neutron_net(neutron_client, - network_dict['net_id'], - shared=True): - logger.error("Failed to update network...") - exit(-1) - else: - logger.debug("Network '%s' available..." % PRIVATE_NET_NAME) + exit(1) if args.test_name == "all": for test_name in tests: diff --git a/testcases/OpenStack/tempest/custom_tests/blacklist.txt b/testcases/OpenStack/tempest/custom_tests/blacklist.txt index 6dd7fad5..e26223b0 100644 --- a/testcases/OpenStack/tempest/custom_tests/blacklist.txt +++ b/testcases/OpenStack/tempest/custom_tests/blacklist.txt @@ -61,3 +61,17 @@ - tempest.scenario.test_server_basic_ops.TestServerBasicOps.test_server_basic_ops - tempest.scenario.test_volume_boot_pattern.TestVolumeBootPattern.test_volume_boot_pattern - tempest.scenario.test_volume_boot_pattern.TestVolumeBootPatternV2.test_volume_boot_pattern + +- + # https://bugs.launchpad.net/tempest/+bug/1586931 + scenarios: + - os-odl_l2-nofeature-ha + - os-odl_l2-sfc-ha + - os-odl_l3-nofeature-ha + - os-nosdn-kvm-ha + - os-nosdn-nofeature-ha + - os-nosdn-ovs-ha + installers: + - fuel + tests: + - tempest.scenario.test_server_basic_ops.TestServerBasicOps.test_server_basic_ops diff --git a/testcases/OpenStack/tempest/run_tempest.py b/testcases/OpenStack/tempest/run_tempest.py index 64a5ed77..306664fe 100755 --- a/testcases/OpenStack/tempest/run_tempest.py +++ b/testcases/OpenStack/tempest/run_tempest.py @@ -125,8 +125,6 @@ def get_info(file_result): def create_tempest_resources(): keystone_client = os_utils.get_keystone_client() - neutron_client = os_utils.get_neutron_client() - glance_client = os_utils.get_glance_client() logger.debug("Creating tenant and user for Tempest suite") tenant_id = os_utils.create_tenant(keystone_client, @@ -141,40 +139,19 @@ def create_tempest_resources(): logger.error("Error : Failed to create %s user" % USER_NAME) logger.debug("Creating private network for Tempest suite") - network_dic = os_utils.create_network_full(neutron_client, - PRIVATE_NET_NAME, - PRIVATE_SUBNET_NAME, - ROUTER_NAME, - PRIVATE_SUBNET_CIDR) - if network_dic: - if not os_utils.update_neutron_net(neutron_client, - network_dic['net_id'], - shared=True): - logger.error("Failed to update private network...") - exit(-1) - else: - logger.debug("Network '%s' is available..." % PRIVATE_NET_NAME) - else: - logger.error("Private network creation failed") - exit(-1) + network_dic = os_utils.create_shared_network_full(PRIVATE_NET_NAME, + PRIVATE_SUBNET_NAME, + ROUTER_NAME, + PRIVATE_SUBNET_CIDR) + if not network_dic: + exit(1) logger.debug("Creating image for Tempest suite") - # Check if the given image exists - image_id = os_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME) - if image_id != '': - logger.info("Using existing image '%s'..." % GLANCE_IMAGE_NAME) - else: - logger.info("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME, - GLANCE_IMAGE_PATH)) - image_id = os_utils.create_glance_image(glance_client, - GLANCE_IMAGE_NAME, - GLANCE_IMAGE_PATH, - GLANCE_IMAGE_FORMAT) - if not image_id: - logger.error("Failed to create a Glance image...") - exit(-1) - logger.debug("Image '%s' with ID=%s created successfully." - % (GLANCE_IMAGE_NAME, image_id)) + _, image_id = os_utils.get_or_create_image(GLANCE_IMAGE_NAME, + GLANCE_IMAGE_PATH, + GLANCE_IMAGE_FORMAT) + if not image_id: + exit(-1) def configure_tempest(deployment_dir): diff --git a/testcases/OpenStack/vPing/vping_util.py b/testcases/OpenStack/vPing/vping_util.py index c16c5d65..3f4adae7 100644 --- a/testcases/OpenStack/vPing/vping_util.py +++ b/testcases/OpenStack/vPing/vping_util.py @@ -147,24 +147,11 @@ def create_security_group(): def create_image(): - EXIT_CODE = -1 - - # Check if the given image exists - image_id = os_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME) - if image_id != '': - logger.info("Using existing image '%s'..." % GLANCE_IMAGE_NAME) - else: - logger.info("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME, - GLANCE_IMAGE_PATH)) - image_id = os_utils.create_glance_image(glance_client, - GLANCE_IMAGE_NAME, - GLANCE_IMAGE_PATH, - GLANCE_IMAGE_FORMAT) - if not image_id: - logger.error("Failed to create a Glance image...") - exit(EXIT_CODE) - logger.debug("Image '%s' with ID=%s created successfully." - % (GLANCE_IMAGE_NAME, image_id)) + _, image_id = os_utils.get_or_create_image(GLANCE_IMAGE_NAME, + GLANCE_IMAGE_PATH, + GLANCE_IMAGE_FORMAT) + if not image_id: + exit(-1) return image_id diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py index d30ca629..bc718bb2 100755 --- a/utils/openstack_utils.py +++ b/utils/openstack_utils.py @@ -671,6 +671,28 @@ def create_network_full(neutron_client, return network_dic +def create_shared_network_full(net_name, subnt_name, router_name, subnet_cidr): + neutron_client = get_neutron_client() + + network_dic = create_network_full(neutron_client, + net_name, + subnt_name, + router_name, + subnet_cidr) + if network_dic: + if not update_neutron_net(neutron_client, + network_dic['net_id'], + shared=True): + logger.error("Failed to update network %s..." % net_name) + return None + else: + logger.debug("Network '%s' is available..." % net_name) + else: + logger.error("Network %s creation failed" % net_name) + return None + return network_dic + + def create_bgpvpn(neutron_client, **kwargs): # route_distinguishers # route_targets @@ -889,6 +911,26 @@ def create_glance_image(glance_client, image_name, file_path, disk="qcow2", return None +def get_or_create_image(name, path, format): + image_exists = False + glance_client = get_glance_client() + + image_id = get_image_id(glance_client, name) + if image_id != '': + logger.info("Using existing image '%s'..." % name) + image_exists = True + else: + logger.info("Creating image '%s' from '%s'..." % (name, path)) + image_id = create_glance_image(glance_client, name, path, format) + if not image_id: + logger.error("Failed to create a Glance image...") + else: + logger.debug("Image '%s' with ID=%s created successfully." + % (name, image_id)) + + return image_exists, image_id + + def delete_glance_image(nova_client, image_id): try: nova_client.images.delete(image_id) |