Update tests to use Direction enum

pull/3986/head
Jason Wilder 2015-09-04 08:51:48 -06:00
parent 330363bec4
commit df70a1c8ce
4 changed files with 48 additions and 48 deletions

View File

@ -2204,7 +2204,7 @@ func TestServer_Query_Aggregates(t *testing.T) {
// order by time desc
&Query{
name: "order by time desc",
name: "aggregate order by time desc",
params: url.Values{"db": []string{"db0"}},
command: `SELECT max(value) FROM intmany where time >= '2000-01-01T00:00:00Z' AND time <= '2000-01-01T00:01:00Z' group by time(10s) order by time desc`,
exp: `{"results":[{"series":[{"name":"intmany","columns":["time","max"],"values":[["2000-01-01T00:01:00Z",7],["2000-01-01T00:00:50Z",5],["2000-01-01T00:00:40Z",5],["2000-01-01T00:00:30Z",4],["2000-01-01T00:00:20Z",4],["2000-01-01T00:00:10Z",4],["2000-01-01T00:00:00Z",2]]}]}]}`,

View File

@ -14,8 +14,8 @@ import (
// Ensure the multi-cursor can correctly iterate across a single subcursor.
func TestMultiCursor_Single(t *testing.T) {
mc := tsdb.MultiCursor(true,
NewCursor(true, []CursorItem{
mc := tsdb.MultiCursor(tsdb.Forward,
NewCursor(tsdb.Forward, []CursorItem{
{Key: []byte{0x00}, Value: []byte{0x00}},
{Key: []byte{0x01}, Value: []byte{0x10}},
{Key: []byte{0x02}, Value: []byte{0x20}},
@ -35,8 +35,8 @@ func TestMultiCursor_Single(t *testing.T) {
// Ensure the multi-cursor can correctly iterate across a single subcursor in reverse order.
func TestMultiCursor_Single_Reverse(t *testing.T) {
mc := tsdb.MultiCursor(false,
NewCursor(false, []CursorItem{
mc := tsdb.MultiCursor(tsdb.Reverse,
NewCursor(tsdb.Reverse, []CursorItem{
{Key: []byte{0x00}, Value: []byte{0x00}},
{Key: []byte{0x01}, Value: []byte{0x10}},
{Key: []byte{0x02}, Value: []byte{0x20}},
@ -56,13 +56,13 @@ func TestMultiCursor_Single_Reverse(t *testing.T) {
// Ensure the multi-cursor can correctly iterate across multiple non-overlapping subcursors.
func TestMultiCursor_Multiple_NonOverlapping(t *testing.T) {
mc := tsdb.MultiCursor(true,
NewCursor(true, []CursorItem{
mc := tsdb.MultiCursor(tsdb.Forward,
NewCursor(tsdb.Forward, []CursorItem{
{Key: []byte{0x00}, Value: []byte{0x00}},
{Key: []byte{0x03}, Value: []byte{0x30}},
{Key: []byte{0x04}, Value: []byte{0x40}},
}),
NewCursor(true, []CursorItem{
NewCursor(tsdb.Forward, []CursorItem{
{Key: []byte{0x01}, Value: []byte{0x10}},
{Key: []byte{0x02}, Value: []byte{0x20}},
}),
@ -85,13 +85,13 @@ func TestMultiCursor_Multiple_NonOverlapping(t *testing.T) {
// Ensure the multi-cursor can correctly iterate across multiple non-overlapping subcursors.
func TestMultiCursor_Multiple_NonOverlapping_Reverse(t *testing.T) {
mc := tsdb.MultiCursor(false,
NewCursor(false, []CursorItem{
mc := tsdb.MultiCursor(tsdb.Reverse,
NewCursor(tsdb.Reverse, []CursorItem{
{Key: []byte{0x00}, Value: []byte{0x00}},
{Key: []byte{0x03}, Value: []byte{0x30}},
{Key: []byte{0x04}, Value: []byte{0x40}},
}),
NewCursor(false, []CursorItem{
NewCursor(tsdb.Reverse, []CursorItem{
{Key: []byte{0x01}, Value: []byte{0x10}},
{Key: []byte{0x02}, Value: []byte{0x20}},
}),
@ -114,13 +114,13 @@ func TestMultiCursor_Multiple_NonOverlapping_Reverse(t *testing.T) {
// Ensure the multi-cursor can correctly iterate across multiple overlapping subcursors.
func TestMultiCursor_Multiple_Overlapping(t *testing.T) {
mc := tsdb.MultiCursor(true,
NewCursor(true, []CursorItem{
mc := tsdb.MultiCursor(tsdb.Forward,
NewCursor(tsdb.Forward, []CursorItem{
{Key: []byte{0x00}, Value: []byte{0x00}},
{Key: []byte{0x03}, Value: []byte{0x03}},
{Key: []byte{0x04}, Value: []byte{0x04}},
}),
NewCursor(true, []CursorItem{
NewCursor(tsdb.Forward, []CursorItem{
{Key: []byte{0x00}, Value: []byte{0xF0}},
{Key: []byte{0x02}, Value: []byte{0xF2}},
{Key: []byte{0x04}, Value: []byte{0xF4}},
@ -142,13 +142,13 @@ func TestMultiCursor_Multiple_Overlapping(t *testing.T) {
// Ensure the multi-cursor can correctly iterate across multiple overlapping subcursors.
func TestMultiCursor_Multiple_Overlapping_Reverse(t *testing.T) {
mc := tsdb.MultiCursor(false,
NewCursor(false, []CursorItem{
mc := tsdb.MultiCursor(tsdb.Reverse,
NewCursor(tsdb.Reverse, []CursorItem{
{Key: []byte{0x00}, Value: []byte{0x00}},
{Key: []byte{0x03}, Value: []byte{0x03}},
{Key: []byte{0x04}, Value: []byte{0x04}},
}),
NewCursor(false, []CursorItem{
NewCursor(tsdb.Reverse, []CursorItem{
{Key: []byte{0x00}, Value: []byte{0xF0}},
{Key: []byte{0x02}, Value: []byte{0xF2}},
{Key: []byte{0x04}, Value: []byte{0xF4}},
@ -196,7 +196,7 @@ func TestMultiCursor_Quick(t *testing.T) {
sort.Sort(byteSlices(exp))
// Create multi-cursor and iterate over all items.
mc := tsdb.MultiCursor(true, tsdbCursorSlice(cursors)...)
mc := tsdb.MultiCursor(tsdb.Forward, tsdbCursorSlice(cursors)...)
for k, v := mc.Seek(u64tob(seek)); k != nil; k, v = mc.Next() {
got = append(got, append(k, v...))
}

View File

@ -176,7 +176,7 @@ func TestEngine_WriteIndex_Append(t *testing.T) {
defer tx.Rollback()
// Iterate over "cpu" series.
c := tx.Cursor("cpu", true)
c := tx.Cursor("cpu", tsdb.Forward)
if k, v := c.Seek(u64tob(0)); !reflect.DeepEqual(k, []byte{0, 0, 0, 0, 0, 0, 0, 1}) || !reflect.DeepEqual(v, []byte{0x10}) {
t.Fatalf("unexpected key/value: %x / %x", k, v)
} else if k, v = c.Next(); !reflect.DeepEqual(k, []byte{0, 0, 0, 0, 0, 0, 0, 2}) || !reflect.DeepEqual(v, []byte{0x20}) {
@ -186,7 +186,7 @@ func TestEngine_WriteIndex_Append(t *testing.T) {
}
// Iterate over "mem" series.
c = tx.Cursor("mem", true)
c = tx.Cursor("mem", tsdb.Forward)
if k, v := c.Seek(u64tob(0)); !reflect.DeepEqual(k, []byte{0, 0, 0, 0, 0, 0, 0, 0}) || !reflect.DeepEqual(v, []byte{0x30}) {
t.Fatalf("unexpected key/value: %x / %x", k, v)
} else if k, _ = c.Next(); k != nil {
@ -236,7 +236,7 @@ func TestEngine_WriteIndex_Insert(t *testing.T) {
defer tx.Rollback()
// Iterate over "cpu" series.
c := tx.Cursor("cpu", true)
c := tx.Cursor("cpu", tsdb.Forward)
if k, v := c.Seek(u64tob(0)); btou64(k) != 9 || !bytes.Equal(v, []byte{0x09}) {
t.Fatalf("unexpected key/value: %x / %x", k, v)
} else if k, v = c.Next(); btou64(k) != 10 || !bytes.Equal(v, []byte{0xFF}) {
@ -294,7 +294,7 @@ func TestEngine_Cursor_Reverse(t *testing.T) {
defer tx.Rollback()
// Iterate over "cpu" series.
c := tx.Cursor("cpu", false)
c := tx.Cursor("cpu", tsdb.Reverse)
if k, v := c.Seek(u64tob(math.MaxUint64)); btou64(k) != 31 || !bytes.Equal(v, []byte{0xFF}) {
t.Fatalf("unexpected key/value: %x / %x", k, v)
} else if k, v = c.Next(); btou64(k) != 30 || !bytes.Equal(v, []byte{0x30}) {
@ -335,7 +335,7 @@ func TestEngine_WriteIndex_SeekAgainstInBlockValue(t *testing.T) {
defer tx.Rollback()
// Ensure that we can seek to a block in the middle
c := tx.Cursor("cpu", true)
c := tx.Cursor("cpu", tsdb.Forward)
if k, _ := c.Seek(u64tob(15)); btou64(k) != 20 {
t.Fatalf("expected to seek to time 20, but got %d", btou64(k))
}
@ -393,7 +393,7 @@ func TestEngine_WriteIndex_Quick(t *testing.T) {
// Iterate over results to ensure they are correct.
for _, key := range keys {
c := tx.Cursor(key, true)
c := tx.Cursor(key, tsdb.Forward)
// Read list of key/values.
var got [][]byte
@ -440,7 +440,7 @@ func TestEngine_WriteIndex_Quick_Append(t *testing.T) {
// Iterate over results to ensure they are correct.
for _, key := range keys {
c := tx.Cursor(key, true)
c := tx.Cursor(key, tsdb.Forward)
// Read list of key/values.
var got [][]byte

View File

@ -46,7 +46,7 @@ func TestWAL_WritePoints(t *testing.T) {
}
verify := func() {
c := log.Cursor("cpu,host=A", true)
c := log.Cursor("cpu,host=A", tsdb.Forward)
k, v := c.Seek(inttob(1))
// ensure the series are there and points are in order
@ -64,7 +64,7 @@ func TestWAL_WritePoints(t *testing.T) {
t.Fatalf("expected nil on last seek: %v %v", k, v)
}
c = log.Cursor("cpu,host=B", true)
c = log.Cursor("cpu,host=B", tsdb.Forward)
k, v = c.Next()
if bytes.Compare(v, p3.Data()) != 0 {
t.Fatalf("expected to seek to first point but got key and value: %v %v", k, v)
@ -92,7 +92,7 @@ func TestWAL_WritePoints(t *testing.T) {
}
verify2 := func() {
c := log.Cursor("cpu,host=A", true)
c := log.Cursor("cpu,host=A", tsdb.Forward)
k, v := c.Next()
if bytes.Compare(v, p1.Data()) != 0 {
t.Fatalf("order wrong, expected p1, %v %v %v", v, k, p1.Data())
@ -110,7 +110,7 @@ func TestWAL_WritePoints(t *testing.T) {
t.Fatal("order wrong, expected p6")
}
c = log.Cursor("cpu,host=C", true)
c = log.Cursor("cpu,host=C", tsdb.Forward)
_, v = c.Next()
if bytes.Compare(v, p5.Data()) != 0 {
t.Fatal("order wrong, expected p6")
@ -150,7 +150,7 @@ func TestWAL_CorruptDataLengthSize(t *testing.T) {
}
verify := func() {
c := log.Cursor("cpu,host=A", true)
c := log.Cursor("cpu,host=A", tsdb.Forward)
_, v := c.Next()
if bytes.Compare(v, p1.Data()) != 0 {
t.Fatal("p1 value wrong")
@ -183,7 +183,7 @@ func TestWAL_CorruptDataLengthSize(t *testing.T) {
}
verify = func() {
c := log.Cursor("cpu,host=A", true)
c := log.Cursor("cpu,host=A", tsdb.Forward)
_, v := c.Next()
if bytes.Compare(v, p1.Data()) != 0 {
t.Fatal("p1 value wrong")
@ -229,7 +229,7 @@ func TestWAL_CorruptDataBlock(t *testing.T) {
}
verify := func() {
c := log.Cursor("cpu,host=A", true)
c := log.Cursor("cpu,host=A", tsdb.Forward)
_, v := c.Next()
if bytes.Compare(v, p1.Data()) != 0 {
t.Fatal("p1 value wrong")
@ -268,7 +268,7 @@ func TestWAL_CorruptDataBlock(t *testing.T) {
}
verify = func() {
c := log.Cursor("cpu,host=A", true)
c := log.Cursor("cpu,host=A", tsdb.Forward)
_, v := c.Next()
if bytes.Compare(v, p1.Data()) != 0 {
t.Fatal("p1 value wrong")
@ -349,7 +349,7 @@ func TestWAL_CompactAfterPercentageThreshold(t *testing.T) {
}
// ensure we have some data
c := log.Cursor("cpu,host=A,region=uswest23", true)
c := log.Cursor("cpu,host=A,region=uswest23", tsdb.Forward)
k, v := c.Next()
if btou64(k) != 1 {
t.Fatalf("expected timestamp of 1, but got %v %v", k, v)
@ -365,13 +365,13 @@ func TestWAL_CompactAfterPercentageThreshold(t *testing.T) {
}
// should be nil
c = log.Cursor("cpu,host=A,region=uswest23", true)
c = log.Cursor("cpu,host=A,region=uswest23", tsdb.Forward)
k, v = c.Next()
if k != nil || v != nil {
t.Fatal("expected cache to be nil after flush: ", k, v)
}
c = log.Cursor("cpu,host=A,region=useast1", true)
c = log.Cursor("cpu,host=A,region=useast1", tsdb.Forward)
k, v = c.Next()
if btou64(k) != 1 {
t.Fatal("expected cache to be there after flush and compact: ", k, v)
@ -385,13 +385,13 @@ func TestWAL_CompactAfterPercentageThreshold(t *testing.T) {
log.Close()
log.Open()
c = log.Cursor("cpu,host=A,region=uswest23", true)
c = log.Cursor("cpu,host=A,region=uswest23", tsdb.Forward)
k, v = c.Next()
if k != nil || v != nil {
t.Fatal("expected cache to be nil after flush and re-open: ", k, v)
}
c = log.Cursor("cpu,host=A,region=useast1", true)
c = log.Cursor("cpu,host=A,region=useast1", tsdb.Forward)
k, v = c.Next()
if btou64(k) != 1 {
t.Fatal("expected cache to be there after flush and compact: ", k, v)
@ -444,7 +444,7 @@ func TestWAL_CompactAfterTimeWithoutWrite(t *testing.T) {
}
// ensure we have some data
c := log.Cursor("cpu,host=A,region=uswest10", true)
c := log.Cursor("cpu,host=A,region=uswest10", tsdb.Forward)
k, _ := c.Next()
if btou64(k) != 1 {
t.Fatalf("expected first data point but got one with key: %v", k)
@ -625,12 +625,12 @@ func TestWAL_DeleteSeries(t *testing.T) {
}
// ensure data is there
c := log.Cursor("cpu,host=A", true)
c := log.Cursor("cpu,host=A", tsdb.Forward)
if k, _ := c.Next(); btou64(k) != 1 {
t.Fatal("expected data point for cpu,host=A")
}
c = log.Cursor("cpu,host=B", true)
c = log.Cursor("cpu,host=B", tsdb.Forward)
if k, _ := c.Next(); btou64(k) != 2 {
t.Fatal("expected data point for cpu,host=B")
}
@ -641,13 +641,13 @@ func TestWAL_DeleteSeries(t *testing.T) {
}
// ensure data is there
c = log.Cursor("cpu,host=A", true)
c = log.Cursor("cpu,host=A", tsdb.Forward)
if k, _ := c.Next(); btou64(k) != 1 {
t.Fatal("expected data point for cpu,host=A")
}
// ensure series is deleted
c = log.Cursor("cpu,host=B", true)
c = log.Cursor("cpu,host=B", tsdb.Forward)
if k, _ := c.Next(); k != nil {
t.Fatal("expected no data for cpu,host=B")
}
@ -675,13 +675,13 @@ func TestWAL_DeleteSeries(t *testing.T) {
}
// ensure data is there
c = log.Cursor("cpu,host=A", true)
c = log.Cursor("cpu,host=A", tsdb.Forward)
if k, _ := c.Next(); btou64(k) != 1 {
t.Fatal("expected data point for cpu,host=A")
}
// ensure series is deleted
c = log.Cursor("cpu,host=B", true)
c = log.Cursor("cpu,host=B", tsdb.Forward)
if k, _ := c.Next(); k != nil {
t.Fatal("expected no data for cpu,host=B")
}
@ -805,7 +805,7 @@ func TestWAL_QueryDuringCompaction(t *testing.T) {
}
verify := func() {
c := log.Cursor("cpu,host=A", true)
c := log.Cursor("cpu,host=A", tsdb.Forward)
k, v := c.Seek(inttob(1))
// ensure the series are there and points are in order
if bytes.Compare(v, p1.Data()) != 0 {
@ -851,7 +851,7 @@ func TestWAL_PointsSorted(t *testing.T) {
t.Fatalf("failed to write points: %s", err.Error())
}
c := log.Cursor("cpu,host=A", true)
c := log.Cursor("cpu,host=A", tsdb.Forward)
k, _ := c.Next()
if btou64(k) != 1 {
t.Fatal("points out of order")
@ -896,7 +896,7 @@ func TestWAL_Cursor_Reverse(t *testing.T) {
t.Fatalf("failed to write points: %s", err.Error())
}
c := log.Cursor("cpu,host=A", false)
c := log.Cursor("cpu,host=A", tsdb.Reverse)
k, _ := c.Next()
if btou64(k) != 6 {
t.Fatal("points out of order")