|
From: <mat...@us...> - 2007-12-17 22:35:36
|
Revision: 513
http://omc.svn.sourceforge.net/omc/?rev=513&view=rev
Author: mattvryan
Date: 2007-12-17 14:35:21 -0800 (Mon, 17 Dec 2007)
Log Message:
-----------
Added tests for OMC_UnitaryComputerSystem and related.
Modified Paths:
--------------
test/trunk/omcbase_test.py
Modified: test/trunk/omcbase_test.py
===================================================================
--- test/trunk/omcbase_test.py 2007-12-15 06:55:03 UTC (rev 512)
+++ test/trunk/omcbase_test.py 2007-12-17 22:35:21 UTC (rev 513)
@@ -5,6 +5,9 @@
import pywbem
import os
+from time import sleep
+from socket import getfqdn
+
_globalVerbose = False
_globalNamespace = 'root/cimv2'
@@ -112,17 +115,201 @@
def _omc_initdservicerunlevel_test(self):
pass
+ def _omc_unitarycomputersystem_test(self):
+ hostname = getfqdn()
+
+ insts = self._conn.EnumerateInstances('OMC_UnitaryComputerSystem', LocalOnly=False)
+ if 1 < len(insts):
+ self.fail('More than one OMC_UnitaryComputerSystem instance returned from EnumerateInstances')
+ if insts[0]['name'] != hostname:
+ self.fail('EnumerateInstances on OMC_UnitaryComputerSystem returned different instance than expected')
+
+ insts = self._conn.EnumerateInstanceNames('OMC_UnitaryComputerSystem')
+ if 1 < len(insts):
+ self.fail('More than one OMC_UnitaryComputerSystem instance returned from EnumerateInstanceNames')
+ if insts[0]['name'] != hostname:
+ self.fail('EnumerateInstanceNames on OMC_UnitaryComputerSystem returned different instance name than expected')
+
+ inst = self._conn.GetInstance(insts[0], LocalOnly=False)
+ if inst is None:
+ self.fail('Failed to GetInstance of OMC_UnitaryComputerSystem using %s' % insts[0])
+ if inst['name'] != hostname:
+ self.fail('GetInstance on OMC_UnitaryComputerSystem returned different instance than expected')
+
+ try:
+ self._conn.DeleteInstance(insts[0])
+ self.fail('DeleteInstance of OMC_UnitaryComputerSystem succeeded when it should have failed')
+ except pywbem.CIMError, ce:
+ if ce[0] != 7:
+ self.fail('Exception on DeleteInstance of OMC_UnitaryComputerSystem was not "Not Supported" as expected')
+ pass
+
+ try:
+ caption = 'Caption1'
+ if inst['Caption'] == caption:
+ caption = 'Caption2'
+ inst['Caption'] = caption
+ self._conn.ModifyInstance(inst)
+ insts = self._conn.EnumerateInstances('OMC_UnitaryComputerSystem', LocalOnly=False)
+ if insts[0]['Caption'] != caption:
+ self.fail('Attempt to ModifyInstance of OMC_UnitaryComputerSystem failed')
+ except pywbem.CIMError, ce:
+ self.fail('ModifyInstance of OMC_UnitaryComputerSystem failed')
+
+ try:
+ inst = pywbem.CIMInstance('OMC_UnitaryComputerSystem',
+ properties={'CreationClassName' : 'OMC_UnitaryComputerSystem',
+ 'Name':getfqdn()})
+ self._conn.CreateInstance(inst)
+ self.fail('CreateInstance of OMC_UnitaryComputerSystem succeeded when it should have failed')
+ except pywbem.CIMError, ce:
+ if ce[0] != 7:
+ # Should be 7, not supported.
+ self.fail('Exception on CreateInstance of OMC_UnitaryComputerSystem was not "Not Supported" as expected')
+
+ def _omc_hostnamesettingdata_test(self):
+ hostname = getfqdn()
+
+ insts = self._conn.EnumerateInstances('OMC_HostNameSettingData', LocalOnly=False)
+ if 1 < len(insts):
+ self.fail('More than one instance of OMC_HostNameSettingData returned from EnumerateInstances')
+ if insts[0]['ComputerName'] != hostname:
+ self.fail('EnumerateInstances on OMC_HostNameSettingData returned different instance than expected')
+
+ insts = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData')
+ if 1 < len(insts):
+ self.fail('More than one instance name of OMC_HostNameSettingData returned from EnumerateInstanceNames')
+ if insts[0]['InstanceID'] != 'omc:computername':
+ self.fail('EnumerateInstanceNames on OMC_HostNameSettingData returned different instance name than expected')
+
+ inst = self._conn.GetInstance(insts[0], LocalOnly=False)
+ if inst is None:
+ self.fail('Failed to GetInstance of OMC_HostNameSettingData using %s' % insts[0])
+ if inst['ComputerName'] != hostname:
+ self.fail('GetInstance of OMC_HostNameSettingData returned different instance than expected')
+
+ try:
+ self._conn.DeleteInstance(insts[0])
+ self.fail('DeleteInstance of OMC_HostNameSettingData succeeded when it should have failed')
+ except pywbem.CIMError, ce:
+ if ce[0] != 7:
+ # Should be 7, not supported.
+ self.fail('Exception on DeleteInstance of OMC_HostNameSettingData was not "Not Supported" as expected')
+
+ try:
+ elems = hostname.split('.')
+ for elem in elems:
+ if elem == elems[0]:
+ newhostname = 'fakehostname'
+ else:
+ newhostname = newhostname + '.' + elem
+ inst['ComputerName'] = newhostname
+ self._conn.ModifyInstance(inst)
+ insts = self._conn.EnumerateInstances('OMC_HostNameSettingData', LocalOnly=False)
+ failmsg = None
+ if insts[0]['ComputerName'] != newhostname:
+ failmsg = 'Attempt to ModifyInstance of OMC_HostNameSettingData failed'
+ self._dbgPrint('Modified ComputerName of OMC_HostNameSettingData instance, awaiting serialization')
+ ctr = 0
+ while ctr < 100 and newhostname != getfqdn():
+ sleep(1)
+ ctr = ctr + 1
+ if newhostname != getfqdn():
+ failmsg = 'ModifyInstance of OMC_HostNameSettingData successful but hostname not modified on system'
+ else:
+ # Should get here always; try to set the name back to the original
+ self._dbgPrint('New host name setting now applied: %s' % getfqdn())
+ inst['ComputerName'] = hostname
+ self._conn.ModifyInstance(inst)
+ ctr = 0
+ self._dbgPrint('Restored ComputerName of OMC_HostNameSettingData instance, awaiting serialization')
+ while ctr < 100 and hostname != getfqdn():
+ sleep(1)
+ ctr = ctr + 1
+ self._dbgPrint('Previous host name setting now applied: %s' % getfqdn())
+ if failmsg is not None:
+ self.fail(failmsg)
+ except pywbem.CIMError:
+ self.fail('ModifyInstance of OMC_HostNameSettingData failed')
+
+ try:
+ inst = pywbem.CIMInstance('OMC_HostNameSettingData',
+ properties={'InstanceID' : 'omc:computername2',
+ 'ComputerName':getfqdn()})
+ self._conn.CreateInstance(inst)
+ self.fail('CreateInstance of OMC_HostNameSettingData succeeded when it should have failed')
+ except pywbem.CIMError, ce:
+ if ce[0] != 7:
+ # Should be 7, not supported.
+ self.fail('Exception on CreateInstance of OMC_HostNameSettingData was not "Not Supported" as expected')
+
+ def _omc_computersystemhostnamesettingdata_test(self):
+ ucs_op = self._conn.EnumerateInstanceNames('OMC_UnitaryComputerSystem')[0]
+ hnsd_op = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData')[0]
+ insts = self._conn.EnumerateInstances('OMC_ComputerSystemHostNameSettingData', LocalOnly=False)
+ if 1 < len(insts):
+ self.fail('EnumerateInstances of OMC_ComputerSystemHostNameSettingData returned multiple instances when only one was expected')
+ if insts[0]['ManagedElement'] != ucs_op:
+ self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid')
+ if insts[0]['SettingData'] != hnsd_op:
+ self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid')
+
+ insts = self._conn.EnumerateInstanceNames('OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(insts):
+ self.fail('EnumerateInstanceNames of OMC_ComputerSystemHostNameSettingData returned multiple instance names when only one was expected')
+ if insts[0]['ManagedElement'] != ucs_op:
+ self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid')
+ if insts[0]['SettingData'] != hnsd_op:
+ self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid')
+
+ refs = self._conn.References(ucs_op, ResultClass='OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(refs):
+ self.fail('References of OMC_UnitaryComputersystem returned multiple instances when only one was expected')
+ if refs[0]['ManagedElement'] != ucs_op:
+ self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid')
+ if refs[0]['SettingData'] != hnsd_op:
+ self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid')
+
+ refs = self._conn.References(hnsd_op, ResultClass='OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(refs):
+ self.fail('References of OMC_HostNameSettingData returned multiple instances when only one was expected')
+ if refs[0]['ManagedElement'] != ucs_op:
+ self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid')
+ if refs[0]['SettingData'] != hnsd_op:
+ self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid')
+
+ assocs = self._conn.AssociatorNames(ucs_op, AssocClass='OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(assocs):
+ self.fail('AssociatorNames of OMC_UnitaryComputerSystem returned multiple instances when only one was expected')
+ qualified_hnsd_op = str(hnsd_op)
+ if not qualified_hnsd_op.startswith('//%s/' % getfqdn()):
+ qualified_hnsd_op = '//%s/%s' % (getfqdn(), str(hnsd_op))
+ if str(assocs[0]) != qualified_hnsd_op:
+ self.fail('AssociatorNames for %s is not valid' % ucs_op)
+
+ assocs = self._conn.AssociatorNames(hnsd_op, AssocClass='OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(assocs):
+ self.fail('AssociatorNames of OMC_HostNameSettingData returned multiple instances when only one was expected')
+ qualified_ucs_op = str(ucs_op)
+ if not qualified_ucs_op.startswith('//%s/' % getfqdn()):
+ qualified_ucs_op = '//%s/%s' % (getfqdn(), str(ucs_op))
+ if str(assocs[0]) != qualified_ucs_op:
+ self.fail('AssociatorNames for %s is not valid' % hnsd_op)
+
+ def _run_omcbase_component_tests(self, testname, testmap):
+ for classname in testmap.keys():
+ if not self._isClassSupported(classname):
+ self._showMissingclassNotice(classname, testname)
+ else:
+ testmap[classname]()
+
def test_initd(self):
initdClasses = {'OMC_InitdService' : self._omc_initdservice_test,
'OMC_Runlevel' : self._omc_runlevel_test,
'OMC_HostedInitdService' : self._omc_hostedinitdservice_test,
'OMC_RunlevelInComputerSystem' : self._omc_runlevelincomputersystem_test,
'OMC_InitdServiceRunLevel' : self._omc_initdservicerunlevel_test}
- for classname in initdClasses.keys():
- if not self._isClassSupported(classname):
- self._showMissingClassNotice(classname, 'initd')
- else:
- initdClasses[classname]()
+ self._run_omcbase_component_tests('initd', initdClasses)
def test_syslogd(self):
pass
@@ -134,7 +321,11 @@
pass
def test_unitary_computer_system(self):
- pass
+ ucsClasses = {'OMC_UnitaryComputerSystem' : self._omc_unitarycomputersystem_test,
+ 'OMC_HostNameSettingData' : self._omc_hostnamesettingdata_test,
+ 'OMC_ComputerSystemHostNameSettingData' : self._omc_computersystemhostnamesettingdata_test}
+ self._run_omcbase_component_tests('unitary_computer_system', ucsClasses)
+
def test_unix_process(self):
pass
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kwo...@us...> - 2007-12-21 20:56:39
|
Revision: 525
http://omc.svn.sourceforge.net/omc/?rev=525&view=rev
Author: kwoodson
Date: 2007-12-21 12:56:40 -0800 (Fri, 21 Dec 2007)
Log Message:
-----------
Updated tests but still needs work
Modified Paths:
--------------
test/trunk/omcbase_test.py
Modified: test/trunk/omcbase_test.py
===================================================================
--- test/trunk/omcbase_test.py 2007-12-21 20:37:06 UTC (rev 524)
+++ test/trunk/omcbase_test.py 2007-12-21 20:56:40 UTC (rev 525)
@@ -4,7 +4,9 @@
import optparse
import pywbem
import os
+import commands
+from lib import ProviderSanityTest as PST
from time import sleep
from socket import getfqdn
@@ -55,6 +57,20 @@
print('\t -- %s --' % msg)
else:
print('')
+
+ def _sanity_check(self, type, classname):
+ try:
+ print self._conn.default_namespace
+ if type == 'instance':
+ PST.instance_sanity_check(self, self._conn,
+ classname,
+ self._verbose)
+ else:
+ PST.association_sanity_check(self, self._conn,
+ classname,
+ self._verbose)
+ except:
+ raise
def _showMissingClassNotice(self, classname, testname):
self._dbgPrint("NOTICE: Skipping all %s tests for test %s: Class not loaded." % (classname, testname))
@@ -312,13 +328,47 @@
self._run_omcbase_component_tests('initd', initdClasses)
def test_syslogd(self):
+ #TODO
+ #FILL IN SYSLOGD test
pass
def test_logical_file(self):
- pass
+ '''OMC_LogicalFile'''
+ try:
+ #TODO Traverse a folder on filesystem and retrieve all of the
+ #LinuxDataFiles
+ #Get through GetInstance using keybindings since they are
+ #non-enumerable
+ #self._conn.GetInstance("OMC_LinuxdataFile")
+ pass
+ except pywbem.CIMError, arg:
+ raise
def test_operating_system(self):
- pass
+ '''OMC_OperatingSystem'''
+ if self._isSupportedAssn('OMC_OperatingSystem',
+ 'OMC_InstalledOS',
+ 'OMC_OSProcess',
+ 'os_test'):
+ os_classes = { 'OMC_InstalledOS': _omc_installed_os,
+ 'OMC_OSProcess': _omc_os_process }
+
+ #TODO Finish Filling out OMC_OperatingSystem
+ try:
+
+ os_list = self._conn.EnumerateInstanceNames("OMC_OperatingSystem")
+ self.failUnless(os_list > 0, \
+ "No instances of OperatingSystem returned")
+
+
+ os_list = self._conn.EnumerateInstances("OMC_OperatingSystem")
+ self.failUnless(os_list > 0, \
+ "No instances of OperatingSystem returned")
+
+ except pywbem.CIMError, arg:
+ raise
+ else:
+ self.fail("OMC_OperatingSystem _isSupportedAssn failed")
def test_unitary_computer_system(self):
ucsClasses = {'OMC_UnitaryComputerSystem' : self._omc_unitarycomputersystem_test,
@@ -326,13 +376,251 @@
'OMC_ComputerSystemHostNameSettingData' : self._omc_computersystemhostnamesettingdata_test}
self._run_omcbase_component_tests('unitary_computer_system', ucsClasses)
+ def _omc_process_executable(self):
+ '''OMC_ProcessExecutable'''
+ try:
+ #Can't do these because of OMC_LinuxDataFile is non-enumerable
+ print "OMC_ProcessExecutable"
+ self._sanity_check(type="association", \
+ classname="OMC_ProcessExecutable")
+ except pywbem.CIMError, arg:
+ raise
+ def _omc_os_process(self):
+ '''OMC_OSProcess'''
+ try:
+ #Can't do these because of OMC_LinuxDataFile is non-enumerable
+ print "OMC_OSProcess"
+ self._sanity_check(type="association", \
+ classname="OMC_OSProcess")
+ except pywbem.CIMError, arg:
+ raise
+
def test_unix_process(self):
- pass
+ '''UnixProcess'''
+ #process_classes = {
+ # 'OMC_ProcessExecutable': self._omc_process_executable,
+ # 'OMC_OSProcess': self._omc_os_process }
+
+ #for classname in process_classes.keys():
+ # if not self._isClassSupported(classname):
+ # #print "Not supported: %s"%str(classname)
+ # self._showMissingClassNotice(classname, 'process_test')
+ # else:
+ # #print "Calling: %s..."%str(time_classes[classname])
+ # process_classes[classname]()
+ #TODO Fill out OMC_UnixProcess
+ try:
+
+ cim_procs = self._conn.EnumerateInstances("OMC_UnixProcess")
+
+ procs = commands.getoutput("ls -d /proc/[0-9]*").split()
+
+ self.failUnless(procs or len(procs) < 1 or len(cim_procs) < 1 or\
+ cim_procs, "No processes returned")
+
+ self.failUnless(len(cim_procs) == len(procs)-1, \
+ "Returned a different number of processes")
+
+ proc_nums = {}
+ ci_proc = []
+ failed = []
+ for proc in procs:
+ proc_nums[proc[6:]]=proc
+ for proc in cim_procs:
+ ci_proc.append(proc['handle'])
+ print proc_nums
+ #Check the PID with cim_instance['handle']
+ for proc in proc_nums.keys():
+ if proc not in ci_proc:
+ failed.append(proc)
+
+ print "failed=",failed
+ #print "percentage=%s"%str(len(failed)/len(cim_procs))
+ print "proc_nums",proc_nums
+
+ for fail in failed:#Getting rid of the 'ls' process
+ del(proc_nums[fail])
+ for ci in cim_procs:#Check that ci['ModulePath'] is correct
+ #print "Checking ModulePath is not none"
+ #print ci['handle']
+ if ci['ModulePath'] and ci['ModulePath'] is not None:
+ path = proc_nums[ci['handle']]
+ #print "ci=",ci['ModulePath']
+ #print "link=",os.readlink(os.path.join(path,"exe"))
+ self.failUnless(ci['ModulePath'] == os.readlink(\
+ os.path.join(path, "exe")), \
+ "ModulePath is incorrect for %s"%str(ci['ModulePath']))
+
+ #TODO
+ #Fill in the following methods
+ #SendSignal
+ #RequestStateChange
+ #KillAll
+
+ except pywbem.CIMError, arg:
+ raise
+
+
+ def _omc_system_time_service(self):
+ '''SystemTimeService Test'''
+ try:
+
+ self._sanity_check(type="association",
+ classname="OMC_SystemTimeService")
+
+ ci = pywbem.CIMInstance("OMC_SystemTimeService")
+ ci['CreationClassName'] = "OMC_SystemTimeService"
+ ci['Name'] = "timeservice_test"
+ ci['SystemCreationClassName'] = "OMC_UnitaryComputerSystem"
+ ci['SystemName'] = "c119.cim.lab.novell.com"
+ ci['AvailableRequestedState'] = [ pywbem.Uint16(2) ]
+ ci['Caption'] = 'test'
+ ci['Description'] = 'test system time service'
+ ci['EnabledDefault'] = pywbem.Uint16(2)
+ ci['EnabledState'] = pywbem.Uint16(2)
+ ci['HealthState'] = pywbem.Uint16(5)
+ ci['StartMode'] = "Automatic"
+ ci['Started'] = True
+ ci['Status'] = "Ok"
+
+ try:
+ ci.path = self._conn.CreateInstance(ci)
+ self.fail("Created Instance when it was supposed to fail")
+ except pywbem.CIMError, arg:
+ #Should fail
+ self.failUnless(pywbem.CIM_ERR_NOT_SUPPORTED == arg[0],\
+ "Unknown Exception: %s"%str(arg))
+ try:
+ sts_list = self._conn.EnumerateInstanceNames(\
+ "OMC_SystemTimeService")
+ self.failUnless(len(sts_list)==1, \
+ "EnumInstNames: OMC_SystemTimeService: No instance returned")
+ ci_name = sts_list[0]
+ try:
+ self._conn.DeleteInstance(ci_name)
+ self.fail("Deleted Instance when it was supposed to fail")
+ except pywbem.CIMError, arg:
+ #Should fail
+ self.failUnless(pywbem.CIM_ERR_NOT_SUPPORTED == arg[0], \
+ "Unknown Exception: %s"%str(arg))
+ except pywbem.CIMError, arg:
+ raise
+ #ManageSystemTime
+ #SetTime/GetTime
+ c_time = pywbem.CIMDateTime.now()
+ test_time=pywbem.CIMDateTime('20121218141923.690382-420')
+ self._conn.InvokeMethod("ManageSystemTime", \
+ "OMC_SystemTimeService", \
+ GetRequest=False, TimeData=test_time.datetime)
+
+ mst_time = self._conn.InvokeMethod("ManageSystemTime", \
+ "OMC_SystemTimeService", \
+ GetRequest=True)
+ delta = mst_time[1]['TimeData'].datetime - test_time.datetime
+ self.failUnless(delta.days == 0, \
+ "ManageSystemTime: Time returned is incorrect")
+ self.failUnless(delta.seconds < _epsilon, \
+ "ManageSystemTime: Time returned is incorrect")
+
+ self._conn.InvokeMethod("ManageSystemTime", \
+ "OMC_SystemTimeService", \
+ GetRequest=False, TimeData=c_time.datetime)
+ #StartService
+ #StopService
+ #ManageTime
+ #ChangeAffectedElementsAssignedSequence
+ #These methods are not implemented under the C++ providers
+ #In the python provider, these throw the "CIM_ERR_NOT_SUPPORTED" exception
+
+ #try:
+ # self._conn.InvokeMethod("StopService", \
+ # "OMC_SystemTimeService")
+ #except pywbem.CIMError, arg:
+ # self.failUnless(pywbem.CIM_ERR_NOT_SUPPORTED == arg[0], \
+ # "Unexpected Exception: %s"%str(arg))
+ #try:
+ # self._conn.InvokeMethod("StartService", \
+ # "OMC_SystemTimeService")
+ #except pywbem.CIMError, arg:
+ # self.failUnless(pywbem.CIM_ERR_NOT_SUPPORTED == arg[0], \
+ # "Unexpected Exception: %s"%str(arg))
+ except pywbem.CIMError, arg:
+ raise
+
+ def _omc_hosted_time_service(self):
+ if self._isSupportedAssn('OMC_HostedTimeService',
+ 'OMC_UnitaryComputerSystem',
+ 'OMC_SystemTimeService',
+ 'h_time_test'):
+ try:
+ self._sanity_check(type="association",
+ classname="OMC_HostedTimeService")
+
+ except pywbem.CIMError, arg:
+ raise
+ else:
+ self.fail("HostedTimeService _isSupportedAssn failed")
+
+ def _omc_time_service_access_by_sap(self):
+ '''TimeServiceAccessBySap'''
+ try:
+ self._sanity_check(type="association",
+ classname="OMC_TimeServiceAccessBySAP")
+ except pywbem.CIMError, arg:
+ raise
+
+ def _omc_time_service_available_to_element(self):
+ '''TimeServiceAvailableToElement'''
+ try:
+ self._sanity_check(type="association",
+ classname="OMC_TimeServiceAvailableToElement")
+ except pywbem.CIMError, arg:
+ raise
+
+ def _omc_time_service_time_zone_setting_data(self):
+ '''TimeServiceTimeZoneSettingData'''
+ try:
+ tsate_nlist = self._conn.EnumerateInstanceNames(\
+ "OMC_TimeZoneSettingData")
+ self.failUnless(len(tsate_nlist) == 1, \
+ "TimeZoneSettingData returned no instance names")
+ tsate_ilist = self._conn.EnumerateInstances(\
+ "OMC_TimeZoneSettingData", LocalOnly=False)
+ self.failUnless(len(tsate_ilist) == 1, \
+ "TimeZoneSettingData returned no instances")
+ ci = tsate_ilist[0]
+ self.failUnless(ci['InstanceID'] == "omc:timezone",\
+ "TimeZoneSettingData InstanceID returned is incorrect")
+ self.failUnless(ci['TimeZone'] == "US/Mountain",\
+ "TimeZoneSettingData TimeZone returned is incorrect")
+
+
+ except pywbem.CIMError, arg:
+ raise
+
+
def test_time_service(self):
- pass
+ '''Test Time Services'''
+ #return
+ time_classes = {
+ 'OMC_SystemTimeService': self._omc_system_time_service,
+ 'OMC_HostedTimeService': self._omc_hosted_time_service, #assoc
+ 'OMC_TimeServiceAccessBySAP': self._omc_time_service_access_by_sap, #assoc
+ 'OMC_TimeServiceAvailableToElement': \
+ self._omc_time_service_available_to_element, #assoc
+ 'OMC_TimeServiceTimeZoneSettingData': \
+ self._omc_time_service_time_zone_setting_data } #assoc
+ for classname in time_classes.keys():
+ if not self._isClassSupported(classname):
+ #print "Not supported: %s"%str(classname)
+ self._showMissingClassNotice(classname, 'h_time_tested')
+ else:
+ #print "Calling: %s..."%str(time_classes[classname])
+ time_classes[classname]()
+
if __name__ == '__main__':
parser = optparse.OptionParser()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-31 23:22:13
|
Revision: 532
http://omc.svn.sourceforge.net/omc/?rev=532&view=rev
Author: bartw
Date: 2007-12-31 15:22:18 -0800 (Mon, 31 Dec 2007)
Log Message:
-----------
changed CL options. added tests for LogicalFile
Modified Paths:
--------------
test/trunk/omcbase_test.py
Modified: test/trunk/omcbase_test.py
===================================================================
--- test/trunk/omcbase_test.py 2007-12-27 04:28:09 UTC (rev 531)
+++ test/trunk/omcbase_test.py 2007-12-31 23:22:18 UTC (rev 532)
@@ -5,7 +5,10 @@
import pywbem
import os
import commands
+import shutil
+from stat import *
+from tempfile import mkdtemp
from lib import ProviderSanityTest as PST
from time import sleep
from socket import getfqdn
@@ -24,13 +27,10 @@
self.__dict__ = WBEMConn._shared_state
if options:
- proto = 'http'
- if options.secure:
- proto = 'https'
- url = '%s://%s' % (proto, options.host)
- self.conn = pywbem.WBEMConnection(
- url,
- (options.user, options.password),
+ creds = None
+ if options.user is not None:
+ creds = (options.user, options.password)
+ self.conn = pywbem.WBEMConnection(options.url, creds,
default_namespace = options.namespace)
@@ -92,9 +92,11 @@
self._conn = WBEMConn().conn
self._verbose = _globalVerbose
self._dbgPrint()
+ self._tmpdir = mkdtemp()
def tearDown(self):
unittest.TestCase.tearDown(self)
+ shutil.rmtree(self._tmpdir, ignore_errors=True)
def _omc_initdservice_test(self):
svcs = []
@@ -334,16 +336,105 @@
def test_logical_file(self):
'''OMC_LogicalFile'''
- try:
- #TODO Traverse a folder on filesystem and retrieve all of the
- #LinuxDataFiles
- #Get through GetInstance using keybindings since they are
- #non-enumerable
- #self._conn.GetInstance("OMC_LinuxdataFile")
- pass
- except pywbem.CIMError, arg:
- raise
+ inames = self._conn.EnumerateInstanceNames('OMC_LinuxDirectory')
+ inames.sort()
+ names = [x['Name'] for x in inames]
+ gnames = os.listdir('/')
+ isdir = lambda x: S_ISDIR(os.stat(x).st_mode)
+ gnames = ['/'+x for x in gnames]
+ gnames = [x for x in gnames if isdir(x)]
+ gnames.append('/')
+ gnames.sort()
+ self.assertEqual(gnames, names)
+
+ for sock in ['/var/run/tog-pegasus/cimxml.socket',
+ '/tmp/OW@LCL@APIIPC_72859_Xq47Bf_P9r761-5_J-7_Q']:
+ if os.path.exists(sock):
+ iname = pywbem.CIMInstanceName('OMC_LinuxSocketFile',
+ keybindings={'Name':sock})
+ sockinst = self._conn.GetInstance(iname)
+ self.assertEqual(sockinst.classname.lower(),
+ 'omc_linuxsocketfile')
+ self.assertEqual(sockinst['ElementName'],
+ os.path.basename(sock))
+ self.assertEqual(sockinst['CSName'], getfqdn())
+ # TODO check more stuff.
+ break
+ else:
+ self.fail('Failed to find a socket file to test.')
+
+ os.mkdir(self._tmpdir + '/dir')
+ fo = open(self._tmpdir + '/file', 'w')
+ fo.write('1234')
+ fo.close()
+ os.symlink('file', self._tmpdir + '/symlink')
+ iname = pywbem.CIMInstanceName('OMC_LinuxDirectory',
+ keybindings={'Name':self._tmpdir})
+ ccontents = self._conn.Associators(iname,
+ AssocClass='OMC_LinuxDirectoryContainsFile',
+ Role='GroupComponent',
+ ResultRole='PartComponent')
+ self.assertEqual(len(ccontents), 3)
+ ccontents = dict([(os.path.basename(x['Name']), x) for x in ccontents])
+ self.assertEqual(ccontents['file']['FileSize'], 4)
+ self.assertEqual(ccontents['file'].classname.lower(),
+ 'omc_linuxdatafile')
+ self.assertEqual(ccontents['dir'].classname.lower(),
+ 'omc_linuxdirectory')
+ self.assertEqual(ccontents['symlink'].classname.lower(),
+ 'omc_linuxsymboliclink')
+ self.assertEqual(ccontents['symlink']['TargetFile'], 'file')
+
+ parent = self._conn.Associators(ccontents['file'].path,
+ AssocClass='OMC_LinuxDirectoryContainsFile',
+ Role='PartComponent',
+ ResultRole='GroupComponent')
+ self.assertEquals(len(parent), 1)
+ parent = parent[0]
+ self.assertEquals(parent['Name'], self._tmpdir)
+ self.assertEquals(parent.classname.lower(), 'omc_linuxdirectory')
+
+ iname = pywbem.CIMInstanceName('OMC_LinuxDeviceFile',
+ keybindings={'Name':'/dev/null'})
+ null = self._conn.GetInstance(iname, LocalOnly=False)
+ self.assertEquals(null.classname.lower(), 'omc_linuxdevicefile')
+ self.assertEquals(null['DeviceId'], '259') # same on every system?
+ self.assertEquals(null['DeviceMajor'], '1')
+ self.assertEquals(null['DeviceMinor'], '3')
+ self.assertEquals(null['DeviceFileType'], 3)
+
+ os.chmod(self._tmpdir + '/file', 0700)
+
+ iname = pywbem.CIMInstanceName('OMC_LinuxFile',
+ keybindings={'LFName':self._tmpdir + '/file'})
+ lf = self._conn.GetInstance(iname, LocalOnly=False)
+ self.assertTrue(lf['UserReadable'])
+ self.assertTrue(lf['UserWritable'])
+ self.assertTrue(lf['UserExecutable'])
+ self.assertFalse(lf['WorldReadable'])
+ self.assertFalse(lf['WorldWritable'])
+ self.assertFalse(lf['WorldExecutable'])
+ self.assertFalse(lf['GroupReadable'])
+ self.assertFalse(lf['GroupWritable'])
+ self.assertFalse(lf['GroupExecutable'])
+
+ lf['GroupReadable'] = True
+ lf['GroupWritable'] = True
+ lf['GroupExecutable'] = True
+
+ self._conn.ModifyInstance(lf)
+ lf2 = self._conn.GetInstance(iname, LocalOnly=False)
+
+ self.assertEquals(lf, lf2)
+
+ st = os.stat(self._tmpdir + '/file')
+ self.assertTrue(st.st_mode & S_IRGRP)
+ self.assertTrue(st.st_mode & S_IWGRP)
+ self.assertTrue(st.st_mode & S_IXGRP)
+
+ # TODO test chmod/chown/delete
+
def test_operating_system(self):
'''OMC_OperatingSystem'''
if self._isSupportedAssn('OMC_OperatingSystem',
@@ -631,15 +722,13 @@
dest='dbglevel',
help='Indicate the level of debugging statements to display (default=2)',
default=2)
- parser.add_option('', '--host', default='localhost',
- help='Specify the hosting machine of the CIMOM (default=localhost)')
- parser.add_option('-s', '--secure', action='store_true', default=False,
- help='Use the HTTPS protocol. Default is HTTP')
+ parser.add_option('-u', '--url', default='https://localhost',
+ help='Specify the URL to the CIMOM')
parser.add_option('-n', '--namespace', default='root/cimv2',
help='Specify the namespace the test runs against (default=root/cimv2)')
- parser.add_option('', '--user', default='',
+ parser.add_option('', '--user', default=None,
help='Specify the user name used when connection to the CIMOM')
- parser.add_option('', '--password', default='',
+ parser.add_option('', '--password', default=None,
help='Specify the password for the user')
parser.add_option('--verbose', '', action='store_true', default=False,
help='Show verbose output')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|