[PATCH] [TEST]Fixing 01_netport.py tc failure

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1207835007 -19800 # Node ID 0b1dc112438b0362c88891c4a690fd92bf6ca628 # Parent 19ff9c851ed8cb76b74d158a4c439dfa5f4ccb50 [TEST]Fixing 01_netport.py tc failure. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 19ff9c851ed8 -r 0b1dc112438b suites/libvirt-cim/cimtest/NetworkPort/01_netport.py --- a/suites/libvirt-cim/cimtest/NetworkPort/01_netport.py Wed Apr 09 18:00:14 2008 +0530 +++ b/suites/libvirt-cim/cimtest/NetworkPort/01_netport.py Thu Apr 10 19:13:27 2008 +0530 @@ -51,6 +51,7 @@ def main(): def main(): options = main.options log_param() + status = PASS vsxml = get_class(options.virt)(test_dom, mac=test_mac) vsxml.define(options.ip) @@ -61,9 +62,7 @@ def main(): 'SystemName' : test_dom, 'SystemCreationClassName' : get_typed_class(options.virt, "ComputerSystem") } - dev = None - try: dev = eval('devices.' + get_typed_class(options.virt, "NetworkPort"))(options.ip, key_list) @@ -72,12 +71,10 @@ def main(): vsxml.undefine(options.ip) return XFAIL_RC(bug) - if dev == None: + if devid not in dev.DeviceID : logger.error("Error retrieving instance for devid %s" % devid) vsxml.undefine(options.ip) return FAIL - - status = PASS if dev.LinkTechnology != devices.LinkTechnology_Ethernet: logger.error("LinkTechnology should be set to `%i' instead of `%s'" % \ @@ -86,20 +83,17 @@ def main(): addrs = dev.NetworkAddresses if len(addrs) != 1: - logger.error("Too many NetworkAddress entries (%i instead of %i)" % \ - (len(addrs), 1)) + logger.error("Too many NetworkAddress entries (%i instead of %i)" % (len(addrs), 1)) status = FAIL if addrs[0] != test_mac: - logger.error("MAC address reported incorrectly (%s instead of %s)" % \ - (addrs[0], test_mac)) + logger.error("MAC address reported incorrectly (%s instead of %s)" % (addrs[0], test_mac)) status = FAIL if status == FAIL: logger.error("Checked interface %s" % test_mac) vsxml.undefine(options.ip) - return status if __name__ == "__main__":

- if dev == None: + if devid not in dev.DeviceID :
I checked in Daisy's fix for this, however it is probably a better check since we're looking for a specific device instance. However, instead of devid not in dev.DeviceID, I would use dev.DeviceID != devid. A DeviceID should be unique. If the provider returns "test_domain/procAndsomegarbage" and our devid is "test_domain/proc", we'd pass here. Due to similar logic, I should have rejected Daisy's patch - a mistake on my part.
logger.error("Error retrieving instance for devid %s" % devid) vsxml.undefine(options.ip) return FAIL - - status = PASS
if dev.LinkTechnology != devices.LinkTechnology_Ethernet: logger.error("LinkTechnology should be set to `%i' instead of `%s'" % \ @@ -86,20 +83,17 @@ def main():
addrs = dev.NetworkAddresses if len(addrs) != 1: - logger.error("Too many NetworkAddress entries (%i instead of %i)" % \ - (len(addrs), 1)) + logger.error("Too many NetworkAddress entries (%i instead of %i)" % (len(addrs), 1))
This line and the next end up spanning 80 characters long. The libvirt-cim convention is 80 character lines. Even though we don't follow their convention, I like the idea of shorter line lengths. This helps prevent text from running into the next line - helps with readability. You can do the following without in python (I believe): logger.error("Too many NetworkAddress entries (%i instead of %i)" % (len(addrs), 1)) -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
- if dev == None: + if devid not in dev.DeviceID :
I checked in Daisy's fix for this, however it is probably a better check since we're looking for a specific device instance.
However, instead of devid not in dev.DeviceID, I would use dev.DeviceID != devid. A DeviceID should be unique. If the provider returns "test_domain/procAndsomegarbage" and our devid is "test_domain/proc", we'd pass here.
Sorry , my mistake.
Due to similar logic, I should have rejected Daisy's patch - a mistake on my part.
logger.error("Error retrieving instance for devid %s" % devid) vsxml.undefine(options.ip) return FAIL - - status = PASS if dev.LinkTechnology != devices.LinkTechnology_Ethernet: logger.error("LinkTechnology should be set to `%i' instead of `%s'" % \ @@ -86,20 +83,17 @@ def main():
addrs = dev.NetworkAddresses if len(addrs) != 1: - logger.error("Too many NetworkAddress entries (%i instead of %i)" % \ - (len(addrs), 1)) + logger.error("Too many NetworkAddress entries (%i instead of %i)" % (len(addrs), 1))
This line and the next end up spanning 80 characters long. The libvirt-cim convention is 80 character lines. Even though we don't follow their convention, I like the idea of shorter line lengths. This helps prevent text from running into the next line - helps with readability. You can do the following without in python (I believe):
logger.error("Too many NetworkAddress entries (%i instead of %i)" % (len(addrs), 1))
I usually run pylint on the tc before submitting them and the pylint config file has the max-line-length set to 90. Do you want it to be 80 ?

This line and the next end up spanning 80 characters long. The libvirt-cim convention is 80 character lines. Even though we don't follow their convention, I like the idea of shorter line lengths. This helps prevent text from running into the next line - helps with readability. You can do the following without in python (I believe):
logger.error("Too many NetworkAddress entries (%i instead of %i)" % (len(addrs), 1))
I usually run pylint on the tc before submitting them and the pylint config file has the max-line-length set to 90. Do you want it to be 80 ?
Yes, if you are using a pylint config, then setting a max line length of 80 would be great. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> This line and the next end up spanning 80 characters long. The KR> libvirt-cim convention is 80 character lines. Even though we KR> don't follow their convention, I like the idea of shorter line KR> lengths. This helps prevent text from running into the next line KR> - helps with readability. +1.5. The whitespace in many parts of cimtest really hurts my eyes :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

"Deepti B. Kalakeri" <deeptik@linux.vn To et.ibm.com> libvirt-cim@redhat.com Sent by: cc libvirt-cim-bounc es@redhat.com Subject [Libvirt-cim] [PATCH] [TEST]Fixing 01_netport.py tc failure 2008-04-10 21:44 Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redh at.com> # HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1207835007 -19800 # Node ID 0b1dc112438b0362c88891c4a690fd92bf6ca628 # Parent 19ff9c851ed8cb76b74d158a4c439dfa5f4ccb50 [TEST]Fixing 01_netport.py tc failure. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 19ff9c851ed8 -r 0b1dc112438b suites/libvirt-cim/cimtest/NetworkPort/01_netport.py --- a/suites/libvirt-cim/cimtest/NetworkPort/01_netport.py Wed Apr 09 18:00:14 2008 +0530 +++ b/suites/libvirt-cim/cimtest/NetworkPort/01_netport.py Thu Apr 10 19:13:27 2008 +0530 @@ -51,6 +51,7 @@ def main(): def main(): options = main.options log_param() + status = PASS vsxml = get_class(options.virt)(test_dom, mac=test_mac) vsxml.define(options.ip) @@ -61,9 +62,7 @@ def main(): 'SystemName' : test_dom, 'SystemCreationClassName' : get_typed_class(options.virt, "ComputerSystem") } - dev = None - try: dev = eval('devices.' + get_typed_class(options.virt, "NetworkPort"))(options.ip, key_list) @@ -72,12 +71,10 @@ def main(): vsxml.undefine(options.ip) return XFAIL_RC(bug) - if dev == None: + if devid not in dev.DeviceID : logger.error("Error retrieving instance for devid %s" % devid) vsxml.undefine(options.ip) return FAIL - - status = PASS if dev.LinkTechnology != devices.LinkTechnology_Ethernet: logger.error("LinkTechnology should be set to `%i' instead of `%s'" % \ @@ -86,20 +83,17 @@ def main(): addrs = dev.NetworkAddresses if len(addrs) != 1: - logger.error("Too many NetworkAddress entries (%i instead of %i)" % \ - (len(addrs), 1)) + logger.error("Too many NetworkAddress entries (%i instead of %i)" % (len(addrs), 1)) status = FAIL if addrs[0] != test_mac: - logger.error("MAC address reported incorrectly (%s instead of %s)" % \ - (addrs[0], test_mac)) + logger.error("MAC address reported incorrectly (%s instead of %s)" % (addrs[0], test_mac)) status = FAIL if status == FAIL: logger.error("Checked interface %s" % test_mac) vsxml.undefine(options.ip) - return status if __name__ == "__main__": +1 from me. _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (5)
-
Dan Smith
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Guo Lian Yun
-
Kaitlin Rupert