mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
clientv3/integration: move isServerCtxTimeout to server_shutdown_test.go
Tests with cluster_proxy tags were failing, since isServerCtxTimeout was defined with "+build !cluster_proxy". Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
96e32a408f
commit
bd76ac85db
@ -19,7 +19,6 @@ package integration
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -27,8 +26,6 @@ import (
|
|||||||
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
|
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
|
||||||
"github.com/coreos/etcd/integration"
|
"github.com/coreos/etcd/integration"
|
||||||
"github.com/coreos/etcd/pkg/testutil"
|
"github.com/coreos/etcd/pkg/testutil"
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var errExpected = errors.New("expected error")
|
var errExpected = errors.New("expected error")
|
||||||
@ -92,18 +89,6 @@ func TestBalancerUnderNetworkPartitionLinearizableGetWithShortTimeout(t *testing
|
|||||||
}, time.Second)
|
}, 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) {
|
func TestBalancerUnderNetworkPartitionSerializableGet(t *testing.T) {
|
||||||
testBalancerUnderNetworkPartition(t, func(cli *clientv3.Client, ctx context.Context) error {
|
testBalancerUnderNetworkPartition(t, func(cli *clientv3.Client, ctx context.Context) error {
|
||||||
_, err := cli.Get(ctx, "a", clientv3.WithSerializable())
|
_, err := cli.Get(ctx, "a", clientv3.WithSerializable())
|
||||||
|
@ -17,6 +17,7 @@ package integration
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -24,6 +25,9 @@ import (
|
|||||||
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
|
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
|
||||||
"github.com/coreos/etcd/integration"
|
"github.com/coreos/etcd/integration"
|
||||||
"github.com/coreos/etcd/pkg/testutil"
|
"github.com/coreos/etcd/pkg/testutil"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestBalancerUnderServerShutdownWatch expects that watch client
|
// 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)
|
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")
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user