def test_initialization_executable(self): """Test the initialization of the object""" executable = Executable() executable.source_code_file = "source" executable.compilation_script = "script" executable.compilation_type = "type" executable.singularity_app_folder = "app_folder" executable.singularity_image_file = "image.img" executable.status = "NOT_COMPILED" self.assertEquals("source", executable.source_code_file) self.assertEquals("script", executable.compilation_script) self.assertEquals("type", executable.compilation_type) self.assertEquals("NOT_COMPILED", executable.status) self.assertEquals("app_folder", executable.singularity_app_folder) self.assertEquals("image.img", executable.singularity_image_file)
def test_execute_srun(self, mock_shell): """ Verifyies the correct work of the function "execute_srun" """ # We define the different entities necessaryb for the test. testbed = Testbed( name="nova2", on_line=True, category="SLURM", protocol="SSH", endpoint="*****@*****.**", package_formats=['sbatch', 'SINGULARITY'], extra_config={ "enqueue_compss_sc_cfg": "nova.cfg", "enqueue_env_file": "/home_nfs/home_ejarquej/installations/rc1707/COMPSs/compssenv" }) application = Application(name="super_app") executable = Executable() executable.source_code_file = 'test.zip' executable.compilation_script = 'gcc -X' executable.compilation_type = "SINGULARITY:SRUN" executable.singularity_app_folder = "/singularity/app/folder" executable.singularity_image_file = "pepito.img" executable.status = "COMPILED" executable.application = application deployment = Deployment() deployment.testbed_id = testbed.id deployment.executable_id = executable.id deployment.path = "/pepito/pepito.img" execution_config = ExecutionConfiguration() execution_config.execution_type = "SINGULARITY:SRUN" execution_config.application = application execution_config.testbed = testbed execution_config.executable = executable execution_config.num_nodes = 2 #execution_config.num_gpus_per_node = 2 execution_config.num_cpus_per_node = 16 execution_config.exec_time = 10 execution_config.command = "/apps/application/master/Matmul 2 1024 12.34 /home_nfs/home_ejarquej/demo_test/cpu_gpu_run_data" execution_config.compss_config = "--worker_in_master_cpus=12 --worker_in_master_memory=24000 --worker_working_dir=/home_nfs/home_ejarquej --lang=c --monitoring=1000 -d" output = b' JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)\n 4610 all singular garciad R 0:01 2 ns[55-56]\n' mock_shell.return_value = output # TEST starts here: output_srun = slurm.execute_srun(testbed, execution_config, executable, deployment, True) call_1 = call('(', "*****@*****.**", [ "srun", "-N", "2", "-n", "16", "singularity", "run", "/pepito/pepito.img", ">", "allout.txt", "2>&1", "&", ")", ";", "sleep", "1;", "squeue" ]) # adding a new type of execution execution_config = ExecutionConfiguration() execution_config.execution_type = "SINGULARITY:SRUN" execution_config.application = application execution_config.testbed = testbed execution_config.executable = executable execution_config.num_gpus_per_node = 2 execution_config.num_cpus_per_node = 16 execution_config.exec_time = 10 execution_config.command = "/apps/application/master/Matmul 2 1024 12.34 /home_nfs/home_ejarquej/demo_test/cpu_gpu_run_data" execution_config.compss_config = "--worker_in_master_cpus=12 --worker_in_master_memory=24000 --worker_working_dir=/home_nfs/home_ejarquej --lang=c --monitoring=1000 -d" self.assertEquals(output, output_srun) output_srun = slurm.execute_srun(testbed, execution_config, executable, deployment, True) call_2 = call('(', "*****@*****.**", [ "srun", "--gres=gpu:2", "-n", "16", "singularity", "run", "/pepito/pepito.img", ">", "allout.txt", "2>&1", "&", ")", ";", "sleep", "1;", "squeue" ]) calls = [call_1, call_2] mock_shell.assert_has_calls(calls) self.assertEquals(output, output_srun)