@@ -70,7 +70,10 @@ func (spt staticPolicyTest) PseudoClone() staticPolicyTest {
70
70
}
71
71
72
72
func TestStaticPolicyName (t * testing.T ) {
73
- policy , _ := NewStaticPolicy (topoSingleSocketHT , 1 , cpuset .New (), topologymanager .NewFakeManager (), nil )
73
+ policy , err := NewStaticPolicy (topoSingleSocketHT , 1 , cpuset .New (), topologymanager .NewFakeManager (), nil )
74
+ if err != nil {
75
+ t .Fatalf ("NewStaticPolicy() failed: %v" , err )
76
+ }
74
77
75
78
policyName := policy .Name ()
76
79
if policyName != "static" {
@@ -168,13 +171,16 @@ func TestStaticPolicyStart(t *testing.T) {
168
171
for _ , testCase := range testCases {
169
172
t .Run (testCase .description , func (t * testing.T ) {
170
173
featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , pkgfeatures .CPUManagerPolicyAlphaOptions , true )
171
- p , _ := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpuset .New (), topologymanager .NewFakeManager (), testCase .options )
174
+ p , err := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpuset .New (), topologymanager .NewFakeManager (), testCase .options )
175
+ if err != nil {
176
+ t .Fatalf ("NewStaticPolicy() failed: %v" , err )
177
+ }
172
178
policy := p .(* staticPolicy )
173
179
st := & mockState {
174
180
assignments : testCase .stAssignments ,
175
181
defaultCPUSet : testCase .stDefaultCPUSet ,
176
182
}
177
- err : = policy .Start (st )
183
+ err = policy .Start (st )
178
184
if ! reflect .DeepEqual (err , testCase .expErr ) {
179
185
t .Errorf ("StaticPolicy Start() error (%v). expected error: %v but got: %v" ,
180
186
testCase .description , testCase .expErr , err )
@@ -637,15 +643,18 @@ func runStaticPolicyTestCase(t *testing.T, testCase staticPolicyTest) {
637
643
if testCase .reservedCPUs != nil {
638
644
cpus = testCase .reservedCPUs .Clone ()
639
645
}
640
- policy , _ := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpus , tm , testCase .options )
646
+ policy , err := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpus , tm , testCase .options )
647
+ if err != nil {
648
+ t .Fatalf ("NewStaticPolicy() failed: %v" , err )
649
+ }
641
650
642
651
st := & mockState {
643
652
assignments : testCase .stAssignments ,
644
653
defaultCPUSet : testCase .stDefaultCPUSet ,
645
654
}
646
655
647
656
container := & testCase .pod .Spec .Containers [0 ]
648
- err : = policy .Allocate (st , testCase .pod , container )
657
+ err = policy .Allocate (st , testCase .pod , container )
649
658
if ! reflect .DeepEqual (err , testCase .expErr ) {
650
659
t .Errorf ("StaticPolicy Allocate() error (%v). expected add error: %q but got: %q" ,
651
660
testCase .description , testCase .expErr , err )
@@ -708,7 +717,10 @@ func TestStaticPolicyReuseCPUs(t *testing.T) {
708
717
}
709
718
710
719
for _ , testCase := range testCases {
711
- policy , _ := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpuset .New (), topologymanager .NewFakeManager (), nil )
720
+ policy , err := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpuset .New (), topologymanager .NewFakeManager (), nil )
721
+ if err != nil {
722
+ t .Fatalf ("NewStaticPolicy() failed: %v" , err )
723
+ }
712
724
713
725
st := & mockState {
714
726
assignments : testCase .stAssignments ,
@@ -761,7 +773,10 @@ func TestStaticPolicyDoNotReuseCPUs(t *testing.T) {
761
773
}
762
774
763
775
for _ , testCase := range testCases {
764
- policy , _ := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpuset .New (), topologymanager .NewFakeManager (), nil )
776
+ policy , err := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpuset .New (), topologymanager .NewFakeManager (), nil )
777
+ if err != nil {
778
+ t .Fatalf ("NewStaticPolicy() failed: %v" , err )
779
+ }
765
780
766
781
st := & mockState {
767
782
assignments : testCase .stAssignments ,
@@ -843,7 +858,10 @@ func TestStaticPolicyRemove(t *testing.T) {
843
858
}
844
859
845
860
for _ , testCase := range testCases {
846
- policy , _ := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpuset .New (), topologymanager .NewFakeManager (), nil )
861
+ policy , err := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , cpuset .New (), topologymanager .NewFakeManager (), nil )
862
+ if err != nil {
863
+ t .Fatalf ("NewStaticPolicy() failed: %v" , err )
864
+ }
847
865
848
866
st := & mockState {
849
867
assignments : testCase .stAssignments ,
@@ -933,13 +951,16 @@ func TestTopologyAwareAllocateCPUs(t *testing.T) {
933
951
},
934
952
}
935
953
for _ , tc := range testCases {
936
- p , _ := NewStaticPolicy (tc .topo , 0 , cpuset .New (), topologymanager .NewFakeManager (), nil )
954
+ p , err := NewStaticPolicy (tc .topo , 0 , cpuset .New (), topologymanager .NewFakeManager (), nil )
955
+ if err != nil {
956
+ t .Fatalf ("NewStaticPolicy() failed: %v" , err )
957
+ }
937
958
policy := p .(* staticPolicy )
938
959
st := & mockState {
939
960
assignments : tc .stAssignments ,
940
961
defaultCPUSet : tc .stDefaultCPUSet ,
941
962
}
942
- err : = policy .Start (st )
963
+ err = policy .Start (st )
943
964
if err != nil {
944
965
t .Errorf ("StaticPolicy Start() error (%v)" , err )
945
966
continue
@@ -1107,15 +1128,18 @@ func TestStaticPolicyAddWithResvList(t *testing.T) {
1107
1128
}
1108
1129
1109
1130
for _ , testCase := range testCases {
1110
- policy , _ := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , testCase .reserved , topologymanager .NewFakeManager (), nil )
1131
+ policy , err := NewStaticPolicy (testCase .topo , testCase .numReservedCPUs , testCase .reserved , topologymanager .NewFakeManager (), nil )
1132
+ if err != nil {
1133
+ t .Fatalf ("NewStaticPolicy() failed: %v" , err )
1134
+ }
1111
1135
1112
1136
st := & mockState {
1113
1137
assignments : testCase .stAssignments ,
1114
1138
defaultCPUSet : testCase .stDefaultCPUSet ,
1115
1139
}
1116
1140
1117
1141
container := & testCase .pod .Spec .Containers [0 ]
1118
- err : = policy .Allocate (st , testCase .pod , container )
1142
+ err = policy .Allocate (st , testCase .pod , container )
1119
1143
if ! reflect .DeepEqual (err , testCase .expErr ) {
1120
1144
t .Errorf ("StaticPolicy Allocate() error (%v). expected add error: %v but got: %v" ,
1121
1145
testCase .description , testCase .expErr , err )
0 commit comments