diff --git a/dumpling/dumpling.go b/dumpling/dumpling.go index b28bb34bc0..cde225f7eb 100644 --- a/dumpling/dumpling.go +++ b/dumpling/dumpling.go @@ -177,7 +177,7 @@ func (m *Dumpling) constructArgs() (*export.Config, error) { var ret []string extraArgs := strings.Fields(cfg.ExtraArgs) if len(extraArgs) > 0 { - err := parseExtraArgs(dumpConfig, extraArgs) + err := parseExtraArgs(dumpConfig, ParseArgLikeBash(extraArgs)) if err != nil { m.logger.Warn("parsed some unsupported arguments", zap.Error(err)) ret = append(ret, extraArgs...) diff --git a/dumpling/util_test.go b/dumpling/util_test.go index 26e5e2bdb1..384f400288 100644 --- a/dumpling/util_test.go +++ b/dumpling/util_test.go @@ -17,8 +17,9 @@ import ( "strings" "testing" + "github.com/pingcap/dm/dm/config" + . "github.com/pingcap/check" - "github.com/pingcap/dumpling/v4/export" ) var _ = Suite(&testDumplingSuite{}) @@ -31,16 +32,17 @@ type testDumplingSuite struct { } func (m *testDumplingSuite) TestParseArgs(c *C) { - extraArgs := `--statement-size=100 --where "t > 10" --threads 8 -F 50` - cfg := export.DefaultConfig() - err := parseExtraArgs(cfg, strings.Fields(extraArgs)) + cfg := &config.SubTaskConfig{} + cfg.ExtraArgs = `--statement-size=100 --where "t>10" --threads 8 -F 50` + d := NewDumpling(cfg) + exportCfg, err := d.constructArgs() c.Assert(err, IsNil) - c.Assert(cfg.StatementSize, Equals, uint64(100)) - c.Assert(cfg.Where, Equals, "t > 10") - c.Assert(cfg.Threads, Equals, 8) - c.Assert(cfg.FileSize, Equals, uint64(50)) + c.Assert(exportCfg.StatementSize, Equals, uint64(100)) + c.Assert(exportCfg.Where, Equals, "t>10") + c.Assert(exportCfg.Threads, Equals, 8) + c.Assert(exportCfg.FileSize, Equals, uint64(50)) - extraArgs = `--statement-size=100 --skip-tz-utc` - err = parseExtraArgs(cfg, strings.Fields(extraArgs)) + extraArgs := `--statement-size=100 --skip-tz-utc` + err = parseExtraArgs(exportCfg, strings.Fields(extraArgs)) c.Assert(err, NotNil) } diff --git a/go.mod b/go.mod index 313f49da18..f8852cd1f5 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/soheilhy/cmux v0.1.4 github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/cobra v0.0.6 - github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/pflag v1.0.5 github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965 // indirect github.com/twitchtv/retool v1.3.8-0.20180918173430-41330f8b4e07 github.com/uber-go/atomic v1.4.0 // indirect