2 # Copyright (C) 2006-2020 CEA/DEN, EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
29 class TestEdit(unittest.TestCase):
32 SALOMERuntime.RuntimeSALOME_setRuntime()
33 self.r = pilot.getRuntime()
34 self.l = loader.YACSLoader()
35 self.e = pilot.ExecutorSwig()
39 """ Test the conservation of the python context between two nodes sharing
45 proc=runtime.createProc("MySchema")
46 ti=proc.createType("int","int")
47 cont=proc.createContainer("MyContainer","Salome")
48 # type "multi" : the workload manager chooses the resource
49 # type "mono" : the workload manager does not choose the resource
50 cont.setProperty("type","multi")
51 # number of cores used by the container
52 cont.setProperty("nb_parallel_procs", "1")
53 n1=runtime.createScriptNode("","n1")
54 n2=runtime.createScriptNode("","n2")
55 n1.setExecutionMode("remote")
56 n2.setExecutionMode("remote")
60 res_port=n2.edAddOutputPort("v", ti)
63 proc.edAddCFLink(n1,n2)
64 # set the default execution mode using the workload manager
65 proc.setProperty("executor", "workloadmanager")
66 # reuse the same python context for every execution
67 cont.setStoreContext(True)
68 #proc.saveSchema("mini_wlm.xml")
69 executor=pilot.ExecutorSwig()
70 # default run method of the executor which uses the property "executor"
71 # in order to choose the actual run method
73 # you can also impose the executor, ignoring the property "executor"
74 #executor.RunB(proc,0) # use the "historical" executor
75 #executor.runWlm(proc,0) # use the workload manager based executor
77 self.assertEqual(res_port.getPyObj(), 42)
79 if __name__ == '__main__':
80 dir_test = tempfile.mkdtemp(suffix=".yacstest")
81 file_test = os.path.join(dir_test,"UnitTestsResult")
82 with open(file_test, 'a') as f:
83 f.write(" --- TEST src/yacsloader: testWorkloadManager.py\n")
84 suite = unittest.makeSuite(TestEdit)
85 result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
86 sys.exit(not result.wasSuccessful())