@@ -535,33 +535,29 @@ def test_per_step_isolation(self, mock_get_nodes: Mock, slurm_system: SlurmSyste
535535@pytest .mark .parametrize (
536536 "scontrol_output,expected_support" ,
537537 [
538- # Case 1: gres/gpu in AccountingStorageTRES and gpu in GresTypes - should be supported
538+ # Case 1: GresTypes includes gpu - should be supported
539539 (
540540 """Configuration data as of 2023-06-14T16:28:09
541- AccountingStorageTRES = cpu,mem,energy,node,billing,fs/disk,vmem,pages,gres/gpu,gres/gpumem,gres/gpuutil
542541GresTypes = gpu""" ,
543542 True ,
544543 ),
545- # Case 2: gres/gpu in AccountingStorageTRES but GresTypes is (null) - should NOT be supported
544+ # Case 2: GresTypes is (null) - should NOT be supported
546545 (
547546 """Configuration data as of 2023-06-14T16:28:09
548- AccountingStorageTRES = cpu,mem,energy,node,billing,fs/disk,vmem,pages,gres/gpu,gres/gpumem,gres/gpuutil
549547GresTypes = (null)""" ,
550548 False ,
551549 ),
552- # Case 3: No gres/gpu in AccountingStorageTRES - should NOT be supported
550+ # Case 3: GresTypes does not include gpu - should NOT be supported
553551 (
554552 """Configuration data as of 2023-06-14T16:28:09
555- AccountingStorageTRES = cpu,mem,energy,node,billing,fs/disk,vmem,pages
556- GresTypes = gpu""" ,
553+ GresTypes = cpu""" ,
557554 False ,
558555 ),
559- # Case 4: No gres/gpu in AccountingStorageTRES and GresTypes is (null) - should NOT be supported
556+ # Case 4: GresTypes includes multiple types including gpu - should be supported
560557 (
561558 """Configuration data as of 2023-06-14T16:28:09
562- AccountingStorageTRES = cpu,mem,energy,node,billing,fs/disk,vmem,pages
563- GresTypes = (null)""" ,
564- False ,
559+ GresTypes = cpu,gpu,fpga""" ,
560+ True ,
565561 ),
566562 ],
567563)
@@ -571,3 +567,14 @@ def test_supports_gpu_directives(
571567):
572568 mock_fetch_command_output .return_value = (scontrol_output , "" )
573569 assert slurm_system .supports_gpu_directives == expected_support
570+
571+
572+ @pytest .mark .parametrize (
573+ "cache_value" ,
574+ [True , False ],
575+ )
576+ @patch ("cloudai.systems.slurm.slurm_system.SlurmSystem.fetch_command_output" )
577+ def test_supports_gpu_directives_cache (mock_fetch_command_output , cache_value : bool , slurm_system : SlurmSystem ):
578+ slurm_system .supports_gpu_directives_cache = cache_value
579+ assert slurm_system .supports_gpu_directives is cache_value
580+ mock_fetch_command_output .assert_not_called ()
0 commit comments