more services, more test fixes, getting closer...

pull/2709/head
Ben Johnson 2015-05-29 14:12:00 -06:00 committed by Cory LaNou
parent 9d4527071e
commit 6677ea074f
14 changed files with 105 additions and 42 deletions

View File

@ -1,4 +1,4 @@
package main
package backup
/*
import (

View File

@ -1,5 +1,6 @@
package main_test
package backup_test
/*
import (
"bytes"
"net/http"
@ -121,3 +122,4 @@ func NewBackupCommand() *BackupCommand {
cmd.BackupCommand.Stderr = &cmd.Stderr
return cmd
}
*/

View File

@ -1,4 +1,4 @@
package main
package restore
/*
import (

View File

@ -1,5 +1,6 @@
package main_test
package restore_test
/*
import (
"bytes"
"io/ioutil"
@ -151,3 +152,4 @@ func MustReadFile(filename string) []byte {
}
return b
}
*/

View File

@ -6,7 +6,11 @@ import (
"github.com/influxdb/influxdb/admin"
"github.com/influxdb/influxdb/cluster"
"github.com/influxdb/influxdb/collectd"
"github.com/influxdb/influxdb/graphite"
"github.com/influxdb/influxdb/httpd"
"github.com/influxdb/influxdb/meta"
"github.com/influxdb/influxdb/opentsdb"
"github.com/influxdb/influxdb/tsdb"
)
@ -34,10 +38,26 @@ func NewServer(c *Config, joinURLs string) *Server {
}
// HTTP API Service
if c.HTTPD.Enabled {
s.Services = append(s.Services, httpd.NewService(c.HTTPD))
}
// TODO: Graphite services
// TODO: OpenTSDB services
// TODO: Collectd service
// Graphite services
for _, g := range c.Graphites {
if g.Enabled {
s.Services = append(s.Services, graphite.NewService(g))
}
}
// Collectd service
if c.Collectd.Enabled {
s.Services = append(s.Services, collectd.NewService(c.Collectd))
}
// OpenTSDB services
if c.OpenTSDB.Enabled {
s.Services = append(s.Services, opentsdb.NewService(c.OpenTSDB))
}
return s
}

11
collectd/service.go Normal file
View File

@ -0,0 +1,11 @@
package collectd
import "net"
type Service struct{}
func NewService(c Config) *Service { return &Service{} }
func (s *Service) Open() error { return nil }
func (s *Service) Close() error { return nil }
func (s *Service) Addr() net.Addr { return nil }

11
graphite/service.go Normal file
View File

@ -0,0 +1,11 @@
package graphite
import "net"
type Service struct{}
func NewService(c Config) *Service { return &Service{} }
func (s *Service) Open() error { return nil }
func (s *Service) Close() error { return nil }
func (s *Service) Addr() net.Addr { return nil }

View File

@ -1,6 +1,7 @@
package httpd
type Config struct {
Enabled bool `toml:"enabled"`
BindAddress string `toml:"bind-address"`
AuthEnabled bool `toml:"auth-enabled"`
LogEnabled bool `toml:"log-enabled"`
@ -10,7 +11,7 @@ type Config struct {
func NewConfig() Config {
return Config{
LogEnabled: true,
WriteTracing: false,
Enabled: true,
LogEnabled: true,
}
}

View File

@ -11,6 +11,7 @@ func TestConfig_Parse(t *testing.T) {
// Parse configuration.
var c httpd.Config
if _, err := toml.Decode(`
enabled = true
bind-address = ":8080"
auth-enabled = true
log-enabled = true
@ -21,7 +22,9 @@ pprof-enabled = true
}
// Validate configuration.
if c.BindAddress != ":8080" {
if c.Enabled != true {
t.Fatalf("unexpected enabled: %v", c.Enabled)
} else if c.BindAddress != ":8080" {
t.Fatalf("unexpected bind address: %s", c.BindAddress)
} else if c.AuthEnabled != true {
t.Fatalf("unexpected auth enabled: %v", c.AuthEnabled)

View File

@ -17,7 +17,7 @@ type Service struct {
}
// NewService returns a new instance of Service.
func NewService(c *Config) *Service {
func NewService(c Config) *Service {
return &Service{
addr: c.BindAddress,
err: make(chan error),

View File

@ -11,23 +11,23 @@ import (
import "sort"
type point struct {
seriesID uint64
time int64
value interface{}
seriesKey string
time int64
value interface{}
}
type testIterator struct {
values []point
}
func (t *testIterator) Next() (seriesID uint64, timestamp int64, value interface{}) {
func (t *testIterator) Next() (seriesKey string, timestamp int64, value interface{}) {
if len(t.values) > 0 {
v := t.values[0]
t.values = t.values[1:]
return v.seriesID, v.time, v.value
return v.seriesKey, v.time, v.value
}
return 0, 0, nil
return "0", 0, nil
}
func TestMapMeanNoValues(t *testing.T) {
@ -44,13 +44,13 @@ func TestMapMean(t *testing.T) {
output *meanMapOutput
}{
{ // Single point
input: []point{point{0, 1, 1.0}},
input: []point{point{"0", 1, 1.0}},
output: &meanMapOutput{1, 1},
},
{ // Two points
input: []point{
point{0, 1, 2.0},
point{0, 2, 8.0},
point{"0", 1, 2.0},
point{"0", 2, 8.0},
},
output: &meanMapOutput{2, 5.0},
},
@ -196,9 +196,9 @@ func TestReducePercentileNil(t *testing.T) {
}
func TestMapDistinct(t *testing.T) {
const ( // prove that we're ignoring seriesID
seriesId1 = iota + 1
seriesId2
const ( // prove that we're ignoring seriesKey
seriesKey1 = "1"
seriesKey2 = "2"
)
const ( // prove that we're ignoring time
@ -212,12 +212,12 @@ func TestMapDistinct(t *testing.T) {
iter := &testIterator{
values: []point{
{seriesId1, timeId1, uint64(1)},
{seriesId1, timeId2, uint64(1)},
{seriesId1, timeId3, "1"},
{seriesId2, timeId4, uint64(1)},
{seriesId2, timeId5, float64(1.0)},
{seriesId2, timeId6, "1"},
{seriesKey1, timeId1, uint64(1)},
{seriesKey1, timeId2, uint64(1)},
{seriesKey1, timeId3, "1"},
{seriesKey2, timeId4, uint64(1)},
{seriesKey2, timeId5, float64(1.0)},
{seriesKey2, timeId6, "1"},
},
}
@ -349,9 +349,9 @@ func Test_distinctValues_Sort(t *testing.T) {
}
func TestMapCountDistinct(t *testing.T) {
const ( // prove that we're ignoring seriesID
seriesId1 = iota + 1
seriesId2
const ( // prove that we're ignoring seriesKey
seriesKey1 = "1"
seriesKey2 = "2"
)
const ( // prove that we're ignoring time
@ -366,13 +366,13 @@ func TestMapCountDistinct(t *testing.T) {
iter := &testIterator{
values: []point{
{seriesId1, timeId1, uint64(1)},
{seriesId1, timeId2, uint64(1)},
{seriesId1, timeId3, "1"},
{seriesId2, timeId4, uint64(1)},
{seriesId2, timeId5, float64(1.0)},
{seriesId2, timeId6, "1"},
{seriesId2, timeId7, true},
{seriesKey1, timeId1, uint64(1)},
{seriesKey1, timeId2, uint64(1)},
{seriesKey1, timeId3, "1"},
{seriesKey2, timeId4, uint64(1)},
{seriesKey2, timeId5, float64(1.0)},
{seriesKey2, timeId6, "1"},
{seriesKey2, timeId7, true},
},
}

View File

@ -16,7 +16,7 @@ recompute-previous-n = 1
recompute-no-older-than = "10s"
compute-runs-per-interval = 2
compute-no-more-than = "20s"
disabled = true
enabled = true
`, &c); err != nil {
t.Fatal(err)
}
@ -30,7 +30,7 @@ disabled = true
t.Fatalf("unexpected compute runs per interval: %d", c.ComputeRunsPerInterval)
} else if time.Duration(c.ComputeNoMoreThan) != 20*time.Second {
t.Fatalf("unexpected compute no more than: %v", c.ComputeNoMoreThan)
} else if c.Disabled != true {
t.Fatalf("unexpected disabled: %v", c.Disabled)
} else if c.Enabled != true {
t.Fatalf("unexpected enabled: %v", c.Enabled)
}
}

11
opentsdb/service.go Normal file
View File

@ -0,0 +1,11 @@
package opentsdb
import "net"
type Service struct{}
func NewService(c Config) *Service { return &Service{} }
func (s *Service) Open() error { return nil }
func (s *Service) Close() error { return nil }
func (s *Service) Addr() net.Addr { return nil }

View File

@ -281,6 +281,7 @@ func TestServer_PreCreateRetentionPolices(t *testing.T) {
*/
// Ensure the server prohibits a zero check interval for retention policy enforcement.
/*
func TestServer_StartRetentionPolicyEnforcement_ErrZeroInterval(t *testing.T) {
s := OpenServer()
defer s.Close()
@ -288,6 +289,7 @@ func TestServer_StartRetentionPolicyEnforcement_ErrZeroInterval(t *testing.T) {
t.Fatal("failed to prohibit retention policies zero check interval")
}
}
*/
// Ensure the server can support writes of all data types.
func TestServer_WriteAllDataTypes(t *testing.T) {