Skip to content

Commit

Permalink
Update unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Sep 9, 2024
1 parent 55d8c4d commit 1a145a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 59 deletions.
41 changes: 14 additions & 27 deletions go/textutil/strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/sqltypes"

binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)
Expand Down Expand Up @@ -131,53 +133,38 @@ func TestValueIsSimulatedNull(t *testing.T) {
val: "test",
isNull: false,
},
{
name: "case string true",
val: SimulatedNullString,
isNull: true,
},
{
name: "case []string true",
val: []string{SimulatedNullString},
val: []string{sqltypes.NULL.String()},
isNull: true,
},
{
name: "case []string false",
val: []string{SimulatedNullString, SimulatedNullString},
val: []string{sqltypes.NULL.String(), sqltypes.NULL.String()},
isNull: false,
},
{
name: "case binlogdatapb.OnDDLAction true",
val: binlogdatapb.OnDDLAction(SimulatedNullInt),
isNull: true,
},
{
name: "case int true",
val: SimulatedNullInt,
isNull: true,
},
{
name: "case int32 true",
val: int32(SimulatedNullInt),
isNull: true,
name: "case binlogdatapb.OnDDLAction exec",
val: binlogdatapb.OnDDLAction_EXEC,
isNull: false,
},
{
name: "case int64 true",
val: int64(SimulatedNullInt),
isNull: true,
name: "case int false",
val: 1,
isNull: false,
},
{
name: "case []topodatapb.TabletType true",
val: []topodatapb.TabletType{topodatapb.TabletType(SimulatedNullInt)},
isNull: true,
},
{
name: "case binlogdatapb.VReplicationWorkflowState true",
val: binlogdatapb.VReplicationWorkflowState(SimulatedNullInt),
isNull: true,
name: "case binlogdatapb.VReplicationWorkflowState running",
val: binlogdatapb.VReplicationWorkflowState_Running,
isNull: false,
},
{
name: "case default",
name: "case float false",
val: float64(1),
isNull: false,
},
Expand Down
32 changes: 0 additions & 32 deletions go/vt/vttablet/tabletmanager/rpc_vreplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package tabletmanager
import (
"context"
"fmt"
"runtime/debug"
"strings"

"golang.org/x/exp/maps"
Expand All @@ -30,7 +29,6 @@ import (
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/textutil"
"vitess.io/vitess/go/vt/discovery"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/proto/vttime"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/topo/topoproto"
Expand Down Expand Up @@ -121,11 +119,6 @@ func (tm *TabletManager) CreateVReplicationWorkflow(ctx context.Context, req *ta
}

func (tm *TabletManager) DeleteVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.DeleteVReplicationWorkflowRequest) (*tabletmanagerdatapb.DeleteVReplicationWorkflowResponse, error) {
defer func() {
if x := recover(); x != nil {
log.Errorf("DeleteVReplicationWorkflow panic %v: stack: %s", x, debug.Stack())
}
}()
if req == nil || req.Workflow == "" {
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid request, no workflow provided")
}
Expand Down Expand Up @@ -180,11 +173,6 @@ func (tm *TabletManager) HasVReplicationWorkflows(ctx context.Context, req *tabl
}

func (tm *TabletManager) ReadVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.ReadVReplicationWorkflowsRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowsResponse, error) {
defer func() {
if x := recover(); x != nil {
log.Errorf("ReadVReplicationWorkflows panic %v: stack: %s", x, debug.Stack())
}
}()
query, err := tm.buildReadVReplicationWorkflowsQuery(req)
if err != nil {
return nil, err
Expand Down Expand Up @@ -289,11 +277,6 @@ func (tm *TabletManager) ReadVReplicationWorkflows(ctx context.Context, req *tab
}

func (tm *TabletManager) ReadVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.ReadVReplicationWorkflowRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowResponse, error) {
defer func() {
if x := recover(); x != nil {
log.Errorf("ReadVReplicationWorkflow panic %v: stack: %s", x, debug.Stack())
}
}()
if req == nil || req.Workflow == "" {
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid request, no workflow provided")
}
Expand Down Expand Up @@ -420,11 +403,6 @@ func isStreamCopying(tm *TabletManager, id int64) (bool, error) {
// workflow stream when the record is updated, so we also in effect
// restart the workflow stream via the update.
func (tm *TabletManager) UpdateVReplicationWorkflow(ctx context.Context, req *tabletmanagerdatapb.UpdateVReplicationWorkflowRequest) (*tabletmanagerdatapb.UpdateVReplicationWorkflowResponse, error) {
defer func() {
if x := recover(); x != nil {
log.Errorf("UpdateVReplicationWorkflow panic %v: stack: %s", x, debug.Stack())
}
}()
bindVars := map[string]*querypb.BindVariable{
"wf": sqltypes.StringBindVariable(req.Workflow),
}
Expand Down Expand Up @@ -533,11 +511,6 @@ func (tm *TabletManager) UpdateVReplicationWorkflow(ctx context.Context, req *ta
// Note: today this is only used during Reshard as all of the vreplication
// streams need to be migrated from the old shards to the new ones.
func (tm *TabletManager) UpdateVReplicationWorkflows(ctx context.Context, req *tabletmanagerdatapb.UpdateVReplicationWorkflowsRequest) (*tabletmanagerdatapb.UpdateVReplicationWorkflowsResponse, error) {
defer func() {
if x := recover(); x != nil {
log.Errorf("UpdateVReplicationWorkflows panic %v: stack: %s", x, debug.Stack())
}
}()
query, err := tm.buildUpdateVReplicationWorkflowsQuery(req)
if err != nil {
return nil, err
Expand Down Expand Up @@ -643,11 +616,6 @@ func (tm *TabletManager) buildReadVReplicationWorkflowsQuery(req *tabletmanagerd
// the metadata/flow control fields for N vreplication workflows based on the
// request.
func (tm *TabletManager) buildUpdateVReplicationWorkflowsQuery(req *tabletmanagerdatapb.UpdateVReplicationWorkflowsRequest) (string, error) {
defer func() {
if x := recover(); x != nil {
log.Errorf("buildUpdateVReplicationWorkflowsQuery panic %v: stack: %s", x, debug.Stack())
}
}()
if req.GetAllWorkflows() && (len(req.GetIncludeWorkflows()) > 0 || len(req.GetExcludeWorkflows()) > 0) {
return "", errAllWithIncludeExcludeWorkflows
}
Expand Down

0 comments on commit 1a145a5

Please sign in to comment.