Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
| 2 | # Copyright 2013 IBM Corp. |
| 3 | # All Rights Reserved. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. You may obtain |
| 7 | # a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations |
| 15 | # under the License. |
| 16 | |
| 17 | # NOTE(soliosg) Do not edit this file. It will only stay temporarily |
| 18 | # in ironic, while QA refactors the tempest.scenario interface. This |
| 19 | # file was copied from openstack/tempest/tempest/scenario/manager.py, |
| 20 | # openstack/tempest commit: 82a278e88c9e9f9ba49f81c1f8dba0bca7943daf |
| 21 | |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 22 | from oslo_log import log |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 23 | from tempest import config |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 24 | from tempest.lib import exceptions as lib_exc |
Roman Popelka | 082919c | 2022-03-17 11:44:31 +0100 | [diff] [blame] | 25 | from tempest.scenario import manager |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 26 | |
| 27 | CONF = config.CONF |
| 28 | |
| 29 | LOG = log.getLogger(__name__) |
| 30 | |
| 31 | |
Roman Popelka | 082919c | 2022-03-17 11:44:31 +0100 | [diff] [blame] | 32 | class ScenarioTest(manager.ScenarioTest): |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 33 | """Base class for scenario tests. Uses tempest own clients. """ |
| 34 | |
Julia Kreger | 3a07c4d | 2021-06-22 10:27:56 -0700 | [diff] [blame] | 35 | credentials = ['primary', 'admin', 'system_admin'] |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 36 | |
| 37 | @classmethod |
| 38 | def setup_clients(cls): |
| 39 | super(ScenarioTest, cls).setup_clients() |
| 40 | # Clients (in alphabetical order) |
Vu Cong Tuan | f825d19 | 2017-06-21 18:32:15 +0700 | [diff] [blame] | 41 | cls.flavors_client = cls.os_primary.flavors_client |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 42 | cls.compute_floating_ips_client = ( |
Vu Cong Tuan | f825d19 | 2017-06-21 18:32:15 +0700 | [diff] [blame] | 43 | cls.os_primary.compute_floating_ips_client) |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 44 | if CONF.service_available.glance: |
| 45 | # Check if glance v1 is available to determine which client to use. |
| 46 | if CONF.image_feature_enabled.api_v1: |
Vu Cong Tuan | f825d19 | 2017-06-21 18:32:15 +0700 | [diff] [blame] | 47 | cls.image_client = cls.os_primary.image_client |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 48 | elif CONF.image_feature_enabled.api_v2: |
Vu Cong Tuan | f825d19 | 2017-06-21 18:32:15 +0700 | [diff] [blame] | 49 | cls.image_client = cls.os_primary.image_client_v2 |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 50 | else: |
| 51 | raise lib_exc.InvalidConfiguration( |
| 52 | 'Either api_v1 or api_v2 must be True in ' |
| 53 | '[image-feature-enabled].') |
| 54 | # Compute image client |
Vu Cong Tuan | f825d19 | 2017-06-21 18:32:15 +0700 | [diff] [blame] | 55 | cls.compute_images_client = cls.os_primary.compute_images_client |
| 56 | cls.keypairs_client = cls.os_primary.keypairs_client |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 57 | # Nova security groups client |
| 58 | cls.compute_security_groups_client = ( |
Vu Cong Tuan | f825d19 | 2017-06-21 18:32:15 +0700 | [diff] [blame] | 59 | cls.os_primary.compute_security_groups_client) |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 60 | cls.compute_security_group_rules_client = ( |
Vu Cong Tuan | f825d19 | 2017-06-21 18:32:15 +0700 | [diff] [blame] | 61 | cls.os_primary.compute_security_group_rules_client) |
| 62 | cls.servers_client = cls.os_primary.servers_client |
| 63 | cls.interface_client = cls.os_primary.interfaces_client |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 64 | # Neutron network client |
Vu Cong Tuan | f825d19 | 2017-06-21 18:32:15 +0700 | [diff] [blame] | 65 | cls.networks_client = cls.os_primary.networks_client |
| 66 | cls.ports_client = cls.os_primary.ports_client |
| 67 | cls.routers_client = cls.os_primary.routers_client |
| 68 | cls.subnets_client = cls.os_primary.subnets_client |
| 69 | cls.floating_ips_client = cls.os_primary.floating_ips_client |
| 70 | cls.security_groups_client = cls.os_primary.security_groups_client |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 71 | cls.security_group_rules_client = ( |
Vu Cong Tuan | f825d19 | 2017-06-21 18:32:15 +0700 | [diff] [blame] | 72 | cls.os_primary.security_group_rules_client) |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 73 | |
Ghanshyam Mann | 3b663f6 | 2019-12-12 17:01:16 +0000 | [diff] [blame] | 74 | cls.volumes_client = cls.os_primary.volumes_client_latest |
| 75 | cls.snapshots_client = cls.os_primary.snapshots_client_latest |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 76 | |
| 77 | # ## Test functions library |
| 78 | # |
| 79 | # The create_[resource] functions only return body and discard the |
| 80 | # resp part which is not used in scenario tests |
| 81 | |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 82 | |
Roman Popelka | 082919c | 2022-03-17 11:44:31 +0100 | [diff] [blame] | 83 | class NetworkScenarioTest(manager.NetworkScenarioTest): |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 84 | """Base class for network scenario tests. |
| 85 | |
| 86 | This class provide helpers for network scenario tests, using the neutron |
| 87 | API. Helpers from ancestor which use the nova network API are overridden |
| 88 | with the neutron API. |
| 89 | |
| 90 | This Class also enforces using Neutron instead of novanetwork. |
| 91 | Subclassed tests will be skipped if Neutron is not enabled |
| 92 | |
| 93 | """ |
| 94 | |
Julia Kreger | 3a07c4d | 2021-06-22 10:27:56 -0700 | [diff] [blame] | 95 | credentials = ['primary', 'admin', 'system_admin'] |
Solio Sarabia | 60095ff | 2017-02-28 18:18:26 -0600 | [diff] [blame] | 96 | |
| 97 | @classmethod |
| 98 | def skip_checks(cls): |
| 99 | super(NetworkScenarioTest, cls).skip_checks() |
| 100 | if not CONF.service_available.neutron: |
| 101 | raise cls.skipException('Neutron not available') |