@@ -363,7 +363,7 @@ func TestOneRuleMultiHistory(t *testing.T) {
363363 lg , _ := logger .CreateLoggerForTest (t )
364364 br := NewBackendReader (lg , nil , nil , nil , nil , nil )
365365 var lastTs model.Time
366- var length int
366+ var step1Len , step2Len int
367367 for i , test := range tests {
368368 br .queryRules = map [string ]QueryRule {
369369 "key" : {
@@ -379,17 +379,30 @@ func TestOneRuleMultiHistory(t *testing.T) {
379379 }
380380
381381 br .metric2History (mfs , "backend" )
382+ history := br .history ["key" ]
383+ if ! math .IsNaN (float64 (test .step1Value )) {
384+ step1Len ++
385+ }
386+ if step1Len > 0 {
387+ require .Equal (t , step1Len , len (history ["backend" ].Step1History ), "case %d" , i )
388+ }
389+ if ! math .IsNaN (float64 (test .step2Value )) {
390+ step2Len ++
391+ }
392+ if step2Len > 0 {
393+ require .Equal (t , step2Len , len (history ["backend" ].Step2History ), "case %d" , i )
394+ }
395+
382396 res := br .history2Value ("backend" )
383397 value := res ["key" ]
384398 if math .IsNaN (float64 (test .step2Value )) {
385399 continue
386400 }
387- length ++
388401 require .Equal (t , model .ValMatrix , value .Type (), "case %d" , i )
389402 matrix := value .(model.Matrix )
390403 require .Len (t , matrix , 1 , "case %d" , i )
391404 require .Equal (t , model .LabelValue ("backend" ), matrix [0 ].Metric [LabelNameInstance ], "case %d" , i )
392- require .Len (t , matrix [0 ].Values , length , "case %d" , i )
405+ require .Len (t , matrix [0 ].Values , step2Len , "case %d" , i )
393406 pair := matrix [0 ].Values [len (matrix [0 ].Values )- 1 ]
394407 require .Equal (t , test .step2Value , pair .Value , "case %d" , i )
395408 require .GreaterOrEqual (t , pair .Timestamp , lastTs , "case %d" , i )
0 commit comments