diff --git a/command/operator_debug.go b/command/operator_debug.go index 914732220450..86e90218e936 100644 --- a/command/operator_debug.go +++ b/command/operator_debug.go @@ -169,7 +169,7 @@ Debug Options: -pprof-interval= The interval between pprof collections. Set interval equal to - duration to capture a single snapshot. Defaults to 30s. + duration to capture a single snapshot. Defaults to 250ms. -log-level= The log level to monitor. Defaults to DEBUG. @@ -355,8 +355,8 @@ func (c *OperatorDebugCommand) Run(args []string) int { flags.StringVar(&serverIDs, "server-id", "all", "") flags.BoolVar(&allowStale, "stale", false, "") flags.StringVar(&output, "output", "", "") - flags.StringVar(&pprofDuration, "pprof-duration", "1m", "") - flags.StringVar(&pprofInterval, "pprof-interval", "30s", "") + flags.StringVar(&pprofDuration, "pprof-duration", "1s", "") + flags.StringVar(&pprofInterval, "pprof-interval", "250ms", "") flags.BoolVar(&c.verbose, "verbose", false, "") c.consul = &external{tls: &api.TLSConfig{}} diff --git a/command/operator_debug_test.go b/command/operator_debug_test.go index caeb3f8142fb..e5de2971f3b4 100644 --- a/command/operator_debug_test.go +++ b/command/operator_debug_test.go @@ -208,12 +208,12 @@ func TestDebug_MultiRegion(t *testing.T) { // Good { name: "no region - all servers, all clients", - args: []string{"-address", addrServer1, "-duration", "250ms", "-interval", "250ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "0"}, + args: []string{"-address", addrServer1, "-duration", "250ms", "-interval", "250ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "1s", "-pprof-interval", "250ms"}, expectedCode: 0, }, { name: "region1 - server1 address", - args: []string{"-address", addrServer1, "-region", region1, "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "0"}, + args: []string{"-address", addrServer1, "-region", region1, "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "1s", "-pprof-interval", "250ms"}, expectedCode: 0, expectedOutputs: []string{ "Region: " + region1 + "\n", @@ -224,7 +224,7 @@ func TestDebug_MultiRegion(t *testing.T) { }, { name: "region1 - client1 address", - args: []string{"-address", addrClient1, "-region", region1, "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "0"}, + args: []string{"-address", addrClient1, "-region", region1, "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "1s", "-pprof-interval", "250ms"}, expectedCode: 0, expectedOutputs: []string{ "Region: " + region1 + "\n", @@ -235,7 +235,7 @@ func TestDebug_MultiRegion(t *testing.T) { }, { name: "region2 - server2 address", - args: []string{"-address", addrServer2, "-region", region2, "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "0"}, + args: []string{"-address", addrServer2, "-region", region2, "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "1s", "-pprof-interval", "250ms"}, expectedCode: 0, expectedOutputs: []string{ "Region: " + region2 + "\n", @@ -246,7 +246,7 @@ func TestDebug_MultiRegion(t *testing.T) { }, { name: "region2 - client2 address", - args: []string{"-address", addrClient2, "-region", region2, "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "0"}, + args: []string{"-address", addrClient2, "-region", region2, "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "1s", "-pprof-interval", "250ms"}, expectedCode: 0, expectedOutputs: []string{ "Region: " + region2 + "\n", @@ -259,7 +259,7 @@ func TestDebug_MultiRegion(t *testing.T) { // Bad { name: "invalid region - all servers, all clients", - args: []string{"-address", addrServer1, "-region", "never", "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "0"}, + args: []string{"-address", addrServer1, "-region", "never", "-duration", "50ms", "-interval", "50ms", "-server-id", "all", "-node-id", "all", "-pprof-duration", "1s", "-pprof-interval", "250ms"}, expectedCode: 1, expectedError: "500 (No path to region)", }, @@ -344,6 +344,11 @@ func TestDebug_Failures(t *testing.T) { args: []string{"-pprof-duration", "baz"}, expectedCode: 1, }, + { + name: "Fails bad pprof interval", + args: []string{"-pprof-interval", "bar"}, + expectedCode: 1, + }, { name: "Fails bad address", args: []string{"-address", url + "bogus"}, @@ -478,7 +483,8 @@ func TestDebug_CapturedFiles(t *testing.T) { "-node-id", clientID, "-duration", duration.String(), "-interval", interval.String(), - "-pprof-duration", "0", + "-pprof-duration", "1s", + "-pprof-interval", "250ms", }) // Get capture directory