Salome HOME
updated copyright message
[modules/kernel.git] / src / LifeCycleCORBA_SWIG / Test / testcontainermanager.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import os
22 import unittest
23 import salome
24 import Engines
25 import LifeCycleCORBA
26 salome.salome_init()
27 cm= salome.lcc.getContainerManager()
28 rm= salome.lcc.getResourcesManager()
29
30 class TestContainerManager(unittest.TestCase):
31   """
32 Test with catalog :
33 <!DOCTYPE ResourcesCatalog>
34 <resources>
35    <machine hostname="claui2c6" >
36    </machine>
37    <machine hostname="clt10br" >
38    </machine>
39 </resources>
40 """
41   def setUp(self):
42     self.container_name = "MyContainer-%s"%(os.getpid())
43     pass
44
45   def test0(self):
46     """"""
47     rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
48     p=LifeCycleCORBA.ContainerParameters(container_name=self.container_name,mode="start",resource_params=rp)
49     co=cm.GiveContainer( p )
50     host1=co.getHostName()
51     name1="/Containers/%s/%s" % (host1,self.container_name)
52     self.assertEqual(co._get_name(), name1)
53     co=cm.GiveContainer( p )
54     host2=co.getHostName()
55     name2="/Containers/%s/%s" % (host2,self.container_name)
56     self.assertEqual(co._get_name(), name2)
57
58   def test1(self):
59     """"""
60     rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
61     p=LifeCycleCORBA.ContainerParameters(container_name=self.container_name,mode="get",resource_params=rp)
62     co=cm.GiveContainer( p )
63     host1=co.getHostName()
64     name1="/Containers/%s/%s" % (host1,self.container_name)
65     self.assertEqual(co._get_name(), name1)
66     co=cm.GiveContainer( p )
67     host2=co.getHostName()
68     name2="/Containers/%s/%s" % (host2,self.container_name)
69     self.assertEqual(co._get_name(), name2)
70
71   def test2(self):
72     """"""
73     rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"])
74     p=LifeCycleCORBA.ContainerParameters(container_name=self.container_name,mode="getorstart",resource_params=rp)
75     co=cm.GiveContainer( p )
76     host1=co.getHostName()
77     name1="/Containers/%s/%s" % (host1,self.container_name)
78     self.assertEqual(co._get_name(), name1)
79     co=cm.GiveContainer( p )
80     host2=co.getHostName()
81     name2="/Containers/%s/%s" % (host2,self.container_name)
82     self.assertEqual(co._get_name(), name2)
83
84
85 if __name__ == '__main__':
86   #suite = unittest.TestLoader().loadTestsFromTestCase(TestContainerManager)
87   #unittest.TextTestRunner().run(suite)
88   unittest.main()