From df2e282bdfea2c729cf90f21ade047b969496ac9 Mon Sep 17 00:00:00 2001 From: Michael Baird Date: Wed, 19 Apr 2017 16:52:49 -0500 Subject: [PATCH] fix server tests to bind to new node if changing the node set --- cmd/server_test.go | 75 ++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/cmd/server_test.go b/cmd/server_test.go index e51825e60..edd61c601 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -29,25 +29,25 @@ func TestServerConfig(t *testing.T) { tests := []commandTest{ // TEST 0 { - args: []string{"server", "--data-dir", actualDataDir, "--cluster.hosts", "example.com:10101,example.com:10110"}, + args: []string{"server", "--data-dir", actualDataDir, "--cluster.hosts", "example.com:10111,example.com:10110", "--bind", "example.com:10111"}, env: map[string]string{"PILOSA_DATA_DIR": "/tmp/myEnvDatadir", "PILOSA_CLUSTER.POLL_INTERVAL": "3m2s"}, cfgFileContent: ` -data-dir = "/tmp/myFileDatadir" -bind = "localhost:0" + data-dir = "/tmp/myFileDatadir" + bind = "localhost:0" -[cluster] - poll-interval = "45s" - replicas = 2 - hosts = [ - "localhost:19444", - ] -`, + [cluster] + poll-interval = "45s" + replicas = 2 + hosts = [ + "localhost:19444", + ] + `, validation: func() error { v := validator{} v.Check(cmd.Server.Config.DataDir, actualDataDir) - v.Check(cmd.Server.Config.Host, "localhost:0") + v.Check(cmd.Server.Config.Host, "example.com:10111") v.Check(cmd.Server.Config.Cluster.ReplicaN, 2) - v.Check(cmd.Server.Config.Cluster.Hosts, []string{"example.com:10101", "example.com:10110"}) + v.Check(cmd.Server.Config.Cluster.Hosts, []string{"example.com:10111", "example.com:10110"}) v.Check(cmd.Server.Config.Cluster.PollingInterval, pilosa.Duration(time.Second*182)) return v.Error() }, @@ -55,17 +55,17 @@ bind = "localhost:0" // TEST 1 { args: []string{"server", "--anti-entropy.interval", "9m0s"}, - env: map[string]string{"PILOSA_CLUSTER.HOSTS": "example.com:1110,example.com:1111"}, + env: map[string]string{"PILOSA_CLUSTER.HOSTS": "example.com:1110,example.com:1111", "PILOSA_BIND": "example.com:1110"}, cfgFileContent: ` -bind = "localhost:0" -data-dir = "` + actualDataDir + `" -[cluster] - hosts = [ - "localhost:19444", - ] -[plugins] - path = "/var/sloth" -`, + bind = "localhost:0" + data-dir = "` + actualDataDir + `" + [cluster] + hosts = [ + "localhost:19444", + ] + [plugins] + path = "/var/sloth" + `, validation: func() error { v := validator{} v.Check(cmd.Server.Config.Cluster.Hosts, []string{"example.com:1110", "example.com:1111"}) @@ -79,19 +79,22 @@ data-dir = "` + actualDataDir + `" args: []string{"server", "--log-path", logFile.Name()}, env: map[string]string{"PILOSA_PROFILE.CPU_TIME": "1m"}, cfgFileContent: ` -bind = "localhost:0" -data-dir = "` + actualDataDir + `" -[cluster] - poll-interval = "2m0s" - hosts = [ - "localhost:19444", - ] -[anti-entropy] - interval = "11m0s" -[profile] - cpu = "` + profFile.Name() + `" - cpu-time = "35s" -`, + bind = "localhost:19444" + data-dir = "` + actualDataDir + `" + [cluster] + poll-interval = "2m0s" + hosts = [ + "localhost:19444", + ] + [anti-entropy] + interval = "11m0s" + [profile] + cpu = "` + profFile.Name() + `" + cpu-time = "35s" + [metric] + service = "statsd" + host = "127.0.0.1:8125" + `, validation: func() error { v := validator{} v.Check(cmd.Server.Config.Cluster.Hosts, []string{"localhost:19444"}) @@ -100,6 +103,8 @@ data-dir = "` + actualDataDir + `" v.Check(cmd.Server.CPUProfile, profFile.Name()) v.Check(cmd.Server.CPUTime, time.Minute) v.Check(cmd.Server.Config.LogPath, logFile.Name()) + v.Check(cmd.Server.Config.Metric.Service, "statsd") + v.Check(cmd.Server.Config.Metric.Host, "127.0.0.1:8125") if v.Error() != nil { return v.Error() }