Salome HOME
Add TestSSLAttached.py to test that rm,cm,esm and dsm are retrieved properly in SSL...
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 23 Aug 2021 11:43:48 +0000 (13:43 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 23 Aug 2021 11:43:48 +0000 (13:43 +0200)
src/Launcher/Test/CMakeLists.txt
src/Launcher/Test/CTestTestfileInstall.cmake
src/Launcher/Test/TestSSLAttached.py [new file with mode: 0644]
src/Launcher/Test/launcher_use_case.py
src/Launcher/Test/test_launcher.py

index 29648192684b9617ec68723e6b33127269cb2dae..3ff71e8e10e111c7a02873ee83a90b672fe4e077 100644 (file)
@@ -27,7 +27,7 @@ IF(NOT WIN32)
 #           ${CMAKE_CURRENT_SOURCE_DIR}/test_launcher.py
 #           -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
 #          )
-  INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/test_launcher.py
+  INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/test_launcher.py ${CMAKE_CURRENT_SOURCE_DIR}/TestSSLAttached.py
           DESTINATION ${KERNEL_TEST_DIR}/Launcher)
 
   INSTALL(FILES CTestTestfileInstall.cmake
index d59354ee70255c915235315b7d0570f35d8981c0..3256ff976c844b822a824f490fde5ea9ee6d4915 100644 (file)
 
 IF(NOT WIN32)
   SET(TEST_NAME ${COMPONENT_NAME}_Launcher)
-  ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} 2000 test_launcher.py)
+  ADD_TEST(${TEST_NAME} ${PYTHON_TEST_DRIVER} 2000 test_launcher.py)
   SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}"
     #                                                 TIMEOUT 500
     )
+    
+    SET(TEST_NAME ${COMPONENT_NAME}_AttachedLauncher)
+    ADD_TEST(${TEST_NAME} ${PYTHON_TEST_DRIVER} 2000 TestSSLAttached.py)
+    SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}"
+      #                                                 TIMEOUT 500
+      )
 
   SET(TEST_NAME ${COMPONENT_NAME}_StressLauncher)
-  ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} 2000 ./test_stress.sh)
+  ADD_TEST(${TEST_NAME} ${PYTHON_TEST_DRIVER} 2000 ./test_stress.sh)
   SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}"
     #                                                 TIMEOUT 500
     )
diff --git a/src/Launcher/Test/TestSSLAttached.py b/src/Launcher/Test/TestSSLAttached.py
new file mode 100644 (file)
index 0000000..69fbbe8
--- /dev/null
@@ -0,0 +1,92 @@
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+# 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 os
+import sys
+import salome
+import Engines
+
+salome.salome_init_without_session()
+rp=Engines.ResourceParameters(name="localhost",
+                                hostname="localhost",
+                                can_launch_batch_jobs=False,
+                                can_run_containers=True,
+                                OS="Linux",
+                                componentList=[],
+                                nb_proc=1,
+                                mem_mb=1000,
+                                cpu_clock=1000,
+                                nb_node=1,
+                                nb_proc_per_node=1,
+                                policy="first",
+                                resList=[])
+
+cp=Engines.ContainerParameters(container_name="container_test",
+                                 mode="start",
+                                 workingdir=os.getcwd(),
+                                 nb_proc=1,
+                                 isMPI=False,
+                                 parallelLib="",
+                                 resource_params=rp)
+
+cm=salome.naming_service.Resolve("/ContainerManager")
+
+cont_prov=cm.GiveContainer(cp)
+import CORBA
+import pickle
+orb=CORBA.ORB_init([''])
+
+# Testing for CM
+ref_cm = orb.object_to_string(salome.cm)
+pyscript = cont_prov.createPyScriptNode("testCM","""import salome\nsalome.salome_init()\nthe_cm=salome.cm""")
+pyscript.execute([],pickle.dumps(([],{})))
+cm_to_test = orb.object_to_string(pickle.loads(pyscript.execute(["the_cm"],pickle.dumps(([],{}))))[0])
+if cm_to_test!=ref_cm:
+    raise AssertionError("The ContainerManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
+del pyscript,ref_cm,cm_to_test
+
+# Testing for RM
+ref_rm = orb.object_to_string(salome.lcc.getResourcesManager())
+pyscript4 = cont_prov.createPyScriptNode("testRM","""import salome\nsalome.salome_init()\nthe_rm=salome.lcc.getResourcesManager()""")
+pyscript4.execute([],pickle.dumps(([],{})))
+rm_to_test = orb.object_to_string(pickle.loads(pyscript4.execute(["the_rm"],pickle.dumps(([],{}))))[0])
+if rm_to_test!=ref_rm:
+    raise AssertionError("The ResourcesManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
+del pyscript4,ref_rm,rm_to_test
+
+# Testing for DSM
+ref_dsm = orb.object_to_string(salome.dsm)
+pyscript2 = cont_prov.createPyScriptNode("testDSM","""import salome\nsalome.salome_init()\nthe_dsm=salome.dsm""")
+dsm_to_test = orb.object_to_string(pickle.loads(pyscript2.execute(["the_dsm"],pickle.dumps(([],{}))))[0])
+if dsm_to_test!=ref_dsm:
+    raise AssertionError("The DataServerManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
+del pyscript2,ref_dsm,dsm_to_test
+
+# Testing for ESM
+ref_esm = orb.object_to_string(salome.esm)
+pyscript3 = cont_prov.createPyScriptNode("testESM","""import salome\nsalome.salome_init()\nthe_esm=salome.esm""")
+esm_to_test = orb.object_to_string(pickle.loads(pyscript3.execute(["the_esm"],pickle.dumps(([],{}))))[0])
+if esm_to_test!=ref_esm:
+    raise AssertionError("The ExternalServerLauncher of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
+del pyscript3,ref_esm,esm_to_test
+
+# End of test
+cont_prov.Shutdown()
index 4a2952e48abc7706c11e81db396d0e1d1a1e3f79..de16da76c6642d5e791d01894769e2ff860d74c7 100644 (file)
@@ -27,6 +27,7 @@ import time
 import sys
 
 if __name__ == '__main__':
+  salome.standalone()
   salome.salome_init()
   launcher = salome.naming_service.Resolve('/SalomeLauncher')
   job_params = salome.JobParameters()
index dd869ff574d7c2ee5d5297657356930b78fae3eb..0785c17ca400555c90d39a2723f0d684cbc494e5 100755 (executable)
@@ -104,6 +104,7 @@ class TestCompo(unittest.TestCase):
 
 # verify import salome
 import salome
+salome.standalone()
 salome.salome_init()
 
 f = open('result.txt', 'w')
@@ -666,5 +667,6 @@ f.close()
 if __name__ == '__main__':
     # create study
     import salome
+    salome.standalone()
     salome.salome_init()
     unittest.main()