From af2d7fa1b1f4ec9c99df319fb2b9c4f7eab0382a Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 23 Aug 2021 13:43:48 +0200 Subject: [PATCH] Add TestSSLAttached.py to test that rm,cm,esm and dsm are retrieved properly in SSL mode in new container server process context --- src/Launcher/Test/CMakeLists.txt | 2 +- src/Launcher/Test/CTestTestfileInstall.cmake | 10 ++- src/Launcher/Test/TestSSLAttached.py | 92 ++++++++++++++++++++ src/Launcher/Test/launcher_use_case.py | 1 + src/Launcher/Test/test_launcher.py | 2 + 5 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 src/Launcher/Test/TestSSLAttached.py diff --git a/src/Launcher/Test/CMakeLists.txt b/src/Launcher/Test/CMakeLists.txt index 296481926..3ff71e8e1 100644 --- a/src/Launcher/Test/CMakeLists.txt +++ b/src/Launcher/Test/CMakeLists.txt @@ -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 diff --git a/src/Launcher/Test/CTestTestfileInstall.cmake b/src/Launcher/Test/CTestTestfileInstall.cmake index d59354ee7..3256ff976 100644 --- a/src/Launcher/Test/CTestTestfileInstall.cmake +++ b/src/Launcher/Test/CTestTestfileInstall.cmake @@ -19,13 +19,19 @@ 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 index 000000000..69fbbe8ba --- /dev/null +++ b/src/Launcher/Test/TestSSLAttached.py @@ -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() diff --git a/src/Launcher/Test/launcher_use_case.py b/src/Launcher/Test/launcher_use_case.py index 4a2952e48..de16da76c 100644 --- a/src/Launcher/Test/launcher_use_case.py +++ b/src/Launcher/Test/launcher_use_case.py @@ -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() diff --git a/src/Launcher/Test/test_launcher.py b/src/Launcher/Test/test_launcher.py index dd869ff57..0785c17ca 100755 --- a/src/Launcher/Test/test_launcher.py +++ b/src/Launcher/Test/test_launcher.py @@ -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() -- 2.39.2