from functest.core import testcase
from functest.opnfv_tests.openstack.snaps import snaps_utils
from functest.opnfv_tests.openstack.tempest import conf_utils
-from functest.utils.constants import CONST
+from functest.utils import config
from functest.utils import env
import functest.utils.functest_utils as ft_utils
% conf_utils.TEMPEST_CUSTOM)
else:
if self.mode == 'smoke':
- testr_mode = "smoke"
+ testr_mode = r"'tempest\.(api|scenario).*\[.*\bsmoke\b.*\]'"
elif self.mode == 'full':
- testr_mode = ""
+ testr_mode = r"'^tempest\.'"
else:
- testr_mode = 'tempest.api.' + self.mode
+ testr_mode = self.mode
cmd = ("cd {0};"
"testr list-tests {1} > {2};"
"cd -;".format(verifier_repo_dir,
f_stdout.close()
f_stderr.close()
- def parse_verifier_result(self):
- """Parse and save test results."""
if self.verification_id is None:
raise Exception('Verification UUID not found')
+ def parse_verifier_result(self):
+ """Parse and save test results."""
stat = self.get_verifier_result(self.verification_id)
try:
num_executed = stat['num_tests'] - stat['num_skipped']
LOGGER.info("Tempest %s success_rate is %s%%",
self.case_name, self.result)
+ def generate_report(self):
+ """Generate verification report."""
+ html_file = os.path.join(conf_utils.TEMPEST_RESULTS_DIR,
+ "tempest-report.html")
+ cmd = ["rally", "verify", "report", "--type", "html", "--uuid",
+ self.verification_id, "--to", html_file]
+ subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+
def run(self, **kwargs):
self.start_time = time.time()
self.apply_tempest_blacklist()
self.run_verifier_tests()
self.parse_verifier_result()
+ self.generate_report()
res = testcase.TestCase.EX_OK
except Exception as err: # pylint: disable=broad-except
LOGGER.error('Error with run: %s', err)
self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
self.guid = '-' + str(uuid.uuid4())
self.creators = list()
-
- if hasattr(CONST, 'snaps_images_cirros'):
- self.cirros_image_config = CONST.__getattribute__(
- 'snaps_images_cirros')
- else:
- self.cirros_image_config = None
+ self.cirros_image_config = getattr(
+ config.CONF, 'snaps_images_cirros', None)
def _create_project(self):
"""Create project for tests."""
project_creator = deploy_utils.create_project(
self.os_creds, ProjectConfig(
- name=CONST.__getattribute__(
- 'tempest_identity_tenant_name') + self.guid,
- description=CONST.__getattribute__(
- 'tempest_identity_tenant_description')))
+ name=getattr(
+ config.CONF, 'tempest_identity_tenant_name') + self.guid,
+ description=getattr(
+ config.CONF, 'tempest_identity_tenant_description')))
if project_creator is None or project_creator.get_project() is None:
raise Exception("Failed to create tenant")
self.creators.append(project_creator)
"""Create user for tests."""
user_creator = deploy_utils.create_user(
self.os_creds, UserConfig(
- name=CONST.__getattribute__(
- 'tempest_identity_user_name') + self.guid,
- password=CONST.__getattribute__(
- 'tempest_identity_user_password'),
- project_name=CONST.__getattribute__(
- 'tempest_identity_tenant_name') + self.guid))
+ name=getattr(
+ config.CONF, 'tempest_identity_user_name') + self.guid,
+ password=getattr(
+ config.CONF, 'tempest_identity_user_password'),
+ project_name=getattr(
+ config.CONF, 'tempest_identity_tenant_name') + self.guid))
if user_creator is None or user_creator.get_user() is None:
raise Exception("Failed to create user")
self.creators.append(user_creator)
tempest_physical_network = None
tempest_segmentation_id = None
- if hasattr(CONST, 'tempest_network_type'):
- tempest_network_type = CONST.__getattribute__(
- 'tempest_network_type')
- if hasattr(CONST, 'tempest_physical_network'):
- tempest_physical_network = CONST.__getattribute__(
- 'tempest_physical_network')
- if hasattr(CONST, 'tempest_segmentation_id'):
- tempest_segmentation_id = CONST.__getattribute__(
- 'tempest_segmentation_id')
-
- tempest_net_name = CONST.__getattribute__(
- 'tempest_private_net_name') + self.guid
+ tempest_network_type = getattr(
+ config.CONF, 'tempest_network_type', None)
+ tempest_physical_network = getattr(
+ config.CONF, 'tempest_physical_network', None)
+ tempest_segmentation_id = getattr(
+ config.CONF, 'tempest_segmentation_id', None)
+ tempest_net_name = getattr(
+ config.CONF, 'tempest_private_net_name') + self.guid
network_creator = deploy_utils.create_network(
self.os_creds, NetworkConfig(
physical_network=tempest_physical_network,
segmentation_id=tempest_segmentation_id,
subnet_settings=[SubnetConfig(
- name=CONST.__getattribute__(
+ name=getattr(
+ config.CONF,
'tempest_private_subnet_name') + self.guid,
project_name=project_name,
- cidr=CONST.__getattribute__(
- 'tempest_private_subnet_cidr'))]))
+ cidr=getattr(
+ config.CONF, 'tempest_private_subnet_cidr'))]))
if network_creator is None or network_creator.get_network() is None:
raise Exception("Failed to create private network")
self.creators.append(network_creator)
flavor_creator = OpenStackFlavor(
self.os_creds, FlavorConfig(
name=name,
- ram=CONST.__getattribute__('openstack_flavor_ram'),
- disk=CONST.__getattribute__('openstack_flavor_disk'),
- vcpus=CONST.__getattribute__('openstack_flavor_vcpus'),
+ ram=getattr(config.CONF, 'openstack_flavor_ram'),
+ disk=getattr(config.CONF, 'openstack_flavor_disk'),
+ vcpus=getattr(config.CONF, 'openstack_flavor_vcpus'),
metadata=flavor_metadata))
flavor = flavor_creator.create()
if flavor is None:
if create_project:
LOGGER.debug("Creating project and user for Tempest suite")
- project_name = CONST.__getattribute__(
- 'tempest_identity_tenant_name') + self.guid
+ project_name = getattr(
+ config.CONF, 'tempest_identity_tenant_name') + self.guid
result['project_id'] = self._create_project()
result['user_id'] = self._create_user()
result['tenant_id'] = result['project_id'] # for compatibility
result['tempest_net_name'] = self._create_network(project_name)
LOGGER.debug("Creating image for Tempest suite")
- image_name = CONST.__getattribute__('openstack_image_name') + self.guid
+ image_name = getattr(config.CONF, 'openstack_image_name') + self.guid
result['image_id'] = self._create_image(image_name)
if use_custom_images:
LOGGER.debug("Creating 2nd image for Tempest suite")
- image_name = CONST.__getattribute__(
- 'openstack_image_name_alt') + self.guid
+ image_name = getattr(
+ config.CONF, 'openstack_image_name_alt') + self.guid
result['image_id_alt'] = self._create_image(image_name)
- if (CONST.__getattribute__('tempest_use_custom_flavors') == 'True' or
+ if (getattr(config.CONF, 'tempest_use_custom_flavors') == 'True' or
use_custom_flavors):
LOGGER.info("Creating flavor for Tempest suite")
- name = CONST.__getattribute__('openstack_flavor_name') + self.guid
+ name = getattr(config.CONF, 'openstack_flavor_name') + self.guid
result['flavor_id'] = self._create_flavor(name)
if use_custom_flavors:
LOGGER.info("Creating 2nd flavor for Tempest suite")
scenario = env.get('DEPLOY_SCENARIO')
if 'ovs' in scenario or 'fdio' in scenario:
- CONST.__setattr__('openstack_flavor_ram', 1024)
- name = CONST.__getattribute__(
- 'openstack_flavor_name_alt') + self.guid
+ setattr(config.CONF, 'openstack_flavor_ram', 1024)
+ name = getattr(
+ config.CONF, 'openstack_flavor_name_alt') + self.guid
result['flavor_id_alt'] = self._create_flavor(name)
return result