mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 18:39:58 +00:00
TUN-7553: Add flag to enable management diagnostic services
With the new flag --management-diagnostics (an opt-in flag) cloudflared's will be able to report additional diagnostic information over the management.argotunnel.com request path. Additions include the /metrics prometheus endpoint; which is already bound to a local port via --metrics. /debug/pprof/(goroutine|heap) are also provided to allow for remotely retrieving heap information from a running cloudflared connector.
This commit is contained in:
@@ -3,9 +3,13 @@ package management
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -15,9 +19,23 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
noopLogger = zerolog.New(io.Discard)
|
||||
noopLogger = zerolog.New(io.Discard)
|
||||
managementHostname = "https://management.argotunnel.com"
|
||||
)
|
||||
|
||||
func TestDisableDiagnosticRoutes(t *testing.T) {
|
||||
mgmt := New("management.argotunnel.com", false, "1.1.1.1:80", uuid.Nil, "", &noopLogger, nil)
|
||||
for _, path := range []string{"/metrics", "/debug/pprof/goroutine", "/debug/pprof/heap"} {
|
||||
t.Run(strings.Replace(path, "/", "_", -1), func(t *testing.T) {
|
||||
req := httptest.NewRequest("GET", managementHostname+path+"?access_token="+validToken, nil)
|
||||
recorder := httptest.NewRecorder()
|
||||
mgmt.ServeHTTP(recorder, req)
|
||||
resp := recorder.Result()
|
||||
require.Equal(t, http.StatusNotFound, resp.StatusCode)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadEventsLoop(t *testing.T) {
|
||||
sentEvent := EventStartStreaming{
|
||||
ClientEvent: ClientEvent{Type: StartStreaming},
|
||||
|
Reference in New Issue
Block a user