Skip to content

Commit 69ffd4f

Browse files
committed
Modify tests and update label on operation_mode metric
Signed-off-by: Mike Eves <[email protected]>
1 parent 2720965 commit 69ffd4f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

collector/slm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The Prometheus Authors
1+
// Copyright 2022 The Prometheus Authors
22
// Licensed under the Apache License, Version 2.0 (the "License");
33
// you may not use this file except in compliance with the License.
44
// You may obtain a copy of the License at
@@ -233,7 +233,7 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
233233
Desc: prometheus.NewDesc(
234234
prometheus.BuildFQName(namespace, "slm_stats", "operation_mode"),
235235
"Operating status of SLM",
236-
defaultPolicyLabels, nil,
236+
[]string{"operation_mode"}, nil,
237237
),
238238
Value: func(slmStatus SLMStatusResponse, operationMode string) float64 {
239239
if slmStatus.OperationMode == operationMode {

collector/slm_response.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The Prometheus Authors
1+
// Copyright 2022 The Prometheus Authors
22
// Licensed under the Apache License, Version 2.0 (the "License");
33
// you may not use this file except in compliance with the License.
44
// You may obtain a copy of the License at

collector/slm_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The Prometheus Authors
1+
// Copyright 2022 The Prometheus Authors
22
// Licensed under the Apache License, Version 2.0 (the "License");
33
// you may not use this file except in compliance with the License.
44
// You may obtain a copy of the License at
@@ -31,16 +31,16 @@ func TestSLM(t *testing.T) {
3131
// curl -XPUT http://127.0.0.1:9200/_slm/policy/everything -H 'Content-Type: application/json' -d '{"schedule":"0 */15 * * * ?","name":"<everything-{now/d}>","repository":"my_repository","config":{"indices":".*","include_global_state":true,"ignore_unavailable":true},"retention":{"expire_after":"7d"}}'
3232
// curl http://127.0.0.1:9200/_slm/stats (Numbers manually tweaked)
3333

34-
tcs := map[string][]string{
35-
"7.15.0": {`{"retention_runs":9,"retention_failed":0,"retention_timed_out":0,"retention_deletion_time":"1.2m","retention_deletion_time_millis":72491,"total_snapshots_taken":103,"total_snapshots_failed":2,"total_snapshots_deleted":20,"total_snapshot_deletion_failures":0,"policy_stats":[{"policy":"everything","snapshots_taken":50,"snapshots_failed":2,"snapshots_deleted":20,"snapshot_deletion_failures":0}]}`},
34+
tcs := map[string]string{
35+
"7.15.0": `{"retention_runs":9,"retention_failed":0,"retention_timed_out":0,"retention_deletion_time":"1.2m","retention_deletion_time_millis":72491,"total_snapshots_taken":103,"total_snapshots_failed":2,"total_snapshots_deleted":20,"total_snapshot_deletion_failures":0,"policy_stats":[{"policy":"everything","snapshots_taken":50,"snapshots_failed":2,"snapshots_deleted":20,"snapshot_deletion_failures":0}]}`,
3636
}
3737
for ver, out := range tcs {
3838
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
3939
if r.RequestURI == "/_slm/stats" {
40-
fmt.Fprint(w, out[0])
40+
fmt.Fprint(w, out)
4141
return
4242
}
43-
fmt.Fprint(w, out[1])
43+
fmt.Fprint(w, out)
4444
}))
4545
defer ts.Close()
4646

0 commit comments

Comments
 (0)