Skip to content

Commit 83f18d9

Browse files
committed
Remove unnecessary field from TestTopologyAlignedAllocation() test cases
1 parent bb08fd1 commit 83f18d9

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

pkg/kubelet/cm/devicemanager/topology_hints_test.go

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,13 @@ func TestGetTopologyHints(t *testing.T) {
431431

432432
func TestTopologyAlignedAllocation(t *testing.T) {
433433
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
442441
}{
443442
{
444443
description: "Single Request, no alignment",
@@ -452,8 +451,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
452451
NUMANodeAffinity: makeSocketMask(0, 1),
453452
Preferred: true,
454453
},
455-
expectedAllocation: 1,
456-
expectedAlignment: map[int]int{},
454+
expectedAlignment: map[int]int{},
457455
},
458456
{
459457
description: "Request for 1, partial alignment",
@@ -467,8 +465,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
467465
NUMANodeAffinity: makeSocketMask(1),
468466
Preferred: true,
469467
},
470-
expectedAllocation: 1,
471-
expectedAlignment: map[int]int{1: 1},
468+
expectedAlignment: map[int]int{1: 1},
472469
},
473470
{
474471
description: "Single Request, socket 0",
@@ -482,8 +479,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
482479
NUMANodeAffinity: makeSocketMask(0),
483480
Preferred: true,
484481
},
485-
expectedAllocation: 1,
486-
expectedAlignment: map[int]int{0: 1},
482+
expectedAlignment: map[int]int{0: 1},
487483
},
488484
{
489485
description: "Single Request, socket 1",
@@ -497,8 +493,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
497493
NUMANodeAffinity: makeSocketMask(1),
498494
Preferred: true,
499495
},
500-
expectedAllocation: 1,
501-
expectedAlignment: map[int]int{1: 1},
496+
expectedAlignment: map[int]int{1: 1},
502497
},
503498
{
504499
description: "Request for 2, socket 0",
@@ -514,8 +509,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
514509
NUMANodeAffinity: makeSocketMask(0),
515510
Preferred: true,
516511
},
517-
expectedAllocation: 2,
518-
expectedAlignment: map[int]int{0: 2},
512+
expectedAlignment: map[int]int{0: 2},
519513
},
520514
{
521515
description: "Request for 2, socket 1",
@@ -531,8 +525,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
531525
NUMANodeAffinity: makeSocketMask(1),
532526
Preferred: true,
533527
},
534-
expectedAllocation: 2,
535-
expectedAlignment: map[int]int{1: 2},
528+
expectedAlignment: map[int]int{1: 2},
536529
},
537530
{
538531
description: "Request for 4, unsatisfiable, prefer socket 0",
@@ -550,8 +543,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
550543
NUMANodeAffinity: makeSocketMask(0),
551544
Preferred: true,
552545
},
553-
expectedAllocation: 4,
554-
expectedAlignment: map[int]int{0: 3, 1: 1},
546+
expectedAlignment: map[int]int{0: 3, 1: 1},
555547
},
556548
{
557549
description: "Request for 4, unsatisfiable, prefer socket 1",
@@ -569,8 +561,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
569561
NUMANodeAffinity: makeSocketMask(1),
570562
Preferred: true,
571563
},
572-
expectedAllocation: 4,
573-
expectedAlignment: map[int]int{0: 1, 1: 3},
564+
expectedAlignment: map[int]int{0: 1, 1: 3},
574565
},
575566
{
576567
description: "Request for 4, multisocket",
@@ -590,8 +581,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
590581
NUMANodeAffinity: makeSocketMask(1, 3),
591582
Preferred: true,
592583
},
593-
expectedAllocation: 4,
594-
expectedAlignment: map[int]int{1: 2, 3: 2},
584+
expectedAlignment: map[int]int{1: 2, 3: 2},
595585
},
596586
}
597587
for _, tc := range tcases {
@@ -621,8 +611,8 @@ func TestTopologyAlignedAllocation(t *testing.T) {
621611
continue
622612
}
623613

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))
626616
}
627617

628618
alignment := make(map[int]int)

0 commit comments

Comments
 (0)