зеркало из https://github.com/github/vitess-gh.git
fixing linter errors
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
This commit is contained in:
Родитель
f0f8e60ed0
Коммит
e27fb43922
|
@ -31,6 +31,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"vitess.io/vitess/go/vt/log"
|
||||
"vitess.io/vitess/go/vt/vtgate/vtgateconn"
|
||||
"vitess.io/vitess/go/vt/vttest"
|
||||
|
|
|
@ -18,6 +18,7 @@ package k8stopo
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"vitess.io/vitess/go/vt/topo"
|
||||
)
|
||||
|
||||
|
|
|
@ -274,12 +274,12 @@ func rewriteProtoImports(pkg *types.Package) string {
|
|||
func extractLocalPointerType(v *types.Var) (name string, localImport string, pkgPath string, err error) {
|
||||
ptr, ok := v.Type().(*types.Pointer)
|
||||
if !ok {
|
||||
return "", "", "", fmt.Errorf("expected a pointer type for %s, got %V", v.Name(), v.Type())
|
||||
return "", "", "", fmt.Errorf("expected a pointer type for %s, got %v", v.Name(), v.Type())
|
||||
}
|
||||
|
||||
typ, ok := ptr.Elem().(*types.Named)
|
||||
if !ok {
|
||||
return "", "", "", fmt.Errorf("expected an underlying named type for %s, got %V", v.Name(), ptr.Elem())
|
||||
return "", "", "", fmt.Errorf("expected an underlying named type for %s, got %v", v.Name(), ptr.Elem())
|
||||
}
|
||||
|
||||
name = typ.Obj().Name()
|
||||
|
|
|
@ -98,6 +98,7 @@ import (
|
|||
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
"vitess.io/vitess/go/flagutil"
|
||||
"vitess.io/vitess/go/json2"
|
||||
"vitess.io/vitess/go/mysql"
|
||||
|
|
|
@ -179,34 +179,40 @@ func TestDiscoveryGatewayWaitForTablets(t *testing.T) {
|
|||
dg.tsc.ResetForTesting()
|
||||
hc.AddTestTablet(cell, "2.2.2.2", 1001, keyspace, shard, topodatapb.TabletType_REPLICA, true, 10, nil)
|
||||
hc.AddTestTablet(cell, "1.1.1.1", 1001, keyspace, shard, topodatapb.TabletType_MASTER, true, 5, nil)
|
||||
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second) //nolint
|
||||
err := dg.WaitForTablets(ctx, []topodatapb.TabletType{topodatapb.TabletType_REPLICA, topodatapb.TabletType_MASTER})
|
||||
if err != nil {
|
||||
t.Errorf("want %+v, got %+v", nil, err)
|
||||
}
|
||||
{
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) //nolint
|
||||
defer cancel()
|
||||
err := dg.WaitForTablets(ctx, []topodatapb.TabletType{topodatapb.TabletType_REPLICA, topodatapb.TabletType_MASTER})
|
||||
if err != nil {
|
||||
t.Errorf("want %+v, got %+v", nil, err)
|
||||
}
|
||||
|
||||
// fails if there are no available tablets for the desired TabletType
|
||||
err = dg.WaitForTablets(ctx, []topodatapb.TabletType{topodatapb.TabletType_RDONLY})
|
||||
if err == nil {
|
||||
t.Errorf("expected error, got nil")
|
||||
// fails if there are no available tablets for the desired TabletType
|
||||
err = dg.WaitForTablets(ctx, []topodatapb.TabletType{topodatapb.TabletType_RDONLY})
|
||||
if err == nil {
|
||||
t.Errorf("expected error, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
// errors because there is no primary on ks2
|
||||
ctx, _ = context.WithTimeout(context.Background(), 1*time.Second) //nolint
|
||||
srvTopo.SrvKeyspaceNames = []string{keyspace, "ks2"}
|
||||
err = dg.WaitForTablets(ctx, []topodatapb.TabletType{topodatapb.TabletType_MASTER})
|
||||
if err == nil {
|
||||
t.Errorf("expected error, got nil")
|
||||
{
|
||||
// errors because there is no primary on ks2
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) //nolint
|
||||
defer cancel()
|
||||
srvTopo.SrvKeyspaceNames = []string{keyspace, "ks2"}
|
||||
err := dg.WaitForTablets(ctx, []topodatapb.TabletType{topodatapb.TabletType_MASTER})
|
||||
if err == nil {
|
||||
t.Errorf("expected error, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
discovery.KeyspacesToWatch = []string{keyspace}
|
||||
// does not wait for ks2 if it's not part of the filter
|
||||
ctx, _ = context.WithTimeout(context.Background(), 1*time.Second) //nolint
|
||||
err = dg.WaitForTablets(ctx, []topodatapb.TabletType{topodatapb.TabletType_MASTER})
|
||||
if err != nil {
|
||||
t.Errorf("want %+v, got %+v", nil, err)
|
||||
{
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) //nolint
|
||||
defer cancel()
|
||||
err := dg.WaitForTablets(ctx, []topodatapb.TabletType{topodatapb.TabletType_MASTER})
|
||||
if err != nil {
|
||||
t.Errorf("want %+v, got %+v", nil, err)
|
||||
}
|
||||
}
|
||||
|
||||
discovery.KeyspacesToWatch = []string{}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче