Makes the metrics ACL test call the right endpoint.

This also required setting up a proper in-mem sink so we don't get
metrics-related errors.

Fixes #3655
pull/3661/head
James Phillips 2017-11-06 21:50:04 -08:00
parent 172d5c0c40
commit aa199ab6ba
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
2 changed files with 4 additions and 4 deletions

View File

@ -243,14 +243,14 @@ func TestAgent_Metrics_ACLDeny(t *testing.T) {
t.Run("no token", func(t *testing.T) {
req, _ := http.NewRequest("GET", "/v1/agent/metrics", nil)
if _, err := a.srv.AgentSelf(nil, req); !acl.IsErrPermissionDenied(err) {
if _, err := a.srv.AgentMetrics(nil, req); !acl.IsErrPermissionDenied(err) {
t.Fatalf("err: %v", err)
}
})
t.Run("agent master token", func(t *testing.T) {
req, _ := http.NewRequest("GET", "/v1/agent/metrics?token=towel", nil)
if _, err := a.srv.AgentSelf(nil, req); err != nil {
if _, err := a.srv.AgentMetrics(nil, req); err != nil {
t.Fatalf("err: %v", err)
}
})
@ -258,7 +258,7 @@ func TestAgent_Metrics_ACLDeny(t *testing.T) {
t.Run("read-only token", func(t *testing.T) {
ro := makeReadOnlyAgentACL(t, a.srv)
req, _ := http.NewRequest("GET", fmt.Sprintf("/v1/agent/metrics?token=%s", ro), nil)
if _, err := a.srv.AgentSelf(nil, req); err != nil {
if _, err := a.srv.AgentMetrics(nil, req); err != nil {
t.Fatalf("err: %v", err)
}
})

View File

@ -144,7 +144,7 @@ func (a *TestAgent) Start() *TestAgent {
agent.LogOutput = logOutput
agent.LogWriter = a.LogWriter
agent.logger = log.New(logOutput, a.Name+" - ", log.LstdFlags|log.Lmicroseconds)
agent.MemSink = &metrics.InmemSink{}
agent.MemSink = metrics.NewInmemSink(1*time.Second, time.Minute)
// we need the err var in the next exit condition
if err := agent.Start(); err == nil {