Fix H404/405 violations for scenario tests

There is a lot of H404/405 violations in Tempest now, and that leads
difficult to migrate the code to tempest-lib or the other projects'
repos. This patch fixes these violations for scenario tests.

Change-Id: Ia2b3cdbd0da49eeb16742c1eed05ea56ca41a8f7
This commit is contained in:
Ken'ichi Ohmichi 2015-11-17 08:16:12 +00:00
parent a112a59290
commit c4e4f1cb3f
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)
def _wait_for_cleanups(self):
"""To handle async delete actions, a list of waits is added
which will be iterated over as the last step of clearing the
cleanup queue. That way all the delete calls are made up front
and the tests won't succeed unless the deletes are eventually
successful. This is the same basic approach used in the api tests to
limit cleanup execution time except here it is multi-resource,
because of the nature of the scenario tests.
"""
# To handle async delete actions, a list of waits is added
# which will be iterated over as the last step of clearing the
# cleanup queue. That way all the delete calls are made up front
# and the tests won't succeed unless the deletes are eventually
# successful. This is the same basic approach used in the api tests to
# limit cleanup execution time except here it is multi-resource,
# because of the nature of the scenario tests.
for wait in self.cleanup_waits:
waiter_callable = wait.pop('waiter_callable')
waiter_callable(**wait)
@ -519,7 +518,8 @@ class ScenarioTest(tempest.test.BaseTestCase):
username=None,
private_key=None,
should_connect=True):
"""
"""Check server connectivity
:param ip_address: server to test against
:param username: server's ssh username
:param private_key: server's ssh private key to be used
@ -603,6 +603,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
class NetworkScenarioTest(ScenarioTest):
"""Base class for network scenario tests.
This class provide helpers for network scenario tests, using the neutron
API. Helpers from ancestor which use the nova network API are overridden
with the neutron API.
@ -673,9 +674,9 @@ class NetworkScenarioTest(ScenarioTest):
def _create_subnet(self, network, client=None, subnets_client=None,
namestart='subnet-smoke', **kwargs):
"""
Create a subnet for the given network within the cidr block
configured for tenant networks.
"""Create a subnet for the given network
within the cidr block configured for tenant networks.
"""
if not client:
client = self.network_client
@ -683,7 +684,8 @@ class NetworkScenarioTest(ScenarioTest):
subnets_client = self.subnets_client
def cidr_in_use(cidr, tenant_id):
"""
"""Check cidr existence
:return True if subnet with cidr already exist in tenant
False else
"""
@ -801,9 +803,7 @@ class NetworkScenarioTest(ScenarioTest):
return 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)
self.assertIsNone(floating_ip.port_id)
return floating_ip
@ -856,8 +856,7 @@ class NetworkScenarioTest(ScenarioTest):
raise
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 dest: and IP to ping against
@ -988,7 +987,9 @@ class NetworkScenarioTest(ScenarioTest):
return sg_rule
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.
Setting a group_id would only permit traffic from ports
belonging to the same security group.
@ -1349,9 +1350,7 @@ class BaremetalScenarioTest(ScenarioTest):
class EncryptionScenarioTest(ScenarioTest):
"""
Base class for encryption scenario tests
"""
"""Base class for encryption scenario tests"""
credentials = ['primary', 'admin']
@ -1401,8 +1400,7 @@ class EncryptionScenarioTest(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
class.
@ -1470,10 +1468,8 @@ class ObjectStorageScenarioTest(ScenarioTest):
def list_and_check_container_objects(self, container_name,
present_obj=None,
not_present_obj=None):
"""
List objects for a given container and assert which are present and
which are not.
"""
# List objects for a given container and assert which are present and
# which are not.
if present_obj is None:
present_obj = []
if not_present_obj is None:

View File

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

View File

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

View File

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

View File

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

View File

@ -31,8 +31,7 @@ LOG = logging.getLogger(__name__)
class TestLargeOpsScenario(manager.ScenarioTest):
"""
Test large operations.
"""Test large operations.
This test below:
* 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):
"""
This is a basic minimum scenario test.
"""This is a basic minimum scenario test.
This test below:
* across the multiple components

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,11 +27,7 @@ LOG = logging.getLogger(__name__)
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']
@classmethod

View File

@ -27,8 +27,8 @@ LOG = log.getLogger(__name__)
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:
* boot an instance and create a timestamp file in it
* shelve the instance

View File

@ -26,8 +26,8 @@ LOG = log.getLogger(__name__)
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:
* boot an instance and create a timestamp file in it
* snapshot the instance

View File

@ -33,7 +33,8 @@ LOG = logging.getLogger(__name__)
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
created from snapshot to the instance booted from snapshot.
The following is the scenario outline:

View File

@ -25,8 +25,7 @@ LOG = log.getLogger(__name__)
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
* Boot an instance from the bootable volume

View File

@ -72,8 +72,7 @@ class ImageUtils(object):
@misc.singleton
class InputScenarioUtils(object):
"""
Example usage:
"""Example usage:
import testscenarios
(...)
@ -124,9 +123,7 @@ class InputScenarioUtils(object):
@property
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:
return []
if not hasattr(self, '_scenario_images'):
@ -143,9 +140,7 @@ class InputScenarioUtils(object):
@property
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'):
try:
flavors = self.flavors_client.list_flavors()['flavors']
@ -160,10 +155,11 @@ class InputScenarioUtils(object):
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:
loader, standard_tests, pattern = args
else: