mirror of https://github.com/status-im/consul.git
39 lines
740 B
Go
39 lines
740 B
Go
|
package consul
|
||
|
|
||
|
import (
|
||
|
"github.com/hashicorp/consul/rpc"
|
||
|
"os"
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func TestCatalogRegister(t *testing.T) {
|
||
|
dir1, s1 := testServer(t)
|
||
|
defer os.RemoveAll(dir1)
|
||
|
defer s1.Shutdown()
|
||
|
client := rpcClient(t, s1)
|
||
|
defer client.Close()
|
||
|
|
||
|
arg := rpc.RegisterRequest{
|
||
|
Datacenter: "dc1",
|
||
|
Node: "foo",
|
||
|
Address: "127.0.0.1",
|
||
|
ServiceName: "db",
|
||
|
ServiceTag: "master",
|
||
|
ServicePort: 8000,
|
||
|
}
|
||
|
var out struct{}
|
||
|
|
||
|
err := client.Call("Catalog.Register", &arg, &out)
|
||
|
if err == nil || err.Error() != "No cluster leader" {
|
||
|
t.Fatalf("err: %v", err)
|
||
|
}
|
||
|
|
||
|
// Wait for leader
|
||
|
time.Sleep(100 * time.Millisecond)
|
||
|
|
||
|
if err := client.Call("Catalog.Register", &arg, &out); err != nil {
|
||
|
t.Fatalf("err: %v", err)
|
||
|
}
|
||
|
}
|