|
|
@ -1,14 +1,10 @@ |
|
|
|
package api |
|
|
|
package api |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"io/ioutil" |
|
|
|
|
|
|
|
"os" |
|
|
|
|
|
|
|
"runtime" |
|
|
|
|
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func TestStatusLeaderTCP(t *testing.T) { |
|
|
|
func TestStatusLeader(t *testing.T) { |
|
|
|
c, s := makeClient(t) |
|
|
|
c, s := makeClient(t) |
|
|
|
defer s.stop() |
|
|
|
defer s.stop() |
|
|
|
|
|
|
|
|
|
|
@ -23,43 +19,6 @@ func TestStatusLeaderTCP(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestStatusLeaderUnix(t *testing.T) { |
|
|
|
|
|
|
|
if runtime.GOOS == "windows" { |
|
|
|
|
|
|
|
t.SkipNow() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tempdir, err := ioutil.TempDir("", "consul-test-") |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
t.Fatalf("err: %s", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
defer os.RemoveAll(tempdir) |
|
|
|
|
|
|
|
socket := fmt.Sprintf("unix://%s/test.sock", tempdir) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clientConfig := func(c *Config) { |
|
|
|
|
|
|
|
c.Address = socket |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
serverConfig := func(c *testServerConfig) { |
|
|
|
|
|
|
|
if c.Addresses == nil { |
|
|
|
|
|
|
|
c.Addresses = &testAddressConfig{} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
c.Addresses.HTTP = socket |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c, s := makeClientWithConfig(t, clientConfig, serverConfig) |
|
|
|
|
|
|
|
defer s.stop() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status := c.Status() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
leader, err := status.Leader() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
t.Fatalf("err: %v", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if leader == "" { |
|
|
|
|
|
|
|
t.Fatalf("Expected leader") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestStatusPeers(t *testing.T) { |
|
|
|
func TestStatusPeers(t *testing.T) { |
|
|
|
c, s := makeClient(t) |
|
|
|
c, s := makeClient(t) |
|
|
|
defer s.stop() |
|
|
|
defer s.stop() |
|
|
|