mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge pull request #1101 from travisturner/cluster-coordinator-fix
fix bug in NewServerCluster where each host was its own coordinator
This commit is contained in:
commit
6fa742ee36
3 changed files with 22 additions and 20 deletions
|
|
@ -222,7 +222,7 @@ func TestClusterResize_EmptyNodes(t *testing.T) {
|
|||
|
||||
gossipHost := "localhost"
|
||||
gossipPort := 0
|
||||
seed, coord, err := m0.RunWithTransport(gossipHost, gossipPort, "", nil)
|
||||
seed, coord, err := m0.RunWithTransport(gossipHost, gossipPort, "", pilosa.URI{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -231,7 +231,7 @@ func TestClusterResize_EmptyNodes(t *testing.T) {
|
|||
m1 := test.NewMainWithCluster()
|
||||
defer m1.Close()
|
||||
|
||||
seed, coord, err = m1.RunWithTransport(gossipHost, gossipPort, seed, &coord)
|
||||
seed, coord, err = m1.RunWithTransport(gossipHost, gossipPort, seed, coord)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -250,7 +250,7 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
m0 := test.NewMainWithCluster()
|
||||
defer m0.Close()
|
||||
|
||||
seed, coord, err := m0.RunWithTransport("localhost", 0, "", nil)
|
||||
seed, coord, err := m0.RunWithTransport("localhost", 0, "", pilosa.URI{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -261,7 +261,7 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
|
||||
var eg errgroup.Group
|
||||
eg.Go(func() error {
|
||||
_, _, err = m1.RunWithTransport("localhost", 0, seed, &coord)
|
||||
_, _, err = m1.RunWithTransport("localhost", 0, seed, coord)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
m0 := test.NewMainWithCluster()
|
||||
defer m0.Close()
|
||||
|
||||
seed, coord, err := m0.RunWithTransport("localhost", 0, "", nil)
|
||||
seed, coord, err := m0.RunWithTransport("localhost", 0, "", pilosa.URI{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
|
||||
var eg errgroup.Group
|
||||
eg.Go(func() error {
|
||||
_, _, err = m1.RunWithTransport("localhost", 0, seed, &coord)
|
||||
_, _, err = m1.RunWithTransport("localhost", 0, seed, coord)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
m0 := test.NewMainWithCluster()
|
||||
defer m0.Close()
|
||||
|
||||
seed, coord, err := m0.RunWithTransport("localhost", 0, "", nil)
|
||||
seed, coord, err := m0.RunWithTransport("localhost", 0, "", pilosa.URI{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -360,7 +360,7 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
|
||||
var eg errgroup.Group
|
||||
eg.Go(func() error {
|
||||
_, _, err = m1.RunWithTransport("localhost", 0, seed, &coord)
|
||||
_, _, err = m1.RunWithTransport("localhost", 0, seed, coord)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -385,7 +385,7 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
m0 := test.NewMainWithCluster()
|
||||
defer m0.Close()
|
||||
|
||||
seed, coord, err := m0.RunWithTransport("localhost", 0, "", nil)
|
||||
seed, coord, err := m0.RunWithTransport("localhost", 0, "", pilosa.URI{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -415,7 +415,7 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
|
||||
var eg errgroup.Group
|
||||
eg.Go(func() error {
|
||||
_, _, err = m1.RunWithTransport("localhost", 0, seed, &coord)
|
||||
_, _, err = m1.RunWithTransport("localhost", 0, seed, coord)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func runMainWithCluster(size int) ([]*Main, error) {
|
|||
for i := 0; i < size; i++ {
|
||||
m := NewMainWithCluster()
|
||||
|
||||
gossipSeed, coordinator, err = m.RunWithTransport(gossipHost, gossipPort, gossipSeed, &coordinator)
|
||||
gossipSeed, coordinator, err = m.RunWithTransport(gossipHost, gossipPort, gossipSeed, coordinator)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "RunWithTransport")
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ func (m *Main) Reopen() error {
|
|||
}
|
||||
|
||||
// RunWithTransport runs Main and returns the dynamically allocated gossip port.
|
||||
func (m *Main) RunWithTransport(host string, bindPort int, joinSeed string, coordinator *pilosa.URI) (seed string, coord pilosa.URI, err error) {
|
||||
func (m *Main) RunWithTransport(host string, bindPort int, joinSeed string, coordinator pilosa.URI) (seed string, coord pilosa.URI, err error) {
|
||||
defer close(m.Started)
|
||||
|
||||
/*
|
||||
|
|
@ -185,12 +185,7 @@ func (m *Main) RunWithTransport(host string, bindPort int, joinSeed string, coor
|
|||
return seed, coord, err
|
||||
}
|
||||
|
||||
if coordinator != nil {
|
||||
coord = *coordinator
|
||||
} else {
|
||||
coord = m.Server.URI
|
||||
}
|
||||
m.Server.Cluster.Coordinator = coord
|
||||
m.Server.Cluster.Coordinator = coordinator
|
||||
m.Server.Cluster.Static = false
|
||||
|
||||
// Initialize server.
|
||||
|
|
@ -199,7 +194,7 @@ func (m *Main) RunWithTransport(host string, bindPort int, joinSeed string, coor
|
|||
return seed, coord, err
|
||||
}
|
||||
|
||||
return seed, coord, nil
|
||||
return seed, m.Server.Cluster.Coordinator, nil
|
||||
}
|
||||
|
||||
// URL returns the base URL string for accessing the running program.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,14 @@ import (
|
|||
)
|
||||
|
||||
func TestNewCluster(t *testing.T) {
|
||||
cluster := test.MustRunMainWithCluster(t, 3)
|
||||
numNodes := 3
|
||||
cluster := test.MustRunMainWithCluster(t, numNodes)
|
||||
coordinator := cluster[0].Server.Cluster.Coordinator
|
||||
for i := 1; i < numNodes; i++ {
|
||||
if coordi := cluster[i].Server.Cluster.Coordinator; coordi != coordinator {
|
||||
t.Fatalf("node %d does not have the same coordinator as node 0. '%v' and '%v' respectively", i, coordi, coordinator)
|
||||
}
|
||||
}
|
||||
|
||||
response, err := http.Get("http://" + cluster[0].Server.Addr().String() + "/status")
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue