Skip to content

Commit 6c43f2e

Browse files
committed
api/prometheus/v1/api_test.go: Add test case for runtimeinfo endpoint
Signed-off-by: Lili Cosic <[email protected]>
1 parent c9e3c02 commit 6c43f2e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

api/prometheus/v1/api_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ func TestAPIs(t *testing.T) {
144144
}
145145
}
146146

147+
doRuntimeinfo := func() func() (interface{}, Warnings, error) {
148+
return func() (interface{}, Warnings, error) {
149+
v, err := promAPI.Runtimeinfo(context.Background())
150+
return v, nil, err
151+
}
152+
}
153+
147154
doLabelNames := func(label string) func() (interface{}, Warnings, error) {
148155
return func() (interface{}, Warnings, error) {
149156
return promAPI.LabelNames(context.Background())
@@ -605,6 +612,48 @@ func TestAPIs(t *testing.T) {
605612
err: fmt.Errorf("some error"),
606613
},
607614

615+
{
616+
do: doRuntimeinfo(),
617+
reqMethod: "GET",
618+
reqPath: "/api/v1/status/runtimeinfo",
619+
inErr: fmt.Errorf("some error"),
620+
err: fmt.Errorf("some error"),
621+
},
622+
623+
{
624+
do: doRuntimeinfo(),
625+
reqMethod: "GET",
626+
reqPath: "/api/v1/status/runtimeinfo",
627+
inRes: map[string]interface{}{
628+
"startTime": "2020-05-18T15:52:53.4503113Z",
629+
"CWD": "/prometheus",
630+
"reloadConfigSuccess": true,
631+
"lastConfigTime": "2020-05-18T15:52:56Z",
632+
"chunkCount": 72692,
633+
"timeSeriesCount": 18476,
634+
"corruptionCount": 0,
635+
"goroutineCount": 217,
636+
"GOMAXPROCS": 2,
637+
"GOGC": "100",
638+
"GODEBUG": "allocfreetrace",
639+
"storageRetention": "1d",
640+
},
641+
res: RuntimeinfoResult{
642+
StartTime: "2020-05-18T15:52:53.4503113Z",
643+
CWD: "/prometheus",
644+
ReloadConfigSuccess: true,
645+
LastConfigTime: "2020-05-18T15:52:56Z",
646+
ChunkCount: 72692,
647+
TimeSeriesCount: 18476,
648+
CorruptionCount: 0,
649+
GoroutineCount: 217,
650+
GOMAXPROCS: 2,
651+
GOGC: "100",
652+
GODEBUG: "allocfreetrace",
653+
StorageRetention: "1d",
654+
},
655+
},
656+
608657
{
609658
do: doAlertManagers(),
610659
reqMethod: "GET",

0 commit comments

Comments
 (0)