Salome HOME
updated copyright message
[modules/kernel.git] / src / Launcher / Test / TestSSLAttached.py
1 #! /usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2021-2023  CEA, EDF
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 pyscriptt = cont_prov.createPyScriptNode("testCM2","""import salome\nsalome.salome_init()\nthe_cm=salome.naming_service.Resolve("/ContainerManager")""")
65 pyscriptt.execute([],pickle.dumps(([],{})))
66 cm_to_testt = orb.object_to_string(pickle.loads(pyscriptt.execute(["the_cm"],pickle.dumps(([],{}))))[0])
67 if cm_to_testt!=ref_cm:
68     raise AssertionError("The ContainerManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
69 del pyscript,pyscriptt,ref_cm,cm_to_test,cm_to_testt
70
71 # Testing for RM
72 ref_rm = orb.object_to_string(salome.lcc.getResourcesManager())
73 pyscript4 = cont_prov.createPyScriptNode("testRM","""import salome\nsalome.salome_init()\nthe_rm=salome.lcc.getResourcesManager()""")
74 pyscript4.execute([],pickle.dumps(([],{})))
75 rm_to_test = orb.object_to_string(pickle.loads(pyscript4.execute(["the_rm"],pickle.dumps(([],{}))))[0])
76 if rm_to_test!=ref_rm:
77     raise AssertionError("The ResourcesManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
78 pyscript44 = cont_prov.createPyScriptNode("testRM2","""import salome\nsalome.salome_init()\nthe_rm=salome.naming_service.Resolve("/ResourcesManager")""")
79 pyscript44.execute([],pickle.dumps(([],{})))
80 rm_to_testt = orb.object_to_string(pickle.loads(pyscript44.execute(["the_rm"],pickle.dumps(([],{}))))[0])
81 if rm_to_testt!=ref_rm:
82     raise AssertionError("The ResourcesManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
83 del pyscript4,pyscript44,ref_rm,rm_to_test,rm_to_testt
84
85 # Testing for DSM
86 ref_dsm = orb.object_to_string(salome.dsm)
87 pyscript2 = cont_prov.createPyScriptNode("testDSM","""import salome\nsalome.salome_init()\nthe_dsm=salome.dsm""")
88 dsm_to_test = orb.object_to_string(pickle.loads(pyscript2.execute(["the_dsm"],pickle.dumps(([],{}))))[0])
89 if dsm_to_test!=ref_dsm:
90     raise AssertionError("The DataServerManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
91 pyscript22 = cont_prov.createPyScriptNode("testDSM","""import salome\nsalome.salome_init()\nthe_dsm=salome.naming_service.Resolve("/DataServerManager")""")
92 dsm_to_test_2 = orb.object_to_string(pickle.loads(pyscript22.execute(["the_dsm"],pickle.dumps(([],{}))))[0])
93 if dsm_to_test_2!=ref_dsm:
94     raise AssertionError("The DataServerManager of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
95 del pyscript2,pyscript22,ref_dsm,dsm_to_test,dsm_to_test_2
96
97 # Testing for ESM
98 ref_esm = orb.object_to_string(salome.esm)
99 pyscript3 = cont_prov.createPyScriptNode("testESM","""import salome\nsalome.salome_init()\nthe_esm=salome.esm""")
100 esm_to_test = orb.object_to_string(pickle.loads(pyscript3.execute(["the_esm"],pickle.dumps(([],{}))))[0])
101 if esm_to_test!=ref_esm:
102     raise AssertionError("The ExternalServerLauncher of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
103 pyscript33 = cont_prov.createPyScriptNode("testDSM","""import salome\nsalome.salome_init()\nthe_esm=salome.naming_service.Resolve("/ExternalServers")""")
104 esm_to_test_2 = orb.object_to_string(pickle.loads(pyscript33.execute(["the_esm"],pickle.dumps(([],{}))))[0])
105 if esm_to_test_2!=ref_esm:
106     raise AssertionError("The ExternalServerLauncher of salome_init launched in SALOME_Container_No_NS_Serv is not those in current process !")
107 del pyscript3,pyscript33,ref_esm,esm_to_test,esm_to_test_2
108
109 # End of test
110 cont_prov.Shutdown()