test: descending array cursor should include end time
parent
dd98d65bac
commit
e6e55038e8
cmd/influxd/launcher
tsdb/tsm1
|
@ -759,6 +759,25 @@ func TestQueryPushDowns(t *testing.T) {
|
|||
op string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "range last single point start time",
|
||||
data: []string{
|
||||
"m,tag=a f=1i 1",
|
||||
},
|
||||
query: `
|
||||
from(bucket: v.bucket)
|
||||
|> range(start: 1970-01-01T00:00:00.000000001Z, stop: 1970-01-01T01:00:00Z)
|
||||
|> last()
|
||||
`,
|
||||
op: "readWindow(last)",
|
||||
want: `
|
||||
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,string,string,string
|
||||
#group,false,false,true,true,false,false,true,true,true
|
||||
#default,_result,,,,,,,,
|
||||
,result,table,_start,_stop,_time,_value,_field,_measurement,tag
|
||||
,,0,1970-01-01T00:00:00.000000001Z,1970-01-01T01:00:00Z,1970-01-01T00:00:00.000000001Z,1,f,m,a
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "window last",
|
||||
data: []string{
|
||||
|
|
|
@ -70,6 +70,67 @@ func newFiles(dir string, values ...keyValues) ([]string, error) {
|
|||
return files, nil
|
||||
}
|
||||
|
||||
func TestDescendingCursor_SinglePointStartTime(t *testing.T) {
|
||||
t.Run("cache", func(t *testing.T) {
|
||||
dir := MustTempDir()
|
||||
defer os.RemoveAll(dir)
|
||||
fs := NewFileStore(dir)
|
||||
|
||||
const START, END = 10, 1
|
||||
kc := fs.KeyCursor(context.Background(), []byte("m,_field=v#!~#v"), START, false)
|
||||
defer kc.Close()
|
||||
cur := newIntegerArrayDescendingCursor()
|
||||
// Include a cached value with timestamp equal to END
|
||||
cur.reset(START, END, Values{NewIntegerValue(1, 1)}, kc)
|
||||
|
||||
var got []int64
|
||||
ar := cur.Next()
|
||||
for ar.Len() > 0 {
|
||||
got = append(got, ar.Timestamps...)
|
||||
ar = cur.Next()
|
||||
}
|
||||
|
||||
if exp := []int64{1}; !cmp.Equal(got, exp) {
|
||||
t.Errorf("unexpected values; -got/+exp\n%s", cmp.Diff(got, exp))
|
||||
}
|
||||
})
|
||||
t.Run("tsm", func(t *testing.T) {
|
||||
dir := MustTempDir()
|
||||
defer os.RemoveAll(dir)
|
||||
fs := NewFileStore(dir)
|
||||
|
||||
const START, END = 10, 1
|
||||
|
||||
data := []keyValues{
|
||||
// Write a single data point with timestamp equal to END
|
||||
{"m,_field=v#!~#v", []Value{NewIntegerValue(1, 1)}},
|
||||
}
|
||||
|
||||
files, err := newFiles(dir, data...)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error creating files: %v", err)
|
||||
}
|
||||
|
||||
_ = fs.Replace(nil, files)
|
||||
|
||||
kc := fs.KeyCursor(context.Background(), []byte("m,_field=v#!~#v"), START, false)
|
||||
defer kc.Close()
|
||||
cur := newIntegerArrayDescendingCursor()
|
||||
cur.reset(START, END, nil, kc)
|
||||
|
||||
var got []int64
|
||||
ar := cur.Next()
|
||||
for ar.Len() > 0 {
|
||||
got = append(got, ar.Timestamps...)
|
||||
ar = cur.Next()
|
||||
}
|
||||
|
||||
if exp := []int64{1}; !cmp.Equal(got, exp) {
|
||||
t.Errorf("unexpected values; -got/+exp\n%s", cmp.Diff(got, exp))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestFileStore_DuplicatePoints(t *testing.T) {
|
||||
dir := MustTempDir()
|
||||
defer os.RemoveAll(dir)
|
||||
|
|
Loading…
Reference in New Issue