test: cover daemon telemetry publication
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/rvbox/rvbox/internal/observability"
|
||||
"github.com/rvbox/rvbox/internal/server/store"
|
||||
)
|
||||
|
||||
func TestPublishServerTelemetrySample_HP_OPS_07(t *testing.T) {
|
||||
t.Parallel()
|
||||
health := observability.New()
|
||||
publishServerTelemetrySample(context.Background(), func(context.Context) (store.Telemetry, error) {
|
||||
return store.Telemetry{QueuedCommands: 3, ChargedBytes: 4096}, nil
|
||||
}, health)
|
||||
snapshot := health.MetricsSnapshot()
|
||||
if snapshot.Gauges["queue_depth"] != 3 || snapshot.Gauges["server_charged_bytes"] != 4096 {
|
||||
t.Fatalf("server telemetry gauges = %#v", snapshot.Gauges)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublishServerTelemetrySampleFailure_BH_OPS_04(t *testing.T) {
|
||||
t.Parallel()
|
||||
health := observability.New()
|
||||
publishServerTelemetrySample(context.Background(), func(context.Context) (store.Telemetry, error) {
|
||||
return store.Telemetry{}, errors.New("store unavailable")
|
||||
}, health)
|
||||
_, _, counters := health.Snapshot()
|
||||
if counters["telemetry_read_failure"] != 1 {
|
||||
t.Fatalf("telemetry failure counters = %#v", counters)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user