From: <mik...@us...> - 2008-08-19 23:49:12
|
Revision: 872 http://omc.svn.sourceforge.net/omc/?rev=872&view=rev Author: mike-brasher Date: 2008-08-19 23:49:21 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Expanded profile tests to find all associators associated through profile related classes. Modified Paths: -------------- cmpiprofiles/test/trunk/ProfileTest.py Added Paths: ----------- cmpiprofiles/test/trunk/Makefile Added: cmpiprofiles/test/trunk/Makefile =================================================================== --- cmpiprofiles/test/trunk/Makefile (rev 0) +++ cmpiprofiles/test/trunk/Makefile 2008-08-19 23:49:21 UTC (rev 872) @@ -0,0 +1,17 @@ + +help: + @ echo "targets: all sanity profiles" + +all: sanity profiles + +sanity: + ./AllSanityTest.py --url=http://localhost + +URL=http://localhost + +profiles: + @ ./ProfileTest.py --url $(URL) Linux_EthernetPort Linux_EthernetPortRegisteredProfile + @ ./ProfileTest.py --url $(URL) Linux_BootService Linux_BootRegisteredProfile + @ ./ProfileTest.py --url $(URL) Linux_SSHProtocolService Linux_SSHRegisteredProfile + @ ./ProfileTest.py --url $(URL) Linux_Fan Linux_FanRegisteredProfile + @ ./ProfileTest.py --url $(URL) Linux_PowerSupply Linux_PowerSupplyRegisteredProfile Modified: cmpiprofiles/test/trunk/ProfileTest.py =================================================================== --- cmpiprofiles/test/trunk/ProfileTest.py 2008-08-19 22:16:16 UTC (rev 871) +++ cmpiprofiles/test/trunk/ProfileTest.py 2008-08-19 23:49:21 UTC (rev 872) @@ -43,31 +43,72 @@ globalParser=p # Get centralClassName argument: - if (len(arguments) == 0): - print "missing central class argument\n" + if len(arguments) != 2: + print "error: need centrl-class registered-profile-class args\n" sys.exit(1) centralClassName = arguments[0]; + registeredProfileClassName = arguments[1]; + print ">>>> Now Testing Profile: [%s]" %(centralClassName) + # Create connection. c = wbem_connection.WBEMConnFromOptions(p) - # For each instance of the central class. + # Find instances of the central class. + names = c.EnumerateInstanceNames(centralClassName) if len(names) == 0: print "no instances of the central class found: %s" %(centralClassName) sys.exit(1) - # Each instance of central class must have exactly one associator of type - # CIM_Registered profile. + # For each instance of central class be sure there is exactly one + # RegisteredProfile instance (associated through ElementConformsToProfile). for name in names: inst = c.GetInstance(name) - assocs = c.Associators(name, AssocClass='CIM_ElementConformsToProfile') + # Find associators through ElementConformsToProfile. + + assocs = c.AssociatorNames( \ + name, AssocClass='CIM_ElementConformsToProfile') + if len(assocs) != 1: print "error: expected instance of central class to have 1 " \ "associator through CIM_ElementConformsToProfile but found %d" \ %(len(assocs)) sys.exit(1) + + # Get RegisteredProfile instance. + + assoc = assocs[0] + inst = c.GetInstance(assocs[0]) + + if inst.classname != registeredProfileClassName: + print "expected registered profile classname to be %s but got %s" \ + %(registeredProfileClassName, inst.classname) + sys.exit(1) + + # Be sure there is an association between RegisteredProfile instance + # and ComputerSystem through ReferenceProfile. + # [RegisteredProfile<-ReferenceProfile->ComputerSystem] + + assocs = c.AssociatorNames( \ + assoc, AssocClass='CIM_ReferencedProfile') + + if len(assocs) != 1: + print "error: expected instance of registered profile to have 1 " \ + "associator through CIM_ReferencedProfile but found %d" \ + %(len(assocs)) + sys.exit(1) + + # Expect CIM_RegisteredProfile.InstanceID='SBLIM:Base_Computer' + # associator. + + assoc = assocs[0] + + if assoc['InstanceID'] != 'SBLIM:Base_Computer': + print "expected " \ + "CIM_RegisteredProfile.InstanceID='SBLIM:Base_Computer'" + sys.exit(1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |