github.com/Hnampk/fabric@v2.1.1+incompatible/gossip/metrics/metrics_test.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package metrics 8 9 import ( 10 "testing" 11 12 "github.com/hyperledger/fabric/common/metrics/metricsfakes" 13 "github.com/stretchr/testify/assert" 14 ) 15 16 func TestMetrics(t *testing.T) { 17 18 provider := &metricsfakes.Provider{} 19 20 counter := &metricsfakes.Counter{} 21 gauge := &metricsfakes.Gauge{} 22 histogram := &metricsfakes.Histogram{} 23 24 provider.NewCounterReturns(counter) 25 provider.NewGaugeReturns(gauge) 26 provider.NewHistogramReturns(histogram) 27 28 gossipMetrics := NewGossipMetrics(provider) 29 30 // make sure all metrics were created 31 assert.NotNil(t, gossipMetrics) 32 33 assert.NotNil(t, gossipMetrics.StateMetrics) 34 assert.NotNil(t, gossipMetrics.StateMetrics.Height) 35 assert.NotNil(t, gossipMetrics.StateMetrics.CommitDuration) 36 assert.NotNil(t, gossipMetrics.StateMetrics.PayloadBufferSize) 37 38 assert.NotNil(t, gossipMetrics.ElectionMetrics) 39 assert.NotNil(t, gossipMetrics.ElectionMetrics.Declaration) 40 41 assert.NotNil(t, gossipMetrics.CommMetrics) 42 assert.NotNil(t, gossipMetrics.CommMetrics.SentMessages) 43 assert.NotNil(t, gossipMetrics.CommMetrics.ReceivedMessages) 44 assert.NotNil(t, gossipMetrics.CommMetrics.BufferOverflow) 45 46 assert.NotNil(t, gossipMetrics.MembershipMetrics) 47 assert.NotNil(t, gossipMetrics.MembershipMetrics.Total) 48 49 assert.NotNil(t, gossipMetrics.PrivdataMetrics) 50 assert.NotNil(t, gossipMetrics.PrivdataMetrics.CommitPrivateDataDuration) 51 assert.NotNil(t, gossipMetrics.PrivdataMetrics.FetchDuration) 52 assert.NotNil(t, gossipMetrics.PrivdataMetrics.ListMissingPrivateDataDuration) 53 assert.NotNil(t, gossipMetrics.PrivdataMetrics.PurgeDuration) 54 assert.NotNil(t, gossipMetrics.PrivdataMetrics.ValidationDuration) 55 assert.NotNil(t, gossipMetrics.PrivdataMetrics.SendDuration) 56 assert.NotNil(t, gossipMetrics.PrivdataMetrics.ReconciliationDuration) 57 assert.NotNil(t, gossipMetrics.PrivdataMetrics.PullDuration) 58 assert.NotNil(t, gossipMetrics.PrivdataMetrics.RetrieveDuration) 59 }