Skip to content

Commit

Permalink
Merge pull request #10548 from jingyih/add_TestMemberAddWithExistingURLs
Browse files Browse the repository at this point in the history
clientv3/integration: Add TestMemberAddWithExistingURLs
  • Loading branch information
xiang90 authored Mar 19, 2019
2 parents 2d9b32d + 9bd86a6 commit 09d0844
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions clientv3/integration/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package integration
import (
"context"
"reflect"
"strings"
"testing"

"go.etcd.io/etcd/integration"
Expand Down Expand Up @@ -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) {
defer testutil.AfterTest(t)

Expand Down

0 comments on commit 09d0844

Please sign in to comment.