Merge "Fix H404/405 violations for scenario tests"

This commit is contained in:
Jenkins 2015-11-17 23:07:22 +00:00 committed by Gerrit Code Review
commit 1d017e3eaa
19 changed files with 85 additions and 110 deletions

View File

@ -131,14 +131,13 @@ class ScenarioTest(tempest.test.BaseTestCase):
self.cleanup_waits.append(wait_dict) self.cleanup_waits.append(wait_dict)
def _wait_for_cleanups(self): def _wait_for_cleanups(self):
"""To handle async delete actions, a list of waits is added # To handle async delete actions, a list of waits is added
which will be iterated over as the last step of clearing the # which will be iterated over as the last step of clearing the
cleanup queue. That way all the delete calls are made up front # cleanup queue. That way all the delete calls are made up front
and the tests won't succeed unless the deletes are eventually # and the tests won't succeed unless the deletes are eventually
successful. This is the same basic approach used in the api tests to # successful. This is the same basic approach used in the api tests to
limit cleanup execution time except here it is multi-resource, # limit cleanup execution time except here it is multi-resource,
because of the nature of the scenario tests. # because of the nature of the scenario tests.
"""
for wait in self.cleanup_waits: for wait in self.cleanup_waits:
waiter_callable = wait.pop('waiter_callable') waiter_callable = wait.pop('waiter_callable')
waiter_callable(**wait) waiter_callable(**wait)
@ -519,7 +518,8 @@ class ScenarioTest(tempest.test.BaseTestCase):
username=None, username=None,
private_key=None, private_key=None,
should_connect=True): should_connect=True):
""" """Check server connectivity
:param ip_address: server to test against :param ip_address: server to test against
:param username: server's ssh username :param username: server's ssh username
:param private_key: server's ssh private key to be used :param private_key: server's ssh private key to be used
@ -603,6 +603,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
class NetworkScenarioTest(ScenarioTest): class NetworkScenarioTest(ScenarioTest):
"""Base class for network scenario tests. """Base class for network scenario tests.
This class provide helpers for network scenario tests, using the neutron This class provide helpers for network scenario tests, using the neutron
API. Helpers from ancestor which use the nova network API are overridden API. Helpers from ancestor which use the nova network API are overridden
with the neutron API. with the neutron API.
@ -673,9 +674,9 @@ class NetworkScenarioTest(ScenarioTest):
def _create_subnet(self, network, client=None, subnets_client=None, def _create_subnet(self, network, client=None, subnets_client=None,
namestart='subnet-smoke', **kwargs): namestart='subnet-smoke', **kwargs):
""" """Create a subnet for the given network
Create a subnet for the given network within the cidr block
configured for tenant networks. within the cidr block configured for tenant networks.
""" """
if not client: if not client:
client = self.network_client client = self.network_client
@ -683,7 +684,8 @@ class NetworkScenarioTest(ScenarioTest):
subnets_client = self.subnets_client subnets_client = self.subnets_client
def cidr_in_use(cidr, tenant_id): def cidr_in_use(cidr, tenant_id):
""" """Check cidr existence
:return True if subnet with cidr already exist in tenant :return True if subnet with cidr already exist in tenant
False else False else
""" """
@ -801,9 +803,7 @@ class NetworkScenarioTest(ScenarioTest):
return floating_ip return floating_ip
def _disassociate_floating_ip(self, floating_ip): def _disassociate_floating_ip(self, floating_ip):
""" """:param floating_ip: type DeletableFloatingIp"""
:param floating_ip: type DeletableFloatingIp
"""
floating_ip.update(port_id=None) floating_ip.update(port_id=None)
self.assertIsNone(floating_ip.port_id) self.assertIsNone(floating_ip.port_id)
return floating_ip return floating_ip
@ -856,8 +856,7 @@ class NetworkScenarioTest(ScenarioTest):
raise raise
def _check_remote_connectivity(self, source, dest, should_succeed=True): def _check_remote_connectivity(self, source, dest, should_succeed=True):
""" """check ping server via source ssh connection
check ping server via source ssh connection
:param source: RemoteClient: an ssh connection from which to ping :param source: RemoteClient: an ssh connection from which to ping
:param dest: and IP to ping against :param dest: and IP to ping against
@ -988,7 +987,9 @@ class NetworkScenarioTest(ScenarioTest):
return sg_rule return sg_rule
def _create_loginable_secgroup_rule(self, client=None, secgroup=None): def _create_loginable_secgroup_rule(self, client=None, secgroup=None):
"""These rules are intended to permit inbound ssh and icmp """Create loginable security group rule
These rules are intended to permit inbound ssh and icmp
traffic from all sources, so no group_id is provided. traffic from all sources, so no group_id is provided.
Setting a group_id would only permit traffic from ports Setting a group_id would only permit traffic from ports
belonging to the same security group. belonging to the same security group.
@ -1349,9 +1350,7 @@ class BaremetalScenarioTest(ScenarioTest):
class EncryptionScenarioTest(ScenarioTest): class EncryptionScenarioTest(ScenarioTest):
""" """Base class for encryption scenario tests"""
Base class for encryption scenario tests
"""
credentials = ['primary', 'admin'] credentials = ['primary', 'admin']
@ -1401,8 +1400,7 @@ class EncryptionScenarioTest(ScenarioTest):
class ObjectStorageScenarioTest(ScenarioTest): class ObjectStorageScenarioTest(ScenarioTest):
""" """Provide harness to do Object Storage scenario tests.
Provide harness to do Object Storage scenario tests.
Subclasses implement the tests that use the methods provided by this Subclasses implement the tests that use the methods provided by this
class. class.
@ -1470,10 +1468,8 @@ class ObjectStorageScenarioTest(ScenarioTest):
def list_and_check_container_objects(self, container_name, def list_and_check_container_objects(self, container_name,
present_obj=None, present_obj=None,
not_present_obj=None): not_present_obj=None):
""" # List objects for a given container and assert which are present and
List objects for a given container and assert which are present and # which are not.
which are not.
"""
if present_obj is None: if present_obj is None:
present_obj = [] present_obj = []
if not_present_obj is None: if not_present_obj is None:

View File

@ -25,8 +25,8 @@ LOG = logging.getLogger(__name__)
class TestAggregatesBasicOps(manager.ScenarioTest): class TestAggregatesBasicOps(manager.ScenarioTest):
""" """Creates an aggregate within an availability zone
Creates an aggregate within an availability zone
Adds a host to the aggregate Adds a host to the aggregate
Checks aggregate details Checks aggregate details
Updates aggregate's name Updates aggregate's name

View File

@ -26,9 +26,9 @@ LOG = logging.getLogger(__name__)
class BaremetalBasicOps(manager.BaremetalScenarioTest): class BaremetalBasicOps(manager.BaremetalScenarioTest):
""" """This smoke test tests the pxe_ssh Ironic driver.
This smoke test tests the pxe_ssh Ironic driver. It follows this basic
set of operations: It follows this basic set of operations:
* Creates a keypair * Creates a keypair
* Boots an instance using the keypair * Boots an instance using the keypair
* Monitors the associated Ironic node for power and * Monitors the associated Ironic node for power and

View File

@ -58,7 +58,8 @@ class HorizonHTMLParser(HTMLParser.HTMLParser):
class TestDashboardBasicOps(manager.ScenarioTest): class TestDashboardBasicOps(manager.ScenarioTest):
""" """The test suite for dashboard basic operations
This is a basic scenario test: This is a basic scenario test:
* checks that the login page is available * checks that the login page is available
* logs in as a regular user * logs in as a regular user

View File

@ -22,7 +22,8 @@ CONF = config.CONF
class TestEncryptedCinderVolumes(manager.EncryptionScenarioTest): class TestEncryptedCinderVolumes(manager.EncryptionScenarioTest):
""" """The test suite for encrypted cinder volumes
This test is for verifying the functionality of encrypted cinder volumes. This test is for verifying the functionality of encrypted cinder volumes.
For both LUKS and cryptsetup encryption types, this test performs For both LUKS and cryptsetup encryption types, this test performs

View File

@ -31,8 +31,7 @@ LOG = logging.getLogger(__name__)
class TestLargeOpsScenario(manager.ScenarioTest): class TestLargeOpsScenario(manager.ScenarioTest):
""" """Test large operations.
Test large operations.
This test below: This test below:
* Spin up multiple instances in one nova call, and repeat three times * Spin up multiple instances in one nova call, and repeat three times

View File

@ -29,8 +29,7 @@ LOG = logging.getLogger(__name__)
class TestMinimumBasicScenario(manager.ScenarioTest): class TestMinimumBasicScenario(manager.ScenarioTest):
""" """This is a basic minimum scenario test.
This is a basic minimum scenario test.
This test below: This test below:
* across the multiple components * across the multiple components

View File

@ -70,12 +70,13 @@ class TestGettingAddress(manager.NetworkScenarioTest):
'security_groups': [{'name': self.sec_grp['name']}]} 'security_groups': [{'name': self.sec_grp['name']}]}
def prepare_network(self, address6_mode, n_subnets6=1, dualnet=False): def prepare_network(self, address6_mode, n_subnets6=1, dualnet=False):
"""Creates network with """Prepare network
given number of IPv6 subnets in the given mode and
one IPv4 subnet Creates network with given number of IPv6 subnets in the given mode and
Creates router with ports on all subnets one IPv4 subnet.
if dualnet - create IPv6 subnets on a different network Creates router with ports on all subnets.
:return: list of created networks if dualnet - create IPv6 subnets on a different network
:return: list of created networks
""" """
self.network = self._create_network(tenant_id=self.tenant_id) self.network = self._create_network(tenant_id=self.tenant_id)
if dualnet: if dualnet:

View File

@ -25,8 +25,8 @@ LOG = logging.getLogger(__name__)
class TestObjectStorageBasicOps(manager.ObjectStorageScenarioTest): class TestObjectStorageBasicOps(manager.ObjectStorageScenarioTest):
""" """Test swift basic ops.
Test swift basic ops.
* get swift stat. * get swift stat.
* create container. * create container.
* upload a file to the created container. * upload a file to the created container.
@ -57,6 +57,7 @@ class TestObjectStorageBasicOps(manager.ObjectStorageScenarioTest):
@test.services('object_storage') @test.services('object_storage')
def test_swift_acl_anonymous_download(self): def test_swift_acl_anonymous_download(self):
"""This test will cover below steps: """This test will cover below steps:
1. Create container 1. Create container
2. Upload object to the new container 2. Upload object to the new container
3. Change the ACL of the container 3. Change the ACL of the container

View File

@ -35,8 +35,8 @@ NOTIFICATIONS_SLEEP = 1
class TestObjectStorageTelemetry(manager.ObjectStorageScenarioTest): class TestObjectStorageTelemetry(manager.ObjectStorageScenarioTest):
""" """Test that swift uses the ceilometer middleware.
Test that swift uses the ceilometer middleware.
* create container. * create container.
* upload a file to the created container. * upload a file to the created container.
* retrieve the file from the created container. * retrieve the file from the created container.
@ -57,19 +57,15 @@ class TestObjectStorageTelemetry(manager.ObjectStorageScenarioTest):
cls.telemetry_client = cls.os_operator.telemetry_client cls.telemetry_client = cls.os_operator.telemetry_client
def _confirm_notifications(self, container_name, obj_name): def _confirm_notifications(self, container_name, obj_name):
""" # NOTE: Loop seeking for appropriate notifications about the containers
Loop seeking for appropriate notifications about the containers # and objects sent to swift.
and objects sent to swift.
"""
def _check_samples(): def _check_samples():
""" # NOTE: Return True only if we have notifications about some
Return True only if we have notifications about some # containers and some objects and the notifications are about
containers and some objects and the notifications are about # the expected containers and objects.
the expected containers and objects. # Otherwise returning False will case _check_samples to be
Otherwise returning False will case _check_samples to be # called again.
called again.
"""
results = self.telemetry_client.list_samples( results = self.telemetry_client.list_samples(
'storage.objects.incoming.bytes') 'storage.objects.incoming.bytes')
LOG.debug('got samples %s', results) LOG.debug('got samples %s', results)

View File

@ -28,7 +28,8 @@ LOG = logging.getLogger(__name__)
class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
""" """The test suite for security groups
This test suite assumes that Nova has been configured to This test suite assumes that Nova has been configured to
boot VM's with Neutron-managed networking, and attempts to boot VM's with Neutron-managed networking, and attempts to
verify cross tenant connectivity as follows verify cross tenant connectivity as follows
@ -95,8 +96,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
credentials = ['primary', 'alt', 'admin'] credentials = ['primary', 'alt', 'admin']
class TenantProperties(object): class TenantProperties(object):
""" """helper class to save tenant details
helper class to save tenant details
id id
credentials credentials
network network
@ -232,9 +232,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
return port['device_owner'].startswith('network:router_interface') return port['device_owner'].startswith('network:router_interface')
def _create_server(self, name, tenant, security_groups=None): def _create_server(self, name, tenant, security_groups=None):
""" """creates a server and assigns to security group"""
creates a server and assigns to security group
"""
self._set_compute_context(tenant) self._set_compute_context(tenant)
if security_groups is None: if security_groups is None:
security_groups = [tenant.security_groups['default']] security_groups = [tenant.security_groups['default']]
@ -268,11 +266,9 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
tenant.servers.append(server) tenant.servers.append(server)
def _set_access_point(self, tenant): def _set_access_point(self, tenant):
""" # creates a server in a secgroup with rule allowing external ssh
creates a server in a secgroup with rule allowing external ssh # in order to access tenant internal network
in order to access tenant internal network # workaround ip namespace
workaround ip namespace
"""
secgroups = tenant.security_groups.values() secgroups = tenant.security_groups.values()
name = 'server-{tenant}-access_point'.format( name = 'server-{tenant}-access_point'.format(
tenant=tenant.creds.tenant_name) tenant=tenant.creds.tenant_name)
@ -301,8 +297,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
return self.servers_client return self.servers_client
def _deploy_tenant(self, tenant_or_id): def _deploy_tenant(self, tenant_or_id):
""" """creates:
creates:
network network
subnet subnet
router (if public not defined) router (if public not defined)
@ -320,9 +315,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
self._set_access_point(tenant) self._set_access_point(tenant)
def _get_server_ip(self, server, floating=False): def _get_server_ip(self, server, floating=False):
""" """returns the ip (floating/internal) of a server"""
returns the ip (floating/internal) of a server
"""
if floating: if floating:
server_ip = self.floating_ips[server['id']].floating_ip_address server_ip = self.floating_ips[server['id']].floating_ip_address
else: else:
@ -333,9 +326,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
return server_ip return server_ip
def _connect_to_access_point(self, tenant): def _connect_to_access_point(self, tenant):
""" """create ssh connection to tenant access point"""
create ssh connection to tenant access point
"""
access_point_ssh = \ access_point_ssh = \
self.floating_ips[tenant.access_point['id']].floating_ip_address self.floating_ips[tenant.access_point['id']].floating_ip_address
private_key = tenant.keypair['private_key'] private_key = tenant.keypair['private_key']
@ -374,10 +365,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
ip=self._get_server_ip(server)) ip=self._get_server_ip(server))
def _test_cross_tenant_block(self, source_tenant, dest_tenant): def _test_cross_tenant_block(self, source_tenant, dest_tenant):
""" # if public router isn't defined, then dest_tenant access is via
if public router isn't defined, then dest_tenant access is via # floating-ip
floating-ip
"""
access_point_ssh = self._connect_to_access_point(source_tenant) access_point_ssh = self._connect_to_access_point(source_tenant)
ip = self._get_server_ip(dest_tenant.access_point, ip = self._get_server_ip(dest_tenant.access_point,
floating=self.floating_ip_access) floating=self.floating_ip_access)

View File

@ -28,9 +28,9 @@ LOG = logging.getLogger(__name__)
class TestServerAdvancedOps(manager.ScenarioTest): class TestServerAdvancedOps(manager.ScenarioTest):
""" """The test suite for server advanced operations
This test case stresses some advanced server instance operations:
This test case stresses some advanced server instance operations:
* Resizing an instance * Resizing an instance
* Sequence suspend resume * Sequence suspend resume
""" """

View File

@ -32,9 +32,9 @@ load_tests = test_utils.load_tests_input_scenario_utils
class TestServerBasicOps(manager.ScenarioTest): class TestServerBasicOps(manager.ScenarioTest):
""" """The test suite for server basic operations
This smoke test case follows this basic set of operations:
This smoke test case follows this basic set of operations:
* Create a keypair for use in launching an instance * Create a keypair for use in launching an instance
* Create a security group to control network access in instance * Create a security group to control network access in instance
* Add simple permissive rules to the security group * Add simple permissive rules to the security group

View File

@ -27,11 +27,7 @@ LOG = logging.getLogger(__name__)
class TestServerMultinode(manager.ScenarioTest): class TestServerMultinode(manager.ScenarioTest):
"""This is a set of tests specific to multinode testing."""
"""
This is a set of tests specific to multinode testing.
"""
credentials = ['primary', 'admin'] credentials = ['primary', 'admin']
@classmethod @classmethod

View File

@ -27,8 +27,8 @@ LOG = log.getLogger(__name__)
class TestShelveInstance(manager.ScenarioTest): class TestShelveInstance(manager.ScenarioTest):
""" """This test shelves then unshelves a Nova instance
This test shelves then unshelves a Nova instance
The following is the scenario outline: The following is the scenario outline:
* boot an instance and create a timestamp file in it * boot an instance and create a timestamp file in it
* shelve the instance * shelve the instance

View File

@ -26,8 +26,8 @@ LOG = log.getLogger(__name__)
class TestSnapshotPattern(manager.ScenarioTest): class TestSnapshotPattern(manager.ScenarioTest):
""" """This test is for snapshotting an instance and booting with it.
This test is for snapshotting an instance and booting with it.
The following is the scenario outline: The following is the scenario outline:
* boot an instance and create a timestamp file in it * boot an instance and create a timestamp file in it
* snapshot the instance * snapshot the instance

View File

@ -33,7 +33,8 @@ LOG = logging.getLogger(__name__)
class TestStampPattern(manager.ScenarioTest): class TestStampPattern(manager.ScenarioTest):
""" """The test suite for both snapshoting and attaching of volume
This test is for snapshotting an instance/volume and attaching the volume This test is for snapshotting an instance/volume and attaching the volume
created from snapshot to the instance booted from snapshot. created from snapshot to the instance booted from snapshot.
The following is the scenario outline: The following is the scenario outline:

View File

@ -25,8 +25,7 @@ LOG = log.getLogger(__name__)
class TestVolumeBootPattern(manager.ScenarioTest): class TestVolumeBootPattern(manager.ScenarioTest):
""" """This test case attempts to reproduce the following steps:
This test case attempts to reproduce the following steps:
* Create in Cinder some bootable volume importing a Glance image * Create in Cinder some bootable volume importing a Glance image
* Boot an instance from the bootable volume * Boot an instance from the bootable volume

View File

@ -72,8 +72,7 @@ class ImageUtils(object):
@misc.singleton @misc.singleton
class InputScenarioUtils(object): class InputScenarioUtils(object):
""" """Example usage:
Example usage:
import testscenarios import testscenarios
(...) (...)
@ -124,9 +123,7 @@ class InputScenarioUtils(object):
@property @property
def scenario_images(self): def scenario_images(self):
""" """:return: a scenario with name and uuid of images"""
:return: a scenario with name and uuid of images
"""
if not CONF.service_available.glance: if not CONF.service_available.glance:
return [] return []
if not hasattr(self, '_scenario_images'): if not hasattr(self, '_scenario_images'):
@ -143,9 +140,7 @@ class InputScenarioUtils(object):
@property @property
def scenario_flavors(self): def scenario_flavors(self):
""" """:return: a scenario with name and uuid of flavors"""
:return: a scenario with name and uuid of flavors
"""
if not hasattr(self, '_scenario_flavors'): if not hasattr(self, '_scenario_flavors'):
try: try:
flavors = self.flavors_client.list_flavors()['flavors'] flavors = self.flavors_client.list_flavors()['flavors']
@ -160,10 +155,11 @@ class InputScenarioUtils(object):
def load_tests_input_scenario_utils(*args): def load_tests_input_scenario_utils(*args):
"""Wrapper for testscenarios to set the scenarios
The purpose is to avoid running a getattr on the CONF object at import.
""" """
Wrapper for testscenarios to set the scenarios to avoid running a getattr
on the CONF object at import.
"""
if getattr(args[0], 'suiteClass', None) is not None: if getattr(args[0], 'suiteClass', None) is not None:
loader, standard_tests, pattern = args loader, standard_tests, pattern = args
else: else: