]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: update LifeCycleCORBA module and associated tests with new IDL interface
authorcaremoli <caremoli>
Thu, 21 Oct 2010 12:52:08 +0000 (12:52 +0000)
committercaremoli <caremoli>
Thu, 21 Oct 2010 12:52:08 +0000 (12:52 +0000)
src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py
src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py
src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py

index 417cf4e1616b8010c0d2c36adc8e62f5e125bea0..fb610bf3cd56b34b23244a5dfa7ab1a3845414de 100644 (file)
@@ -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=[],
index 4e7b68d8f1f7e2bb858783ccea72e6ffdcdb2bbc..dde270f3da48b7fc7666e9ab071e137da862207e 100644 (file)
@@ -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)
 
index e8211ffc5b3043c1e699c6033ab1b61b45454a21..2ec086bcf49b3cff5abe3a9af9fc0bb2727ca866 100644 (file)
@@ -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)