Updated tests for 'influx_tsm'
Also changed some things to fix failing tests on circleCI, and removed old TODO itempull/5454/head
parent
908259340b
commit
482772997e
|
@ -1,46 +1,58 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdb/influxdb/tsdb/engine/tsm1"
|
"github.com/influxdb/influxdb/tsdb/engine/tsm1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_scrubValuesNoFilter(t *testing.T) {
|
func TestScrubValues(t *testing.T) {
|
||||||
values := []tsm1.Value{tsm1.NewValue(time.Unix(0, 0), 1.0)}
|
dummy := Converter{
|
||||||
scrubbed := scrubValues(values)
|
tracker: new(tracker),
|
||||||
if !reflect.DeepEqual(values, scrubbed) {
|
}
|
||||||
t.Fatalf("mismatch:\n\nexp=%+v\n\ngot=%+v\n\n", values, scrubbed)
|
|
||||||
|
epoch := time.Unix(0, 0)
|
||||||
|
simple := []tsm1.Value{tsm1.NewValue(epoch, 1.0)}
|
||||||
|
|
||||||
|
for _, tt := range []struct {
|
||||||
|
input, expected []tsm1.Value
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
input: simple,
|
||||||
|
expected: simple,
|
||||||
|
}, {
|
||||||
|
input: []tsm1.Value{simple[0], tsm1.NewValue(epoch, math.NaN())},
|
||||||
|
expected: simple,
|
||||||
|
}, {
|
||||||
|
input: []tsm1.Value{simple[0], tsm1.NewValue(epoch, math.Inf(-1))},
|
||||||
|
expected: simple,
|
||||||
|
}, {
|
||||||
|
input: []tsm1.Value{simple[0], tsm1.NewValue(epoch, math.Inf(1)), tsm1.NewValue(epoch, math.NaN())},
|
||||||
|
expected: simple,
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
out := dummy.scrubValues(tt.input)
|
||||||
|
if !reflect.DeepEqual(out, tt.expected) {
|
||||||
|
t.Errorf("Failed to scrub '%s': Got '%s', Expected '%s'", pretty(tt.input), pretty(out), pretty(tt.expected))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_scrubValuesFilterNaN(t *testing.T) {
|
func pretty(vals []tsm1.Value) string {
|
||||||
intV := tsm1.NewValue(time.Unix(0, 0), 1.0)
|
if len(vals) == 0 {
|
||||||
values := []tsm1.Value{intV, tsm1.NewValue(time.Unix(0, 0), math.NaN())}
|
return "[]"
|
||||||
scrubbed := scrubValues(values)
|
|
||||||
if !reflect.DeepEqual([]tsm1.Value{intV}, scrubbed) {
|
|
||||||
t.Fatalf("mismatch:\n\nexp=%+v\n\ngot=%+v\n\n", []tsm1.Value{intV}, scrubbed)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func Test_scrubValuesFilterInf(t *testing.T) {
|
strs := make([]string, len(vals))
|
||||||
intV := tsm1.NewValue(time.Unix(0, 0), 1.0)
|
|
||||||
values := []tsm1.Value{intV, tsm1.NewValue(time.Unix(0, 0), math.Inf(-1))}
|
|
||||||
scrubbed := scrubValues(values)
|
|
||||||
if !reflect.DeepEqual([]tsm1.Value{intV}, scrubbed) {
|
|
||||||
t.Fatalf("mismatch:\n\nexp=%+v\n\ngot=%+v\n\n", []tsm1.Value{intV}, scrubbed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_scrubValuesFilterBoth(t *testing.T) {
|
for i := range vals {
|
||||||
intV := tsm1.NewValue(time.Unix(0, 0), 1.0)
|
strs[i] = fmt.Sprintf("{%v: %v}", vals[i].UnixNano(), vals[i].Value())
|
||||||
values := []tsm1.Value{intV, tsm1.NewValue(time.Unix(0, 0), math.Inf(-1)), tsm1.NewValue(time.Unix(0, 0), math.NaN())}
|
|
||||||
scrubbed := scrubValues(values)
|
|
||||||
if !reflect.DeepEqual([]tsm1.Value{intV}, scrubbed) {
|
|
||||||
t.Fatalf("mismatch:\n\nexp=%+v\n\ngot=%+v\n\n", []tsm1.Value{intV}, scrubbed)
|
|
||||||
}
|
}
|
||||||
return
|
|
||||||
|
return "[" + strings.Join(strs, ", ") + "]"
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ func (o *options) Parse() error {
|
||||||
|
|
||||||
var opts options
|
var opts options
|
||||||
|
|
||||||
const maxTSMSz = 2 * 1024 * 1024 * 1024
|
const maxTSMSz uint64 = 2 * 1024 * 1024 * 1024
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.SetOutput(os.Stderr)
|
log.SetOutput(os.Stderr)
|
||||||
|
@ -240,7 +240,6 @@ func copyDir(dest, src string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(jlegasse): this just appends to the current backup file, if it exists
|
|
||||||
out, err := os.OpenFile(toPath, os.O_CREATE|os.O_WRONLY, info.Mode())
|
out, err := os.OpenFile(toPath, os.O_CREATE|os.O_WRONLY, info.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -16,13 +16,13 @@ import (
|
||||||
|
|
||||||
// tracker will orchestrate and track the conversions of non-TSM shards to TSM
|
// tracker will orchestrate and track the conversions of non-TSM shards to TSM
|
||||||
type tracker struct {
|
type tracker struct {
|
||||||
|
stats Stats
|
||||||
|
|
||||||
shards tsdb.ShardInfos
|
shards tsdb.ShardInfos
|
||||||
opts options
|
opts options
|
||||||
|
|
||||||
pg ParallelGroup
|
pg ParallelGroup
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
stats Stats
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
|
|
Loading…
Reference in New Issue