29
29
"DIRACOSVER" : "master" ,
30
30
"DIRACOS_TARBALL_PATH" : None ,
31
31
"TEST_HTTPS" : "Yes" ,
32
+ "TEST_DIRACX" : "No" ,
32
33
"DIRAC_FEWER_CFG_LOCKS" : None ,
33
34
"DIRAC_USE_JSON_ENCODE" : None ,
34
35
"INSTALLATION_BRANCH" : "" ,
35
36
}
36
- DEFAULT_MODULES = {
37
- "DIRAC" : Path (__file__ ).parent .absolute (),
38
- }
37
+ DIRACX_OPTIONS = (
38
+ "DIRAC_ENABLE_DIRACX_LOGIN" ,
39
+ "DIRAC_ENABLE_DIRACX_JOB_MONITORING" ,
40
+ )
41
+ DEFAULT_MODULES = {"DIRAC" : Path (__file__ ).parent .absolute ()}
39
42
40
43
# Static configuration
41
44
DB_USER = "Dirac"
@@ -180,7 +183,7 @@ def destroy():
180
183
with _gen_docker_compose (DEFAULT_MODULES ) as docker_compose_fn :
181
184
os .execvpe (
182
185
"docker-compose" ,
183
- ["docker-compose" , "-f" , docker_compose_fn , "down" , "--remove-orphans" , "-t" , "0" ],
186
+ ["docker-compose" , "-f" , docker_compose_fn , "down" , "--remove-orphans" , "-t" , "0" , "--volumes" ],
184
187
_make_env ({}),
185
188
)
186
189
@@ -193,7 +196,6 @@ def prepare_environment(
193
196
release_var : Optional [str ] = None ,
194
197
):
195
198
"""Prepare the local environment for installing DIRAC."""
196
-
197
199
_check_containers_running (is_up = False )
198
200
if editable is None :
199
201
editable = sys .stdout .isatty ()
@@ -224,7 +226,7 @@ def prepare_environment(
224
226
typer .secho ("Running docker-compose to create containers" , fg = c .GREEN )
225
227
with _gen_docker_compose (modules ) as docker_compose_fn :
226
228
subprocess .run (
227
- ["docker-compose" , "-f" , docker_compose_fn , "up" , "-d" ],
229
+ ["docker-compose" , "-f" , docker_compose_fn , "up" , "-d" , "dirac-server" , "dirac-client" ],
228
230
check = True ,
229
231
env = docker_compose_env ,
230
232
)
@@ -313,6 +315,27 @@ def prepare_environment(
313
315
)
314
316
subprocess .run (command , check = True , shell = True )
315
317
318
+ docker_compose_fn_final = Path (tempfile .mkdtemp ()) / "ci"
319
+ typer .secho ("Running docker-compose to create DiracX containers" , fg = c .GREEN )
320
+ typer .secho (f"Will leave a folder behind: { docker_compose_fn_final } " , fg = c .YELLOW )
321
+
322
+ with _gen_docker_compose (modules ) as docker_compose_fn :
323
+ # We cannot use the temporary directory created in the context manager because
324
+ # we don't stay in the contect manager (Popen)
325
+ # So we need something that outlives it.
326
+ shutil .copytree (docker_compose_fn .parent , docker_compose_fn_final , dirs_exist_ok = True )
327
+ # We use Popen because we don't want to wait for this command to finish.
328
+ # It is going to start all the diracx containers, including one which waits
329
+ # for the DIRAC installation to be over.
330
+ subprocess .Popen (
331
+ ["docker-compose" , "-f" , docker_compose_fn_final / "docker-compose.yml" , "up" , "-d" , "diracx" ],
332
+ env = docker_compose_env ,
333
+ stdin = None ,
334
+ stdout = None ,
335
+ stderr = None ,
336
+ close_fds = True ,
337
+ )
338
+
316
339
317
340
@app .command ()
318
341
def install_server ():
@@ -326,6 +349,15 @@ def install_server():
326
349
check = True ,
327
350
)
328
351
352
+ # This runs a continuous loop that exports the config in yaml
353
+ # for the diracx container to use
354
+ typer .secho ("Starting configuration export loop for diracx" , fg = c .GREEN )
355
+ base_cmd = _build_docker_cmd ("server" , tty = False , daemon = True )
356
+ subprocess .run (
357
+ base_cmd + ["bash" , "/home/dirac/LocalRepo/ALTERNATIVE_MODULES/DIRAC/tests/CI/exportCSLoop.sh" ],
358
+ check = True ,
359
+ )
360
+
329
361
typer .secho ("Copying credentials and certificates" , fg = c .GREEN )
330
362
base_cmd = _build_docker_cmd ("client" , tty = False )
331
363
subprocess .run (
@@ -508,13 +540,24 @@ def _gen_docker_compose(modules):
508
540
# Load the docker-compose configuration and mount the necessary volumes
509
541
input_fn = Path (__file__ ).parent / "tests/CI/docker-compose.yml"
510
542
docker_compose = yaml .safe_load (input_fn .read_text ())
543
+ # diracx-wait-for-db needs the volume to be able to run the witing script
544
+ for ctn in ("dirac-server" , "dirac-client" , "diracx-wait-for-db" ):
545
+ if "volumes" not in docker_compose ["services" ][ctn ]:
546
+ docker_compose ["services" ][ctn ]["volumes" ] = []
511
547
volumes = [f"{ path } :/home/dirac/LocalRepo/ALTERNATIVE_MODULES/{ name } " for name , path in modules .items ()]
512
548
volumes += [f"{ path } :/home/dirac/LocalRepo/TestCode/{ name } " for name , path in modules .items ()]
513
- docker_compose ["services" ]["dirac-server" ]["volumes" ] = volumes [:]
514
- docker_compose ["services" ]["dirac-client" ]["volumes" ] = volumes [:]
549
+ docker_compose ["services" ]["dirac-server" ]["volumes" ].extend (volumes [:])
550
+ docker_compose ["services" ]["dirac-client" ]["volumes" ].extend (volumes [:])
551
+ docker_compose ["services" ]["diracx-wait-for-db" ]["volumes" ].extend (volumes [:])
552
+
553
+ module_configs = _load_module_configs (modules )
554
+ if "diracx" in module_configs :
555
+ docker_compose ["services" ]["diracx" ]["volumes" ].append (
556
+ f"{ modules ['diracx' ]} /src/diracx:{ module_configs ['diracx' ]['install-location' ]} "
557
+ )
515
558
516
559
# Add any extension services
517
- for module_name , module_configs in _load_module_configs ( modules ) .items ():
560
+ for module_name , module_configs in module_configs .items ():
518
561
for service_name , service_config in module_configs ["extra-services" ].items ():
519
562
typer .secho (f"Adding service { service_name } for { module_name } " , err = True , fg = c .GREEN )
520
563
docker_compose ["services" ][service_name ] = service_config .copy ()
@@ -981,6 +1024,8 @@ def _make_config(modules, flags, release_var, editable):
981
1024
"CLIENT_HOST" : "client" ,
982
1025
# Test specific variables
983
1026
"WORKSPACE" : "/home/dirac" ,
1027
+ # DiracX variable
1028
+ "DIRACX_URL" : "http://diracx:8000" ,
984
1029
}
985
1030
986
1031
if editable :
@@ -1006,6 +1051,12 @@ def _make_config(modules, flags, release_var, editable):
1006
1051
except KeyError :
1007
1052
typer .secho (f"Required feature variable { key !r} is missing" , err = True , fg = c .RED )
1008
1053
raise typer .Exit (code = 1 )
1054
+
1055
+ # If we test DiracX, enable all the options
1056
+ if config ["TEST_DIRACX" ].lower () in ("yes" , "true" ):
1057
+ for key in DIRACX_OPTIONS :
1058
+ config [key ] = "Yes"
1059
+
1009
1060
config ["TESTREPO" ] = [f"/home/dirac/LocalRepo/TestCode/{ name } " for name in modules ]
1010
1061
config ["ALTERNATIVE_MODULES" ] = [f"/home/dirac/LocalRepo/ALTERNATIVE_MODULES/{ name } " for name in modules ]
1011
1062
@@ -1027,7 +1078,7 @@ def _load_module_configs(modules):
1027
1078
return module_ci_configs
1028
1079
1029
1080
1030
- def _build_docker_cmd (container_name , * , use_root = False , cwd = "/home/dirac" , tty = True ):
1081
+ def _build_docker_cmd (container_name , * , use_root = False , cwd = "/home/dirac" , tty = True , daemon = False ):
1031
1082
if use_root or os .getuid () == 0 :
1032
1083
user = "root"
1033
1084
else :
@@ -1042,6 +1093,8 @@ def _build_docker_cmd(container_name, *, use_root=False, cwd="/home/dirac", tty=
1042
1093
err = True ,
1043
1094
fg = c .YELLOW ,
1044
1095
)
1096
+ if daemon :
1097
+ cmd += ["-d" ]
1045
1098
cmd += [
1046
1099
"-e=TERM=xterm-color" ,
1047
1100
"-e=INSTALLROOT=/home/dirac" ,
0 commit comments