Skip to content

add assert of response code, and fix the bug of parent test #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions elastic/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (s *elasticTestSuite) TestSimple(c *C) {

r, err := s.c.Get(index, docType, "1")
c.Assert(err, IsNil)
c.Assert(r.Code, Equals, 200)
c.Assert(r.ID, Equals, "1")

err = s.c.Delete(index, docType, "1")
Expand All @@ -78,6 +79,7 @@ func (s *elasticTestSuite) TestSimple(c *C) {

resp, err := s.c.IndexTypeBulk(index, docType, items)
c.Assert(err, IsNil)
c.Assert(resp.Code, Equals, 200)
c.Assert(resp.Errors, Equals, false)

for i := 0; i < 10; i++ {
Expand All @@ -90,16 +92,26 @@ func (s *elasticTestSuite) TestSimple(c *C) {

resp, err = s.c.IndexTypeBulk(index, docType, items)
c.Assert(err, IsNil)
c.Assert(resp.Code, Equals, 200)
c.Assert(resp.Errors, Equals, false)
}

// this requires a parent setting in _mapping
func (s *elasticTestSuite) TestParent(c *C) {
index := "dummy"
docType := "comment"
ParentType := "parent"

mapping := map[string]interface{}{
docType: map[string]interface{}{
"_parent": map[string]string{"type": ParentType},
},
}
err := s.c.CreateMapping(index, docType, mapping)
c.Assert(err, IsNil)

items := make([]*BulkRequest, 10)

for i := 0; i < 10; i++ {
id := fmt.Sprintf("%d", i)
req := new(BulkRequest)
Expand All @@ -112,16 +124,20 @@ func (s *elasticTestSuite) TestParent(c *C) {

resp, err := s.c.IndexTypeBulk(index, docType, items)
c.Assert(err, IsNil)
c.Assert(resp.Code, Equals, 200)
c.Assert(resp.Errors, Equals, false)

for i := 0; i < 10; i++ {
id := fmt.Sprintf("%d", i)
req := new(BulkRequest)
req.Index = index
req.Type = docType
req.Action = ActionDelete
req.ID = id
req.Parent = "1"
items[i] = req
}
resp, err = s.c.IndexTypeBulk(index, docType, items)
resp, err = s.c.Bulk(items)
c.Assert(err, IsNil)
c.Assert(resp.Code, Equals, 200)
c.Assert(resp.Errors, Equals, false)
}
1 change: 1 addition & 0 deletions etc/river.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
my_addr = "127.0.0.1:3306"
my_user = "root"
my_pass = ""
my_charset = "utf8"

# Elasticsearch address
es_addr = "127.0.0.1:9200"
Expand Down
2 changes: 1 addition & 1 deletion glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import:
- package: github.com/satori/go.uuid
version: ^1.1.0
- package: github.com/siddontang/go-mysql
version: 3fef0652795ca3a9d47e4af1a2f6d885e574e9bb
version: ead11cac47bd127a8c667efa07f171a9143d8a25
subpackages:
- canal
- client
Expand Down
1 change: 1 addition & 0 deletions river/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Config struct {
MyAddr string `toml:"my_addr"`
MyUser string `toml:"my_user"`
MyPassword string `toml:"my_pass"`
MyCharset string `toml:"my_charset"`

ESAddr string `toml:"es_addr"`

Expand Down
2 changes: 2 additions & 0 deletions river/river.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (r *River) newCanal() error {
cfg.Addr = r.c.MyAddr
cfg.User = r.c.MyUser
cfg.Password = r.c.MyPassword
cfg.Charset = r.c.MyCharset
cfg.Flavor = r.c.Flavor

cfg.ServerID = r.c.ServerID
Expand Down Expand Up @@ -234,6 +235,7 @@ func (r *River) prepareRule() error {
if len(rule.TableInfo.PKColumns) == 0 {
return errors.Errorf("%s.%s must have a PK for a column", rule.Schema, rule.Table)
}

}

return nil
Expand Down
3 changes: 2 additions & 1 deletion river/river_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (s *riverTestSuite) SetUpSuite(c *C) {
cfg.MyAddr = *my_addr
cfg.MyUser = "root"
cfg.MyPassword = ""
cfg.MyCharset = "utf8"
cfg.ESAddr = *es_addr

cfg.ServerID = 1001
Expand Down Expand Up @@ -121,7 +122,7 @@ func (s *riverTestSuite) TestConfig(c *C) {
my_addr = "127.0.0.1:3306"
my_user = "root"
my_pass = ""

my_charset = "utf8"
es_addr = "127.0.0.1:9200"

data_dir = "./var"
Expand Down
4 changes: 4 additions & 0 deletions vendor/github.com/siddontang/go-mysql/canal/canal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions vendor/github.com/siddontang/go-mysql/canal/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion vendor/github.com/siddontang/go-mysql/dump/dump.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions vendor/github.com/siddontang/go-mysql/replication/parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.