diff options
Diffstat (limited to 'functest')
24 files changed, 401 insertions, 136 deletions
diff --git a/functest/ci/add_proxy.sh b/functest/ci/add_proxy.sh new file mode 100644 index 000000000..3244f246a --- /dev/null +++ b/functest/ci/add_proxy.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +set -e + +pushd "${1:-/home/opnfv/functest/images}" > /dev/null + +images=${images-"\ +cloudify-manager-premium-4.0.1.qcow2 \ +ubuntu-14.04-server-cloudimg-amd64-disk1.img \ +ubuntu-16.04-server-cloudimg-amd64-disk1.img"} + +add_proxy () { + cat << EOF >> "$1" +http_proxy=${http_proxy:-http://proxy:8080} +HTTP_PROXY=${http_proxy:-http://proxy:8080} +https_proxy=${https_proxy:-${http_proxy:-http://proxy:8080}} +HTTPS_PROXY=${https_proxy:-${http_proxy:-http://proxy:8080}} +ftp_proxy=${ftp_proxy:-${http_proxy:-http://proxy:8080}} +FTP_PROXY=${ftp_proxy:-${http_proxy:-http://proxy:8080}} +no_proxy=${no_proxy:-"10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"} +NO_PROXY=${no_proxy:-"10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"} +EOF +} + +add_proxy_apt () { + cat << EOF >> "$1" +Acquire::http::Proxy "${http_proxy:-http://proxy:8080}"; +Acquire::https::Proxy "${https_proxy:-http://proxy:8080}"; +EOF +} + +tmpdir=$(mktemp -d) +for image in $images; do + if [ ! -f "$image" ]; then + echo "skip ${image} ($(pwd)/${image} not found)" + continue + fi + guestmount -a "${image}" -i --rw "${tmpdir}" + add_proxy "${tmpdir}/etc/environment" + if [[ ${image} == *"cloudify-manager"* ]]; then + echo >> "${tmpdir}/etc/sysconfig/cloudify-mgmtworker" + add_proxy "${tmpdir}/etc/sysconfig/cloudify-mgmtworker" + echo >> "${tmpdir}/etc/sysconfig/cloudify-restservice" + add_proxy "${tmpdir}/etc/sysconfig/cloudify-restservice" + fi + if [[ ${image} == "ubuntu"* ]]; then + add_proxy_apt "${tmpdir}/etc/apt/apt.conf" + fi + guestunmount "${tmpdir}" +done + +rmdir "${tmpdir}" +popd > /dev/null diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml index 7e51ee790..dbea320c9 100644 --- a/functest/ci/config_functest.yaml +++ b/functest/ci/config_functest.yaml @@ -11,8 +11,9 @@ general: functest_conf: /home/opnfv/functest/conf functest_data: /home/opnfv/functest/data ims_data: /home/opnfv/functest/data/ims/ + rally_data: /home/opnfv/functest/data/rally refstack_data: /home/opnfv/functest/data/refstack - router_data: /home/opnfv/functest/data/router/ + router_data: /home/opnfv/functest/data/router/opnfv-vnf-data functest_images: /home/opnfv/functest/images rally_inst: /root/.rally diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml index 2413287ac..16365b0b7 100644 --- a/functest/ci/testcases.yaml +++ b/functest/ci/testcases.yaml @@ -225,6 +225,17 @@ tiers: name: rally_sanity - + case_name: rally_jobs + project_name: functest + criteria: 100 + blocking: false + description: >- + This test case runs a group of Rally jobs used in + OpenStack gating + run: + name: rally_jobs + + - case_name: refstack_defcore project_name: functest criteria: 100 @@ -254,6 +265,7 @@ tiers: - 'network' excludes: - 'test_networks_multiprovider_rbac' + - 'test_auto_allocated_topology_rbac' - case_name: snaps_smoke @@ -386,6 +398,7 @@ tiers: - case_name: doctor-notification project_name: doctor + enabled: false criteria: 100 blocking: false description: >- @@ -401,6 +414,7 @@ tiers: - case_name: bgpvpn project_name: sdnvpn + enabled: false criteria: 100 blocking: false description: >- @@ -413,6 +427,7 @@ tiers: - case_name: functest-odl-sfc project_name: sfc + enabled: false criteria: 100 blocking: false description: >- @@ -426,6 +441,7 @@ tiers: - case_name: barometercollectd project_name: barometer + enabled: false criteria: 100 blocking: false description: >- @@ -440,6 +456,7 @@ tiers: - case_name: fds project_name: fastdatastacks + enabled: false criteria: 100 blocking: false description: >- @@ -468,6 +485,7 @@ tiers: - case_name: stor4nfv_os project_name: stor4nfv + enabled: false criteria: 100 blocking: false description: >- diff --git a/functest/core/tenantnetwork.py b/functest/core/tenantnetwork.py index 9f5913c70..e03740767 100644 --- a/functest/core/tenantnetwork.py +++ b/functest/core/tenantnetwork.py @@ -106,6 +106,12 @@ class NewProject(object): self.orig_cloud.delete_project(self.project.id) if self.role: self.orig_cloud.delete_role(self.role.id) + secgroups = self.orig_cloud.list_security_groups( + filters={'name': 'default', + 'project_id': self.project.id}) + if secgroups: + sec_id = secgroups[0].id + self.orig_cloud.delete_security_group(sec_id) except Exception: # pylint: disable=broad-except self.__logger.exception("Cannot clean all resources") diff --git a/functest/opnfv_tests/openstack/rally/blacklist.txt b/functest/opnfv_tests/openstack/rally/blacklist.txt index 0900f21c1..1ade43eaf 100644 --- a/functest/opnfv_tests/openstack/rally/blacklist.txt +++ b/functest/opnfv_tests/openstack/rally/blacklist.txt @@ -17,3 +17,8 @@ functionality: - NovaServers.boot_server_attach_created_volume_and_live_migrate - NovaServers.boot_server_from_volume_and_live_migrate - NovaServers.boot_and_migrate_server + - + functions: + - no_net_trunk_service + tests: + - '^NeutronTrunk' diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index a91059a2b..ac44de118 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -16,11 +16,14 @@ import json import logging import os import re +import shutil import subprocess import time import pkg_resources import prettytable +from ruamel.yaml import YAML +from six.moves import configparser from xtesting.core import testcase from xtesting.energy import energy import yaml @@ -52,7 +55,6 @@ class RallyBase(singlevm.VmReady2): TENANTS_AMOUNT = 3 ITERATIONS_AMOUNT = 10 CONCURRENCY = 4 - RESULTS_DIR = os.path.join(getattr(config.CONF, 'dir_results'), 'rally') BLACKLIST_FILE = os.path.join(RALLY_DIR, "blacklist.txt") TEMP_DIR = os.path.join(RALLY_DIR, "var") @@ -74,6 +76,9 @@ class RallyBase(singlevm.VmReady2): role_name, user=self.project.user.id, project=self.project.project.id, domain=self.project.domain.id) + self.results_dir = os.path.join( + getattr(config.CONF, 'dir_results'), self.case_name) + self.task_file = os.path.join(self.RALLY_DIR, 'task.yaml') self.creators = [] self.summary = [] self.scenario_dir = '' @@ -85,8 +90,8 @@ class RallyBase(singlevm.VmReady2): self.compute_cnt = 0 self.flavor_alt = None self.tests = [] - self.task_file = '' self.run_cmd = '' + self.network_extensions = [] def _build_task_args(self, test_file_name): """Build arguments for the Rally task.""" @@ -137,10 +142,34 @@ class RallyBase(singlevm.VmReady2): if not os.path.exists(self.TEMP_DIR): os.makedirs(self.TEMP_DIR) - self._apply_blacklist(scenario_file_name, test_file_name) + self.apply_blacklist(scenario_file_name, test_file_name) return test_file_name @staticmethod + def update_keystone_default_role(rally_conf='/etc/rally/rally.conf'): + """Set keystone_default_role in rally.conf""" + if env.get("NEW_USER_ROLE").lower() != "member": + rconfig = configparser.RawConfigParser() + rconfig.read(rally_conf) + if not rconfig.has_section('openstack'): + rconfig.add_section('openstack') + rconfig.set( + 'openstack', 'keystone_default_role', env.get("NEW_USER_ROLE")) + with open(rally_conf, 'wb') as config_file: + rconfig.write(config_file) + + @staticmethod + def clean_rally_conf(rally_conf='/etc/rally/rally.conf'): + """Clean Rally config""" + if env.get("NEW_USER_ROLE").lower() != "member": + rconfig = configparser.RawConfigParser() + rconfig.read(rally_conf) + if rconfig.has_option('openstack', 'keystone_default_role'): + rconfig.remove_option('openstack', 'keystone_default_role') + with open(rally_conf, 'wb') as config_file: + rconfig.write(config_file) + + @staticmethod def get_task_id(cmd_raw): """ Get task id from command rally result. @@ -179,7 +208,12 @@ class RallyBase(singlevm.VmReady2): """Determine if migration is supported.""" if self.compute_cnt > 1: return True + return False + def _network_trunk_supported(self): + """Determine if network trunk service is available""" + if 'trunk' in self.network_extensions: + return True return False @staticmethod @@ -236,6 +270,8 @@ class RallyBase(singlevm.VmReady2): if not self._migration_supported(): func_list.append("no_migration") + if not self._network_trunk_supported(): + func_list.append("no_net_trunk_service") if 'functionality' in black_list_yaml.keys(): for item in black_list_yaml['functionality']: @@ -249,7 +285,7 @@ class RallyBase(singlevm.VmReady2): return black_tests - def _apply_blacklist(self, case_file_name, result_file_name): + def apply_blacklist(self, case_file_name, result_file_name): """Apply blacklist.""" LOGGER.debug("Applying blacklist...") cases_file = open(case_file_name, 'r') @@ -292,10 +328,10 @@ class RallyBase(singlevm.VmReady2): def _save_results(self, test_name, task_id): """ Generate and save task execution results""" # check for result directory and create it otherwise - if not os.path.exists(self.RESULTS_DIR): + if not os.path.exists(self.results_dir): LOGGER.debug('%s does not exist, we create it.', - self.RESULTS_DIR) - os.makedirs(self.RESULTS_DIR) + self.results_dir) + os.makedirs(self.results_dir) # put detailed result to log cmd = (["rally", "task", "detailed", "--uuid", task_id]) @@ -304,8 +340,8 @@ class RallyBase(singlevm.VmReady2): LOGGER.info("%s\n%s", " ".join(cmd), output) # save report as JSON - report_json_name = 'opnfv-{}.json'.format(test_name) - report_json_dir = os.path.join(self.RESULTS_DIR, report_json_name) + report_json_name = '{}.json'.format(test_name) + report_json_dir = os.path.join(self.results_dir, report_json_name) cmd = (["rally", "task", "report", "--json", "--uuid", task_id, "--out", report_json_dir]) LOGGER.debug('running command: %s', cmd) @@ -313,8 +349,8 @@ class RallyBase(singlevm.VmReady2): LOGGER.info("%s\n%s", " ".join(cmd), output) # save report as HTML - report_html_name = 'opnfv-{}.html'.format(test_name) - report_html_dir = os.path.join(self.RESULTS_DIR, report_html_name) + report_html_name = '{}.html'.format(test_name) + report_html_dir = os.path.join(self.results_dir, report_html_name) cmd = (["rally", "task", "report", "--html", "--uuid", task_id, "--out", report_html_dir]) LOGGER.debug('running command: %s', cmd) @@ -384,13 +420,14 @@ class RallyBase(singlevm.VmReady2): else: raise Exception("Test name '%s' is invalid" % self.test_name) - self.task_file = os.path.join(self.RALLY_DIR, 'task.yaml') if not os.path.exists(self.task_file): LOGGER.error("Task file '%s' does not exist.", self.task_file) raise Exception("Task file '{}' does not exist.". format(self.task_file)) + self.update_keystone_default_role() self.compute_cnt = len(self.cloud.list_hypervisors()) + self.network_extensions = self.cloud.get_network_extensions() self.flavor_alt = self.create_flavor_alt() LOGGER.debug("flavor: %s", self.flavor_alt) @@ -438,7 +475,7 @@ class RallyBase(singlevm.VmReady2): except ZeroDivisionError: success_avg = 0 success_str = str("{:0.2f}".format(success_avg)) + '%' - duration_str = time.strftime("%M:%S", + duration_str = time.strftime("%H:%M:%S", time.gmtime(item['overall_duration'])) res_table.add_row([item['test_name'], duration_str, item['nb_tests'], success_str]) @@ -470,6 +507,7 @@ class RallyBase(singlevm.VmReady2): def clean(self): """Cleanup of OpenStack resources. Should be called on completion.""" + self.clean_rally_conf() if self.flavor_alt: self.orig_cloud.delete_flavor(self.flavor_alt.id) super(RallyBase, self).clean() @@ -495,6 +533,11 @@ class RallyBase(singlevm.VmReady2): OS_PROJECT_NAME=self.project.project.name, OS_PROJECT_ID=self.project.project.id, OS_PASSWORD=self.project.password) + try: + del environ['OS_TENANT_NAME'] + del environ['OS_TENANT_ID'] + except Exception: # pylint: disable=broad-except + pass conf_utils.create_rally_deployment(environ=environ) self.prepare_run() self.run_tests() @@ -532,3 +575,109 @@ class RallyFull(RallyBase): self.test_name = 'all' self.smoke = False self.scenario_dir = os.path.join(self.RALLY_SCENARIO_DIR, 'full') + + +class RallyJobs(RallyBase): + """Rally OpenStack CI testcase implementation.""" + + TESTS = ["neutron"] + + def __init__(self, **kwargs): + """Initialize RallyJobs object.""" + if "case_name" not in kwargs: + kwargs["case_name"] = "rally_jobs" + super(RallyJobs, self).__init__(**kwargs) + self.test_name = 'all' + self.task_file = os.path.join(self.RALLY_DIR, 'rally_jobs.yaml') + self.task_yaml = None + + def prepare_run(self): + """Create resources needed by test scenarios.""" + super(RallyJobs, self).prepare_run() + with open(os.path.join(self.RALLY_DIR, + 'rally_jobs.yaml'), 'r') as task_file: + self.task_yaml = yaml.safe_load(task_file) + + if not all(task in self.task_yaml for task in self.tests): + raise Exception("Test '%s' not in '%s'" % + (self.test_name, self.tests)) + + def apply_blacklist(self, case_file_name, result_file_name): + # pylint: disable=too-many-branches + """Apply blacklist.""" + LOGGER.debug("Applying blacklist...") + black_tests = list(set(self.excl_func() + + self.excl_scenario())) + if black_tests: + LOGGER.debug("Blacklisted tests: %s", str(black_tests)) + + template = YAML(typ='jinja2') + with open(case_file_name, 'r') as fname: + cases = template.load(fname) + if cases.get("version", 1) == 1: + # scenarios in dictionary + for name in cases.keys(): + if self.in_iterable_re(name, black_tests): + cases.pop(name) + else: + # workloads in subtasks + for sind, subtask in enumerate(cases.get('subtasks', [])): + idx = [] + for wind, workload in enumerate(subtask.get('workloads', [])): + scenario = workload.get('scenario', {}) + for name in scenario.keys(): + if self.in_iterable_re(name, black_tests): + idx.append(wind) + break + for wind in reversed(idx): + cases['subtasks'][sind]['workloads'].pop(wind) + # scenarios in subtasks + idx = [] + for sind, subtask in enumerate(cases.get('subtasks', [])): + scenario = subtask.get('scenario', {}) + for name in scenario.keys(): + if self.in_iterable_re(name, black_tests): + idx.append(sind) + break + for sind in reversed(idx): + cases['subtasks'].pop(sind) + + with open(result_file_name, 'w') as fname: + template.dump(cases, fname) + + @staticmethod + def _remove_plugins_extra(): + inst_dir = getattr(config.CONF, 'dir_rally_inst') + try: + shutil.rmtree(os.path.join(inst_dir, 'plugins')) + shutil.rmtree(os.path.join(inst_dir, 'extra')) + except Exception: # pylint: disable=broad-except + pass + + def prepare_task(self, test_name): + """Prepare resources for test run.""" + self._remove_plugins_extra() + jobs_dir = os.path.join( + getattr(config.CONF, 'dir_rally_data'), test_name, 'rally-jobs') + inst_dir = getattr(config.CONF, 'dir_rally_inst') + shutil.copytree(os.path.join(jobs_dir, 'plugins'), + os.path.join(inst_dir, 'plugins')) + shutil.copytree(os.path.join(jobs_dir, 'extra'), + os.path.join(inst_dir, 'extra')) + + task_name = self.task_yaml.get(test_name).get("task") + task = os.path.join(jobs_dir, task_name) + if not os.path.exists(task): + raise Exception("The scenario '%s' does not exist." % task) + LOGGER.debug('Scenario fetched from : %s', task) + + if not os.path.exists(self.TEMP_DIR): + os.makedirs(self.TEMP_DIR) + task_file_name = os.path.join(self.TEMP_DIR, task_name) + self.apply_blacklist(task, task_file_name) + self.run_cmd = (["rally", "task", "start", "--task", task_file_name]) + return True + + def clean(self): + self._remove_plugins_extra() + super(RallyJobs, self).clean() diff --git a/functest/opnfv_tests/openstack/rally/rally_jobs.yaml b/functest/opnfv_tests/openstack/rally/rally_jobs.yaml new file mode 100644 index 000000000..2092fb4cf --- /dev/null +++ b/functest/opnfv_tests/openstack/rally/rally_jobs.yaml @@ -0,0 +1,3 @@ +--- +neutron: + task: task-neutron.yaml diff --git a/functest/opnfv_tests/openstack/rally/scenario/full/opnfv-nova.yaml b/functest/opnfv_tests/openstack/rally/scenario/full/opnfv-nova.yaml index 512448fd4..0e65ac15f 100644 --- a/functest/opnfv_tests/openstack/rally/scenario/full/opnfv-nova.yaml +++ b/functest/opnfv_tests/openstack/rally/scenario/full/opnfv-nova.yaml @@ -381,6 +381,40 @@ sla: {{ no_failures_sla() }} + NovaServers.boot_server_associate_and_dissociate_floating_ip: + - + args: + {{ vm_params(image_name, flavor_name) }} + create_floating_ip_args: + ext_network: {{ floating_network }} + nics: + - net-id: {{ netid }} + context: + {% call user_context(tenants_amount, users_amount, use_existing_users) %} + network: {} + {% endcall %} + runner: + {{ constant_runner(concurrency=concurrency, times=iterations, is_smoke=smoke) }} + sla: + {{ no_failures_sla() }} + + NovaServers.boot_and_associate_floating_ip: + - + args: + {{ vm_params(image_name, flavor_name) }} + create_floating_ip_args: + ext_network: {{ floating_network }} + nics: + - net-id: {{ netid }} + context: + {% call user_context(tenants_amount, users_amount, use_existing_users) %} + network: {} + {% endcall %} + runner: + {{ constant_runner(concurrency=concurrency, times=iterations, is_smoke=smoke) }} + sla: + {{ no_failures_sla() }} + NovaServerGroups.create_and_delete_server_group: - args: diff --git a/functest/opnfv_tests/openstack/rally/scenario/sanity/opnfv-nova.yaml b/functest/opnfv_tests/openstack/rally/scenario/sanity/opnfv-nova.yaml index 801938c4e..7dd252da5 100644 --- a/functest/opnfv_tests/openstack/rally/scenario/sanity/opnfv-nova.yaml +++ b/functest/opnfv_tests/openstack/rally/scenario/sanity/opnfv-nova.yaml @@ -132,6 +132,23 @@ sla: {{ no_failures_sla() }} + NovaServers.boot_server_associate_and_dissociate_floating_ip: + - + args: + {{ vm_params(image_name, flavor_name) }} + create_floating_ip_args: + ext_network: {{ floating_network }} + nics: + - net-id: {{ netid }} + context: + {% call user_context(tenants_amount, users_amount, use_existing_users) %} + network: {} + {% endcall %} + runner: + {{ constant_runner(concurrency=concurrency, times=iterations, is_smoke=smoke) }} + sla: + {{ no_failures_sla() }} + NovaServerGroups.create_and_delete_server_group: - args: diff --git a/functest/opnfv_tests/openstack/refstack/refstack.py b/functest/opnfv_tests/openstack/refstack/refstack.py index 22e09bc82..c709e5626 100644 --- a/functest/opnfv_tests/openstack/refstack/refstack.py +++ b/functest/opnfv_tests/openstack/refstack/refstack.py @@ -40,15 +40,18 @@ class Refstack(tempest.TempestCommon): return yaml.load(yaml_data) def _extract_tempest_data(self): + olddir = os.getcwd() try: - cmd = ['stestr', '--here', self.verifier_repo_dir, 'list', - '^tempest.'] + os.chdir(self.verifier_repo_dir) + cmd = ['stestr', 'list', '^tempest.'] output = subprocess.check_output(cmd) except subprocess.CalledProcessError as cpe: self.__logger.error( "Exception when listing tempest tests: %s\n%s", cpe.cmd, cpe.output) raise + finally: + os.chdir(olddir) yaml_data2 = "" for line in output.splitlines(): try: diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index 80f78e979..fc36a72ed 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -81,6 +81,7 @@ def create_rally_deployment(environ=None): cmd = ['rally', 'deployment', 'check'] output = subprocess.check_output(cmd) LOGGER.info("%s\n%s", " ".join(cmd), output) + return get_verifier_deployment_id() def create_verifier(): @@ -101,6 +102,7 @@ def create_verifier(): '--type', 'tempest', '--system-wide'] output = subprocess.check_output(cmd) LOGGER.info("%s\n%s", " ".join(cmd), output) + return get_verifier_id() def get_verifier_id(): @@ -114,9 +116,6 @@ def get_verifier_id(): stdout=subprocess.PIPE, stderr=subprocess.STDOUT) verifier_uuid = proc.stdout.readline().rstrip() - if verifier_uuid == "": - LOGGER.error("Tempest verifier not found.") - raise Exception('Error with command:%s' % cmd) return verifier_uuid @@ -131,9 +130,6 @@ def get_verifier_deployment_id(): stdout=subprocess.PIPE, stderr=subprocess.STDOUT) deployment_uuid = proc.stdout.readline().rstrip() - if deployment_uuid == "": - LOGGER.error("Rally deployment not found.") - raise Exception('Error with command:%s' % cmd) return deployment_uuid @@ -175,17 +171,17 @@ def update_tempest_conf_file(conf_file, rconfig): def configure_tempest_update_params( - tempest_conf_file, network_name=None, image_id=None, flavor_id=None, + tempest_conf_file, image_id=None, flavor_id=None, compute_cnt=1, image_alt_id=None, flavor_alt_id=None, - domain_name="Default"): - # pylint: disable=too-many-branches, too-many-arguments + admin_role_name='admin', cidr='192.168.120.0/24', + domain_id='default'): + # pylint: disable=too-many-branches,too-many-arguments,too-many-statements """ Add/update needed parameters into tempest.conf file """ LOGGER.debug("Updating selected tempest.conf parameters...") rconfig = configparser.RawConfigParser() rconfig.read(tempest_conf_file) - rconfig.set('compute', 'fixed_network_name', network_name) rconfig.set('compute', 'volume_device_name', env.get('VOLUME_DEVICE_NAME')) if image_id is not None: rconfig.set('compute', 'image_ref', image_id) @@ -200,16 +196,14 @@ def configure_tempest_update_params( rconfig.set('compute', 'min_compute_nodes', compute_cnt) rconfig.set('compute-feature-enabled', 'live_migration', True) rconfig.set('compute-feature-enabled', 'shelve', False) + filters = ['RetryFilter', 'AvailabilityZoneFilter', 'ComputeFilter', + 'ComputeCapabilitiesFilter', 'ImagePropertiesFilter', + 'ServerGroupAntiAffinityFilter', 'ServerGroupAffinityFilter'] + rconfig.set( + 'compute-feature-enabled', 'scheduler_available_filters', + convert_list_to_ini(filters)) if os.environ.get('OS_REGION_NAME'): rconfig.set('identity', 'region', os.environ.get('OS_REGION_NAME')) - identity_api_version = os.environ.get("OS_IDENTITY_API_VERSION", '3') - rconfig.set('auth', 'admin_domain_scope', True) - rconfig.set('auth', 'default_credentials_domain_name', domain_name) - if identity_api_version == '3': - auth_version = 'v3' - rconfig.set('identity-feature-enabled', 'api_v2', False) - else: - auth_version = 'v2' if env.get("NEW_USER_ROLE").lower() != "member": rconfig.set( 'auth', 'tempest_roles', @@ -221,13 +215,25 @@ def configure_tempest_update_params( assert os.path.exists( account_file), "{} doesn't exist".format(account_file) rconfig.set('auth', 'test_accounts_file', account_file) - rconfig.set('identity', 'auth_version', auth_version) + rconfig.set('identity', 'auth_version', 'v3') + rconfig.set('identity', 'admin_role', admin_role_name) + rconfig.set('identity', 'admin_domain_scope', True) + rconfig.set('identity', 'default_domain_id', domain_id) + rconfig.set('identity-feature-enabled', 'api_v2', False) + rconfig.set('identity-feature-enabled', 'api_v2_admin', False) + if not rconfig.has_section('network'): + rconfig.add_section('network') + rconfig.set('network', 'default_network', cidr) + rconfig.set('network', 'project_network_cidr', cidr) + rconfig.set('network', 'project_networks_reachable', False) rconfig.set( 'validation', 'ssh_timeout', getattr(config.CONF, 'tempest_validation_ssh_timeout')) rconfig.set('object-storage', 'operator_role', getattr(config.CONF, 'tempest_object_storage_operator_role')) - + if not rconfig.has_section('volume'): + rconfig.add_section('volume') + rconfig.set('volume', 'storage_protocol', env.get('STORAGE_PROTOCOL')) rconfig.set( 'identity', 'v3_endpoint_type', os.environ.get('OS_INTERFACE', 'public')) @@ -261,16 +267,14 @@ def configure_verifier(deployment_dir): if not os.path.isfile(tempest_conf_file): LOGGER.error("Tempest configuration file %s NOT found.", tempest_conf_file) - raise Exception("Tempest configuration file %s NOT found." - % tempest_conf_file) - else: - return tempest_conf_file + return None + return tempest_conf_file def convert_dict_to_ini(value): "Convert dict to oslo.conf input" assert isinstance(value, dict) - return ",".join("{}={}".format( + return ",".join("{}:{}".format( key, val) for (key, val) in six.iteritems(value)) diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index ddd0d640d..4c5308bdf 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -36,7 +36,6 @@ class TempestCommon(singlevm.VmReady2): """TempestCommon testcases implementation class.""" visibility = 'public' - shared_network = True filename_alt = '/home/opnfv/functest/images/cirros-0.4.0-x86_64-disk.img' def __init__(self, **kwargs): @@ -47,27 +46,38 @@ class TempestCommon(singlevm.VmReady2): assert self.cloud assert self.project if self.orig_cloud.get_role("admin"): - role_name = "admin" + self.role_name = "admin" elif self.orig_cloud.get_role("Admin"): - role_name = "Admin" + self.role_name = "Admin" else: raise Exception("Cannot detect neither admin nor Admin") self.orig_cloud.grant_role( - role_name, user=self.project.user.id, + self.role_name, user=self.project.user.id, project=self.project.project.id, domain=self.project.domain.id) + self.orig_cloud.grant_role( + self.role_name, user=self.project.user.id, + domain=self.project.domain.id) environ = dict( os.environ, OS_USERNAME=self.project.user.name, OS_PROJECT_NAME=self.project.project.name, OS_PROJECT_ID=self.project.project.id, OS_PASSWORD=self.project.password) - conf_utils.create_rally_deployment(environ=environ) - conf_utils.create_verifier() - self.verifier_id = conf_utils.get_verifier_id() + try: + del environ['OS_TENANT_NAME'] + del environ['OS_TENANT_ID'] + except Exception: # pylint: disable=broad-except + pass + self.deployment_id = conf_utils.create_rally_deployment( + environ=environ) + if not self.deployment_id: + raise Exception("Deployment create failed") + self.verifier_id = conf_utils.create_verifier() + if not self.verifier_id: + raise Exception("Verifier create failed") self.verifier_repo_dir = conf_utils.get_verifier_repo_dir( self.verifier_id) - self.deployment_id = conf_utils.get_verifier_deployment_id() self.deployment_dir = conf_utils.get_verifier_deployment_dir( self.verifier_id, self.deployment_id) self.verification_id = None @@ -90,6 +100,9 @@ class TempestCommon(singlevm.VmReady2): except Exception: # pylint: disable=broad-except pass + def create_network_resources(self): + pass + def check_services(self): """Check the mandatory services.""" for service in self.services: @@ -112,6 +125,8 @@ class TempestCommon(singlevm.VmReady2): def check_requirements(self): self.check_services() self.check_extensions() + if self.is_skipped: + self.project.clean() @staticmethod def read_file(filename): @@ -394,14 +409,17 @@ class TempestCommon(singlevm.VmReady2): LOGGER.debug("flavor: %s", self.flavor_alt) self.conf_file = conf_utils.configure_verifier(self.deployment_dir) + if not self.conf_file: + raise Exception("Tempest verifier configuring failed") conf_utils.configure_tempest_update_params( - self.conf_file, network_name=self.network.name, + self.conf_file, image_id=self.image.id, flavor_id=self.flavor.id, compute_cnt=compute_cnt, image_alt_id=self.image_alt.id, flavor_alt_id=self.flavor_alt.id, - domain_name=self.cloud.auth.get("project_domain_name", "Default")) + admin_role_name=self.role_name, cidr=self.cidr, + domain_id=self.project.domain.id) self.update_scenario_section() self.backup_tempest_config(self.conf_file, self.res_dir) diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py index fb3c587ca..644911bd7 100644 --- a/functest/opnfv_tests/vnf/epc/juju_epc.py +++ b/functest/opnfv_tests/vnf/epc/juju_epc.py @@ -230,7 +230,7 @@ class JujuEpc(singlevm.VmReady2): self.cloud.region_name if self.cloud.region_name else ( 'RegionOne')), 'abot-controller', - '--agent-version', '2.2.9', + '--agent-version', '2.3.9', '--metadata-source', '/root', '--constraints', 'mem=2G', '--bootstrap-series', 'xenial', diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index f7931b7b7..08699e4bb 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -169,8 +169,18 @@ class CloudifyIms(cloudify.Cloudify): """Deploy Clearwater IMS.""" start_time = time.time() + secgroups = self.cloud.list_security_groups( + filters={'name': 'default', + 'project_id': self.project.project.id}) + if secgroups: + secgroup = secgroups[0] + else: + self.__logger.error("No 'default' security group in project %s", + self.project.project.name) + return False + self.cloud.create_security_group_rule( - 'default', port_range_min=22, port_range_max=22, + secgroup.id, port_range_min=22, port_range_max=22, protocol='tcp', direction='ingress') self.__logger.info("Upload VNFD") diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py index f9266ff17..e8c8632bd 100644 --- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py +++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py @@ -167,11 +167,6 @@ class CloudifyVrouter(cloudify.Cloudify): def deploy_vnf(self): start_time = time.time() - - self.cloud.create_security_group_rule( - 'default', port_range_min=22, port_range_max=22, - protocol='tcp', direction='ingress') - self.__logger.info("Upload VNFD") descriptor = self.vnf['descriptor'] self.util_info["cfy"] = self.cfy_client diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.yaml b/functest/opnfv_tests/vnf/router/cloudify_vrouter.yaml index 649cd6ccd..2d98dffa5 100644 --- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.yaml +++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.yaml @@ -3,9 +3,6 @@ tenant_images: cloudify_manager_4.0: /home/opnfv/functest/images/cloudify-manager-premium-4.0.1.qcow2 vyos1.1.7: /home/opnfv/functest/images/vyos-1.1.7.img -test_data: - url: 'https://github.com/oolorg/opnfv-vnf-data.git' - branch: 'fraser' orchestrator: name: cloudify version: '4.0' diff --git a/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py b/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py index 9d484cb56..0b8a69b73 100644 --- a/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py +++ b/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py @@ -12,6 +12,7 @@ """vrouter function test execution module""" import logging +import os import time import yaml @@ -31,11 +32,11 @@ class FunctionTestExec(object): credentials = util_info["credentials"] self.vnf_ctrl = VnfController(util_info) - test_cmd_map_file = open(self.util.vnf_data_dir + - self.util.opnfv_vnf_data_dir + - self.util.command_template_dir + - self.util.test_cmd_map_yaml_file, - 'r') + test_cmd_map_file = open( + os.path.join( + self.util.vnf_data_dir, self.util.command_template_dir, + self.util.test_cmd_map_yaml_file), + 'r') self.test_cmd_map_yaml = yaml.safe_load(test_cmd_map_file) test_cmd_map_file.close() diff --git a/functest/opnfv_tests/vnf/router/utilvnf.py b/functest/opnfv_tests/vnf/router/utilvnf.py index 4bb277a8d..a54f6cb0b 100644 --- a/functest/opnfv_tests/vnf/router/utilvnf.py +++ b/functest/opnfv_tests/vnf/router/utilvnf.py @@ -14,12 +14,9 @@ import json import logging import os -import pkg_resources import requests import yaml -from git import Repo - from functest.utils import config RESULT_SPRIT_INDEX = { @@ -53,14 +50,12 @@ class Utilvnf(object): # pylint: disable=too-many-instance-attributes def __init__(self): self.vnf_data_dir = getattr(config.CONF, 'dir_router_data') - self.opnfv_vnf_data_dir = "opnfv-vnf-data/" self.command_template_dir = "command_template/" self.test_scenario_yaml = "test_scenario.yaml" test_env_config_yaml_file = "test_env_config.yaml" self.test_cmd_map_yaml_file = "test_cmd_map.yaml" self.test_env_config_yaml = os.path.join( self.vnf_data_dir, - self.opnfv_vnf_data_dir, test_env_config_yaml_file) self.blueprint_dir = "opnfv-vnf-vyos-blueprint/" @@ -69,28 +64,6 @@ class Utilvnf(object): # pylint: disable=too-many-instance-attributes if not os.path.exists(self.vnf_data_dir): os.makedirs(self.vnf_data_dir) - case_dir = pkg_resources.resource_filename( - 'functest', 'opnfv_tests/vnf/router') - - config_file_name = getattr( - config.CONF, 'vnf_{}_config'.format("vyos_vrouter")) - - config_file = os.path.join(case_dir, config_file_name) - - with open(config_file) as file_fd: - vrouter_config_yaml = yaml.safe_load(file_fd) - file_fd.close() - - test_data = vrouter_config_yaml.get("test_data") - - self.logger.debug("Downloading the test data.") - vrouter_data_path = self.vnf_data_dir + self.opnfv_vnf_data_dir - - if not os.path.exists(vrouter_data_path): - Repo.clone_from(test_data['url'], - vrouter_data_path, - branch=test_data['branch']) - with open(self.test_env_config_yaml) as file_fd: test_env_config_yaml = yaml.safe_load(file_fd) file_fd.close() diff --git a/functest/opnfv_tests/vnf/router/vrouter_base.py b/functest/opnfv_tests/vnf/router/vrouter_base.py index fe3058f01..e8a933ff5 100644 --- a/functest/opnfv_tests/vnf/router/vrouter_base.py +++ b/functest/opnfv_tests/vnf/router/vrouter_base.py @@ -32,15 +32,12 @@ class VrouterOnBoardingBase(object): self.logger = logging.getLogger(__name__) self.case_dir = pkg_resources.resource_filename( 'functest', 'opnfv_tests/vnf/router') - self.data_dir = getattr(config.CONF, 'dir_router_data') self.result_dir = os.path.join( getattr(config.CONF, 'dir_results'), case_name) self.util = util self.util_info = util_info self.vnf_list = [] - if not os.path.exists(self.data_dir): - os.makedirs(self.data_dir) if not os.path.exists(self.result_dir): os.makedirs(self.result_dir) diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py index d89ebd634..22ddb1cc5 100644 --- a/functest/tests/unit/openstack/rally/test_rally.py +++ b/functest/tests/unit/openstack/rally/test_rally.py @@ -71,7 +71,7 @@ class OSRallyTesting(unittest.TestCase): @mock.patch('functest.opnfv_tests.openstack.rally.rally.os.path.exists') @mock.patch('functest.opnfv_tests.openstack.rally.rally.os.makedirs') @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' - '_apply_blacklist') + 'apply_blacklist') def test_prepare_test_list_missing_temp_dir( self, mock_method, mock_os_makedirs, mock_path_exists): mock_path_exists.side_effect = self.check_temp_dir @@ -153,10 +153,13 @@ class OSRallyTesting(unittest.TestCase): {'functions': ['no_migration'], 'tests': ['test']}]}) @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' '_migration_supported', return_value=False) - def test_excl_func_default(self, mock_func, mock_yaml_load): + @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' + '_network_trunk_supported', return_value=False) + def test_excl_func_default(self, mock_trunk, mock_func, mock_yaml_load): os.environ['DEPLOY_SCENARIO'] = 'test_scenario' self.assertEqual(self.rally_base.excl_func(), ['test']) mock_func.assert_called() + mock_trunk.assert_called() mock_yaml_load.assert_called() @mock.patch('six.moves.builtins.open', side_effect=Exception) @@ -263,8 +266,7 @@ class OSRallyTesting(unittest.TestCase): with self.assertRaises(Exception): self.rally_base.prepare_run() - @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' - 'get_external_network') + @mock.patch('functest.opnfv_tests.openstack.rally.rally.os.path.exists') def test_prepare_run_flavor_alt_creation_failed(self, *args): # pylint: disable=unused-argument self.rally_base.TESTS = ['test1', 'test2'] diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py index 7c493372f..316f21be2 100644 --- a/functest/tests/unit/openstack/tempest/test_conf_utils.py +++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py @@ -20,9 +20,12 @@ from functest.utils import config class OSTempestConfUtilsTesting(unittest.TestCase): # pylint: disable=too-many-public-methods + @mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils' + '.get_verifier_deployment_id', return_value='foo') @mock.patch('subprocess.check_output') - def test_create_rally_deployment(self, mock_exec): - self.assertEqual(conf_utils.create_rally_deployment(), None) + def test_create_rally_deployment(self, mock_exec, mock_get_id): + # pylint: disable=unused-argument + self.assertEqual(conf_utils.create_rally_deployment(), 'foo') calls = [ mock.call(['rally', 'deployment', 'destroy', '--deployment', str(getattr(config.CONF, 'rally_deployment_name'))]), @@ -51,22 +54,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase): 'create_verifier', return_value=mock.Mock()) @mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' 'create_rally_deployment', return_value=mock.Mock()) - def test_get_verif_id_missing_verif(self, mock_rally, mock_tempest): - # pylint: disable=unused-argument - setattr(config.CONF, 'tempest_verifier_name', 'test_verifier_name') - with mock.patch('functest.opnfv_tests.openstack.tempest.' - 'conf_utils.subprocess.Popen') as mock_popen, \ - self.assertRaises(Exception): - mock_stdout = mock.Mock() - attrs = {'stdout.readline.return_value': ''} - mock_stdout.configure_mock(**attrs) - mock_popen.return_value = mock_stdout - conf_utils.get_verifier_id() - - @mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' - 'create_verifier', return_value=mock.Mock()) - @mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' - 'create_rally_deployment', return_value=mock.Mock()) def test_get_verifier_id_default(self, mock_rally, mock_tempest): # pylint: disable=unused-argument setattr(config.CONF, 'tempest_verifier_name', 'test_verifier_name') @@ -80,17 +67,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase): self.assertEqual(conf_utils.get_verifier_id(), 'test_deploy_id') - def test_get_depl_id_missing_rally(self): - setattr(config.CONF, 'tempest_verifier_name', 'test_deploy_name') - with mock.patch('functest.opnfv_tests.openstack.tempest.' - 'conf_utils.subprocess.Popen') as mock_popen, \ - self.assertRaises(Exception): - mock_stdout = mock.Mock() - attrs = {'stdout.readline.return_value': ''} - mock_stdout.configure_mock(**attrs) - mock_popen.return_value = mock_stdout - conf_utils.get_verifier_deployment_id() - def test_get_depl_id_default(self): setattr(config.CONF, 'tempest_verifier_name', 'test_deploy_name') with mock.patch('functest.opnfv_tests.openstack.tempest.' @@ -186,9 +162,9 @@ class OSTempestConfUtilsTesting(unittest.TestCase): self.assertEqual( conf_utils.convert_dict_to_ini({}), "") self.assertEqual( - conf_utils.convert_dict_to_ini({"a": "b"}), "a=b") + conf_utils.convert_dict_to_ini({"a": "b"}), "a:b") value = conf_utils.convert_dict_to_ini({"a": "b", "c": "d"}) - self.assertTrue(value == "a=b,c=d" or value == "c=d,a=b") + self.assertTrue(value == "a:b,c:d" or value == "c:d,a:b") with self.assertRaises(AssertionError): conf_utils.convert_list_to_ini("") diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py index 2b98267c4..ab90de595 100644 --- a/functest/tests/unit/utils/test_functest_utils.py +++ b/functest/tests/unit/utils/test_functest_utils.py @@ -261,7 +261,7 @@ class FunctestUtilsTesting(unittest.TestCase): def test_openstack_version1(self, *args): cloud = mock.Mock() self.assertEqual(functest_utils.get_openstack_version( - cloud), "Rocky or newer") + cloud), "Rocky") args[0].assert_called_once_with(cloud) @mock.patch('functest.utils.functest_utils.get_nova_version', @@ -327,7 +327,7 @@ class FunctestUtilsTesting(unittest.TestCase): def test_openstack_version10(self, *args): cloud = mock.Mock() self.assertEqual( - functest_utils.get_openstack_version(cloud), "Rocky or newer") + functest_utils.get_openstack_version(cloud), "Master") args[0].assert_called_once_with(cloud) @mock.patch('functest.utils.functest_utils.get_nova_version', diff --git a/functest/utils/env.py b/functest/utils/env.py index 87940ce11..26efbb196 100644 --- a/functest/utils/env.py +++ b/functest/utils/env.py @@ -35,7 +35,8 @@ INPUTS = { 'IMG_PROP': '', 'NAMESERVER': '8.8.8.8', 'NEW_USER_ROLE': 'Member', - 'USE_DYNAMIC_CREDENTIALS': 'True' + 'USE_DYNAMIC_CREDENTIALS': 'True', + 'STORAGE_PROTOCOL': 'iSCSI' } diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py index 1993f1e83..dd2bf1932 100644 --- a/functest/utils/functest_utils.py +++ b/functest/utils/functest_utils.py @@ -109,8 +109,10 @@ def get_openstack_version(cloud): version = get_nova_version(cloud) try: assert version - if version > (2, 60): - osversion = "Rocky or newer" + if version > (2, 65): + osversion = "Master" + elif version > (2, 60): + osversion = "Rocky" elif version > (2, 53): osversion = "Queens" elif version > (2, 42): |