rpc: refactor: unify test server setup
This commit is contained in:
parent
325637b6be
commit
7f5957ee93
|
@ -76,36 +76,32 @@ func testServerConfig(t *testing.T, NodeName string) (string, *Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testServer(t *testing.T) (string, *Server) {
|
func testServer(t *testing.T) (string, *Server) {
|
||||||
return testServerDC(t, "dc1")
|
return testServerWithConfig(t, func(c *Config) {
|
||||||
|
c.Datacenter = "dc1"
|
||||||
|
c.Bootstrap = true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testServerDC(t *testing.T, dc string) (string, *Server) {
|
func testServerDC(t *testing.T, dc string) (string, *Server) {
|
||||||
return testServerDCBootstrap(t, dc, true)
|
return testServerWithConfig(t, func(c *Config) {
|
||||||
|
c.Datacenter = dc
|
||||||
|
c.Bootstrap = true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testServerDCBootstrap(t *testing.T, dc string, bootstrap bool) (string, *Server) {
|
func testServerDCBootstrap(t *testing.T, dc string, bootstrap bool) (string, *Server) {
|
||||||
name := fmt.Sprintf("Node %d", getPort())
|
return testServerWithConfig(t, func(c *Config) {
|
||||||
dir, config := testServerConfig(t, name)
|
c.Datacenter = dc
|
||||||
config.Datacenter = dc
|
c.Bootstrap = bootstrap
|
||||||
config.Bootstrap = bootstrap
|
})
|
||||||
server, err := NewServer(config)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("err: %v", err)
|
|
||||||
}
|
|
||||||
return dir, server
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testServerDCExpect(t *testing.T, dc string, expect int) (string, *Server) {
|
func testServerDCExpect(t *testing.T, dc string, expect int) (string, *Server) {
|
||||||
name := fmt.Sprintf("Node %d", getPort())
|
return testServerWithConfig(t, func(c *Config) {
|
||||||
dir, config := testServerConfig(t, name)
|
c.Datacenter = dc
|
||||||
config.Datacenter = dc
|
c.Bootstrap = false
|
||||||
config.Bootstrap = false
|
c.BootstrapExpect = expect
|
||||||
config.BootstrapExpect = expect
|
})
|
||||||
server, err := NewServer(config)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("err: %v", err)
|
|
||||||
}
|
|
||||||
return dir, server
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testServerWithConfig(t *testing.T, cb func(c *Config)) (string, *Server) {
|
func testServerWithConfig(t *testing.T, cb func(c *Config)) (string, *Server) {
|
||||||
|
|
Loading…
Reference in New Issue