From fdba9e5fb140a702f296280a1321937314c901bd Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Mon, 31 Jul 2017 17:25:13 -0700 Subject: [PATCH] clientv3/integration: test Put succeeds following SetEndpoint Still gets transport closing errors, but no unavailable endpoint errors. --- clientv3/integration/dial_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/clientv3/integration/dial_test.go b/clientv3/integration/dial_test.go index 4d8075de259..31e13937be5 100644 --- a/clientv3/integration/dial_test.go +++ b/clientv3/integration/dial_test.go @@ -16,6 +16,7 @@ package integration import ( "math/rand" + "strings" "testing" "time" @@ -189,3 +190,17 @@ func TestDialForeignEndpoint(t *testing.T) { t.Fatal(err) } } + +// TestSetEndpointAndPut checks that a Put following a SetEndpoint +// to a working endpoint will always succeed. +func TestSetEndpointAndPut(t *testing.T) { + defer testutil.AfterTest(t) + clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 2}) + defer clus.Terminate(t) + + clus.Client(1).SetEndpoints(clus.Members[0].GRPCAddr()) + _, err := clus.Client(1).Put(context.TODO(), "foo", "bar") + if err != nil && !strings.Contains(err.Error(), "closing") { + t.Fatal(err) + } +}