@@ -339,16 +339,32 @@ def test_slurm(db, io_loop):
339
339
re .compile (r'^#SBATCH \s+ --time=3-05:10:10' , re .X | re .M ),
340
340
re .compile (r'^#SBATCH \s+ some_option_asdf' , re .X | re .M ),
341
341
]
342
- script = [
342
+ from .. import SlurmSpawner
343
+ run_spawner_script (db , io_loop , SlurmSpawner , normal_slurm_script ,
344
+ batch_script_re_list = batch_script_re_list ,
345
+ spawner_kwargs = spawner_kwargs )
346
+ # We tend to use slurm as our typical example job. These allow quick
347
+ # Slurm examples.
348
+ normal_slurm_script = [
343
349
(re .compile (r'sudo.*sbatch' ), str (testjob )),
344
350
(re .compile (r'sudo.*squeue' ), 'PENDING ' ), # pending
345
351
(re .compile (r'sudo.*squeue' ), 'RUNNING ' + testhost ), # running
346
352
(re .compile (r'sudo.*squeue' ), 'RUNNING ' + testhost ),
347
353
(re .compile (r'sudo.*scancel' ), 'STOP' ),
348
354
(re .compile (r'sudo.*squeue' ), '' ),
349
355
]
350
- from .. import SlurmSpawner
351
- run_spawner_script (db , io_loop , SlurmSpawner , script ,
356
+ from .. import SlurmSpawner
357
+ def run_typical_slurm_spawner (db , io_loop ,
358
+ spawner = SlurmSpawner ,
359
+ script = normal_slurm_script ,
360
+ batch_script_re_list = None ,
361
+ spawner_kwargs = {}):
362
+ """Run a full slurm job with default (overrideable) parameters.
363
+
364
+ This is useful, for example, for changing options and testing effect
365
+ of batch scripts.
366
+ """
367
+ return run_spawner_script (db , io_loop , spawner , script ,
352
368
batch_script_re_list = batch_script_re_list ,
353
369
spawner_kwargs = spawner_kwargs )
354
370
@@ -424,3 +440,28 @@ def test_lfs(db, io_loop):
424
440
run_spawner_script (db , io_loop , LsfSpawner , script ,
425
441
batch_script_re_list = batch_script_re_list ,
426
442
spawner_kwargs = spawner_kwargs )
443
+
444
+
445
+ def test_keepvars (db , io_loop ):
446
+ # req_keepvars
447
+ spawner_kwargs = {
448
+ 'req_keepvars' : 'ABCDE' ,
449
+ }
450
+ batch_script_re_list = [
451
+ re .compile (r'--export=ABCDE' , re .X | re .M ),
452
+ ]
453
+ run_typical_slurm_spawner (db , io_loop ,
454
+ spawner_kwargs = spawner_kwargs ,
455
+ batch_script_re_list = batch_script_re_list )
456
+
457
+ # req_keepvars AND req_keepvars together
458
+ spawner_kwargs = {
459
+ 'req_keepvars' : 'ABCDE' ,
460
+ 'req_keepvars_extra' : 'XYZ' ,
461
+ }
462
+ batch_script_re_list = [
463
+ re .compile (r'--export=ABCDE,XYZ' , re .X | re .M ),
464
+ ]
465
+ run_typical_slurm_spawner (db , io_loop ,
466
+ spawner_kwargs = spawner_kwargs ,
467
+ batch_script_re_list = batch_script_re_list )
0 commit comments