Skip to content

Commit

Permalink
Modify tests and update label on operation_mode metric
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Eves <michael.eves@autotrader.co.uk>
  • Loading branch information
Evesy committed May 12, 2022
1 parent 2720965 commit 69ffd4f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions collector/slm.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The Prometheus Authors
// Copyright 2022 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -233,7 +233,7 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "slm_stats", "operation_mode"),
"Operating status of SLM",
defaultPolicyLabels, nil,
[]string{"operation_mode"}, nil,
),
Value: func(slmStatus SLMStatusResponse, operationMode string) float64 {
if slmStatus.OperationMode == operationMode {
Expand Down
2 changes: 1 addition & 1 deletion collector/slm_response.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The Prometheus Authors
// Copyright 2022 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down
10 changes: 5 additions & 5 deletions collector/slm_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The Prometheus Authors
// Copyright 2022 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -31,16 +31,16 @@ func TestSLM(t *testing.T) {
// 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"}}'
// curl http://127.0.0.1:9200/_slm/stats (Numbers manually tweaked)

tcs := map[string][]string{
"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}]}`},
tcs := map[string]string{
"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}]}`,
}
for ver, out := range tcs {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.RequestURI == "/_slm/stats" {
fmt.Fprint(w, out[0])
fmt.Fprint(w, out)
return
}
fmt.Fprint(w, out[1])
fmt.Fprint(w, out)
}))
defer ts.Close()

Expand Down

0 comments on commit 69ffd4f

Please sign in to comment.