diff options
-rw-r--r-- | docker/Dockerfile | 4 | ||||
-rwxr-xr-x | functest/ci/testcases.yaml | 72 | ||||
-rw-r--r-- | functest/utils/functest_utils.py | 17 | ||||
-rwxr-xr-x | functest/utils/openstack_utils.py | 112 | ||||
-rwxr-xr-x[-rw-r--r--] | requirements.txt | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | test-requirements.txt | 2 |
6 files changed, 170 insertions, 39 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index 6bdfe5ce6..f76dd7979 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -43,6 +43,7 @@ ARG FUNCTEST_DATA_DIR=${FUNCTEST_BASE_DIR}/data ARG FUNCTEST_RESULTS_DIR=${FUNCTEST_BASE_DIR}/results ARG FUNCTEST_REPO_DIR=${REPOS_DIR}/functest ARG FUNCTEST_TEST_DIR=${FUNCTEST_REPO_DIR}/functest/opnfv_tests +ARG RELENG_MODULE_DIR=${REPOS_DIR}/releng/modules # Environment variables ENV HOME /home/opnfv @@ -117,6 +118,9 @@ RUN cd ${FUNCTEST_REPO_DIR} \ && pip install -r requirements.txt \ && pip install . +RUN cd ${RELENG_MODULE_DIR} \ + && pip install . + RUN pip install -r ${REPOS_DIR}/rally/requirements.txt RUN pip install -r ${REPOS_DIR}/tempest/requirements.txt diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml index 56ca40176..6a11a03f4 100755 --- a/functest/ci/testcases.yaml +++ b/functest/ci/testcases.yaml @@ -19,42 +19,6 @@ tiers: installer: '' scenario: '^((?!lxd).)*$' - - - name: connection_check - criteria: 'status == "PASS"' - blocking: true - description: >- - This test case verifies the retrieval of OpenStack clients: - Keystone, Glance, Neutron and Nova and may perform some - simple queries. When the config value of - snaps.use_keystone is True, functest must have access to - the cloud's private network. - - dependencies: - installer: '' - scenario: '' - run: - module: 'functest.opnfv_tests.openstack.snaps.connection_check' - class: 'ConnectionCheck' - - - - name: api_check - criteria: 'status == "PASS"' - blocking: true - description: >- - This test case verifies the retrieval of OpenStack clients: - Keystone, Glance, Neutron and Nova and may perform some - simple queries. When the config value of - snaps.use_keystone is True, functest must have access to - the cloud's private network. - - dependencies: - installer: '' - scenario: '' - run: - module: 'functest.opnfv_tests.openstack.snaps.api_check' - class: 'ApiCheck' - - name: smoke order: 1 @@ -143,6 +107,42 @@ tiers: scenario: 'onos' - + name: connection_check + criteria: 'status == "PASS"' + blocking: true + description: >- + This test case verifies the retrieval of OpenStack clients: + Keystone, Glance, Neutron and Nova and may perform some + simple queries. When the config value of + snaps.use_keystone is True, functest must have access to + the cloud's private network. + + dependencies: + installer: '' + scenario: '' + run: + module: 'functest.opnfv_tests.openstack.snaps.connection_check' + class: 'ConnectionCheck' + + - + name: api_check + criteria: 'status == "PASS"' + blocking: true + description: >- + This test case verifies the retrieval of OpenStack clients: + Keystone, Glance, Neutron and Nova and may perform some + simple queries. When the config value of + snaps.use_keystone is True, functest must have access to + the cloud's private network. + + dependencies: + installer: '' + scenario: '' + run: + module: 'functest.opnfv_tests.openstack.snaps.api_check' + class: 'ApiCheck' + + - name: snaps_smoke criteria: 'status == "PASS"' blocking: true diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py index 8f816cdf9..b1e4d3cdb 100644 --- a/functest/utils/functest_utils.py +++ b/functest/utils/functest_utils.py @@ -21,6 +21,9 @@ import requests import yaml from git import Repo +import time +import functools + import functest.utils.functest_logger as ft_logger logger = ft_logger.Logger("functest_utils").getLogger() @@ -431,3 +434,17 @@ def get_functest_yaml(): def print_separator(): logger.info("==============================================") + + +def timethis(func): + """Measure the time it takes for a function to complete""" + @functools.wraps(func) + def timed(*args, **kwargs): + ts = time.time() + result = func(*args, **kwargs) + te = time.time() + elapsed = '{0}'.format(te - ts) + logger.info('{f}(*{a}, **{kw}) took: {t} sec'.format( + f=func.__name__, a=args, kw=kwargs, t=elapsed)) + return result, elapsed + return timed diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index c304ae382..8f698d73d 100755 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -133,7 +133,14 @@ def source_credentials(rc_file): def get_credentials_for_rally(): creds = get_credentials("keystone") - admin_keys = ['username', 'tenant_name', 'password'] + keystone_api_version = os.getenv('OS_IDENTITY_API_VERSION') + if (keystone_api_version is None or + keystone_api_version == '2'): + admin_keys = ['username', 'tenant_name', 'password'] + else: + admin_keys = ['username', 'password', 'user_domain_name', + 'project_name', 'project_domain_name'] + endpoint_types = [('internalURL', 'internal'), ('publicURL', 'public'), ('adminURL', 'admin')] if 'endpoint_type' in creds.keys(): @@ -238,6 +245,45 @@ def get_flavor_id_by_ram_range(nova_client, min_ram, max_ram): return id +def get_aggregates(nova_client): + try: + aggregates = nova_client.aggregates.list() + return aggregates + except Exception, e: + logger.error("Error [get_aggregates(nova_client)]: %s" % e) + return None + + +def get_aggregate_id(nova_client, aggregate_name): + try: + aggregates = get_aggregates(nova_client) + _id = [ag.id for ag in aggregates if ag.name == aggregate_name][0] + return _id + except Exception, e: + logger.error("Error [get_aggregate_id(nova_client, %s)]:" + " %s" % (aggregate_name, e)) + return None + + +def get_availability_zones(nova_client): + try: + availability_zones = nova_client.availability_zones.list() + return availability_zones + except Exception, e: + logger.error("Error [get_availability_zones(nova_client)]: %s" % e) + return None + + +def get_availability_zone_names(nova_client): + try: + az_names = [az.zoneName for az in get_availability_zones(nova_client)] + return az_names + except Exception, e: + logger.error("Error [get_availability_zone_names(nova_client)]:" + " %s" % e) + return None + + def create_flavor(nova_client, flavor_name, ram, disk, vcpus, public=True): try: flavor = nova_client.flavors.create( @@ -301,6 +347,40 @@ def get_hypervisors(nova_client): return None +def create_aggregate(nova_client, aggregate_name, av_zone): + try: + nova_client.aggregates.create(aggregate_name, av_zone) + return True + except Exception, e: + logger.error("Error [create_aggregate(nova_client, %s, %s)]: %s" + % (aggregate_name, av_zone, e)) + return None + + +def add_host_to_aggregate(nova_client, aggregate_name, compute_host): + try: + aggregate_id = get_aggregate_id(nova_client, aggregate_name) + nova_client.aggregates.add_host(aggregate_id, compute_host) + return True + except Exception, e: + logger.error("Error [add_host_to_aggregate(nova_client, %s, %s)]: %s" + % (aggregate_name, compute_host, e)) + return None + + +def create_aggregate_with_host( + nova_client, aggregate_name, av_zone, compute_host): + try: + create_aggregate(nova_client, aggregate_name, av_zone) + add_host_to_aggregate(nova_client, aggregate_name, compute_host) + return True + except Exception, e: + logger.error("Error [create_aggregate_with_host(" + "nova_client, %s, %s, %s)]: %s" + % (aggregate_name, av_zone, compute_host, e)) + return None + + def create_instance(flavor_name, image_id, network_id, @@ -423,6 +503,36 @@ def delete_floating_ip(nova_client, floatingip_id): return False +def remove_host_from_aggregate(nova_client, aggregate_name, compute_host): + try: + aggregate_id = get_aggregate_id(nova_client, aggregate_name) + nova_client.aggregates.remove_host(aggregate_id, compute_host) + return True + except Exception, e: + logger.error("Error [remove_host_from_aggregate(nova_client, %s, %s)]:" + " %s" % (aggregate_name, compute_host, e)) + return False + + +def remove_hosts_from_aggregate(nova_client, aggregate_name): + aggregate_id = get_aggregate_id(nova_client, aggregate_name) + hosts = nova_client.aggregates.get(aggregate_id).hosts + assert( + all(remove_host_from_aggregate(nova_client, aggregate_name, host) + for host in hosts)) + + +def delete_aggregate(nova_client, aggregate_name): + try: + remove_hosts_from_aggregate(nova_client, aggregate_name) + nova_client.aggregates.delete(aggregate_name) + return True + except Exception, e: + logger.error("Error [delete_aggregate(nova_client, %s)]: %s" + % (aggregate_name, e)) + return False + + # ********************************************* # NEUTRON # ********************************************* diff --git a/requirements.txt b/requirements.txt index 88d0d7dea..28b3fed3e 100644..100755 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ python-ceilometerclient==2.6.2 python-keystoneclient==3.5.0 python-neutronclient==6.0.0 python-congressclient==1.5.0 -virtualenv==1.11.4 +virtualenv==15.1.0 pexpect==4.0 requests>=2.8.0 robotframework==2.9.1 diff --git a/test-requirements.txt b/test-requirements.txt index d65e12f6e..8be8e2033 100644..100755 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -20,4 +20,4 @@ requests==2.8.0 robotframework==2.9.1 robotframework-requests==0.3.8 robotframework-sshlibrary==2.1.1 -virtualenv==1.11.4
\ No newline at end of file +virtualenv==15.1.0
\ No newline at end of file |