[PATCH] [TEST] Fixing 01_forward.py tc of SystemDevice

# HG changeset patch # User Deepti B. Kalakeri<deeptik@linux.vnet.ibm.com> # Date 1225568161 25200 # Node ID e92fbb2fe87e11509a5d506f4529368f97ee59cd # Parent d1614c101c281b57bd2bc98dfb6625f790748e54 [TEST] Fixing 01_forward.py tc of SystemDevice. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r d1614c101c28 -r e92fbb2fe87e suites/libvirt-cim/cimtest/SystemDevice/01_forward.py --- a/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py Wed Oct 29 20:11:47 2008 -0700 +++ b/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py Sat Nov 01 12:36:01 2008 -0700 @@ -28,7 +28,6 @@ from VirtLib import utils from XenKvmLib import assoc from XenKvmLib import vxml -from XenKvmLib import devices from XenKvmLib.classes import get_typed_class from CimTest.Globals import logger from XenKvmLib.const import do_main @@ -54,7 +53,8 @@ if options.virt == 'LXC': cxml = virt_xml(test_dom) else: - cxml = virt_xml(test_dom, vcpus = test_cpu, mac = test_mac, disk = test_disk) + cxml = virt_xml(test_dom, vcpus = test_cpu, mac = test_mac, + disk = test_disk) ret = cxml.create(options.ip) if not ret: logger.error('Unable to create domain %s' % test_dom) @@ -67,39 +67,36 @@ Name=test_dom, CreationClassName=cs_classname) if devs == None: logger.error("System association failed") - return FAIL - elif len(devs) == 0: - logger.error("No devices returned") + cxml.destroy(options.ip) + cxml.undefine(options.ip) return FAIL + if len(devs) == 0: + logger.error("No devices returned") + cxml.destroy(options.ip) + cxml.undefine(options.ip) + return FAIL + + net_cn = get_typed_class(options.virt, "NetworkPort") + mem_cn = get_typed_class(options.virt, "Memory") + disk_cn = get_typed_class(options.virt, "LogicalDisk") + proc_cn = get_typed_class(options.virt, "Processor") cn_devid = { - get_typed_class(options.virt, "NetworkPort") : '%s/%s' % (test_dom, test_mac), - get_typed_class(options.virt, "Memory") : '%s/mem' % test_dom, - get_typed_class(options.virt, "LogicalDisk") : '%s/%s' % (test_dom, test_disk), - get_typed_class(options.virt, "Processor") : '%s/%s' % (test_dom, test_cpu-1) - } + net_cn : '%s/%s' % (test_dom, test_mac), + mem_cn : '%s/mem' % test_dom, + disk_cn : '%s/%s' % (test_dom, test_disk), + proc_cn : '%s/%s' % (test_dom, test_cpu-1) + } - key_list = {'DeviceID' : '', - 'CreationClassName' : '', - 'SystemName' : test_dom, - 'SystemCreationClassname' : cs_classname - } - - for dev_cn in cn_devid.keys(): - for dev in devs: - key_list['CreationClassName'] = dev['CreationClassname'] - key_list['DeviceID'] = dev['DeviceID'] - device = devices.device_of(options.ip, key_list) - if device.CreationClassName != dev_cn: - continue - devid = device.DeviceID - - _devid = cn_devid[dev_cn] - if devid != _devid: - logger.error("DeviceID `%s` != `%s'" % (devid, _devid)) - status = FAIL - else: - logger.info("Examined %s" % _devid) + for dev in devs: + dev_cn = dev['CreationClassname'] + devid = dev['DeviceID'] + _devid = cn_devid[dev_cn] + if devid != _devid: + logger.error("DeviceID `%s` != `%s'" % (devid, _devid)) + status = FAIL + else: + logger.info("Examined %s" % _devid) cxml.destroy(options.ip) cxml.undefine(options.ip)

Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri<deeptik@linux.vnet.ibm.com> # Date 1225568161 25200 # Node ID e92fbb2fe87e11509a5d506f4529368f97ee59cd # Parent d1614c101c281b57bd2bc98dfb6625f790748e54 [TEST] Fixing 01_forward.py tc of SystemDevice.
Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com>
diff -r d1614c101c28 -r e92fbb2fe87e suites/libvirt-cim/cimtest/SystemDevice/01_forward.py
This loop doesn't verify we got back the instances expected. If we get only 3 instances back, but we expected 4, then we should return an error. Although, we need to check more than the numbers of instances returned. If we get 1 proc inst, 2 net instances when we expected 1 proc, 1 net, and 1 mem inst - we should return an error.
+ for dev in devs: + dev_cn = dev['CreationClassname'] + devid = dev['DeviceID'] + _devid = cn_devid[dev_cn] + if devid != _devid: + logger.error("DeviceID `%s` != `%s'" % (devid, _devid)) + status = FAIL
If the test encounters an error, the test should break from the loop.
+ else: + logger.info("Examined %s" % _devid)
I don't think logging we ids we examined is important. Instead, there should be some kind of check as mentioned above.
cxml.destroy(options.ip) cxml.undefine(options.ip)
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri<deeptik@linux.vnet.ibm.com> # Date 1225568161 25200 # Node ID e92fbb2fe87e11509a5d506f4529368f97ee59cd # Parent d1614c101c281b57bd2bc98dfb6625f790748e54 [TEST] Fixing 01_forward.py tc of SystemDevice.
Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com>
diff -r d1614c101c28 -r e92fbb2fe87e suites/libvirt-cim/cimtest/SystemDevice/01_forward.py
This loop doesn't verify we got back the instances expected. If we get only 3 instances back, but we expected 4, then we should return an error.
Although, we need to check more than the numbers of instances returned. If we get 1 proc inst, 2 net instances when we expected 1 proc, 1 net, and 1 mem inst - we should return an error.
Thats very good points , patch with changes submitted.
+ for dev in devs: + dev_cn = dev['CreationClassname'] + devid = dev['DeviceID'] + _devid = cn_devid[dev_cn] + if devid != _devid: + logger.error("DeviceID `%s` != `%s'" % (devid, _devid)) + status = FAIL
If the test encounters an error, the test should break from the loop.
+ else: + logger.info("Examined %s" % _devid)
I don't think logging we ids we examined is important. Instead, there should be some kind of check as mentioned above.
cxml.destroy(options.ip) cxml.undefine(options.ip)
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert