Skip to content

Commit

Permalink
clientv3/integration: add 'TestDialEndpoints'
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuho committed Sep 7, 2016
1 parent 583ca11 commit 5fd6a0c
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions clientv3/integration/dial_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2016 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package integration

import (
"testing"

"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/integration"
"github.com/coreos/etcd/pkg/testutil"
"golang.org/x/net/context"
)

func TestDialUpdateEndpoints(t *testing.T) {
defer testutil.AfterTest(t)

clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
defer clus.Terminate(t)

cli := clus.Client(0)

clus.AddMember(t)
clus.AddMember(t)
clus.WaitLeader(t)

cli.UpdateEndpoints(clus.Members[1].GRPCAddr())

// stop the original member
clus.Members[0].Stop(t)
clus.WaitLeader(t)

// rpc will only go through if the sync worked
kapi := clientv3.NewKV(cli)
if _, err := kapi.Put(context.Background(), "foo", "bar"); err != nil {
t.Fatal(err)
}

clus.Members[0].Restart(t)
}

0 comments on commit 5fd6a0c

Please sign in to comment.