From 6c43f2ebc25a88f7d96b60fd9e66181ab13e694a Mon Sep 17 00:00:00 2001 From: Lili Cosic Date: Mon, 18 May 2020 20:08:59 +0200 Subject: [PATCH] api/prometheus/v1/api_test.go: Add test case for runtimeinfo endpoint Signed-off-by: Lili Cosic --- api/prometheus/v1/api_test.go | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/api/prometheus/v1/api_test.go b/api/prometheus/v1/api_test.go index b36c380..cb6eaa5 100644 --- a/api/prometheus/v1/api_test.go +++ b/api/prometheus/v1/api_test.go @@ -144,6 +144,13 @@ func TestAPIs(t *testing.T) { } } + doRuntimeinfo := func() func() (interface{}, Warnings, error) { + return func() (interface{}, Warnings, error) { + v, err := promAPI.Runtimeinfo(context.Background()) + return v, nil, err + } + } + doLabelNames := func(label string) func() (interface{}, Warnings, error) { return func() (interface{}, Warnings, error) { return promAPI.LabelNames(context.Background()) @@ -605,6 +612,48 @@ func TestAPIs(t *testing.T) { err: fmt.Errorf("some error"), }, + { + do: doRuntimeinfo(), + reqMethod: "GET", + reqPath: "/api/v1/status/runtimeinfo", + inErr: fmt.Errorf("some error"), + err: fmt.Errorf("some error"), + }, + + { + do: doRuntimeinfo(), + reqMethod: "GET", + reqPath: "/api/v1/status/runtimeinfo", + inRes: map[string]interface{}{ + "startTime": "2020-05-18T15:52:53.4503113Z", + "CWD": "/prometheus", + "reloadConfigSuccess": true, + "lastConfigTime": "2020-05-18T15:52:56Z", + "chunkCount": 72692, + "timeSeriesCount": 18476, + "corruptionCount": 0, + "goroutineCount": 217, + "GOMAXPROCS": 2, + "GOGC": "100", + "GODEBUG": "allocfreetrace", + "storageRetention": "1d", + }, + res: RuntimeinfoResult{ + StartTime: "2020-05-18T15:52:53.4503113Z", + CWD: "/prometheus", + ReloadConfigSuccess: true, + LastConfigTime: "2020-05-18T15:52:56Z", + ChunkCount: 72692, + TimeSeriesCount: 18476, + CorruptionCount: 0, + GoroutineCount: 217, + GOMAXPROCS: 2, + GOGC: "100", + GODEBUG: "allocfreetrace", + StorageRetention: "1d", + }, + }, + { do: doAlertManagers(), reqMethod: "GET",