@@ -431,14 +431,13 @@ func TestGetTopologyHints(t *testing.T) {
431
431
432
432
func TestTopologyAlignedAllocation (t * testing.T ) {
433
433
tcases := []struct {
434
- description string
435
- resource string
436
- request int
437
- devices []pluginapi.Device
438
- allocatedDevices []string
439
- hint topologymanager.TopologyHint
440
- expectedAllocation int
441
- expectedAlignment map [int ]int
434
+ description string
435
+ resource string
436
+ request int
437
+ devices []pluginapi.Device
438
+ allocatedDevices []string
439
+ hint topologymanager.TopologyHint
440
+ expectedAlignment map [int ]int
442
441
}{
443
442
{
444
443
description : "Single Request, no alignment" ,
@@ -452,8 +451,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
452
451
NUMANodeAffinity : makeSocketMask (0 , 1 ),
453
452
Preferred : true ,
454
453
},
455
- expectedAllocation : 1 ,
456
- expectedAlignment : map [int ]int {},
454
+ expectedAlignment : map [int ]int {},
457
455
},
458
456
{
459
457
description : "Request for 1, partial alignment" ,
@@ -467,8 +465,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
467
465
NUMANodeAffinity : makeSocketMask (1 ),
468
466
Preferred : true ,
469
467
},
470
- expectedAllocation : 1 ,
471
- expectedAlignment : map [int ]int {1 : 1 },
468
+ expectedAlignment : map [int ]int {1 : 1 },
472
469
},
473
470
{
474
471
description : "Single Request, socket 0" ,
@@ -482,8 +479,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
482
479
NUMANodeAffinity : makeSocketMask (0 ),
483
480
Preferred : true ,
484
481
},
485
- expectedAllocation : 1 ,
486
- expectedAlignment : map [int ]int {0 : 1 },
482
+ expectedAlignment : map [int ]int {0 : 1 },
487
483
},
488
484
{
489
485
description : "Single Request, socket 1" ,
@@ -497,8 +493,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
497
493
NUMANodeAffinity : makeSocketMask (1 ),
498
494
Preferred : true ,
499
495
},
500
- expectedAllocation : 1 ,
501
- expectedAlignment : map [int ]int {1 : 1 },
496
+ expectedAlignment : map [int ]int {1 : 1 },
502
497
},
503
498
{
504
499
description : "Request for 2, socket 0" ,
@@ -514,8 +509,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
514
509
NUMANodeAffinity : makeSocketMask (0 ),
515
510
Preferred : true ,
516
511
},
517
- expectedAllocation : 2 ,
518
- expectedAlignment : map [int ]int {0 : 2 },
512
+ expectedAlignment : map [int ]int {0 : 2 },
519
513
},
520
514
{
521
515
description : "Request for 2, socket 1" ,
@@ -531,8 +525,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
531
525
NUMANodeAffinity : makeSocketMask (1 ),
532
526
Preferred : true ,
533
527
},
534
- expectedAllocation : 2 ,
535
- expectedAlignment : map [int ]int {1 : 2 },
528
+ expectedAlignment : map [int ]int {1 : 2 },
536
529
},
537
530
{
538
531
description : "Request for 4, unsatisfiable, prefer socket 0" ,
@@ -550,8 +543,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
550
543
NUMANodeAffinity : makeSocketMask (0 ),
551
544
Preferred : true ,
552
545
},
553
- expectedAllocation : 4 ,
554
- expectedAlignment : map [int ]int {0 : 3 , 1 : 1 },
546
+ expectedAlignment : map [int ]int {0 : 3 , 1 : 1 },
555
547
},
556
548
{
557
549
description : "Request for 4, unsatisfiable, prefer socket 1" ,
@@ -569,8 +561,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
569
561
NUMANodeAffinity : makeSocketMask (1 ),
570
562
Preferred : true ,
571
563
},
572
- expectedAllocation : 4 ,
573
- expectedAlignment : map [int ]int {0 : 1 , 1 : 3 },
564
+ expectedAlignment : map [int ]int {0 : 1 , 1 : 3 },
574
565
},
575
566
{
576
567
description : "Request for 4, multisocket" ,
@@ -590,8 +581,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
590
581
NUMANodeAffinity : makeSocketMask (1 , 3 ),
591
582
Preferred : true ,
592
583
},
593
- expectedAllocation : 4 ,
594
- expectedAlignment : map [int ]int {1 : 2 , 3 : 2 },
584
+ expectedAlignment : map [int ]int {1 : 2 , 3 : 2 },
595
585
},
596
586
}
597
587
for _ , tc := range tcases {
@@ -621,8 +611,8 @@ func TestTopologyAlignedAllocation(t *testing.T) {
621
611
continue
622
612
}
623
613
624
- if len (allocated ) != tc .expectedAllocation {
625
- t .Errorf ("%v. expected allocation: %v but got: %v" , tc .description , tc .expectedAllocation , len (allocated ))
614
+ if len (allocated ) != tc .request {
615
+ t .Errorf ("%v. expected allocation size : %v but got: %v" , tc .description , tc .request , len (allocated ))
626
616
}
627
617
628
618
alignment := make (map [int ]int )
0 commit comments