From 1d18d62b0370a2f1f9f74ae169d32d7bd2bfd645 Mon Sep 17 00:00:00 2001 From: caremoli Date: Thu, 21 Oct 2010 12:52:08 +0000 Subject: [PATCH] CCAR: update LifeCycleCORBA module and associated tests with new IDL interface --- src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py | 17 +++++--- .../Test/testcontainermanager.py | 30 +++++++------ .../Test/testresourcemanager.py | 42 ++++++++++++------- 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py index 417cf4e16..fb610bf3c 100644 --- a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py @@ -41,12 +41,17 @@ class LifeCycleCORBA (SALOME_LifeCycleCORBA): componentName) class MachineParameters (Engines.MachineParameters): - def __init__(self, container_name='', hostname='', componentList=[], computerList=[], OS='', - mem_mb=0, cpu_clock=0, nb_proc_per_node=0, nb_node=0, isMPI=False, workingdir='', - mode='start', policy='altcycl', parallelLib='', nb_component_nodes=0): - Engines.MachineParameters.__init__(self,container_name, hostname, componentList, computerList, OS, - mem_mb, cpu_clock, nb_proc_per_node, nb_node, isMPI, workingdir, - mode, policy, parallelLib, nb_component_nodes) + def __init__(self, container_name='', hostname='', componentList=[], computerList=[], OS='', + mem_mb=0, cpu_clock=0, nb_proc_per_node=0, nb_node=0, isMPI=False, workingdir='', + mode='start', policy='altcycl', parallelLib='', nb_component_nodes=0): + Engines.MachineParameters.__init__(self,container_name, hostname, componentList, computerList, OS, + mem_mb, cpu_clock, nb_proc_per_node, nb_node, isMPI, workingdir, + mode, policy, parallelLib, nb_component_nodes) + +class ContainerParameters (Engines.ContainerParameters): + def __init__(self, container_name='', mode='start', workingdir='', nb_proc=0, isMPI=False, parallelLib='',resource_params=None): + if resource_params is None:resource_params=ResourceParameters() + Engines.ContainerParameters.__init__(self,container_name, mode, workingdir, nb_proc, isMPI, parallelLib,resource_params) class ResourceParameters (Engines.ResourceParameters): def __init__(self, name="", hostname="", OS="", componentList=[], diff --git a/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py index 4e7b68d8f..dde270f3d 100644 --- a/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py +++ b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py @@ -42,35 +42,33 @@ Test with catalog : def test0(self): """""" - p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="start", - policy="best",componentList=["PYHELLO"]) - co=cm.StartContainer( p ) - print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"]) + p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="start",resource_params=rp) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") - co=cm.StartContainer( p ) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") def test1(self): """""" - p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="get", - policy="best",componentList=["PYHELLO"]) - co=cm.StartContainer( p ) - print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"]) + p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="get",resource_params=rp) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") - co=cm.StartContainer( p ) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") def test2(self): """""" - p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="getorstart", - policy="best",componentList=["PYHELLO"]) - co=cm.StartContainer( p ) - print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"]) + p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="getorstart",resource_params=rp) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") - co=cm.StartContainer( p ) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") if __name__ == '__main__': - unittest.main() + suite = unittest.TestLoader().loadTestsFromTestCase(TestContainerManager) + unittest.TextTestRunner().run(suite) diff --git a/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py b/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py index e8211ffc5..2ec086bcf 100644 --- a/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py +++ b/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py @@ -21,6 +21,7 @@ import unittest import salome import LifeCycleCORBA +import SALOME salome.salome_init() cm= salome.lcc.getContainerManager() rm= salome.lcc.getResourcesManager() @@ -49,55 +50,60 @@ Test with CatalogResources.xml: def test0(self): """host required""" - params=LifeCycleCORBA.MachineParameters(hostname="m3") + params=LifeCycleCORBA.ResourceParameters(hostname="m3") machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ["m3"]) def test1(self): """OS required""" - params=LifeCycleCORBA.MachineParameters(OS="Linux") - machineList=rm.GetFittingResources(params) - self.assertEqual(machineList, []) + params=LifeCycleCORBA.ResourceParameters(OS="Linux") + self.assertRaises(SALOME.SALOME_Exception,rm.GetFittingResources,params) def test2(self): """component add required""" - params=LifeCycleCORBA.MachineParameters(componentList=["add"]) + params=LifeCycleCORBA.ResourceParameters(componentList=["add"]) machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) def test3(self): """component tutu required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tutu"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["tutu"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['m1', 'm2', 'm3']) def test4(self): """component tata required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tata"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["tata"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['m1', 'm2']) def test5(self): """component titi required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["titi"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["titi"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['m1', 'm2']) def test6(self): """component toto required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) def test7(self): """components add and toto required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) def test8(self): """components add and toto required""" - machineDef=rm.GetMachineParameters('claui2c6') + machineDef=rm.GetResourceDefinition('claui2c6') self.assertEqual(machineDef.componentList, ['toto', 'add']) def test10(self): """policy altcycl""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(rm.Find('altcycl',machineList), "claui2c6") self.assertEqual(rm.Find('altcycl',machineList), "m1") self.assertEqual(rm.Find('altcycl',machineList), "m2") @@ -107,7 +113,8 @@ Test with CatalogResources.xml: def test11(self): """policy cycl""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(rm.Find('cycl',machineList), "claui2c6") self.assertEqual(rm.Find('cycl',machineList), "m1") self.assertEqual(rm.Find('cycl',machineList), "m2") @@ -117,13 +124,15 @@ Test with CatalogResources.xml: def test12(self): """policy first""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(rm.Find('first',machineList), "claui2c6") self.assertEqual(rm.Find('first',machineList), "claui2c6") def test13(self): """policy best""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(rm.Find('best',machineList), "claui2c6") self.assertEqual(rm.Find('best',machineList), "m1") self.assertEqual(rm.Find('best',machineList), "m2") @@ -132,5 +141,6 @@ Test with CatalogResources.xml: self.assertEqual(rm.Find('best',machineList), "m2") if __name__ == '__main__': - unittest.main() + suite = unittest.TestLoader().loadTestsFromTestCase(TestResourceManager) + unittest.TextTestRunner().run(suite) -- 2.39.2