From 74a6bc50486cf5867a825b1a2b3105ca43e3b7e8 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 11 Jun 2021 11:06:51 +0200 Subject: [PATCH] First SSL test for YACS --- src/engine_swig/CMakeLists.txt | 2 +- src/engine_swig/CTestTestfileInstall.cmake | 3 + src/engine_swig/basic_first_SSL.py | 112 +++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/engine_swig/basic_first_SSL.py diff --git a/src/engine_swig/CMakeLists.txt b/src/engine_swig/CMakeLists.txt index af5cd7b97..6eec2abbf 100644 --- a/src/engine_swig/CMakeLists.txt +++ b/src/engine_swig/CMakeLists.txt @@ -144,6 +144,6 @@ SET_TESTS_PROPERTIES(PlayGround0 PROPERTIES ENVIRONMENT "${tests_env}") ADD_TEST(NAME Base64Conv COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testBase64Conv.py) SET_TESTS_PROPERTIES(Base64Conv PROPERTIES ENVIRONMENT "${tests_env}") SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/engine_swig) -SET(LOCAL_TEST_FILES testPlayGround0.py testBase64Conv.py) +SET(LOCAL_TEST_FILES testPlayGround0.py testBase64Conv.py basic_first_SSL.py) INSTALL(PROGRAMS ${LOCAL_TEST_FILES} DESTINATION ${LOCAL_TEST_DIR}) INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${LOCAL_TEST_DIR} RENAME CTestTestfile.cmake) diff --git a/src/engine_swig/CTestTestfileInstall.cmake b/src/engine_swig/CTestTestfileInstall.cmake index 6b5a88b22..36b93b348 100644 --- a/src/engine_swig/CTestTestfileInstall.cmake +++ b/src/engine_swig/CTestTestfileInstall.cmake @@ -24,4 +24,7 @@ IF(NOT WIN32) SET(TEST_NAME ${COMPONENT_NAME}_Base64Conv) ADD_TEST(${TEST_NAME} testBase64Conv.py) SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") + SET(TEST_NAME ${COMPONENT_NAME}_basic_first_SSL) + ADD_TEST(${TEST_NAME} basic_first_SSL.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") ENDIF() diff --git a/src/engine_swig/basic_first_SSL.py b/src/engine_swig/basic_first_SSL.py new file mode 100644 index 000000000..5c770c037 --- /dev/null +++ b/src/engine_swig/basic_first_SSL.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +# Copyright (C) 2021 CEA/DEN, EDF R&D +# +# 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, or (at your option) any later version. +# +# 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 pilot +import SALOMERuntime +import loader +import os +import datetime +import salome +import sys +import time +import NamingService + +class TestBasicFirstSSL(unittest.TestCase): + def test0(self): + """ + First SSL test with YACS. This test launches SALOME_Container_No_NS_Serv servers to perform it's job. + These extra SALOME_Container_No_NS_Serv servers are shut down at the end + """ + salome.standalone() + NamingService.NamingService.SetLogContainersFile() + SALOMERuntime.RuntimeSALOME.setRuntime() + rrr=SALOMERuntime.getSALOMERuntime() + """First test of HP Container no loop here only the 3 sorts of python nodes (the Distributed is it still used and useful ?) """ + fname= "TestSaveLoadRun0.xml" + nbOfNodes=2 + sqrtOfNumberOfTurn=1000 # 3000 -> 3.2s/Node, 1000 -> 0.1s/Node + l=loader.YACSLoader() + p=rrr.createProc("prTest0") + td=p.createType("double","double") + ti=p.createType("int","int") + pg=pilot.PlayGround() + pg.setData([("localhost",4)]) + + script0=""" +def ff(nb,dbg): + from math import cos + import datetime + + ref=datetime.datetime.now() + t=0. ; pas=1./float(nb) + for i in range(nb): + for j in range(nb): + x=j*pas + t+=1.+cos(1.*(x*3.14159)) + pass + pass + print("coucou from script0-%i -> %s"%(dbg,str(datetime.datetime.now()-ref))) + return t + """ + for i in range(nbOfNodes): + cont=p.createContainer("gg{}".format(i),"Salome") + cont.setProperty("name","localhost") + cont.setProperty("hostname","localhost") + cont.setProperty("nb_proc_per_node","1") + node0=rrr.createFuncNode("DistPython","node%i"%(i)) + p.edAddChild(node0) + node0.setFname("ff") + node0.setContainer(cont) + node0.setScript(script0) + nb=node0.edAddInputPort("nb",ti) ; nb.edInitInt(sqrtOfNumberOfTurn) + dbg=node0.edAddInputPort("dbg",ti) ; dbg.edInitInt(i+1) + out0=node0.edAddOutputPort("s",td) + pass + p.saveSchema(fname) + p=l.load(fname) + ex=pilot.ExecutorSwig() + self.assertEqual(p.getState(),pilot.READY) + st=datetime.datetime.now() + p.propagePlayGround(pg) + # 1st exec + #input(os.getpid()) + ex.RunW(p,0) + print("Time spend of test0 to run 1st %s"%(str(datetime.datetime.now()-st))) + self.assertEqual(p.getState(),pilot.DONE) + # 2nd exec using the same already launched remote python interpreters + st=datetime.datetime.now() + ex.RunW(p,0) + print("Time spend of test0 to run 2nd %s"%(str(datetime.datetime.now()-st))) + self.assertEqual(p.getState(),pilot.DONE) + # 3rd exec using the same already launched remote python interpreters + st=datetime.datetime.now() + ex.RunW(p,0) + print("Time spend of test0 to run 3rd %s"%(str(datetime.datetime.now()-st))) + self.assertEqual(p.getState(),pilot.DONE) + print( "file containing list of IORS of containers : \"{}\"".format( NamingService.NamingService.GetLogContainersFile() ) ) + print(NamingService.NamingService.IOROfNS()) + print(NamingService.NamingService.RefOfNS()) + print("Killing all containers") + NamingService.NamingService.KillContainersInFile( NamingService.NamingService.GetLogContainersFile() ) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file -- 2.39.2