Browse Source

clientv3/integration: test Put succeeds following SetEndpoint

Still gets transport closing errors, but no unavailable endpoint errors.
Anthony Romano 8 years ago
parent
commit
fdba9e5fb1
1 changed files with 15 additions and 0 deletions
  1. 15 0
      clientv3/integration/dial_test.go

+ 15 - 0
clientv3/integration/dial_test.go

@@ -16,6 +16,7 @@ package integration
 
 
 import (
 import (
 	"math/rand"
 	"math/rand"
+	"strings"
 	"testing"
 	"testing"
 	"time"
 	"time"
 
 
@@ -189,3 +190,17 @@ func TestDialForeignEndpoint(t *testing.T) {
 		t.Fatal(err)
 		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)
+	}
+}