@@ -27,6 +27,8 @@ import (
2727 "github.com/google/go-cmp/cmp"
2828 "github.com/google/trillian"
2929 "github.com/google/trillian/extension"
30+ "github.com/google/trillian/monitoring"
31+ "github.com/google/trillian/monitoring/testonly"
3032 "github.com/google/trillian/storage"
3133 stestonly "github.com/google/trillian/storage/testonly"
3234 "github.com/google/trillian/storage/tree"
@@ -322,11 +324,16 @@ func TestQueueLeaf(t *testing.T) {
322324 mockStorage .EXPECT ().QueueLeaves (gomock .Any (), cmpMatcher {tree1 }, cmpMatcher {[]* trillian.LogLeaf {leaf1 }}, fakeTime ).After (c1 ).Return ([]* trillian.QueuedLogLeaf {dupeQueuedLeaf (leaf1 )}, nil )
323325
324326 registry := extension.Registry {
325- AdminStorage : fakeAdminStorage (ctrl , storageParams {treeID : queueRequest0 .LogId , numSnapshots : 2 }),
326- LogStorage : mockStorage ,
327+ AdminStorage : fakeAdminStorage (ctrl , storageParams {treeID : queueRequest0 .LogId , numSnapshots : 2 }),
328+ LogStorage : mockStorage ,
329+ MetricFactory : & monitoring.InertMetricFactory {},
327330 }
328331 server := NewTrillianLogRPCServer (registry , fakeTimeSource )
329332
333+ logIDLabel := strconv .FormatInt (queueRequest0 .LogId , 10 )
334+ leafCounterInsertedBase := testonly .NewCounterSnapshot (server .leafCounter , logIDLabel , "inserted" )
335+ leafCounterSkippedBase := testonly .NewCounterSnapshot (server .leafCounter , logIDLabel , "skipped" )
336+
330337 rsp , err := server .QueueLeaf (ctx , & queueRequest0 )
331338 if err != nil {
332339 t .Fatalf ("Failed to queue leaf: %v" , err )
@@ -341,6 +348,12 @@ func TestQueueLeaf(t *testing.T) {
341348 diff := cmp .Diff (queueRequest0 .Leaf , rsp .QueuedLeaf .Leaf )
342349 t .Errorf ("post-QueueLeaf() diff:\n %v" , diff )
343350 }
351+ if d := leafCounterInsertedBase .Delta (); d != 1.0 {
352+ t .Errorf ("%f leaves added, want 1 leaf added" , d )
353+ }
354+ if d := leafCounterSkippedBase .Delta (); d != 0.0 {
355+ t .Errorf ("%f leaves skipped, want 0 leaves added" , d )
356+ }
344357
345358 // Repeating the operation gives ALREADY_EXISTS.
346359 rsp , err = server .QueueLeaf (ctx , & queueRequest0 )
@@ -361,6 +374,13 @@ func TestQueueLeaf(t *testing.T) {
361374 diff := cmp .Diff (queueRequest0 .Leaf , rsp .QueuedLeaf .Leaf )
362375 t .Errorf ("post-QueueLeaf() diff:\n %v" , diff )
363376 }
377+ if d := leafCounterInsertedBase .Delta (); d != 1.0 {
378+ t .Errorf ("%f leaves added, want 1 leaf added" , d )
379+ }
380+ if d := leafCounterSkippedBase .Delta (); d != 1.0 {
381+ t .Errorf ("%f leaves skipped, want 1 leaves added" , d )
382+ }
383+
364384}
365385
366386func TestAddSequencedLeavesStorageError (t * testing.T ) {
0 commit comments