diff --git a/clientv3/integration/network_partition_test.go b/clientv3/integration/network_partition_test.go index 386e76d5d..efe8c914d 100644 --- a/clientv3/integration/network_partition_test.go +++ b/clientv3/integration/network_partition_test.go @@ -19,7 +19,6 @@ package integration import ( "context" "errors" - "strings" "testing" "time" @@ -27,8 +26,6 @@ import ( "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) var errExpected = errors.New("expected error") @@ -92,18 +89,6 @@ func TestBalancerUnderNetworkPartitionLinearizableGetWithShortTimeout(t *testing }, time.Second) } -// e.g. due to clock drifts in server-side, -// client context times out first in server-side -// while original client-side context is not timed out yet -func isServerCtxTimeout(err error) bool { - if err == nil { - return false - } - ev, _ := status.FromError(err) - code := ev.Code() - return code == codes.DeadlineExceeded && strings.Contains(err.Error(), "context deadline exceeded") -} - func TestBalancerUnderNetworkPartitionSerializableGet(t *testing.T) { testBalancerUnderNetworkPartition(t, func(cli *clientv3.Client, ctx context.Context) error { _, err := cli.Get(ctx, "a", clientv3.WithSerializable()) diff --git a/clientv3/integration/server_shutdown_test.go b/clientv3/integration/server_shutdown_test.go index 9b52434e1..ffb46a929 100644 --- a/clientv3/integration/server_shutdown_test.go +++ b/clientv3/integration/server_shutdown_test.go @@ -17,6 +17,7 @@ package integration import ( "bytes" "context" + "strings" "testing" "time" @@ -24,6 +25,9 @@ import ( "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) // TestBalancerUnderServerShutdownWatch expects that watch client @@ -235,3 +239,15 @@ func testBalancerUnderServerShutdownImmutable(t *testing.T, op func(*clientv3.Cl t.Errorf("failed to finish range request in time %v (timeout %v)", err, timeout) } } + +// e.g. due to clock drifts in server-side, +// client context times out first in server-side +// while original client-side context is not timed out yet +func isServerCtxTimeout(err error) bool { + if err == nil { + return false + } + ev, _ := status.FromError(err) + code := ev.Code() + return code == codes.DeadlineExceeded && strings.Contains(err.Error(), "context deadline exceeded") +}