-
-class TempestSmokeSerial(TempestCommon):
- """Tempest smoke serial testcase implementation."""
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = 'tempest_smoke_serial'
- TempestCommon.__init__(self, **kwargs)
- self.mode = "smoke"
- self.option = ["--concurrency", "1"]
-
-
-class TempestNeutronTrunk(TempestCommon):
- """Tempest neutron trunk testcase implementation."""
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = 'neutron_trunk'
- TempestCommon.__init__(self, **kwargs)
- self.mode = "'neutron_tempest_plugin.(api|scenario).test_trunk'"
- self.res_dir = os.path.join(
- getattr(config.CONF, 'dir_results'), 'neutron_trunk')
- self.raw_list = os.path.join(self.res_dir, 'test_raw_list.txt')
- self.list = os.path.join(self.res_dir, 'test_list.txt')
-
- def configure(self, **kwargs):
- super(TempestNeutronTrunk, self).configure(**kwargs)
- rconfig = configparser.RawConfigParser()
- rconfig.read(self.conf_file)
- rconfig.set('network-feature-enabled', 'api_extensions', 'all')
- with open(self.conf_file, 'wb') as config_file:
- rconfig.write(config_file)
-
-
-class TempestBarbican(TempestCommon):
- """Tempest Barbican testcase implementation."""
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = 'barbican'
- TempestCommon.__init__(self, **kwargs)
- self.mode = "'barbican_tempest_plugin.tests.(api|scenario)'"
- self.res_dir = os.path.join(
- getattr(config.CONF, 'dir_results'), 'barbican')
- self.raw_list = os.path.join(self.res_dir, 'test_raw_list.txt')
- self.list = os.path.join(self.res_dir, 'test_list.txt')
-
- def generate_test_list(self):
- self.backup_tempest_config(self.conf_file, '/etc')
- super(TempestBarbican, self).generate_test_list()
- os.remove('/etc/tempest.conf')
-
-
-class TempestSmokeParallel(TempestCommon):
- """Tempest smoke parallel testcase implementation."""
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = 'tempest_smoke_parallel'
- TempestCommon.__init__(self, **kwargs)
- self.mode = "smoke"
-
-
-class TempestFullParallel(TempestCommon):
- """Tempest full parallel testcase implementation."""
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = 'tempest_full_parallel'
- TempestCommon.__init__(self, **kwargs)
- self.mode = "full"
-
-
-class TempestCustom(TempestCommon):
- """Tempest custom testcase implementation."""
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = 'tempest_custom'
- TempestCommon.__init__(self, **kwargs)
- self.mode = "custom"
- self.option = ["--concurrency", "1"]
-
-
-class TempestDefcore(TempestCommon):
- """Tempest Defcore testcase implementation."""
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = 'tempest_defcore'
- TempestCommon.__init__(self, **kwargs)
- self.mode = "defcore"
- self.option = ["--concurrency", "1"]
-
-
-class TempestResourcesManager(object):
- # pylint: disable=too-many-instance-attributes
- """Tempest resource manager."""
- def __init__(self):
- self.guid = '-' + str(uuid.uuid4())
- self.cloud = os_client_config.make_shade()
- LOGGER.debug("cloud: %s", self.cloud)
- self.domain = self.cloud.get_domain(
- name_or_id=self.cloud.auth.get(
- "project_domain_name", "Default"))
- LOGGER.debug("domain: %s", self.domain)
- self.project = None
- self.user = None
- self.network = None
- self.subnet = None
- self.image = None
- self.image_alt = None
- self.flavor = None
- self.flavor_alt = None
-
- def _create_project(self):
- """Create project for tests."""
- self.project = self.cloud.create_project(
- getattr(config.CONF, 'tempest_identity_tenant_name') + self.guid,
- description=getattr(
- config.CONF, 'tempest_identity_tenant_description'),
- domain_id=self.domain.id)
- LOGGER.debug("project: %s", self.project)
-
- def _create_user(self):
- """Create user for tests."""
- self.user = self.cloud.create_user(
- name=getattr(
- config.CONF, 'tempest_identity_user_name') + self.guid,
- password=getattr(config.CONF, 'tempest_identity_user_password'),
- default_project=getattr(
- config.CONF, 'tempest_identity_tenant_name') + self.guid,
- domain_id=self.domain.id)
- LOGGER.debug("user: %s", self.user)
-
- def _create_network(self):
- """Create network for tests."""
- tempest_net_name = getattr(
- config.CONF, 'tempest_private_net_name') + self.guid
- provider = {}
- if hasattr(config.CONF, 'tempest_network_type'):
- provider["network_type"] = getattr(
- config.CONF, 'tempest_network_type')
- if hasattr(config.CONF, 'tempest_physical_network'):
- provider["physical_network"] = getattr(
- config.CONF, 'tempest_physical_network')
- if hasattr(config.CONF, 'tempest_segmentation_id'):
- provider["segmentation_id"] = getattr(
- config.CONF, 'tempest_segmentation_id')
- LOGGER.info(
- "Creating network with name: '%s'", tempest_net_name)
- self.network = self.cloud.create_network(
- tempest_net_name, provider=provider)
- LOGGER.debug("network: %s", self.network)
-
- self.subnet = self.cloud.create_subnet(
- self.network.id,
- subnet_name=getattr(
- config.CONF, 'tempest_private_subnet_name') + self.guid,
- cidr=getattr(config.CONF, 'tempest_private_subnet_cidr'),
- enable_dhcp=True,
- dns_nameservers=[env.get('NAMESERVER')])
- LOGGER.debug("subnet: %s", self.subnet)
-
- def _create_image(self, name):
- """Create image for tests"""
- LOGGER.info("Creating image with name: '%s'", name)
- meta = getattr(config.CONF, 'openstack_extra_properties', None)
- image = self.cloud.create_image(
- name, filename=getattr(config.CONF, 'openstack_image_url'),
- is_public=True, meta=meta)
- LOGGER.debug("image: %s", image)
- return image
-
- def _create_flavor(self, name):
- """Create flavor for tests."""
- flavor = self.cloud.create_flavor(
- name, getattr(config.CONF, 'openstack_flavor_ram'),
- getattr(config.CONF, 'openstack_flavor_vcpus'),
- getattr(config.CONF, 'openstack_flavor_disk'))
- self.cloud.set_flavor_specs(
- flavor.id, getattr(config.CONF, 'flavor_extra_specs', {}))
- LOGGER.debug("flavor: %s", flavor)
- return flavor
-
- def create(self, create_project=False):
- """Create resources for Tempest test suite."""
- if create_project:
- self._create_project()
- self._create_user()
- self._create_network()
-
- LOGGER.debug("Creating two images for Tempest suite")
- self.image = self._create_image(
- getattr(config.CONF, 'openstack_image_name') + self.guid)
- self.image_alt = self._create_image(
- getattr(config.CONF, 'openstack_image_name_alt') + self.guid)
-
- LOGGER.info("Creating two flavors for Tempest suite")
- self.flavor = self._create_flavor(
- getattr(config.CONF, 'openstack_flavor_name') + self.guid)
- self.flavor_alt = self._create_flavor(
- getattr(config.CONF, 'openstack_flavor_name_alt') + self.guid)
-
- def cleanup(self):