Skip to content

Commit

Permalink
CP-33853: Fix travis ci issue
Browse files Browse the repository at this point in the history
Signed-off-by: Deli Zhang <[email protected]>
  • Loading branch information
DeliZhangX committed Jun 23, 2020
1 parent 473cc94 commit ecd22c5
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 19 deletions.
3 changes: 2 additions & 1 deletion autocertkit/ack_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def get_xapi_session(config):


def parse_cmd_args():
parser = OptionParser(usage="%prog [options]", version="%prog @KIT_VERSION@") # NOSONAR
parser = OptionParser( # NOSONAR
usage="%prog [options]", version="%prog @KIT_VERSION@") # NOSONAR

parser.add_option("-d", "--debug",
dest="debug",
Expand Down
8 changes: 5 additions & 3 deletions autocertkit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def __init__(self, xml_device_node):

# We only care about child element nodes
child_elems = [node for node in xml_device_node.childNodes
if node.nodeType == node.ELEMENT_NODE]
if node.nodeType == node.ELEMENT_NODE]

# We expect there to be one child node 'certification_tests'
if len(child_elems) != 1:
Expand Down Expand Up @@ -566,8 +566,10 @@ def print_report(self, stream):

self.print_results(stream, tests_passed, "Tests that passed:")
self.print_results(stream, tests_failed_req, "Tests that failed:")
self.print_results(stream, tests_failed_noreq, "None required tests that failed:")
self.print_results(stream, tests_skipped_req + tests_skipped_noreq, "Tests that skipped:")
self.print_results(stream, tests_failed_noreq,
"None required tests that failed:")
self.print_results(stream, tests_skipped_req +
tests_skipped_noreq, "Tests that skipped:")

def print_results(self, stream, res, header):
if res:
Expand Down
5 changes: 3 additions & 2 deletions autocertkit/network_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ def _run_test(self, session, direction):
log.debug("About to run iperf test...")
iperf_data = IperfTest(session, client, server, self.network_for_test,
self.get_static_manager(self.network_for_test),
{'config': self.IPERF_ARGS, 'multicast_ip': self.MULTICAST_IP}
{'config': self.IPERF_ARGS,
'multicast_ip': self.MULTICAST_IP}
).run()

return {'info': 'Test ran successfully',
Expand Down Expand Up @@ -968,7 +969,7 @@ class MulticastTestClass(IperfTestClass):
IPERF_ARGS = {'format': 'm',
'thread_count': '4'}

MULTICAST_IP = '226.94.1.1' # NOSONAR
MULTICAST_IP = '226.94.1.1' # NOSONAR


class GROOffloadTestClass(testbase.NetworkTestClass):
Expand Down
12 changes: 8 additions & 4 deletions autocertkit/operations_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def test_vm_power_control(self, session):
state a predefined number of times"""
vm_ref_list = self._setup_vms(session)
for i in range(3):
log.debug("Starting test (power control) run %d of %d" % (i + 1, 3))
log.debug("Starting test (power control) run %d of %d" %
(i + 1, 3))

# Make certain the VMs are available
for vm_ref in vm_ref_list:
Expand Down Expand Up @@ -129,7 +130,8 @@ def test_vm_reboot(self, session):
run_xapi_async_tasks(session, task_list)

# Verify the VMs report a 'Running' power state
log.debug("Verrifying VM power control operations (reboot) for 'Running'")
log.debug(
"Verrifying VM power control operations (reboot) for 'Running'")
for vm_ref in vm_ref_list:
if session.xenapi.VM.get_power_state(vm_ref) != 'Running':
raise Exception("ERROR: Unexpected power state")
Expand Down Expand Up @@ -187,7 +189,8 @@ def test_vm_suspend(self, session):
run_xapi_async_tasks(session, task_list)

# Verify the VMs report a 'Running' power state
log.debug("Verrifying VM power control operations (suspend) for 'Running'")
log.debug(
"Verrifying VM power control operations (suspend) for 'Running'")
for vm_ref in vm_ref_list:
if session.xenapi.VM.get_power_state(vm_ref) != 'Running':
raise Exception("ERROR: VM %s did not resume" % vm_ref)
Expand Down Expand Up @@ -226,7 +229,8 @@ def test_vm_relocation(self, session):
run_xapi_async_tasks(session, task_list)

# Verify the VMs report a 'Running' power state
log.debug("Verrifying VM power control operations (relocation) for 'Running'")
log.debug(
"Verrifying VM power control operations (relocation) for 'Running'")
for vm_ref in vm_ref_list:
if session.xenapi.VM.get_power_state(vm_ref) != 'Running':
raise Exception("ERROR: Unexpected power state")
Expand Down
5 changes: 2 additions & 3 deletions autocertkit/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ def append_xml_config(self, doc, xml_node):

test_methods = test_class(self.session, self.config).list_tests()
for method in test_methods:
self.add_method_node(doc, skip_this, test_class_name, xcp_version, class_node, method)
self.add_method_node(
doc, skip_this, test_class_name, xcp_version, class_node, method)

cts_node.appendChild(class_node)

xml_node.appendChild(device_node)


def set_test_class_cap(self, test_class, xcp_version):
if test_class.REQUIRED_FOR:
if utils.eval_expr(test_class.REQUIRED_FOR, xcp_version):
Expand All @@ -184,7 +184,6 @@ def set_test_class_cap(self, test_class, xcp_version):
return True
return False


def add_method_node(self, doc, skipthis, test_class_name, xcp_version, class_node, method):
method_node = doc.createElement('test_method')
method_node.setAttribute('name', str(method))
Expand Down
3 changes: 2 additions & 1 deletion autocertkit/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def get_test_class(fqtn):
if __name__ == "__main__":
# Main function entry point

parser = OptionParser(usage="%prog [-c] [-t]", version="%prog 0.1") # NOSONAR
parser = OptionParser( # NOSONAR
usage="%prog [-c] [-t]", version="%prog 0.1") # NOSONAR

parser.add_option("-t", "--test file",
dest="testfile",
Expand Down
4 changes: 2 additions & 2 deletions autocertkit/testbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def get_vlans(self, iface):

def get_netconf(self):
"""Return the network config dictionary, as provided by the user"""
return eval(self.config['netconf']) # NOSONAR
return eval(self.config['netconf']) # NOSONAR

def singlenicmode(self):
return 'singlenic' in self.config.keys() and self.config['singlenic'] == 'true'
Expand Down Expand Up @@ -593,7 +593,7 @@ def _run_test(self, session):
# retrieve the logs
log.debug("%s test is complete, retrieving logs" % self.test)
self._call_plugin(session, vm_ref_list,
'retrieve_' + self.test + '_logs')
'retrieve_' + self.test + '_logs')

return {'info': 'Test ran successfully'}

Expand Down
9 changes: 6 additions & 3 deletions autocertkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,8 @@ def ping(vm_ip, dst_vm_ip, interface, packet_size=1400,


def ping_with_retry(session, vm_ref, mip, dst_vm_ip, interface, timeout=20, retry=15):
loss_re = re.compile(""".* (?P<loss>[0-9]+)% packet loss, .*""", re.S) # NOSONAR
loss_re = re.compile(
""".* (?P<loss>[0-9]+)% packet loss, .*""", re.S) # NOSONAR

cmd_str = "ping -I %s -w %d %s" % (interface, timeout, dst_vm_ip)
cmd = binascii.hexlify(cmd_str)
Expand Down Expand Up @@ -1851,7 +1852,8 @@ def init_ifs_ip_addressing(session, vm_ref, vifs_info):
device = "ethx%d" % id
mac, ip, netmask, gw = vif_info[1], vif_info[2], vif_info[3], vif_info[4]
if ip:
dev_info = {'iface': device, 'mac': mac, 'ip': ip, 'netmask': netmask, 'gw': gw}
dev_info = {'iface': device, 'mac': mac,
'ip': ip, 'netmask': netmask, 'gw': gw}
droid_add_static_ifcfg(session, host_ref, vm_ref, mip, dev_info)
else:
droid_add_dhcp_ifcfg(session, host_ref, vm_ref, mip, device, mac)
Expand Down Expand Up @@ -2641,7 +2643,8 @@ def get_ack_version(session, host=None):
try:
return call_ack_plugin(session, 'get_ack_version', {}, host=host)
except XenAPI.Failure, e:
log.debug("Failed to execute ack plugin call means ACK is not installed. Exception: %s" % str(e))
log.debug(
"Failed to execute ack plugin call means ACK is not installed. Exception: %s" % str(e))
return None


Expand Down

0 comments on commit ecd22c5

Please sign in to comment.