@@ -234,7 +234,6 @@ func TestCPUManagerGenerate(t *testing.T) {
234
234
cpuPolicyName string
235
235
nodeAllocatableReservation v1.ResourceList
236
236
isTopologyBroken bool
237
- panicMsg string
238
237
expectedPolicy string
239
238
expectedError error
240
239
skipIfPermissionsError bool
@@ -270,14 +269,14 @@ func TestCPUManagerGenerate(t *testing.T) {
270
269
description : "static policy - broken reservation" ,
271
270
cpuPolicyName : "static" ,
272
271
nodeAllocatableReservation : v1.ResourceList {},
273
- panicMsg : "unable to determine reserved CPU resources for static policy" ,
272
+ expectedError : fmt . Errorf ( "unable to determine reserved CPU resources for static policy" ) ,
274
273
skipIfPermissionsError : true ,
275
274
},
276
275
{
277
276
description : "static policy - no CPU resources" ,
278
277
cpuPolicyName : "static" ,
279
278
nodeAllocatableReservation : v1.ResourceList {v1 .ResourceCPU : * resource .NewQuantity (0 , resource .DecimalSI )},
280
- panicMsg : "the static policy requires systemreserved.cpu + kubereserved.cpu to be greater than zero" ,
279
+ expectedError : fmt . Errorf ( "the static policy requires systemreserved.cpu + kubereserved.cpu to be greater than zero" ) ,
281
280
skipIfPermissionsError : true ,
282
281
},
283
282
}
@@ -319,19 +318,6 @@ func TestCPUManagerGenerate(t *testing.T) {
319
318
t .Errorf ("cannot create state file: %s" , err .Error ())
320
319
}
321
320
defer os .RemoveAll (sDir )
322
- defer func () {
323
- if err := recover (); err != nil {
324
- if testCase .panicMsg != "" {
325
- if ! strings .Contains (err .(string ), testCase .panicMsg ) {
326
- t .Errorf ("Unexpected panic message. Have: %q wants %q" , err , testCase .panicMsg )
327
- }
328
- } else {
329
- t .Errorf ("Unexpected panic: %q" , err )
330
- }
331
- } else if testCase .panicMsg != "" {
332
- t .Error ("Expected panic hasn't been raised" )
333
- }
334
- }()
335
321
336
322
mgr , err := NewManager (testCase .cpuPolicyName , 5 * time .Second , machineInfo , testCase .nodeAllocatableReservation , sDir )
337
323
if testCase .expectedError != nil {
0 commit comments