mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
44b071296d
### Describe Your Changes Added an ability to query data across multiple tenants. See: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1434 Currently, the following endpoints work with multi-tenancy: - /prometheus/api/v1/query - /prometheus/api/v1/query_range - /prometheus/api/v1/series - /prometheus/api/v1/labels - /prometheus/api/v1/label/<label_name>/values - /prometheus/api/v1/status/active_queries - /prometheus/api/v1/status/top_queries - /prometheus/api/v1/status/tsdb - /prometheus/api/v1/export - /prometheus/api/v1/export/csv - /vmui A note regarding VMUI: endpoints such as `active_queries` and `top_queries` have been updated to indicate whether query was a single-tenant or multi-tenant, but UI needs to be updated to display this info. cc: @Loori-R --------- Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> Signed-off-by: f41gh7 <nik@victoriametrics.com> Co-authored-by: f41gh7 <nik@victoriametrics.com>
69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
package timeutil
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestAddJitterToDuration(t *testing.T) {
|
|
f := func(d time.Duration) {
|
|
t.Helper()
|
|
result := AddJitterToDuration(d)
|
|
if result < d {
|
|
t.Fatalf("unexpected negative jitter")
|
|
}
|
|
variance := (float64(result) - float64(d)) / float64(d)
|
|
if variance > 0.1 {
|
|
t.Fatalf("too big variance=%.2f for result=%s, d=%s; mustn't exceed 0.1", variance, result, d)
|
|
}
|
|
}
|
|
|
|
f(time.Nanosecond)
|
|
f(time.Microsecond)
|
|
f(time.Millisecond)
|
|
f(time.Second)
|
|
f(time.Hour)
|
|
f(24 * time.Hour)
|
|
}
|
|
|
|
func TestStartOfDay(t *testing.T) {
|
|
f := func(original, expected time.Time) {
|
|
t.Helper()
|
|
|
|
result := StartOfDay(original.UnixMilli())
|
|
if result != expected.UnixMilli() {
|
|
t.Fatalf("unexpected result; got %d; want %d", result, expected.UnixMilli())
|
|
}
|
|
}
|
|
|
|
f(
|
|
time.Date(2021, 1, 1, 1, 1, 1, 0, time.UTC),
|
|
time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
)
|
|
|
|
f(
|
|
time.Date(2021, 1, 1, 23, 59, 59, 999999999, time.UTC),
|
|
time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC),
|
|
)
|
|
}
|
|
|
|
func TestEndOfDay(t *testing.T) {
|
|
f := func(original, expected time.Time) {
|
|
t.Helper()
|
|
|
|
result := EndOfDay(original.UnixMilli())
|
|
if result != expected.UnixMilli() {
|
|
t.Fatalf("unexpected result; got %d; want %d", result, expected.UnixMilli())
|
|
}
|
|
}
|
|
|
|
f(
|
|
time.Date(2021, 1, 1, 1, 1, 1, 0, time.UTC),
|
|
time.Date(2021, 1, 1, 23, 59, 59, 999999999, time.UTC),
|
|
)
|
|
|
|
f(
|
|
time.Date(2021, 1, 1, 23, 59, 59, 999999999, time.UTC),
|
|
time.Date(2021, 1, 1, 23, 59, 59, 999999999, time.UTC),
|
|
)
|
|
}
|