clientv3: Add TestMemberAddWithExistingURLs
TestMemberAddWithExistingURLs ensures adding a new member with URLs already being used in the cluster will not succeed.release-3.4
parent
e1ca3b4434
commit
9bd86a647f
|
@ -17,6 +17,7 @@ package integration
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"go.etcd.io/etcd/integration"
|
"go.etcd.io/etcd/integration"
|
||||||
|
@ -61,6 +62,30 @@ func TestMemberAdd(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMemberAddWithExistingURLs(t *testing.T) {
|
||||||
|
defer testutil.AfterTest(t)
|
||||||
|
|
||||||
|
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
|
||||||
|
defer clus.Terminate(t)
|
||||||
|
|
||||||
|
capi := clus.RandClient()
|
||||||
|
|
||||||
|
resp, err := capi.MemberList(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to list member %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
existingURL := resp.Members[0].PeerURLs[0]
|
||||||
|
_, err = capi.MemberAdd(context.Background(), []string{existingURL})
|
||||||
|
expectedErrKeywords := "Peer URLs already exists"
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("expecting add member to fail, got no error")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), expectedErrKeywords) {
|
||||||
|
t.Errorf("expecting error to contain %s, got %s", expectedErrKeywords, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestMemberRemove(t *testing.T) {
|
func TestMemberRemove(t *testing.T) {
|
||||||
defer testutil.AfterTest(t)
|
defer testutil.AfterTest(t)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue