@@ -23,8 +23,6 @@ import (
23
23
24
24
"github.com/stretchr/testify/assert"
25
25
26
- "k8s.io/node-problem-detector/pkg/custompluginmonitor"
27
- "k8s.io/node-problem-detector/pkg/systemlogmonitor"
28
26
"k8s.io/node-problem-detector/pkg/types"
29
27
)
30
28
@@ -255,15 +253,15 @@ func TestSetConfigFromDeprecatedOptionsOrDie(t *testing.T) {
255
253
name : "no deprecated options" ,
256
254
orig : NodeProblemDetectorOptions {
257
255
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
258
- systemlogmonitor . SystemLogMonitorName : & []string {"config-a" , "config-b" },
259
- custompluginmonitor . CustomPluginMonitorName : & []string {"config-c" , "config-d" },
256
+ systemLogMonitorName : & []string {"config-a" , "config-b" },
257
+ customPluginMonitorName : & []string {"config-c" , "config-d" },
260
258
},
261
259
},
262
260
expectPanic : false ,
263
261
wanted : NodeProblemDetectorOptions {
264
262
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
265
- systemlogmonitor . SystemLogMonitorName : & []string {"config-a" , "config-b" },
266
- custompluginmonitor . CustomPluginMonitorName : & []string {"config-c" , "config-d" },
263
+ systemLogMonitorName : & []string {"config-a" , "config-b" },
264
+ customPluginMonitorName : & []string {"config-c" , "config-d" },
267
265
},
268
266
},
269
267
},
@@ -272,13 +270,16 @@ func TestSetConfigFromDeprecatedOptionsOrDie(t *testing.T) {
272
270
orig : NodeProblemDetectorOptions {
273
271
SystemLogMonitorConfigPaths : []string {"config-a" , "config-b" },
274
272
CustomPluginMonitorConfigPaths : []string {"config-c" , "config-d" },
275
- MonitorConfigPaths : types.ProblemDaemonConfigPathMap {},
273
+ MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
274
+ customPluginMonitorName : & []string {},
275
+ systemLogMonitorName : & []string {},
276
+ },
276
277
},
277
278
expectPanic : false ,
278
279
wanted : NodeProblemDetectorOptions {
279
280
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
280
- systemlogmonitor . SystemLogMonitorName : & []string {"config-a" , "config-b" },
281
- custompluginmonitor . CustomPluginMonitorName : & []string {"config-c" , "config-d" },
281
+ systemLogMonitorName : & []string {"config-a" , "config-b" },
282
+ customPluginMonitorName : & []string {"config-c" , "config-d" },
282
283
},
283
284
},
284
285
},
@@ -287,14 +288,15 @@ func TestSetConfigFromDeprecatedOptionsOrDie(t *testing.T) {
287
288
orig : NodeProblemDetectorOptions {
288
289
SystemLogMonitorConfigPaths : []string {"config-a" , "config-b" },
289
290
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
290
- custompluginmonitor .CustomPluginMonitorName : & []string {"config-c" , "config-d" },
291
+ customPluginMonitorName : & []string {"config-c" , "config-d" },
292
+ systemLogMonitorName : & []string {},
291
293
},
292
294
},
293
295
expectPanic : false ,
294
296
wanted : NodeProblemDetectorOptions {
295
297
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
296
- systemlogmonitor . SystemLogMonitorName : & []string {"config-a" , "config-b" },
297
- custompluginmonitor . CustomPluginMonitorName : & []string {"config-c" , "config-d" },
298
+ systemLogMonitorName : & []string {"config-a" , "config-b" },
299
+ customPluginMonitorName : & []string {"config-c" , "config-d" },
298
300
},
299
301
},
300
302
},
@@ -303,14 +305,15 @@ func TestSetConfigFromDeprecatedOptionsOrDie(t *testing.T) {
303
305
orig : NodeProblemDetectorOptions {
304
306
CustomPluginMonitorConfigPaths : []string {"config-a" , "config-b" },
305
307
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
306
- systemlogmonitor .SystemLogMonitorName : & []string {"config-c" , "config-d" },
308
+ customPluginMonitorName : & []string {},
309
+ systemLogMonitorName : & []string {"config-c" , "config-d" },
307
310
},
308
311
},
309
312
expectPanic : false ,
310
313
wanted : NodeProblemDetectorOptions {
311
314
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
312
- systemlogmonitor . SystemLogMonitorName : & []string {"config-c" , "config-d" },
313
- custompluginmonitor . CustomPluginMonitorName : & []string {"config-a" , "config-b" },
315
+ systemLogMonitorName : & []string {"config-c" , "config-d" },
316
+ customPluginMonitorName : & []string {"config-a" , "config-b" },
314
317
},
315
318
},
316
319
},
@@ -319,30 +322,42 @@ func TestSetConfigFromDeprecatedOptionsOrDie(t *testing.T) {
319
322
orig : NodeProblemDetectorOptions {
320
323
SystemLogMonitorConfigPaths : []string {"config-a" },
321
324
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
322
- systemlogmonitor . SystemLogMonitorName : & []string {"config-b" },
325
+ systemLogMonitorName : & []string {"config-b" },
323
326
},
324
327
},
325
328
expectPanic : true ,
326
- wanted : NodeProblemDetectorOptions {
329
+ },
330
+ {
331
+ name : "using deprecated & new options on CustomPluginMonitor" ,
332
+ orig : NodeProblemDetectorOptions {
333
+ CustomPluginMonitorConfigPaths : []string {"config-a" },
327
334
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
328
- systemlogmonitor . SystemLogMonitorName : & []string {"config-b" },
335
+ customPluginMonitorName : & []string {"config-b" },
329
336
},
330
337
},
338
+ expectPanic : true ,
331
339
},
332
340
{
333
- name : "using deprecated & new options on CustomPluginMonitor " ,
341
+ name : "using deprecated options when SystemLogMonitor is not registered " ,
334
342
orig : NodeProblemDetectorOptions {
335
- CustomPluginMonitorConfigPaths : []string {"config-a" },
343
+ SystemLogMonitorConfigPaths : []string {"config-a" },
344
+ CustomPluginMonitorConfigPaths : []string {"config-b" },
336
345
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
337
- custompluginmonitor . CustomPluginMonitorName : & []string {"config-b" },
346
+ customPluginMonitorName : & []string {},
338
347
},
339
348
},
340
349
expectPanic : true ,
341
- wanted : NodeProblemDetectorOptions {
350
+ },
351
+ {
352
+ name : "using deprecated options when CustomPluginMonitor is not registered" ,
353
+ orig : NodeProblemDetectorOptions {
354
+ SystemLogMonitorConfigPaths : []string {"config-a" },
355
+ CustomPluginMonitorConfigPaths : []string {"config-b" },
342
356
MonitorConfigPaths : types.ProblemDaemonConfigPathMap {
343
- custompluginmonitor . CustomPluginMonitorName : & []string {"config-b" },
357
+ systemLogMonitorName : & []string {},
344
358
},
345
359
},
360
+ expectPanic : true ,
346
361
},
347
362
}
348
363
0 commit comments