Skip to content

Commit

Permalink
include 'mysql' and 'direct' strategies
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed Oct 26, 2023
1 parent 83bb623 commit 8bc34ab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go/vt/schema/ddl_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func ParseDDLStrategy(strategyVariable string) (*DDLStrategySetting, error) {
}

switch setting.Strategy {
case DDLStrategyVitess, DDLStrategyOnline:
case DDLStrategyVitess, DDLStrategyOnline, DDLStrategyMySQL, DDLStrategyDirect:
if opts := setting.RuntimeOptions(); len(opts) > 0 {
return nil, fmt.Errorf("invalid flags for vitess strategy: %s", strings.Join(opts, " "))
}
Expand Down
45 changes: 31 additions & 14 deletions go/vt/schema/ddl_strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,23 @@ func TestIsDirect(t *testing.T) {

func TestIsCutOverThresholdFlag(t *testing.T) {
tt := []struct {
s string
expect bool
val string
d time.Duration
s string
expect bool
expectError string
val string
d time.Duration
}{
{
s: "something",
s: "something",
expectError: "invalid flags",
},
{
s: "-cut-over-threshold",
s: "-cut-over-threshold",
expectError: "invalid flags",
},
{
s: "--cut-over-threshold",
s: "--cut-over-threshold",
expectError: "invalid flags",
},
{
s: "--cut-over-threshold=",
Expand Down Expand Up @@ -87,6 +91,11 @@ func TestIsCutOverThresholdFlag(t *testing.T) {
for _, ts := range tt {
t.Run(ts.s, func(t *testing.T) {
setting, err := ParseDDLStrategy("online " + ts.s)
if ts.expectError != "" {
assert.ErrorContains(t, err, ts.expectError)
return
}

assert.NoError(t, err)

val, isCutOver := isCutOverThresholdFlag(ts.s)
Expand All @@ -104,19 +113,23 @@ func TestIsCutOverThresholdFlag(t *testing.T) {

func TestIsExpireArtifactsFlag(t *testing.T) {
tt := []struct {
s string
expect bool
val string
d time.Duration
s string
expect bool
expectError string
val string
d time.Duration
}{
{
s: "something",
s: "something",
expectError: "invalid flags",
},
{
s: "-retain-artifacts",
s: "-retain-artifacts",
expectError: "invalid flags",
},
{
s: "--retain-artifacts",
s: "--retain-artifacts",
expectError: "invalid flags",
},
{
s: "--retain-artifacts=",
Expand Down Expand Up @@ -150,6 +163,10 @@ func TestIsExpireArtifactsFlag(t *testing.T) {
for _, ts := range tt {
t.Run(ts.s, func(t *testing.T) {
setting, err := ParseDDLStrategy("online " + ts.s)
if ts.expectError != "" {
assert.ErrorContains(t, err, ts.expectError)
return
}
assert.NoError(t, err)

val, isRetainArtifacts := isRetainArtifactsFlag(ts.s)
Expand Down

0 comments on commit 8bc34ab

Please sign in to comment.