mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-25 20:00:06 +01:00
34 lines
794 B
Go
34 lines
794 B
Go
|
package servers
|
||
|
|
||
|
import (
|
||
|
"math"
|
||
|
"runtime"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestCalculateMaxMetricsLimitByResource(t *testing.T) {
|
||
|
f := func(maxConcurrentRequest, remainingMemory, expect int) {
|
||
|
t.Helper()
|
||
|
maxMetricsLimit := calculateMaxUniqueTimeSeriesForResource(maxConcurrentRequest, remainingMemory)
|
||
|
if maxMetricsLimit != expect {
|
||
|
t.Fatalf("unexpected max metrics limit: got %d, want %d", maxMetricsLimit, expect)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Skip when GOARCH=386
|
||
|
if runtime.GOARCH != "386" {
|
||
|
// 8 CPU & 32 GiB
|
||
|
f(16, int(math.Round(32*1024*1024*1024*0.4)), 4294967)
|
||
|
// 4 CPU & 32 GiB
|
||
|
f(8, int(math.Round(32*1024*1024*1024*0.4)), 8589934)
|
||
|
}
|
||
|
|
||
|
// 2 CPU & 4 GiB
|
||
|
f(4, int(math.Round(4*1024*1024*1024*0.4)), 2147483)
|
||
|
|
||
|
// other edge cases
|
||
|
f(0, int(math.Round(4*1024*1024*1024*0.4)), 2e9)
|
||
|
f(4, 0, 0)
|
||
|
|
||
|
}
|