influxdb/cmd/influxd/run/config_test.go

95 lines
2.5 KiB
Go
Raw Normal View History

2015-05-28 21:47:47 +00:00
package run_test
2014-10-21 05:32:47 +00:00
import (
"testing"
2015-04-02 01:20:04 +00:00
"github.com/BurntSushi/toml"
2015-05-29 19:50:05 +00:00
"github.com/influxdb/influxdb/cmd/influxd/run"
2014-10-21 05:32:47 +00:00
)
2015-05-29 19:50:05 +00:00
// Ensure the configuration can be parsed.
func TestConfig_Parse(t *testing.T) {
// Parse configuration.
var c run.Config
if _, err := toml.Decode(`
hostname = "localhost"
bind-address = ":8086"
reporting-enabled = true
2015-03-25 21:01:05 +00:00
2015-05-29 19:50:05 +00:00
[initialization]
join-urls = "serverA,serverB"
2015-03-25 21:01:05 +00:00
2015-05-29 19:50:05 +00:00
[meta]
dir = "/tmp/meta"
2015-03-25 21:01:05 +00:00
2015-05-29 19:50:05 +00:00
[data]
dir = "/tmp/data"
2015-03-25 21:01:05 +00:00
2015-05-29 19:50:05 +00:00
[cluster]
2015-03-25 21:01:05 +00:00
[admin]
2015-05-29 19:50:05 +00:00
bind-address = ":8083"
2015-03-25 21:01:05 +00:00
[api]
2015-05-29 19:50:05 +00:00
bind-address = ":8087"
2015-03-25 21:01:05 +00:00
[[graphite]]
2015-05-29 19:50:05 +00:00
protocol = "udp"
2015-03-25 21:01:05 +00:00
[[graphite]]
2015-05-29 19:50:05 +00:00
protocol = "tcp"
2015-03-25 21:01:05 +00:00
[collectd]
2015-05-29 19:50:05 +00:00
bind-address = ":1000"
2015-03-25 21:01:05 +00:00
[opentsdb]
2015-05-29 19:50:05 +00:00
bind-address = ":2000"
2015-03-25 21:01:05 +00:00
2015-06-03 13:06:36 +00:00
[udp]
bind-address = ":4444"
2015-05-29 19:50:05 +00:00
[monitoring]
enabled = true
2015-03-25 21:01:05 +00:00
[continuous_queries]
enabled = true
2015-05-29 19:50:05 +00:00
`, &c); err != nil {
t.Fatal(err)
}
// Validate configuration.
if c.Hostname != "localhost" {
t.Fatalf("unexpected hostname: %v", c.Hostname)
} else if c.BindAddress != ":8086" {
t.Fatalf("unexpected bind address: %s", c.BindAddress)
} else if c.ReportingEnabled != true {
t.Fatalf("unexpected reporting enabled: %v", c.ReportingEnabled)
} else if c.Initialization.JoinURLs != "serverA,serverB" {
t.Fatalf("unexpected join urls: %s", c.Initialization.JoinURLs)
} else if c.Meta.Dir != "/tmp/meta" {
t.Fatalf("unexpected meta dir: %s", c.Meta.Dir)
} else if c.Data.Dir != "/tmp/data" {
t.Fatalf("unexpected data dir: %s", c.Data.Dir)
} else if c.Admin.BindAddress != ":8083" {
t.Fatalf("unexpected admin bind address: %s", c.Admin.BindAddress)
} else if c.HTTPD.BindAddress != ":8087" {
t.Fatalf("unexpected api bind address: %s", c.HTTPD.BindAddress)
} else if len(c.Graphites) != 2 {
t.Fatalf("unexpected graphites count: %d", len(c.Graphites))
} else if c.Graphites[0].Protocol != "udp" {
t.Fatalf("unexpected graphite protocol(0): %s", c.Graphites[0].Protocol)
} else if c.Graphites[1].Protocol != "tcp" {
t.Fatalf("unexpected graphite protocol(1): %s", c.Graphites[1].Protocol)
} else if c.Collectd.BindAddress != ":1000" {
t.Fatalf("unexpected collectd bind address: %s", c.Collectd.BindAddress)
} else if c.OpenTSDB.BindAddress != ":2000" {
t.Fatalf("unexpected opentsdb bind address: %s", c.OpenTSDB.BindAddress)
2015-06-03 13:06:36 +00:00
} else if c.UDP.BindAddress != ":4444" {
t.Fatalf("unexpected udp bind address: %s", c.UDP.BindAddress)
2015-05-29 19:50:05 +00:00
} else if c.Monitoring.Enabled != true {
t.Fatalf("unexpected monitoring enabled: %v", c.Monitoring.Enabled)
} else if c.ContinuousQuery.Enabled != true {
t.Fatalf("unexpected continuous query enabled: %v", c.ContinuousQuery.Enabled)
2015-01-09 17:44:11 +00:00
}
}