step one
This commit is contained in:
parent
7a8d5d13fa
commit
9e663db9dc
68 changed files with 5647 additions and 2958 deletions
49
internal/metrics/prom_test.go
Normal file
49
internal/metrics/prom_test.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestPromCounters(t *testing.T) {
|
||||
p := NewProm()
|
||||
p.Prediction("standard_profile", 100*time.Millisecond, nil)
|
||||
p.Prediction("standard_profile", 200*time.Millisecond, nil)
|
||||
p.Prediction("float_profile", 50*time.Millisecond, nil)
|
||||
|
||||
var buf bytes.Buffer
|
||||
p.Write(&buf)
|
||||
out := buf.String()
|
||||
|
||||
if !strings.Contains(out, `predictor_predictions_total{profile="standard_profile",status="ok"} 2`) {
|
||||
t.Errorf("expected count=2 for standard_profile, got: %s", out)
|
||||
}
|
||||
if !strings.Contains(out, `predictor_predictions_total{profile="float_profile",status="ok"} 1`) {
|
||||
t.Errorf("expected count=1 for float_profile, got: %s", out)
|
||||
}
|
||||
// Sum of durations: 0.1 + 0.2 = 0.3 seconds.
|
||||
if !strings.Contains(out, "predictor_prediction_duration_seconds_sum") {
|
||||
t.Errorf("expected sum present, got: %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPromGauge(t *testing.T) {
|
||||
p := NewProm()
|
||||
p.ActiveEpoch(time.Unix(1700000000, 0))
|
||||
|
||||
var buf bytes.Buffer
|
||||
p.Write(&buf)
|
||||
out := buf.String()
|
||||
if !strings.Contains(out, "predictor_active_dataset_epoch_seconds 1.7e+09") {
|
||||
t.Errorf("expected gauge with epoch 1700000000, got: %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoop(t *testing.T) {
|
||||
sink := Noop()
|
||||
sink.Prediction("any", time.Second, nil)
|
||||
sink.Download("any", time.Second, "complete", 0)
|
||||
sink.ActiveEpoch(time.Now())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue