aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/openstack
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2017-12-05 19:56:59 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-12-05 19:56:59 +0000
commit0273da05f68727835b5fc778f54eb70ccae209d8 (patch)
tree8850efe34152afb74edc272fbb6d4cbae4a90ba0 /functest/opnfv_tests/openstack
parent90b8e7922a42defb3e571a0a8e81306e9abc0fe3 (diff)
parent0da9c0665df587b97129472b38c52dd6c1ab12a4 (diff)
Merge "Fix pylint errors of vping"
Diffstat (limited to 'functest/opnfv_tests/openstack')
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_base.py33
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_ssh.py2
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_userdata.py12
3 files changed, 25 insertions, 22 deletions
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index de431fe1..318e9c45 100644
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -6,9 +6,10 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+"""Define the parent class of vping_ssh and vping_userdata testcases."""
+
from datetime import datetime
import logging
-import os
import time
import uuid
@@ -32,14 +33,11 @@ class VPingBase(testcase.TestCase):
internal network.
This class is responsible for creating the image, internal network.
"""
+ # pylint: disable=too-many-instance-attributes
def __init__(self, **kwargs):
super(VPingBase, self).__init__(**kwargs)
- # This line is here simply for pep8 as the 'os' package import appears
- # to be required for mock and the unit tests will fail without it
- os.environ
-
self.logger = logging.getLogger(__name__)
if 'os_creds' in kwargs:
@@ -59,6 +57,7 @@ class VPingBase(testcase.TestCase):
self.network_creator = None
self.vm1_creator = None
self.vm2_creator = None
+ self.router_creator = None
# Shared metadata
self.guid = ''
@@ -73,7 +72,8 @@ class VPingBase(testcase.TestCase):
self.vm_boot_timeout = CONST.__getattribute__('vping_vm_boot_timeout')
self.vm_delete_timeout = CONST.__getattribute__(
'vping_vm_delete_timeout')
- self.vm_ssh_connect_timeout = CONST.vping_vm_ssh_connect_timeout
+ self.vm_ssh_connect_timeout = CONST.__getattribute__(
+ 'vping_vm_ssh_connect_timeout')
self.ping_timeout = CONST.__getattribute__('vping_ping_timeout')
self.flavor_name = 'vping-flavor' + self.guid
@@ -91,16 +91,17 @@ class VPingBase(testcase.TestCase):
self.logger.info('Begin virtual environment setup')
self.start_time = time.time()
- self.logger.info("vPing Start Time:'%s'" % (
+ self.logger.info(
+ "vPing Start Time:'%s'",
datetime.fromtimestamp(self.start_time).strftime(
- '%Y-%m-%d %H:%M:%S')))
+ '%Y-%m-%d %H:%M:%S'))
image_base_name = '{}-{}'.format(
CONST.__getattribute__('vping_image_name'),
str(self.guid))
os_image_settings = openstack_tests.cirros_image_settings(
image_base_name, image_metadata=self.cirros_image_config)
- self.logger.info("Creating image with name: '%s'" % image_base_name)
+ self.logger.info("Creating image with name: '%s'", image_base_name)
self.image_creator = deploy_utils.create_image(
self.os_creds, os_image_settings)
@@ -117,18 +118,18 @@ class VPingBase(testcase.TestCase):
vping_physical_network = None
vping_segmentation_id = None
- if (hasattr(CONST, 'vping_network_type')):
+ if hasattr(CONST, 'vping_network_type'):
vping_network_type = CONST.__getattribute__(
'vping_network_type')
- if (hasattr(CONST, 'vping_physical_network')):
+ if hasattr(CONST, 'vping_physical_network'):
vping_physical_network = CONST.__getattribute__(
'vping_physical_network')
- if (hasattr(CONST, 'vping_segmentation_id')):
+ if hasattr(CONST, 'vping_segmentation_id'):
vping_segmentation_id = CONST.__getattribute__(
'vping_segmentation_id')
self.logger.info(
- "Creating network with name: '%s'" % private_net_name)
+ "Creating network with name: '%s'", private_net_name)
self.network_creator = deploy_utils.create_network(
self.os_creds,
NetworkConfig(
@@ -154,7 +155,7 @@ class VPingBase(testcase.TestCase):
self.creators.append(self.router_creator)
self.logger.info(
- "Creating flavor with name: '%s'" % self.flavor_name)
+ "Creating flavor with name: '%s'", self.flavor_name)
scenario = CONST.__getattribute__('DEPLOY_SCENARIO')
flavor_metadata = None
if 'ovs' in scenario or 'fdio' in scenario:
@@ -200,8 +201,8 @@ class VPingBase(testcase.TestCase):
for creator in reversed(self.creators):
try:
creator.clean()
- except Exception as e:
- self.logger.error('Unexpected error cleaning - %s', e)
+ except Exception as error: # pylint: disable=broad-except
+ self.logger.error('Unexpected error cleaning - %s', error)
def _do_vping(self, vm_creator, test_ip):
"""
diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py
index 0d92a7e1..7df767ed 100644
--- a/functest/opnfv_tests/openstack/vping/vping_ssh.py
+++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py
@@ -158,7 +158,7 @@ class VPingSSH(vping_base.VPingBase):
'functest.opnfv_tests.openstack.vping', 'ping.sh')
try:
scp.put(ping_script, "~/")
- except Exception:
+ except Exception: # pylint: disable=broad-except
self.logger.error("Cannot SCP the file '%s'", ping_script)
return False
diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py
index 4cc8f42f..ceba0917 100644
--- a/functest/opnfv_tests/openstack/vping/vping_userdata.py
+++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py
@@ -7,6 +7,8 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+"""vping_userdata testcase."""
+
import time
from snaps.config.network import PortConfig
@@ -47,8 +49,8 @@ class VPingUserdata(vping_base.VPingBase):
port_settings=[port1_settings])
self.logger.info(
- "Creating VM 1 instance with name: '%s'"
- % instance1_settings.name)
+ "Creating VM 1 instance with name: '%s'",
+ instance1_settings.name)
self.vm1_creator = deploy_utils.create_vm_instance(
self.os_creds, instance1_settings,
self.image_creator.image_settings)
@@ -69,8 +71,8 @@ class VPingUserdata(vping_base.VPingBase):
userdata=userdata)
self.logger.info(
- "Creating VM 2 instance with name: '%s'"
- % instance2_settings.name)
+ "Creating VM 2 instance with name: '%s'",
+ instance2_settings.name)
self.vm2_creator = deploy_utils.create_vm_instance(
self.os_creds, instance2_settings,
self.image_creator.image_settings)
@@ -113,7 +115,7 @@ class VPingUserdata(vping_base.VPingBase):
tries += 1
else:
self.logger.debug(
- "Pinging %s. Waiting for response..." % test_ip)
+ "Pinging %s. Waiting for response...", test_ip)
sec += 1
return exit_code