Skip to content

Commit

Permalink
api: fix operator test based on metrics Prometheus format fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasell committed Mar 9, 2021
1 parent 82c0fd1 commit 4452b0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions api/internal/testutil/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type TestServerConfig struct {
Client *ClientConfig `json:"client,omitempty"`
Vault *VaultConfig `json:"vault,omitempty"`
ACL *ACLConfig `json:"acl,omitempty"`
Telemetry *Telemetry `json:"telemetry,omitempty"`
DevMode bool `json:"-"`
Stdout, Stderr io.Writer `json:"-"`
}
Expand Down Expand Up @@ -90,6 +91,11 @@ type ACLConfig struct {
Enabled bool `json:"enabled"`
}

// Telemetry is used to configure the Nomad telemetry setup.
type Telemetry struct {
PrometheusMetrics bool `json:"prometheus_metrics"`
}

// ServerConfigCallback is a function interface which can be
// passed to NewTestServerConfig to modify the server config.
type ServerConfigCallback func(c *TestServerConfig)
Expand Down
5 changes: 4 additions & 1 deletion api/operator_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"testing"

"github.com/hashicorp/nomad/api/internal/testutil"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -31,7 +32,9 @@ func TestOperator_MetricsSummary(t *testing.T) {

func TestOperator_Metrics_Prometheus(t *testing.T) {
t.Parallel()
c, s := makeClient(t, nil, nil)
c, s := makeClient(t, nil, func(c *testutil.TestServerConfig) {
c.Telemetry = &testutil.Telemetry{PrometheusMetrics: true}
})
defer s.Stop()

operator := c.Operator()
Expand Down

0 comments on commit 4452b0d

Please sign in to comment.