Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
759 B

package agent
import (
11 years ago
"github.com/hashicorp/consul/testutil"
"os"
"testing"
)
func TestStatusLeader(t *testing.T) {
dir, srv := makeHTTPServer(t)
defer os.RemoveAll(dir)
defer srv.Shutdown()
defer srv.agent.Shutdown()
testutil.WaitForLeader(t, srv.agent.RPC, "dc1")
obj, err := srv.StatusLeader(nil, nil)
if err != nil {
t.Fatalf("Err: %v", err)
}
val := obj.(string)
if val == "" {
t.Fatalf("bad addr: %v", obj)
}
}
func TestStatusPeers(t *testing.T) {
dir, srv := makeHTTPServer(t)
defer os.RemoveAll(dir)
defer srv.Shutdown()
defer srv.agent.Shutdown()
obj, err := srv.StatusPeers(nil, nil)
if err != nil {
t.Fatalf("Err: %v", err)
}
peers := obj.([]string)
if len(peers) != 1 {
t.Fatalf("bad peers: %v", peers)
}
}