@@ -343,6 +343,25 @@ func TestSnapClient(t *testing.T) {
343
343
})
344
344
})
345
345
346
+ Convey ("unload one of collector plugin" , func () {
347
+ p := c .GetPlugins (false )
348
+ So (p .Err , ShouldBeNil )
349
+ So (len (p .LoadedPlugins ), ShouldEqual , 3 )
350
+
351
+ p2 := c .UnloadPlugin ("collector" , "mock" , 2 )
352
+ So (p2 .Err , ShouldBeNil )
353
+ So (p2 .Name , ShouldEqual , "mock" )
354
+ So (p2 .Version , ShouldEqual , 2 )
355
+ So (p2 .Type , ShouldEqual , "collector" )
356
+
357
+ Convey ("there should be two loaded plugins" , func () {
358
+ p = c .GetPlugins (false )
359
+ So (p .Err , ShouldBeNil )
360
+ So (len (p .LoadedPlugins ), ShouldEqual , 2 )
361
+ So (p .AvailablePlugins , ShouldBeEmpty )
362
+ })
363
+ })
364
+
346
365
Convey ("Tasks" , func () {
347
366
Convey ("Passing a bad task manifest" , func () {
348
367
wfb := getWMFromSample ("bad.json" )
@@ -374,6 +393,7 @@ func TestSnapClient(t *testing.T) {
374
393
correctSchedule := & Schedule {Type : "simple" , Interval : "1s" }
375
394
tt := c .CreateTask (correctSchedule , wf , "baron" , "" , true , 0 )
376
395
So (tt .Err , ShouldBeNil )
396
+ So (tt .State , ShouldEqual , "Running" )
377
397
})
378
398
379
399
Convey ("Creating a task with correct configuration for windowed schedule" , func () {
@@ -384,17 +404,19 @@ func TestSnapClient(t *testing.T) {
384
404
StopTimestamp : & stopTime }
385
405
tt := c .CreateTask (correctSchedule , wf , "baron" , "" , true , 0 )
386
406
So (tt .Err , ShouldBeNil )
407
+ So (tt .State , ShouldEqual , "Running" )
387
408
})
388
409
389
410
Convey ("Creating a task with correct configuration for cron schedule" , func () {
390
411
correctSchedule := & Schedule {Type : "cron" , Interval : "1 1 1 1 1 1" }
391
412
tt := c .CreateTask (correctSchedule , wf , "baron" , "" , true , 0 )
392
413
So (tt .Err , ShouldBeNil )
414
+ So (tt .State , ShouldEqual , "Running" )
393
415
})
394
416
})
395
417
396
- tf := c .CreateTask (sch , wf , "baron" , "" , false , 0 )
397
418
Convey ("valid task not started on creation" , func () {
419
+ tf := c .CreateTask (sch , wf , "baron" , "" , false , 0 )
398
420
So (tf .Err , ShouldBeNil )
399
421
So (tf .Name , ShouldEqual , "baron" )
400
422
So (tf .State , ShouldEqual , "Stopped" )
@@ -436,8 +458,8 @@ func TestSnapClient(t *testing.T) {
436
458
})
437
459
})
438
460
439
- tt := c .CreateTask (sch , wf , "baron" , "" , true , 0 )
440
461
Convey ("valid task started on creation" , func () {
462
+ tt := c .CreateTask (sch , wf , "baron" , "" , true , 0 )
441
463
So (tt .Err , ShouldBeNil )
442
464
So (tt .Name , ShouldEqual , "baron" )
443
465
So (tt .State , ShouldEqual , "Running" )
@@ -533,6 +555,7 @@ func TestSnapClient(t *testing.T) {
533
555
534
556
a := new (ea )
535
557
r := c .WatchTask (tf .ID )
558
+ So (r .Err , ShouldBeNil )
536
559
wait := make (chan struct {})
537
560
go func () {
538
561
for {
@@ -554,10 +577,11 @@ func TestSnapClient(t *testing.T) {
554
577
So (startResp .Err , ShouldBeNil )
555
578
<- wait
556
579
a .Lock ()
580
+ defer a .Unlock ()
581
+
557
582
So (len (a .events ), ShouldEqual , 5 )
558
- a .Unlock ()
559
583
So (a .events [0 ], ShouldEqual , "task-started" )
560
- for x := 2 ; x <= 4 ; x ++ {
584
+ for x := 1 ; x < 5 ; x ++ {
561
585
So (a .events [x ], ShouldEqual , "metric-event" )
562
586
}
563
587
})
@@ -570,16 +594,15 @@ func TestSnapClient(t *testing.T) {
570
594
So (p .Err , ShouldNotBeNil )
571
595
So (p .Err .Error (), ShouldEqual , "plugin not found" )
572
596
})
597
+ Convey ("unload already unloaded plugin" , func () {
598
+ p := c .UnloadPlugin ("collector" , "mock" , 2 )
599
+ So (p .Err , ShouldNotBeNil )
600
+ So (p .Err .Error (), ShouldEqual , "plugin not found" )
601
+ })
573
602
Convey ("unload one of multiple" , func () {
574
603
p1 := c .GetPlugins (false )
575
604
So (p1 .Err , ShouldBeNil )
576
- So (len (p1 .LoadedPlugins ), ShouldEqual , 3 )
577
-
578
- p2 := c .UnloadPlugin ("collector" , "mock" , 2 )
579
- So (p2 .Err , ShouldBeNil )
580
- So (p2 .Name , ShouldEqual , "mock" )
581
- So (p2 .Version , ShouldEqual , 2 )
582
- So (p2 .Type , ShouldEqual , "collector" )
605
+ So (len (p1 .LoadedPlugins ), ShouldEqual , 2 )
583
606
584
607
p3 := c .UnloadPlugin ("publisher" , "mock-file" , 3 )
585
608
So (p3 .Err , ShouldBeNil )
0 commit comments