/usr/lib/salome/bin/testresourcemanager.py is in salome-kernel 6.5.0-7ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | # -*- coding: iso-8859-1 -*-
# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
import unittest
import salome
import LifeCycleCORBA
import SALOME
salome.salome_init()
cm= salome.lcc.getContainerManager()
rm= salome.lcc.getResourcesManager()
class TestResourceManager(unittest.TestCase):
"""
Test with CatalogResources.xml:
<!DOCTYPE ResourcesCatalog>
<resources>
<machine hostname="m1" />
<machine hostname="m2" />
<machine hostname="m3" >
<modules moduleName="tutu" />
</machine>
<machine hostname="m4" >
<component name="sub" moduleName="tata" />
</machine>
<machine hostname="claui2c6" >
<modules moduleName="toto" />
<component name="add" moduleName="titi" />
</machine>
</resources>
"""
def setUp(self):
pass
def test0(self):
"""host required"""
params=LifeCycleCORBA.ResourceParameters(hostname="m3")
machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ["m3"])
def test1(self):
"""OS required"""
params=LifeCycleCORBA.ResourceParameters(OS="Linux")
self.assertRaises(SALOME.SALOME_Exception,rm.GetFittingResources,params)
def test2(self):
"""component add required"""
params=LifeCycleCORBA.ResourceParameters(componentList=["add"])
machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['claui2c6', 'm1', 'm2'])
def test3(self):
"""component tutu required"""
params=LifeCycleCORBA.ResourceParameters(componentList=["tutu"])
machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['m1', 'm2', 'm3'])
def test4(self):
"""component tata required"""
params=LifeCycleCORBA.ResourceParameters(componentList=["tata"])
machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['m1', 'm2'])
def test5(self):
"""component titi required"""
params=LifeCycleCORBA.ResourceParameters(componentList=["titi"])
machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['m1', 'm2'])
def test6(self):
"""component toto required"""
params=LifeCycleCORBA.ResourceParameters(componentList=["toto"])
machineList=rm.GetFittingResources(params)
self.assertEqual(machineList, ['claui2c6', 'm1', 'm2'])
def test7(self):
"""components add and toto required"""
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.GetResourceDefinition('claui2c6')
self.assertEqual(machineDef.componentList, ['toto', 'add'])
def test10(self):
"""policy altcycl"""
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")
self.assertEqual(rm.Find('altcycl',machineList), "claui2c6")
self.assertEqual(rm.Find('altcycl',machineList), "m1")
self.assertEqual(rm.Find('altcycl',machineList), "m2")
def test11(self):
"""policy cycl"""
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")
self.assertEqual(rm.Find('cycl',machineList), "claui2c6")
self.assertEqual(rm.Find('cycl',machineList), "m1")
self.assertEqual(rm.Find('cycl',machineList), "m2")
def test12(self):
"""policy first"""
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"""
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")
self.assertEqual(rm.Find('best',machineList), "claui2c6")
self.assertEqual(rm.Find('best',machineList), "m1")
self.assertEqual(rm.Find('best',machineList), "m2")
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestResourceManager)
unittest.TextTestRunner().run(suite)
|