2 # Copyright (C) 2021-2023 CEA, EDF
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
31 class TestBasicFirstSSL(unittest.TestCase):
34 First SSL test with YACS. This test launches SALOME_Container_No_NS_Serv servers to perform it's job.
35 These extra SALOME_Container_No_NS_Serv servers are shut down at the end
38 NamingService.NamingService.SetLogContainersFile()
39 SALOMERuntime.RuntimeSALOME.setRuntime()
40 rrr=SALOMERuntime.getSALOMERuntime()
41 """First test of HP Container no loop here only the 3 sorts of python nodes (the Distributed is it still used and useful ?) """
42 fname= "TestSaveLoadRun0.xml"
44 sqrtOfNumberOfTurn=1000 # 3000 -> 3.2s/Node, 1000 -> 0.1s/Node
46 p=rrr.createProc("prTest0")
47 td=p.createType("double","double")
48 ti=p.createType("int","int")
50 pg.setData([("localhost",4)])
57 ref=datetime.datetime.now()
58 t=0. ; pas=1./float(nb)
62 t+=1.+cos(1.*(x*3.14159))
65 print("coucou from script0-%i -> %s"%(dbg,str(datetime.datetime.now()-ref)))
68 for i in range(nbOfNodes):
69 cont=p.createContainer("gg{}".format(i),"Salome")
70 cont.setProperty("name","localhost")
71 cont.setProperty("hostname","localhost")
72 cont.setProperty("nb_proc_per_node","1")
73 node0=rrr.createFuncNode("DistPython","node%i"%(i))
76 node0.setContainer(cont)
77 node0.setScript(script0)
78 nb=node0.edAddInputPort("nb",ti) ; nb.edInitInt(sqrtOfNumberOfTurn)
79 dbg=node0.edAddInputPort("dbg",ti) ; dbg.edInitInt(i+1)
80 out0=node0.edAddOutputPort("s",td)
82 with tempfile.TemporaryDirectory() as tmpdir:
83 tmp_fname = os.path.join(tmpdir, fname)
84 p.saveSchema(tmp_fname)
86 ex=pilot.ExecutorSwig()
87 self.assertEqual(p.getState(),pilot.READY)
88 st=datetime.datetime.now()
89 p.propagePlayGround(pg)
93 print("Time spend of test0 to run 1st %s"%(str(datetime.datetime.now()-st)))
94 self.assertEqual(p.getState(),pilot.DONE)
95 # 2nd exec using the same already launched remote python interpreters
96 st=datetime.datetime.now()
98 print("Time spend of test0 to run 2nd %s"%(str(datetime.datetime.now()-st)))
99 self.assertEqual(p.getState(),pilot.DONE)
100 # 3rd exec using the same already launched remote python interpreters
101 st=datetime.datetime.now()
103 print("Time spend of test0 to run 3rd %s"%(str(datetime.datetime.now()-st)))
104 self.assertEqual(p.getState(),pilot.DONE)
105 print( "file containing list of IORS of containers : \"{}\"".format( NamingService.NamingService.GetLogContainersFile() ) )
106 print(NamingService.NamingService.IOROfNS())
107 print(NamingService.NamingService.RefOfNS())
108 print("Killing all containers")
109 NamingService.NamingService.KillContainersInFile( NamingService.NamingService.GetLogContainersFile() )
112 if __name__ == '__main__':