Skip to content

Commit

Permalink
Merge pull request #7829 from iamzili/revert-confidenceMultiplier-tests
Browse files Browse the repository at this point in the history
VPA: Revert ConfidenceMultiplier tests
  • Loading branch information
k8s-ci-robot authored Feb 14, 2025
2 parents edcb1f2 + 6f7415e commit b50491c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions vertical-pod-autoscaler/pkg/recommender/logic/estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ func TestConfidenceMultiplier(t *testing.T) {
// Expect testedEstimator2 to return zero.
assert.Equal(t, model.ResourceAmount(0),
testedEstimator2.GetResourceEstimation(s)[model.ResourceCPU])

timestamp := anyTime
testedCPU3 := WithCPUConfidenceMultiplier(0.1, 2.0, baseCPUEstimator)
testedMemory3 := WithMemoryConfidenceMultiplier(0.1, 2.0, baseMemoryEstimator)
testedEstimator3 := NewCombinedEstimator(testedCPU3, testedMemory3)

for i := 1; i <= 9; i++ {
s.AddSample(&model.ContainerUsageSample{
MeasureStart: timestamp,
Usage: model.CPUAmountFromCores(1.0),
Resource: model.ResourceCPU,
})
timestamp = timestamp.Add(time.Minute * 2)
}

// Expected confidence = 9/(60*24) = 0.00625.
assert.Equal(t, 0.00625, getConfidence(s))
// Expected CPU estimation = 3.14 * (1 + multiplier/confidence)^exponent =
// 3.14 * (1 + 0.1/0.00625)^2 = 907.46.
// Expected Memory estimation =
// 3140000000 * (1 + 0.1/0.00625)^2 = 907460000000
resourceEstimation := testedEstimator3.GetResourceEstimation(s)
assert.Equal(t, 907.46, model.CoresFromCPUAmount(resourceEstimation[model.ResourceCPU]))
assert.Equal(t, 9.0746e+11, model.BytesFromMemoryAmount(resourceEstimation[model.ResourceMemory]))
}

// Verifies that the confidenceMultiplier works for the case of no
Expand Down

0 comments on commit b50491c

Please sign in to comment.