Skip to content

Commit b50491c

Browse files
authored
Merge pull request #7829 from iamzili/revert-confidenceMultiplier-tests
VPA: Revert ConfidenceMultiplier tests
2 parents edcb1f2 + 6f7415e commit b50491c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

vertical-pod-autoscaler/pkg/recommender/logic/estimator_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,30 @@ func TestConfidenceMultiplier(t *testing.T) {
8383
// Expect testedEstimator2 to return zero.
8484
assert.Equal(t, model.ResourceAmount(0),
8585
testedEstimator2.GetResourceEstimation(s)[model.ResourceCPU])
86+
87+
timestamp := anyTime
88+
testedCPU3 := WithCPUConfidenceMultiplier(0.1, 2.0, baseCPUEstimator)
89+
testedMemory3 := WithMemoryConfidenceMultiplier(0.1, 2.0, baseMemoryEstimator)
90+
testedEstimator3 := NewCombinedEstimator(testedCPU3, testedMemory3)
91+
92+
for i := 1; i <= 9; i++ {
93+
s.AddSample(&model.ContainerUsageSample{
94+
MeasureStart: timestamp,
95+
Usage: model.CPUAmountFromCores(1.0),
96+
Resource: model.ResourceCPU,
97+
})
98+
timestamp = timestamp.Add(time.Minute * 2)
99+
}
100+
101+
// Expected confidence = 9/(60*24) = 0.00625.
102+
assert.Equal(t, 0.00625, getConfidence(s))
103+
// Expected CPU estimation = 3.14 * (1 + multiplier/confidence)^exponent =
104+
// 3.14 * (1 + 0.1/0.00625)^2 = 907.46.
105+
// Expected Memory estimation =
106+
// 3140000000 * (1 + 0.1/0.00625)^2 = 907460000000
107+
resourceEstimation := testedEstimator3.GetResourceEstimation(s)
108+
assert.Equal(t, 907.46, model.CoresFromCPUAmount(resourceEstimation[model.ResourceCPU]))
109+
assert.Equal(t, 9.0746e+11, model.BytesFromMemoryAmount(resourceEstimation[model.ResourceMemory]))
86110
}
87111

88112
// Verifies that the confidenceMultiplier works for the case of no

0 commit comments

Comments
 (0)