Merge pull request #10140 from hashicorp/b-gh-10070

agent: return req error if prometheus metrics are disabled.
This commit is contained in:
James Rasell
2021-03-10 17:11:39 +01:00
committed by GitHub
6 changed files with 60 additions and 1 deletions

View File

@@ -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:"-"`
}
@@ -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)

View File

@@ -3,6 +3,7 @@ package api
import (
"testing"
"github.com/hashicorp/nomad/api/internal/testutil"
"github.com/stretchr/testify/require"
)
@@ -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()