@@ -145,10 +145,10 @@ func TestLSFJobDevices(t *testing.T) {
145145}
146146
147147func writeLSFEnvironFile (procFS string , jobid string , val string ) error {
148- envs := []string {"LSB_JOBID =" + jobid , "CUDA_VISIBLE_DEVICES=" + val }
148+ envs := []string {"LSB_BATCH_JID =" + jobid , "CUDA_VISIBLE_DEVICES=" + val }
149149
150150 return os .WriteFile (
151- procFS + "/" + jobid + "/environ" ,
151+ procFS + "/" + strings . ReplaceAll ( strings . ReplaceAll ( jobid , "[" , "" ), "]" , "" ) + "/environ" ,
152152 []byte (strings .Join (envs , "\000 " )+ "\000 " ),
153153 0o600 ,
154154 )
@@ -443,20 +443,20 @@ func TestLSFJobDevicesCaching(t *testing.T) {
443443 require .NoError (t , err )
444444 }
445445
446- for i := 19 ; i < 40 ; i ++ {
447- dir := fmt .Sprintf ("%s/cpuacct/lsf/cluster1/job.%d .12345.123443" , cgroupsPath , i )
446+ for i := 1 ; i <= 20 ; i ++ {
447+ dir := fmt .Sprintf ("%s/cpuacct/lsf/cluster1/job.19[%d] .12345.123443" , cgroupsPath , i )
448448
449449 err = os .MkdirAll (dir , 0o750 )
450450 require .NoError (t , err )
451451
452452 err = os .WriteFile (
453453 dir + "/cgroup.procs" ,
454- fmt .Appendf (nil , "%d\n " , i ),
454+ fmt .Appendf (nil , "19 %d\n " , i ),
455455 0o600 ,
456456 )
457457 require .NoError (t , err )
458458
459- procDir := fmt .Sprintf ("%s/%d" , procFS , i )
459+ procDir := fmt .Sprintf ("%s/19 %d" , procFS , i )
460460
461461 err = os .MkdirAll (procDir , 0o750 )
462462 require .NoError (t , err )
@@ -539,32 +539,32 @@ func TestLSFJobDevicesCaching(t *testing.T) {
539539 NumJobs : 4 ,
540540 Records : []LSFJobRecord {
541541 {
542- ID : "19" ,
542+ ID : "19[1] " ,
543543 AllocSlot : "testhost-1.example.com:testhost-1.example.com:testhost-1.example.com:testhost-1.example.com" ,
544544 GPUSlot : "testhost-1.example.com:0,0,0,0" ,
545545 },
546546 {
547- ID : "20 " ,
547+ ID : "19[2] " ,
548548 AllocSlot : "testhost-1.example.com:testhost-1.example.com:testhost-1.example.com:testhost-1.example.com" ,
549549 GPUSlot : "testhost-1.example.com:2,2,2,2" ,
550550 },
551551 {
552- ID : "21 " ,
552+ ID : "19[3] " ,
553553 AllocSlot : "testhost-1.example.com:testhost-1.example.com:testhost-2.example.com:testhost-2.example.com" ,
554554 GPUSlot : `testhost-1.example.com:1:1\/0;testhost-2.example.com:0:1\/0` ,
555555 },
556556 {
557- ID : "22 " ,
557+ ID : "19[4] " ,
558558 AllocSlot : "testhost-1.example.com:testhost-1.example.com" ,
559559 GPUSlot : "testhost-1.example.com:0,2" ,
560560 },
561561 {
562- ID : "23 " ,
562+ ID : "19[5] " ,
563563 AllocSlot : "testhost-1.example.com:testhost-1.example.com" ,
564564 GPUSlot : `testhost-1.example.com:3:13\/1` ,
565565 },
566566 {
567- ID : "24 " ,
567+ ID : "19[6] " ,
568568 AllocSlot : "testhost-1.example.com:testhost-1.example.com" ,
569569 GPUSlot : `testhost-1.example.com:3:13\/1` ,
570570 },
@@ -610,10 +610,10 @@ func TestLSFJobDevicesCaching(t *testing.T) {
610610
611611 // New expected jobs
612612 expected = map [string ][]ComputeUnit {
613- "0" : {{UUID : "19" , NumShares : 1 }, {UUID : "22 " , NumShares : 1 }},
614- "1" : {{UUID : "21 " , NumShares : 1 }},
615- "2" : {{UUID : "20 " , NumShares : 1 }, {UUID : "22 " , NumShares : 1 }},
616- "5" : {{UUID : "23 " , NumShares : 1 }, {UUID : "24 " , NumShares : 1 }},
613+ "0" : {{UUID : "19[1] " , NumShares : 1 }, {UUID : "19[4] " , NumShares : 1 }},
614+ "1" : {{UUID : "19[3] " , NumShares : 1 }},
615+ "2" : {{UUID : "19[2] " , NumShares : 1 }, {UUID : "19[4] " , NumShares : 1 }},
616+ "5" : {{UUID : "19[5] " , NumShares : 1 }, {UUID : "19[6] " , NumShares : 1 }},
617617 }
618618
619619 for _ , gpu := range c .gpuSMI .Devices {
0 commit comments