Salome HOME
Merge branch 'omu/launcher_ssl'
[modules/kernel.git] / src / Launcher / Test / TestSSLAttached.py
1 #! /usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2021  CEA/DEN, EDF R&D
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21
22 import os
23 import sys
24 import salome
25 import Engines
26
27 salome.salome_init_without_session()
28 rp=Engines.ResourceParameters(name="localhost",
29                                 hostname="localhost",
30                                 can_launch_batch_jobs=False,
31                                 can_run_containers=True,
32                                 OS="Linux",
33                                 componentList=[],
34                                 nb_proc=1,
35                                 mem_mb=1000,
36                                 cpu_clock=1000,
37                                 nb_node=1,
38                                 nb_proc_per_node=1,
39                                 policy="first",
40                                 resList=[])
41
42 cp=Engines.ContainerParameters(container_name="container_test",
43                                  mode="start",
44                                  workingdir=os.getcwd(),
45                                  nb_proc=1,
46                                  isMPI=False,
47                                  parallelLib="",
48                                  resource_params=rp)
49
50 cm=salome.naming_service.Resolve("/ContainerManager")
51
52 cont_prov=cm.GiveContainer(cp)
53 import CORBA
54 import pickle
55 orb=CORBA.ORB_init([''])
56
57 # Testing for CM
58 ref_cm = orb.object_to_string(salome.cm)
59 pyscript = cont_prov.createPyScriptNode("testCM","""import salome\nsalome.salome_init()\nthe_cm=salome.cm""")
60 pyscript.execute([],pickle.dumps(([],{})))
61 cm_to_test = orb.object_to_string(pickle.loads(pyscript.execute(["the_cm"],pickle.dumps(([],{}))))[0])
62 if cm_to_test!=ref_cm:
63     raise AssertionError("The ContainerManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
64 del pyscript,ref_cm,cm_to_test
65
66 # Testing for RM
67 ref_rm = orb.object_to_string(salome.lcc.getResourcesManager())
68 pyscript4 = cont_prov.createPyScriptNode("testRM","""import salome\nsalome.salome_init()\nthe_rm=salome.lcc.getResourcesManager()""")
69 pyscript4.execute([],pickle.dumps(([],{})))
70 rm_to_test = orb.object_to_string(pickle.loads(pyscript4.execute(["the_rm"],pickle.dumps(([],{}))))[0])
71 if rm_to_test!=ref_rm:
72     raise AssertionError("The ResourcesManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
73 del pyscript4,ref_rm,rm_to_test
74
75 # Testing for DSM
76 ref_dsm = orb.object_to_string(salome.dsm)
77 pyscript2 = cont_prov.createPyScriptNode("testDSM","""import salome\nsalome.salome_init()\nthe_dsm=salome.dsm""")
78 dsm_to_test = orb.object_to_string(pickle.loads(pyscript2.execute(["the_dsm"],pickle.dumps(([],{}))))[0])
79 if dsm_to_test!=ref_dsm:
80     raise AssertionError("The DataServerManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
81 del pyscript2,ref_dsm,dsm_to_test
82
83 # Testing for ESM
84 ref_esm = orb.object_to_string(salome.esm)
85 pyscript3 = cont_prov.createPyScriptNode("testESM","""import salome\nsalome.salome_init()\nthe_esm=salome.esm""")
86 esm_to_test = orb.object_to_string(pickle.loads(pyscript3.execute(["the_esm"],pickle.dumps(([],{}))))[0])
87 if esm_to_test!=ref_esm:
88     raise AssertionError("The ExternalServerLauncher of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
89 del pyscript3,ref_esm,esm_to_test
90
91 # End of test
92 cont_prov.Shutdown()