Skip to content

Commit

Permalink
Self-review
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Sep 8, 2024
1 parent d6c39da commit abfcc8d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions go/vt/vtctl/workflow/workflow_state_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 The Vitess Authors.
Copyright 2024 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -21,17 +21,14 @@ import (
"fmt"
"testing"

"vitess.io/vitess/go/vt/log"

"github.com/stretchr/testify/require"

binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
"vitess.io/vitess/go/vt/proto/tabletmanagerdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)

func setupMoveTables(t *testing.T) (context.Context, *testEnv) {
ctx := context.Background()
func setupMoveTables(t *testing.T, ctx context.Context) *testEnv {
schema := map[string]*tabletmanagerdata.SchemaDefinition{
"t1": {
TableDefinitions: []*tabletmanagerdata.TableDefinition{
Expand Down Expand Up @@ -90,14 +87,15 @@ func setupMoveTables(t *testing.T) (context.Context, *testEnv) {
}
te.updateTableRoutingRules(t, ctx, nil, []string{"t1"},
"source", te.targetKeyspace.KeyspaceName, "source")
return ctx, te
return te
}

// TestWorkflowStateMoveTables tests the logic used to determine the state of a MoveTables workflow based on the
// routing rules. We setup two workflows with the same table in both source and target keyspaces.
func TestWorkflowStateMoveTables(t *testing.T) {
ctx, te := setupMoveTables(t)
ctx := context.Background()
te := setupMoveTables(t, ctx)
require.NotNil(t, te)
rules, _ := te.ts.GetRoutingRules(ctx)
log.Infof("rules: %v", rules)
type testCase struct {
name string
wf1SwitchedTabletTypes []topodatapb.TabletType
Expand Down

0 comments on commit abfcc8d

Please sign in to comment.