@@ -305,6 +305,60 @@ partitions:
305
305
assert .Equal (t , 0 , len (app .GetAllAllocations ()), "allocations were not removed from the application" )
306
306
}
307
307
308
+ func TestForeignPodTracking (t * testing.T ) {
309
+ configData := `
310
+ partitions:
311
+ - name: default
312
+ queues:
313
+ - name: root
314
+ submitacl: "*"
315
+ queues:
316
+ - name: a
317
+ resources:
318
+ guaranteed:
319
+ memory: 100000000
320
+ vcore: 10
321
+ max:
322
+ memory: 150000000
323
+ vcore: 20
324
+ `
325
+ cluster := MockScheduler {}
326
+ cluster .init ()
327
+ assert .NilError (t , cluster .start (), "failed to start cluster" )
328
+ defer cluster .stop ()
329
+
330
+ err := cluster .updateConfig (configData , nil )
331
+ assert .NilError (t , err , "update config failed" )
332
+ addNode (& cluster , "node-1" )
333
+
334
+ podResource := common .NewResourceBuilder ().
335
+ AddResource (siCommon .Memory , 1000 ).
336
+ AddResource (siCommon .CPU , 1 ).
337
+ Build ()
338
+ pod1 := createTestPod ("root.a" , "" , "foreign-1" , podResource )
339
+ pod1 .Spec .SchedulerName = ""
340
+ pod1 .Spec .NodeName = "node-1"
341
+ pod2 := createTestPod ("root.a" , "" , "foreign-2" , podResource )
342
+ pod2 .Spec .SchedulerName = ""
343
+ pod2 .Spec .NodeName = "node-1"
344
+
345
+ cluster .AddPod (pod1 )
346
+ cluster .AddPod (pod2 )
347
+
348
+ err = cluster .waitAndAssertForeignAllocationInCore (partitionName , "foreign-1" , "node-1" , true )
349
+ assert .NilError (t , err )
350
+ err = cluster .waitAndAssertForeignAllocationInCore (partitionName , "foreign-2" , "node-1" , true )
351
+ assert .NilError (t , err )
352
+
353
+ cluster .DeletePod (pod1 )
354
+ cluster .DeletePod (pod2 )
355
+
356
+ err = cluster .waitAndAssertForeignAllocationInCore (partitionName , "foreign-1" , "node-1" , false )
357
+ assert .NilError (t , err )
358
+ err = cluster .waitAndAssertForeignAllocationInCore (partitionName , "foreign-2" , "node-1" , false )
359
+ assert .NilError (t , err )
360
+ }
361
+
308
362
func createTestPod (queue string , appID string , taskID string , taskResource * si.Resource ) * v1.Pod {
309
363
containers := make ([]v1.Container , 0 )
310
364
c1Resources := make (map [v1.ResourceName ]resource.Quantity )
0 commit comments