testing: set MetricsHelper if it not provided through base config (#7480)

This commit is contained in:
Calvin Leung Huang 2019-09-16 17:50:51 -07:00 committed by GitHub
parent 3c53db300b
commit 16bc4a4fa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,8 +27,10 @@ import (
"sync/atomic"
"time"
"github.com/armon/go-metrics"
hclog "github.com/hashicorp/go-hclog"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/helper/metricsutil"
"github.com/mitchellh/copystructure"
"golang.org/x/crypto/ed25519"
@ -1488,6 +1490,12 @@ func NewTestCluster(t testing.T, base *CoreConfig, opts *TestClusterOptions) *Te
localConfig.LicensingConfig = testGetLicensingConfig(pubKey)
}
if localConfig.MetricsHelper == nil {
inm := metrics.NewInmemSink(10*time.Second, time.Minute)
metrics.DefaultInmemSignal(inm)
localConfig.MetricsHelper = metricsutil.NewMetricsHelper(inm, false)
}
c, err := NewCore(&localConfig)
if err != nil {
t.Fatalf("err: %v", err)