Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lichunzhu committed Mar 18, 2020
1 parent 4bed416 commit 22681b9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dumpling/dumpling.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
22 changes: 12 additions & 10 deletions dumpling/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22681b9

Please sign in to comment.