open-consul/api/debug_test.go
Ronald 24f91d9077
Add copyright headers for acl, api and bench folders (#16706)
* copyright headers for agent folder

* Ignore test data files

* fix proto files and remove headers in agent/uiserver folder

* ignore deep-copy files

* copyright headers for agent folder

* fix merge conflicts

* copyright headers for agent folder

* Ignore test data files

* fix proto files

* ignore agent/uiserver folder for now

* copyright headers for agent folder

* Add copyright headers for acl, api and bench folders
2023-03-28 16:12:41 -04:00

87 lines
1.5 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package api
import (
"testing"
"github.com/hashicorp/consul/sdk/testutil"
)
func TestAPI_DebugHeap(t *testing.T) {
t.Parallel()
c, s := makeClientWithConfig(t, nil, func(conf *testutil.TestServerConfig) {
conf.EnableDebug = true
})
defer s.Stop()
debug := c.Debug()
raw, err := debug.Heap()
if err != nil {
t.Fatalf("err: %v", err)
}
if len(raw) <= 0 {
t.Fatalf("no response: %#v", raw)
}
}
func TestAPI_DebugProfile(t *testing.T) {
t.Parallel()
c, s := makeClientWithConfig(t, nil, func(conf *testutil.TestServerConfig) {
conf.EnableDebug = true
})
defer s.Stop()
debug := c.Debug()
raw, err := debug.Profile(1)
if err != nil {
t.Fatalf("err: %v", err)
}
if len(raw) <= 0 {
t.Fatalf("no response: %#v", raw)
}
}
func TestAPI_DebugGoroutine(t *testing.T) {
t.Parallel()
c, s := makeClientWithConfig(t, nil, func(conf *testutil.TestServerConfig) {
conf.EnableDebug = true
})
defer s.Stop()
debug := c.Debug()
raw, err := debug.Goroutine()
if err != nil {
t.Fatalf("err: %v", err)
}
if len(raw) <= 0 {
t.Fatalf("no response: %#v", raw)
}
}
func TestAPI_DebugTrace(t *testing.T) {
t.Parallel()
c, s := makeClientWithConfig(t, nil, func(conf *testutil.TestServerConfig) {
conf.EnableDebug = true
})
defer s.Stop()
debug := c.Debug()
raw, err := debug.Trace(1)
if err != nil {
t.Fatalf("err: %v", err)
}
if len(raw) <= 0 {
t.Fatalf("no response: %#v", raw)
}
}