consul/api/debug_test.go
Jeff Mitchell 47c390025b
Convert to Go Modules (#5517)
* First conversion

* Use serf 0.8.2 tag and associated updated deps

* * Move freeport and testutil into internal/

* Make internal/ its own module

* Update imports

* Add replace statements so API and normal Consul code are
self-referencing for ease of development

* Adapt to newer goe/values

* Bump to new cleanhttp

* Fix ban nonprintable chars test

* Update lock bad args test

The error message when the duration cannot be parsed changed in Go 1.12
(ae0c435877d3aacb9af5e706c40f9dddde5d3e67). This updates that test.

* Update another test as well

* Bump travis

* Bump circleci

* Bump go-discover and godo to get rid of launchpad dep

* Bump dockerfile go version

* fix tar command

* Bump go-cleanhttp
2019-03-26 17:04:58 -04:00

84 lines
1.4 KiB
Go

package api
import (
"testing"
"github.com/hashicorp/consul/internal/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)
}
}