libvirt-cim-bounces@redhat.com wrote on 2008-10-07
15:52:49:
>
>
> yunguol@cn.ibm.com wrote:
> > # HG changeset patch
> > # User Guolian Yun <yunguol@cn.ibm.com>
> > # Date 1223348123 25200
> > # Node ID 617b6fb544d62f056f281e75c15d2fcbebe3dac0
> > # Parent 311bf6eda3786eb8e47ede06c4da6dc1570aff61
> > [TEST] #5 Fix HostedService - 03_forward_errs.py to work with
> sblim base provider installed
> >
> > Updats from 4 to 5:
> >
> > Using try_assoc() function to verify the exceptions for the associtations
> >
> > Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
> >
> > diff -r 311bf6eda378 -r 617b6fb544d6 suites/libvirt-
> cim/cimtest/HostedService/03_forward_errs.py
> > --- a/suites/libvirt-cim/cimtest/HostedService/03_forward_errs.py
> Sun Oct 05 23:56:40 2008 -0700
> > +++ b/suites/libvirt-cim/cimtest/HostedService/03_forward_errs.py
> Mon Oct 06 19:55:23 2008 -0700
> > @@ -25,6 +25,7 @@ from pywbem.cim_obj import CIMInstanceNa
> > from pywbem.cim_obj import CIMInstanceName
> > from XenKvmLib import assoc
> > from XenKvmLib import enumclass
> > +from XenKvmLib.common_util import get_host_info, try_assoc
> > from XenKvmLib.classes import get_typed_class
> > from CimTest.Globals import logger, CIM_ERROR_ENUMERATE,
CIM_USER, \
> >
CIM_PASS, CIM_NS
> > @@ -32,8 +33,12 @@ from CimTest.ReturnCodes import PASS, FA
> > from CimTest.ReturnCodes import PASS, FAIL, XFAIL
> >
> > sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
> > -exp_rc = 6 #CIM_ERR_NOT_FOUND
> > -exp_desc = "No such instance"
> > +exp_values = {
> > + "invalid_ccname"
: {"rc" : pywbem.CIM_ERR_NOT_FOUND, \
> > +
"desc"
: "No such instance
> (CreationClassName)"},
> >
> Wrap it to 80 columns.
> > + "invalid_name"
: {"rc" : pywbem.CIM_ERR_NOT_FOUND, \
> > +
"desc"
: "No such instance (Name)"}
> > + }
> >
> > @do_main(sup_types)
> > def main():
> > @@ -41,38 +46,31 @@ def main():
> > rc = -1
> > status = FAIL
> > keys = ['Name', 'CreationClassName']
> > - try:
> > - host_sys = enumclass.enumerate(options.ip,
'HostSystem',
> keys, options.virt)[0]
> > - except Exception:
> > - logger.error(CIM_ERROR_ENUMERATE
% host_sys.name)
> > + status, host_name, host_ccn = get_host_info(options.ip,
options.virt)
> > + if status != PASS:
> > + logger.error("Error in calling
get_host_info function")
> > return FAIL
> >
> >
> > conn = assoc.myWBEMConnection('http://%s'
% options.ip,
> >
(CIM_USER,
CIM_PASS),
> >
CIM_NS)
> > - instanceref = CIMInstanceName(get_typed_class(options.virt,
> "HostSystem"),
> > -
keybindings = {"Wrong"
:
> "wrong", "CreationClassName" : host_sys.CreationClassName})
> > + assoc_classname = get_typed_class(options.virt,
"HostedService")
> > + classname = get_typed_class(options.virt, "HostSystem")
> >
> Hard coding classanme to HostSystem will work only for non-sblim-
> base-provider case. what about the sblim-base-provider installed case
?
> get_typed_class(options.virt, "HostSystem") is not
required,
> host_ccn above gives you the value you are looking for.
>
> > +
> > + keys = {"Wrong" : host_name, "CreationClassName":
host_ccn}
> > + ret = try_assoc(conn, host_ccn, assoc_classname,
keys,
> "Name", exp_values['invalid_name'], bug_no="00007")
> >
> wrap it to 80 coulmns.
> > + if ret != PASS and host_ccn == classname:
> > + logger.error("------ FAILED:
Invalid Name Key Name.------")
> > + status = ret
> >
> > - names = []
> > + keys = {"Name" : host_name, "Wrong"
: host_ccn}
> > + ret = try_assoc(conn, host_ccn, assoc_classname,
keys,
> "CreationClassName", exp_values['invalid_ccname'], bug_no="00007")
> >
> wrap it to 80 coulmns.
> > + if ret != PASS and host_ccn == classname:
> > + logger.error("------ FAILED:
Invalid CreationClassName
> Key Name.------")
> > + status = ret
> >
> >
> This tc is returning false positive. Though ret is returning FAIL
the
> check host_ccn == classname returns false and hence the status is
not
> getting assigned appropriate value and the tc passes because of the
> previously assigned status value.
> We dont need to verify host_ccn == classname condition just verifying
> ret!=PASS is fine, any specific reason for doing it which I am missing
?
I update the tc, if ret!=PASS and host_ccn
= "Linux_ComputerSystem", it
return XFAIL, otherwise it has to return FAIL
without sblim-base provider installed.
Thanks!
> Also, here you need to return XFAIL for sblim-base-provider installed
> machine.
> You can return directly from the ret!=PASS check.
> > - try:
> > - names = conn.AssociatorNames(instanceref,
AssocClass =
> get_typed_class(options.virt, "HostedService"))
> > - rc = 0
> > - except pywbem.CIMError, (rc, desc):
> > - if rc == exp_rc and desc.find(exp_desc)
>= 0:
> > - logger.info("Got
excepted rc code and error string")
> > - status = PASS
> > - else:
> > - logger.error("Unexpected
rc code %s and description %
> s\n" %(rc, desc))
> > - except Exception, details:
> > - logger.error("Unknown exception
happened")
> > - logger.error(details)
> >
> > - if rc == 0:
> > - logger.error("HostedService
associator should NOT return
> excepted result with a wrong key name and value of HostSystem input")
> > - status = FAIL
> > -
> > return status
> >
> > if __name__ == "__main__":
> >
> > _______________________________________________
> > Libvirt-cim mailing list
> > Libvirt-cim@redhat.com
> > https://www.redhat.com/mailman/listinfo/libvirt-cim
> >
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim@redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim