Skip to content

Commit

Permalink
test(storage): add read group test with no agg
Browse files Browse the repository at this point in the history
  • Loading branch information
Faith Chikwekwe committed Apr 20, 2021
1 parent fb21461 commit 94919fb
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions storage/flux/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,7 @@ func TestStorageReader_ReadGroupSelectTags(t *testing.T) {
},
},
},

}

for _, tt := range cases {
Expand All @@ -2973,6 +2974,66 @@ func TestStorageReader_ReadGroupSelectTags(t *testing.T) {
}
}

// TestStorageReader_ReadGroupNoAgg exercises the path where no aggregate is specified
func TestStorageReader_ReadGroupNoAgg(t *testing.T) {
reader := NewStorageReader(t, func(org, bucket platform.ID) (datagen.SeriesGenerator, datagen.TimeRange) {
spec := Spec(org, bucket,
MeasurementSpec("m0",
FloatArrayValuesSequence("f0", 10*time.Second, []float64{1.0, 2.0, 3.0, 4.0}),
TagValuesSequence("t1", "b-%s", 0, 1),
),
)
tr := TimeRange("2019-11-25T00:00:00Z", "2019-11-25T00:00:40Z")
return datagen.NewSeriesGeneratorFromSpec(spec, tr), tr
})
defer reader.Close()

cases := []struct {
aggregate string
want flux.TableIterator
}{
{
want: static.TableGroup{
static.TableMatrix{
{
static.Table{
static.Strings("t1", "b-0", "b-0", "b-0", "b-0"),
static.Strings("_measurement", "m0", "m0", "m0", "m0"),
static.Strings("_field", "f0", "f0", "f0", "f0"),
static.TimeKey("_start", "2019-11-25T00:00:00Z"),
static.TimeKey("_stop", "2019-11-25T00:00:40Z"),
static.Times("_time", "2019-11-25T00:00:00Z", "2019-11-25T00:00:10Z", "2019-11-25T00:00:20Z", "2019-11-25T00:00:30Z"),
static.Floats("_value", 1.0, 2.0, 3.0, 4.0),
},
},
},
},
},
}

for _, tt := range cases {
t.Run("", func(t *testing.T) {
mem := &memory.Allocator{}
got, err := reader.ReadGroup(context.Background(), query.ReadGroupSpec{
ReadFilterSpec: query.ReadFilterSpec{
OrganizationID: reader.Org,
BucketID: reader.Bucket,
Bounds: reader.Bounds,
},
GroupMode: query.GroupModeBy,
GroupKeys: []string{"t0"},
}, mem)
if err != nil {
t.Fatal(err)
}

if diff := table.Diff(tt.want, got); diff != "" {
t.Errorf("unexpected results -want/+got:\n%s", diff)
}
})
}
}

func TestStorageReader_ReadWindowAggregateMonths(t *testing.T) {
reader := NewStorageReader(t, func(org, bucket platform.ID) (datagen.SeriesGenerator, datagen.TimeRange) {
spec := Spec(org, bucket,
Expand Down

0 comments on commit 94919fb

Please sign in to comment.