22import pytest
33import os
44
5- spank_plugin_script = "test_147_1_spank_plugin.c"
6- spank_compiled_plugin = "test_147_1_spank_plugin.so"
5+ spank_tmp = ""
76
87
98# Setup
109@pytest .fixture (scope = "module" , autouse = True )
11- def setup ():
10+ def setup (spank_tmp_lib ):
11+ global spank_tmp
12+ spank_tmp , spank_lib = spank_tmp_lib
1213 atf .require_config_parameter ("JobContainerType" , "job_container/tmpfs" )
1314 atf .require_config_parameter_includes ("SlurmdParameters" , "contain_spank" )
1415 atf .require_config_parameter_includes ("PrologFlags" , "Contain" )
1516
16- # Compile SPANK plugin
17- spank_plugin_script_path = (
18- f"{ atf .properties ['testsuite_scripts_dir' ]} /{ spank_plugin_script } "
19- )
20- atf .compile_against_libslurm (
21- spank_plugin_script_path , spank_compiled_plugin , full = True , shared = True
22- )
23-
2417 # Ensure the SPANK plugin is included in plugstack.conf
2518 atf .require_config_parameter (
2619 "required" ,
27- f"{ atf . module_tmp_path } / { spank_compiled_plugin } " ,
20+ f"{ spank_lib } " ,
2821 delimiter = " " ,
2922 source = "plugstack" ,
3023 )
@@ -35,11 +28,8 @@ def setup():
3528 "BasePath" , "/tmp/%h_%n_base_path" , source = "job_container"
3629 )
3730
38- # Mount /tmp/test_147_1_private in the job container as a private mount
39- atf .require_config_parameter (
40- "Dirs" , "/tmp/test_147_1_private" , source = "job_container"
41- )
42- atf .run_command ("mkdir -p /tmp/test_147_1_private" , fatal = True )
31+ # Mount spank_tmp in the job container as a private mount
32+ atf .require_config_parameter ("Dirs" , spank_tmp , source = "job_container" )
4333
4434 atf .require_slurm_running ()
4535
@@ -49,14 +39,14 @@ def test_spank_plugin_tmpfs():
4939 Test that SPANK plugin hooks execute correctly in the tmpfs job container.
5040 """
5141 # Clear out the private mount and create a file outside the container
52- atf .run_command ("rm -rf /tmp/test_147_1_private /*" , fatal = True )
53- atf .run_command ("touch /tmp/test_147_1_private /file_on_host" , fatal = True )
42+ atf .run_command (f "rm -rf { spank_tmp } /*" , fatal = True )
43+ atf .run_command (f "touch { spank_tmp } /file_on_host" , fatal = True )
5444
5545 atf .make_bash_script (
5646 "job.sh" ,
57- """
47+ f """
5848 # Check to make sure job_container/tmpfs made a private mount
59- if [[ -f /tmp/test_147_1_private /file_on_host ]]; then
49+ if [[ -f { spank_tmp } /file_on_host ]]; then
6050 echo "job_container/tmpfs failed to create private mount"
6151 else
6252 echo "job_container/tmpfs created private mount"
@@ -66,21 +56,21 @@ def test_spank_plugin_tmpfs():
6656 srun hostname
6757
6858 # Check if slurm_spank_user_init executed its functions and left behind a file
69- if [[ -f /tmp/test_147_1_private /slurm_spank_user_init_log ]]; then
59+ if [[ -f { spank_tmp } /slurm_spank_user_init_log ]]; then
7060 echo "Found log for hook slurm_spank_user_init"
7161 else
7262 echo "Couldn't find log for hook slurm_spank_user_init"
7363 fi
7464
7565 # Check if slurm_spank_task_post_fork executed its functions and left behind a file
76- if [[ -f /tmp/test_147_1_private /slurm_spank_task_post_fork_log ]]; then
66+ if [[ -f { spank_tmp } /slurm_spank_task_post_fork_log ]]; then
7767 echo "Found log for hook slurm_spank_task_post_fork"
7868 else
7969 echo "Couldn't find log for hook slurm_spank_task_post_fork"
8070 fi
8171
8272 # Check if slurm_spank_task_exit executed its functions and left behind a file
83- if [[ -f /tmp/test_147_1_private /slurm_spank_task_exit_log ]]; then
73+ if [[ -f { spank_tmp } /slurm_spank_task_exit_log ]]; then
8474 echo "Found log for hook slurm_spank_task_exit"
8575 else
8676 echo "Couldn't find log for hook slurm_spank_task_exit"
@@ -115,7 +105,7 @@ def test_spank_plugin_tmpfs():
115105 "job_container/tmpfs created private mount" in content
116106 ), "job_container/tmpfs failed to create a private mount because we found a pre-existing file on the host when running a job"
117107 assert not (
118- os .path .isfile ("/tmp/test_147_1_private /slurm_spank_user_init_log" )
119- or os .path .isfile ("/tmp/test_147_1_private /slurm_spank_task_post_fork_log" )
120- or os .path .isfile ("/tmp/test_147_1_private /slurm_spank_task_exit_log" )
108+ os .path .isfile (f" { spank_tmp } /slurm_spank_user_init_log" )
109+ or os .path .isfile (f" { spank_tmp } /slurm_spank_task_post_fork_log" )
110+ or os .path .isfile (f" { spank_tmp } /slurm_spank_task_exit_log" )
121111 ), "job_container/tmpfs failed to isolate private mount; files created in container appear on host"
0 commit comments