Skip to content

Commit

Permalink
integrate with new sys/metrics test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
raskchanky committed Apr 26, 2021
1 parent 77750e1 commit 8d3c1ef
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions vault/external_tests/raft/raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"crypto/md5"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -72,22 +71,7 @@ func raftCluster(t testing.TB, ropts *RaftClusterOpts) *vault.TestCluster {
return cluster
}

type SysMetricsJSON struct {
Gauges []GaugeJSON `json:"Gauges"`
}

type GaugeJSON struct {
Name string `json:"Name"`
Value int `json:"Value"`
Labels map[string]interface{} `json:"Labels"`
}

func TestRaft_BoltDBMetrics(t *testing.T) {
//sink := metrics.NewInmemSink(1000000*time.Hour, 2000000*time.Hour)
//conf := vault.CoreConfig{
// MetricSink: metricsutil.NewClusterMetricSink("test-cluster", sink),
// MetricsHelper: metricsutil.NewMetricsHelper(sink, false),
//}
conf := vault.CoreConfig{}
opts := vault.TestClusterOptions{
HandlerFunc: vaulthttp.Handler,
Expand Down Expand Up @@ -120,20 +104,10 @@ func TestRaft_BoltDBMetrics(t *testing.T) {
}
}

r := leaderClient.NewRequest("GET", "/v1/sys/metrics")
var data SysMetricsJSON
resp, err := leaderClient.RawRequestWithContext(context.Background(), r)
if err != nil {
t.Fatal(err)
}
bodyBytes, err := ioutil.ReadAll(resp.Response.Body)
data, err := testhelpers.SysMetricsReq(leaderClient, cluster, true)
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
if err := json.Unmarshal(bodyBytes, &data); err != nil {
t.Fatal(err)
}

noBoltDBMetrics := true
for _, g := range data.Gauges {
Expand Down

0 comments on commit 8d3c1ef

Please sign in to comment.