mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-26 05:01:23 -08:00
Add rendering test of template based web endpoints (#5188)
Signed-off-by: Minh-Long Do <minhlong.langos@gmail.com>
This commit is contained in:
parent
fc10f6d814
commit
b26b5c9e96
|
@ -25,6 +25,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/prometheus/config"
|
||||
"github.com/prometheus/prometheus/notifier"
|
||||
"github.com/prometheus/prometheus/rules"
|
||||
"github.com/prometheus/prometheus/scrape"
|
||||
"github.com/prometheus/prometheus/storage/tsdb"
|
||||
"github.com/prometheus/prometheus/util/testutil"
|
||||
libtsdb "github.com/prometheus/tsdb"
|
||||
|
@ -101,8 +105,8 @@ func TestReadyAndHealthy(t *testing.T) {
|
|||
Context: nil,
|
||||
Storage: &tsdb.ReadyStorage{},
|
||||
QueryEngine: nil,
|
||||
ScrapeManager: nil,
|
||||
RuleManager: nil,
|
||||
ScrapeManager: &scrape.Manager{},
|
||||
RuleManager: &rules.Manager{},
|
||||
Notifier: nil,
|
||||
RoutePrefix: "/",
|
||||
EnableAdminAPI: true,
|
||||
|
@ -118,6 +122,10 @@ func TestReadyAndHealthy(t *testing.T) {
|
|||
opts.Flags = map[string]string{}
|
||||
|
||||
webHandler := New(nil, opts)
|
||||
|
||||
webHandler.config = &config.Config{}
|
||||
webHandler.notifier = ¬ifier.Manager{}
|
||||
|
||||
go func() {
|
||||
err := webHandler.Run(context.Background())
|
||||
if err != nil {
|
||||
|
@ -159,6 +167,46 @@ func TestReadyAndHealthy(t *testing.T) {
|
|||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/graph")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/alerts")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/flags")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/rules")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/service-discovery")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/targets")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/config")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/status")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||
|
||||
// Set to ready.
|
||||
webHandler.Ready()
|
||||
|
||||
|
@ -191,6 +239,41 @@ func TestReadyAndHealthy(t *testing.T) {
|
|||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/alerts")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/flags")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/rules")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/service-discovery")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/targets")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/config")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get("http://localhost:9090/status")
|
||||
|
||||
testutil.Ok(t, err)
|
||||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||
}
|
||||
|
||||
func TestRoutePrefix(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue