@@ -83,6 +83,30 @@ func TestConfidenceMultiplier(t *testing.T) {
83
83
// Expect testedEstimator2 to return zero.
84
84
assert .Equal (t , model .ResourceAmount (0 ),
85
85
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 ]))
86
110
}
87
111
88
112
// Verifies that the confidenceMultiplier works for the case of no
0 commit comments