diff --git a/test-requirements.txt b/test-requirements.txt index aea87ad..77eff33 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,10 +2,10 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=3.0.1,<3.1.0 +hacking>=6.1.0,<6.2.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 -flake8-import-order==0.12 # LGPLv3 +flake8-import-order>=0.18.0,<0.19.0 # LGPLv3 python-subunit>=1.0.0 # Apache-2.0/BSD sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.2;python_version>='3.4' # BSD diff --git a/tox.ini b/tox.ini index 7881d4a..04d0634 100644 --- a/tox.ini +++ b/tox.ini @@ -34,7 +34,8 @@ commands = {posargs} enable-extensions = H106,H203,H204,H205,H904 # H405: multi line docstring summary not separated with an empty line # W504: line break after binary operator -ignore = H405,W504 +# I202 Additional newline in a group of imports +ignore = H405,W504,I202 show-source = true exclude = ./.*,build,dist,doc,*egg*,releasenotes import-order-style = pep8 diff --git a/whitebox_neutron_tempest_plugin/common/tcpdump_capture.py b/whitebox_neutron_tempest_plugin/common/tcpdump_capture.py index 358cbe4..5b66f5f 100644 --- a/whitebox_neutron_tempest_plugin/common/tcpdump_capture.py +++ b/whitebox_neutron_tempest_plugin/common/tcpdump_capture.py @@ -58,7 +58,7 @@ class TcpdumpCapture(fixtures.Fixture): self.cmd_prefix, interface, self.filter_str, capture_file) self.capture_files.append(capture_file) - LOG.debug('Executing command: {}'.format(cmd)) + LOG.debug('Executing command: %s', cmd) process.exec_command(cmd) self.processes.append(process) self.addCleanup(self.cleanup) diff --git a/whitebox_neutron_tempest_plugin/common/utils.py b/whitebox_neutron_tempest_plugin/common/utils.py index 4fa2ec1..89793e0 100644 --- a/whitebox_neutron_tempest_plugin/common/utils.py +++ b/whitebox_neutron_tempest_plugin/common/utils.py @@ -208,7 +208,7 @@ def host_responds_to_ping(ip, count=3): def run_local_cmd(cmd, timeout=10): command = "timeout " + str(timeout) + " " + cmd - LOG.debug("Running local command '{}'".format(command)) + LOG.debug("Running local command '%s'", command) output, errors = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() @@ -217,8 +217,8 @@ def run_local_cmd(cmd, timeout=10): def interface_state_set(client, interface, state): shell_path = 'PATH=$PATH:/sbin' - LOG.debug('Setting interface {} {} on {}'.format( - interface, state, client.host)) + LOG.debug('Setting interface %s %s on %s', + interface, state, client.host) client.exec_command( "{path}; sudo ip link set {interface} {state}".format( path=shell_path, interface=interface, state=state)) @@ -227,7 +227,7 @@ def interface_state_set(client, interface, state): def remote_service_action(client, service, action, target_state): cmd = "sudo systemctl {action} {service}".format( action=action, service=service) - LOG.debug("Running '{}' on {}".format(cmd, client.host)) + LOG.debug("Running '%s' on %s", cmd, client.host) client.exec_command(cmd) common_utils.wait_until_true( lambda: remote_service_check_state(client, service, target_state), diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/base.py b/whitebox_neutron_tempest_plugin/tests/scenario/base.py index 8ccafc8..67588d4 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/base.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/base.py @@ -19,7 +19,9 @@ from multiprocessing import Process import os import random import re + import time + import yaml import netaddr @@ -104,9 +106,9 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): cls.master_cont_cmd_executor = \ cls.proxy_host_client.exec_command else: - LOG.warning(("Unrecognized deployer tool '{}', plugin supports " - "openstack_type as devstack/podified.".format( - WB_CONF.openstack_type))) + LOG.warning(("Unrecognized deployer tool '%s', plugin supports " + "openstack_type as devstack/podified.", + WB_CONF.openstack_type)) @classmethod def run_on_master_controller(cls, cmd): @@ -114,9 +116,9 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): output = cls.proxy_host_client.exec_command(cmd) if WB_CONF.openstack_type == 'devstack': output, errors = local_utils.run_local_cmd(cmd) - LOG.debug("Stderr: {}".format(errors.decode())) + LOG.debug("Stderr: %s", errors.decode()) output = output.decode() - LOG.debug("Output: {}".format(output)) + LOG.debug("Output: %s", output) return output.strip() def get_host_for_server(self, server_id): @@ -283,8 +285,8 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): "{} get {} -o yaml".format(cls.OC, ocp_node)) ocp_node_yaml_list.append(yaml.safe_load(output)) - LOG.debug("Environment is{} based on CRC".format( - "" if is_crc else "n't")) + LOG.debug("Environment is %s based on CRC", + "" if is_crc else "n't") items = inventory_data['all']['children'] hosts_data = {} host_names = [] @@ -535,9 +537,9 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): setting = "{} {} {}".format(config_file, section, param) cmd = "{} {} {} || true".format( service_prefix, cmd_prefix, setting) - LOG.debug("Command = '{}'".format(cmd)) + LOG.debug("Command = '%s'", cmd) result = host['client'].exec_command(cmd).strip() - LOG.debug("Result = '{}'".format(result)) + LOG.debug("Result = '%s'", result) # Since we are checking files in reverse order, # if we've found a value than it's an override and we # should ignore values in other files @@ -865,11 +867,11 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): ssh_client=ssh_client) except exceptions.ShellCommandFailed: LOG.exception( - 'Tested command failed (raising error) -> "{}":'.format(cmd)) + 'Tested command failed (raising error) -> "%s":', cmd) # verify command success using boolean if ret_bool_status and result.exit_status != 0: LOG.debug( - 'Tested command failed (returning False) -> "{}":'.format(cmd)) + 'Tested command failed (returning False) -> "%s":', cmd) return False # verify desired output using exception/boolean all_output = (result.stderr if result.stderr else '') + \ @@ -1162,14 +1164,14 @@ class TrafficFlowTest(BaseTempestWhiteboxTestCase): self.check_remote_connectivity(ssh_client, dst_ip, ping_count=2) time.sleep(5) self._stop_captures() - LOG.debug('Expected routing nodes: {}'.format( - ','.join(expected_routing_nodes))) + LOG.debug('Expected routing nodes: %s', + ','.join(expected_routing_nodes)) actual_routing_nodes = [node['short_name'] for node in self.nodes if (node.get('capture') and not node['capture'].is_empty())] - LOG.debug('Actual routing nodes: {}'.format( - ','.join(actual_routing_nodes))) + LOG.debug('Actual routing nodes: %s', + ','.join(actual_routing_nodes)) self.assertCountEqual(expected_routing_nodes, actual_routing_nodes) def check_north_south_icmp_flow( @@ -1208,13 +1210,13 @@ class TrafficFlowTest(BaseTempestWhiteboxTestCase): self.check_remote_connectivity( ssh_client, dst_ip, mtu=size, ping_count=2) self._stop_captures() - LOG.debug('Expected routing nodes: {}'.format(expected_routing_nodes)) + LOG.debug('Expected routing nodes: %s', expected_routing_nodes) actual_routing_nodes = [node['short_name'] for node in self.nodes if (node.get('capture') and not node['capture'].is_empty())] - LOG.debug('Actual routing nodes: {}'.format( - ','.join(actual_routing_nodes))) + LOG.debug('Actual routing nodes: %s', + ','.join(actual_routing_nodes)) self.assertCountEqual(expected_routing_nodes, actual_routing_nodes) @@ -1312,7 +1314,7 @@ class BaseTempestTestCaseOvn(BaseTempestWhiteboxTestCase): def _port_binding_exist(): self.chassis_id = self.run_on_master_controller(cmd) - LOG.debug("chassis_id = '{}'".format(self.chassis_id)) + LOG.debug("chassis_id = '%s'", self.chassis_id) if self.chassis_id != '[]': return True return False @@ -1323,7 +1325,7 @@ class BaseTempestTestCaseOvn(BaseTempestWhiteboxTestCase): except common_utils.WaitTimeout: self.fail("Port is not bound to chassis") cmd = "{} get chassis {} hostname".format(self.sbctl, self.chassis_id) - LOG.debug("Running '{}' on the master node".format(cmd)) + LOG.debug("Running '%s' on the master node", cmd) res = self.run_on_master_controller(cmd) return res.replace('"', '').split('.')[0] @@ -1413,8 +1415,8 @@ class BaseDisruptiveTempestTestCase(BaseTempestWhiteboxTestCase): return except lib_exceptions.SSHExecCommandFailed: LOG.debug("Attempt to execute virsh command on hypervisor_host: " - "'{}' failed. Trying to discover hypervisor host from " - ".ssh/config file.".format(WB_CONF.hypervisor_host)) + "'%s' failed. Trying to discover hypervisor host from " + ".ssh/config file.", WB_CONF.hypervisor_host) # Depending on ci-fmw version and/or setup, .ssh/config file could # include an entry for either hypervisor or hypervisor-1 host = cls.proxy_host_client.exec_command( diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_broadcast.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_broadcast.py index df93750..3aad1a5 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_broadcast.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_broadcast.py @@ -189,7 +189,7 @@ class BaseBroadcastTest(object): path=file_path)) # We need to make sure that exactly the expected count # of messages reached receiver, no more and no less - LOG.debug('result = {}'. format(result)) + LOG.debug('result = %s', result) count = len( re.findall(self.broadcast_message, result)) self.assertEqual( @@ -227,7 +227,7 @@ class BaseBroadcastTest(object): server['ssh_client'].execute_script( "killall tcpdump && sleep 2", become_root=True) LOG.debug('Validating number of messages on ' - 'receiver {}'.format(server['id'])) + 'receiver %s', server['id']) _validate_number_of_messages( server['ssh_client'], self.capture_output_file, num_pings) @@ -236,7 +236,7 @@ class BaseBroadcastTest(object): server['ssh_client'].execute_script( "killall tcpdump && sleep 2", become_root=True) LOG.debug('Validating number of messages on ' - 'receiver {}'.format(server['id'])) + 'receiver %s', server['id']) _validate_number_of_messages( server['ssh_client'], self.capture_output_file, 0) diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py index ecbaad2..5aed362 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py @@ -100,7 +100,7 @@ class OvnDvrBase(base.TrafficFlowTest, base.BaseTempestTestCaseOvn): self.router_port['id']) self.chassis_name = self.get_router_gateway_chassis_by_id( self.chassis_list[0]) - LOG.debug("router chassis name = {}".format(self.chassis_name)) + LOG.debug("router chassis name = %s", self.chassis_name) # Since we are going to spawn VMs with 'host' option which # is available only for admin user, we create security group @@ -152,7 +152,7 @@ class OvnDvrBase(base.TrafficFlowTest, base.BaseTempestTestCaseOvn): pkey=self.keypair['private_key']) self.fip_port_mac = self.get_fip_port_details( self.server['fip'])['mac_address'] - LOG.debug("FIP port MAC: {}".format(self.fip_port_mac)) + LOG.debug("FIP port MAC: %s", self.fip_port_mac) class OvnDvrTest(OvnDvrBase): @@ -326,7 +326,7 @@ class OvnDvrTest(OvnDvrBase): server2 = self._create_server(exclude_hosts=self.exclude_hosts) compute2 = self.get_host_shortname_for_server( server2['server']['id']) - LOG.debug("compute = {}, compute2 = {}".format(self.compute, compute2)) + LOG.debug("compute = %s, compute2 = %s", self.compute, compute2) if self.compute == compute2: self.skipTest( "Servers are running on same compute - the test can provide " @@ -850,14 +850,14 @@ class OvnDvrAdvancedTest(base.BaseTempestTestCaseAdvanced, self._failover_vip(vm2, vm1, vip_ssh_client, nic, vip_ip) self._stop_captures() - LOG.debug('Expected routing nodes: {}'.format( - ','.join(self.expected_routing_nodes))) + LOG.debug('Expected routing nodes: %s', + ','.join(self.expected_routing_nodes)) actual_routing_nodes = [node['short_name'] for node in self.nodes if (node.get('capture') and not node['capture'].is_empty())] - LOG.debug('Actual routing nodes: {}'.format( - ','.join(actual_routing_nodes))) + LOG.debug('Actual routing nodes: %s', + ','.join(actual_routing_nodes)) self.assertCountEqual( self.expected_routing_nodes, actual_routing_nodes) diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_l3ha_ovn.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_l3ha_ovn.py index 122e4b9..efcfc69 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_l3ha_ovn.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_l3ha_ovn.py @@ -67,8 +67,9 @@ class L3haOvnCommon(base.TrafficFlowTest, base.BaseTempestTestCaseOvn): def _router_gateway_chassis_updated(): self.router_gateway_chassis = self.get_router_gateway_chassis( self.router_port['id']) - LOG.debug("chassis = '{}', expected = {} ".format( - self.router_gateway_chassis, self.expected_gateway_chassis)) + LOG.debug("chassis = '%s', expected = %s ", + self.router_gateway_chassis, + self.expected_gateway_chassis) return self.router_gateway_chassis == self.expected_gateway_chassis try: @@ -102,7 +103,7 @@ class L3haOvnCommon(base.TrafficFlowTest, base.BaseTempestTestCaseOvn): self.router_port['id']) chassis_name = self.get_router_gateway_chassis_by_id( self.chassis_list[0]) - LOG.debug("router chassis name = {}".format(chassis_name)) + LOG.debug("router chassis name = %s", chassis_name) return router, chassis_name if (WB_CONF.avoid_disrupting_controllers and @@ -111,7 +112,7 @@ class L3haOvnCommon(base.TrafficFlowTest, base.BaseTempestTestCaseOvn): controller_nodes = [node['name'] for node in self.nodes if node['is_controller']] for i in range(1, attempts): - LOG.debug("Router creation attempt {}".format(i)) + LOG.debug("Router creation attempt %s", i) router, chassis_name = create_router_candidate() if chassis_name in controller_nodes: continue diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_multicast.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_multicast.py index 7a86ed8..0341a5c 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_multicast.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_multicast.py @@ -439,9 +439,9 @@ class BaseMulticastTest(object): # of messages reached receiver, no more and no less LOG.debug('result = {}'. format(result)) for mcast_group in mcast_groups: - LOG.debug('Validating group {}'.format(mcast_group)) + LOG.debug('Validating group %s', mcast_group) if allowed_group: - LOG.debug('Allowed group {}'.format(allowed_group)) + LOG.debug('Allowed group %s', allowed_group) if ((allowed_group and mcast_group == allowed_group) or self._is_multicast_traffic_expected(mcast_group)): expected_count = 1 @@ -495,8 +495,8 @@ class BaseMulticastTest(object): if start_delay and start_delay > 5: LOG.debug( - "Waiting {} seconds for start delay to expire".format( - start_delay)) + "Waiting %s seconds for start delay to expire", + start_delay) time.sleep(start_delay) else: # (rsafrono) Note, this delay is needed to make sure all @@ -505,8 +505,8 @@ class BaseMulticastTest(object): time.sleep(10) for group in mcast_groups: - LOG.debug("Starting script for group {} on " - "sender".format(group)) + LOG.debug("Starting script for group %s on " + "sender", group) sender['ssh_client'].execute_script( "%s /tmp/multicast_traffic_sender_%s.py" % ( PYTHON3_BIN, group)) @@ -525,7 +525,7 @@ class BaseMulticastTest(object): receiver['ssh_client'].execute_script( "killall tcpdump && sleep 2", become_root=True) LOG.debug('Validating number of messages on ' - 'receiver {}'.format(receiver['id'])) + 'receiver %s', receiver['id']) _validate_number_of_messages( receiver['ssh_client'], mcast_groups, self.capture_output_file, mcast_groups[group_id]) @@ -543,7 +543,7 @@ class BaseMulticastTest(object): server['ssh_client'].execute_script( "killall tcpdump && sleep 2", become_root=True) LOG.debug('Validating number of messages on ' - 'unregistered {}'.format(server['id'])) + 'unregistered %s', server['id']) _validate_number_of_messages( server['ssh_client'], mcast_groups, self.capture_output_file) diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_ovn_dbs.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_ovn_dbs.py index e84c1f0..58794d5 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_ovn_dbs.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_ovn_dbs.py @@ -32,7 +32,7 @@ class OvnDbsMonitoringTest(wb_base.BaseTempestTestCaseOvn): self.process = self.master_node_client.open_session() cmd = '{} OVN_Southbound Chassis external_ids > {}'.format( self.sbmonitorcmd, self.monitoring_file) - LOG.debug('Executing command: {}'.format(cmd)) + LOG.debug('Executing command: %s', cmd) self.process.exec_command(cmd) self.addCleanup(self.stop_process) diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_qos.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_qos.py index 9c487df..3ec4ba0 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_qos.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_qos.py @@ -290,21 +290,21 @@ class QosBaseTest(test_qos.QoSTestMixin, base.TrafficFlowTest): perf_measures = test_bw_method( client['ssh_client'], server['ssh_client'], server_ip, protocol) - LOG.debug('perf_measures = {}'.format(perf_measures)) + LOG.debug('perf_measures = %s', perf_measures) # verify bw limit measured_bw = self._calculate_bw(perf_measures) LOG.debug( - '{} {} / server_ip = {} / measured_bw = {}'.format( - direction, protocol, server_ip, measured_bw)) + '%s %s / server_ip = %s / measured_bw = %f', + direction, protocol, server_ip, measured_bw) if bw_limit is None: - LOG.debug('no {} bw_limit configured'.format(direction)) + LOG.debug('no %s bw_limit configured', direction) self.assertGreater(measured_bw, self.MIN_KBPS_NO_BWLIMIT * 1000) else: - LOG.debug('{} bw_limit = {}'.format(direction, bw_limit)) + LOG.debug('%s bw_limit = %s', direction, bw_limit) # a 20% of upper deviation is allowed self.assertLess(measured_bw, bw_limit * 1.2) # a 20% of lower deviation is allowed @@ -812,7 +812,7 @@ class QosBaseTest(test_qos.QoSTestMixin, base.TrafficFlowTest): self.assertNotEqual(vms_host, vms_new_host, '%s vm did not migrate' % role) - LOG.debug("Validating server '{}'".format(role)) + LOG.debug("Validating server '%s'", role) # Validate that traffic that reach destination host is still marked self._validate_traffic_marked( dscp_mark, vms['sender'], vms['receiver']) @@ -974,7 +974,7 @@ class QosTestCommon(QosBaseTest): def _set_user_policy(self, node, policy, value): cmd = (r"{} sed -i 's/\(\"{}\":\ \).*/\1\"{}\"/' {}".format( self.neutron_container, policy, value, self.user_policy_file)) - LOG.debug("cmd = {}".format(cmd)) + LOG.debug("cmd = %s", cmd) return node['client'].exec_command(cmd).rstrip() diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_security_groups.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_security_groups.py index 7044bf8..6cd1286 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_security_groups.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_security_groups.py @@ -310,7 +310,7 @@ class NetworkDefaultSecGroupTest(base.BaseTempestTestCase): 'networks': [{'uuid': self.network['id']}] } server = self.create_server(**server_args) - LOG.info('test_negative server: {}'.format(server['server'])) + LOG.info('test_negative server: %s', server['server']) # Try to remove "Existing SG ID" that is not associated to VM Network # from VM.