These tests are similar to Go unit tests except that they're targetting tesing of a running cAdvisor client. They do this by interacting with the testing framework that is able to talk to the running cAdvisor. This cAdvisor could be local or remote.
27 lines
495 B
Go
27 lines
495 B
Go
package healthz
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/google/cadvisor/integration/framework"
|
|
)
|
|
|
|
func TestHealthzOk(t *testing.T) {
|
|
fm := framework.New(t)
|
|
defer fm.Cleanup()
|
|
|
|
// Ensure that /heathz returns "ok"
|
|
resp, err := http.Get(fm.Host().FullHost() + "healthz")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer resp.Body.Close()
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
|
|
if string(body) != "ok" {
|
|
t.Fatalf("cAdvisor returned unexpected healthz status of %q", body)
|
|
}
|
|
}
|