@@ -547,6 +547,15 @@ func TestHead_HighConcurrencyReadAndWrite(t *testing.T) {
547
547
})
548
548
}
549
549
550
+ // queryHead is a helper to query the head for a given time range and labelset.
551
+ queryHead := func (mint , maxt uint64 , label labels.Label ) (map [string ][]chunks.Sample , error ) {
552
+ q , err := NewBlockQuerier (head , int64 (mint ), int64 (maxt ))
553
+ if err != nil {
554
+ return nil , err
555
+ }
556
+ return query (t , q , labels .MustNewMatcher (labels .MatchEqual , label .Name , label .Value )), nil
557
+ }
558
+
550
559
// readerTsCh will be used by the coordinator go routine to coordinate which timestamps the reader should read.
551
560
readerTsCh := make (chan uint64 )
552
561
@@ -574,7 +583,7 @@ func TestHead_HighConcurrencyReadAndWrite(t *testing.T) {
574
583
lbls .Range (func (l labels.Label ) {
575
584
lbl = l
576
585
})
577
- samples , err := queryHead (t , head , int64 ( ts - qryRange ), int64 ( ts ) , lbl )
586
+ samples , err := queryHead (ts - qryRange , ts , lbl )
578
587
if err != nil {
579
588
return false , err
580
589
}
@@ -6089,42 +6098,6 @@ func TestCuttingNewHeadChunks(t *testing.T) {
6089
6098
}
6090
6099
}
6091
6100
6092
- func TestAppendDuplicates (t * testing.T ) {
6093
- ts := int64 (1695209650 )
6094
- lbls := labels .FromStrings ("foo" , "bar" )
6095
- h , _ := newTestHead (t , DefaultBlockDuration , wlog .CompressionNone , false )
6096
- defer func () {
6097
- require .NoError (t , h .Close ())
6098
- }()
6099
-
6100
- a := h .Appender (context .Background ())
6101
- _ , err := a .Append (0 , lbls , ts , 42.0 )
6102
- require .NoError (t , err )
6103
- _ , err = a .Append (0 , lbls , ts , 42.0 ) // Exactly the same value.
6104
- require .NoError (t , err )
6105
- _ , err = a .Append (0 , lbls , ts , math .Float64frombits (value .QuietZeroNaN )) // Should be a no-op.
6106
- require .NoError (t , err )
6107
- require .NoError (t , a .Commit ())
6108
-
6109
- result , err := queryHead (t , h , math .MinInt64 , math .MaxInt64 , labels.Label {Name : "foo" , Value : "bar" })
6110
- require .NoError (t , err )
6111
- expectedSamples := []chunks.Sample {sample {t : ts , f : 42.0 }}
6112
- require .Equal (t , expectedSamples , result [`{foo="bar"}` ])
6113
-
6114
- a = h .Appender (context .Background ())
6115
- _ , err = a .Append (0 , lbls , ts + 10 , math .Float64frombits (value .QuietZeroNaN )) // This is at a different timestamp so should append a real zero.
6116
- require .NoError (t , err )
6117
- require .NoError (t , a .Commit ())
6118
-
6119
- result , err = queryHead (t , h , math .MinInt64 , math .MaxInt64 , labels.Label {Name : "foo" , Value : "bar" })
6120
- require .NoError (t , err )
6121
- expectedSamples = []chunks.Sample {
6122
- sample {t : ts , f : 42.0 },
6123
- sample {t : ts + 10 , f : 0 },
6124
- }
6125
- require .Equal (t , expectedSamples , result [`{foo="bar"}` ])
6126
- }
6127
-
6128
6101
// TestHeadDetectsDuplicateSampleAtSizeLimit tests a regression where a duplicate sample
6129
6102
// is appended to the head, right when the head chunk is at the size limit.
6130
6103
// The test adds all samples as duplicate, thus expecting that the result has
0 commit comments