@@ -15,6 +15,7 @@ import (
15
15
"github.com/grafana/metrictank/mdata/cache"
16
16
"github.com/grafana/metrictank/mdata/cache/accnt"
17
17
"github.com/grafana/metrictank/mdata/chunk"
18
+ "github.com/grafana/metrictank/mdata/memorystore"
18
19
"github.com/grafana/metrictank/test"
19
20
"gopkg.in/raintank/schema.v1"
20
21
)
@@ -346,7 +347,10 @@ func TestGetSeriesFixed(t *testing.T) {
346
347
mdata .SetSingleAgg (conf .Avg , conf .Min , conf .Max )
347
348
mdata .SetSingleSchema (conf .NewRetentionMT (10 , 100 , 600 , 10 , true ))
348
349
349
- metrics := mdata .NewAggMetrics (store , & cache.MockCache {}, false , 0 , 0 , 0 )
350
+ metrics := memorystore .NewAggMetrics (0 , 0 , 0 )
351
+ mdata .Cache = & cache.MockCache {}
352
+ mdata .BackendStore = store
353
+ mdata .MemoryStore = metrics
350
354
srv , _ := NewServer ()
351
355
srv .BindBackendStore (store )
352
356
srv .BindMemoryStore (metrics )
@@ -360,13 +364,14 @@ func TestGetSeriesFixed(t *testing.T) {
360
364
for from := uint32 (11 ); from <= 20 ; from ++ { // should always yield result with first point at 20 (because from is inclusive)
361
365
for to := uint32 (31 ); to <= 40 ; to ++ { // should always yield result with last point at 30 (because to is exclusive)
362
366
name := fmt .Sprintf ("case.data.offset.%d.query:%d-%d" , offset , from , to )
363
-
364
- metric := metrics .GetOrCreate (name , name , 0 , 0 )
365
- metric .Add (offset , 10 ) // this point will always be quantized to 10
366
- metric .Add (10 + offset , 20 ) // this point will always be quantized to 20, so it should be selected
367
- metric .Add (20 + offset , 30 ) // this point will always be quantized to 30, so it should be selected
368
- metric .Add (30 + offset , 40 ) // this point will always be quantized to 40
369
- metric .Add (40 + offset , 50 ) // this point will always be quantized to 50
367
+ agg := mdata .Aggregations .Get (0 )
368
+ s := mdata .Schemas .Get (0 )
369
+ metric , _ := metrics .LoadOrStore (name , memorystore .NewAggMetric (name , s .Retentions , s .ReorderWindow , & agg ))
370
+ metric .Add (& schema.MetricPoint {name , offset , 10 }) // this point will always be quantized to 10
371
+ metric .Add (& schema.MetricPoint {name , 10 + offset , 20 }) // this point will always be quantized to 20, so it should be selected
372
+ metric .Add (& schema.MetricPoint {name , 20 + offset , 30 }) // this point will always be quantized to 30, so it should be selected
373
+ metric .Add (& schema.MetricPoint {name , 30 + offset , 40 }) // this point will always be quantized to 40
374
+ metric .Add (& schema.MetricPoint {name , 40 + offset , 50 }) // this point will always be quantized to 50
370
375
req := models .NewReq (name , name , name , from , to , 1000 , 10 , consolidation .Avg , 0 , cluster .Manager .ThisNode (), 0 , 0 )
371
376
req .ArchInterval = 10
372
377
points , err := srv .getSeriesFixed (test .NewContext (), req , consolidation .None )
@@ -578,7 +583,10 @@ func TestGetSeriesCachedStore(t *testing.T) {
578
583
store := mdata .NewMockStore ()
579
584
srv .BindBackendStore (store )
580
585
581
- metrics := mdata .NewAggMetrics (store , & cache.MockCache {}, false , 0 , 0 , 0 )
586
+ metrics := memorystore .NewAggMetrics (0 , 0 , 0 )
587
+ mdata .Cache = & cache.MockCache {}
588
+ mdata .BackendStore = store
589
+ mdata .MemoryStore = metrics
582
590
srv .BindMemoryStore (metrics )
583
591
metric := "metric1"
584
592
var c * cache.CCache
@@ -757,7 +765,10 @@ func TestGetSeriesAggMetrics(t *testing.T) {
757
765
cluster .Init ("default" , "test" , time .Now (), "http" , 6060 )
758
766
store := mdata .NewMockStore ()
759
767
760
- metrics := mdata .NewAggMetrics (store , & cache.MockCache {}, false , 0 , 0 , 0 )
768
+ metrics := memorystore .NewAggMetrics (0 , 0 , 0 )
769
+ mdata .Cache = & cache.MockCache {}
770
+ mdata .BackendStore = store
771
+ mdata .MemoryStore = metrics
761
772
srv , _ := NewServer ()
762
773
srv .BindBackendStore (store )
763
774
srv .BindMemoryStore (metrics )
@@ -768,10 +779,11 @@ func TestGetSeriesAggMetrics(t *testing.T) {
768
779
req := reqRaw (metricKey , from , to , 100 , 10 , consolidation .None , 0 , 0 )
769
780
req .ArchInterval = archInterval
770
781
ctx := newRequestContext (test .NewContext (), & req , consolidation .None )
771
-
772
- metric := metrics .GetOrCreate (metricKey , metricKey , 0 , 0 )
782
+ agg := mdata .Aggregations .Get (0 )
783
+ s := mdata .Schemas .Get (0 )
784
+ metric , _ := metrics .LoadOrStore (metricKey , memorystore .NewAggMetric (metricKey , s .Retentions , s .ReorderWindow , & agg ))
773
785
for i := uint32 (50 ); i < 3000 ; i ++ {
774
- metric .Add (i , float64 (i ^ 2 ) )
786
+ metric .Add (& schema. MetricPoint { metricKey , i , float64 (i ^ 2 )} )
775
787
}
776
788
777
789
res , err := srv .getSeriesAggMetrics (ctx )
0 commit comments