plugin/health: cleanups (#2811)

Small, trivial cleanup: got triggered because I saw a comment on how
health plugins polls other plugins which isn't true.

* Remove useless newHealth function
* healthParse -> parse
* Remove useless constants

Net deletion of code.

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2019-05-04 21:06:04 +01:00
committed by Yong Tang
parent e178291ed6
commit 890cdb5cab
6 changed files with 14 additions and 28 deletions

View File

@@ -9,15 +9,14 @@ import (
)
func TestHealth(t *testing.T) {
h := newHealth(":0")
h := &health{Addr: ":0", stop: make(chan bool)}
if err := h.OnStartup(); err != nil {
t.Fatalf("Unable to startup the health server: %v", err)
}
defer h.OnFinalShutdown()
// Reconstruct the http address based on the port allocated by operating system.
address := fmt.Sprintf("http://%s%s", h.ln.Addr().String(), path)
address := fmt.Sprintf("http://%s%s", h.ln.Addr().String(), "/health")
response, err := http.Get(address)
if err != nil {
@@ -32,14 +31,13 @@ func TestHealth(t *testing.T) {
}
response.Body.Close()
if string(content) != ok {
if string(content) != "OK" {
t.Errorf("Invalid response body: expecting 'OK', got '%s'", string(content))
}
}
func TestHealthLameduck(t *testing.T) {
h := newHealth(":0")
h.lameduck = 250 * time.Millisecond
h := &health{Addr: ":0", stop: make(chan bool), lameduck: 250 * time.Millisecond}
if err := h.OnStartup(); err != nil {
t.Fatalf("Unable to startup the health server: %v", err)