-
Notifications
You must be signed in to change notification settings - Fork 63
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
slaves/dns: 集成测试添加 #156
slaves/dns: 集成测试添加 #156
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码冲突了!
internal/integration/base_test.go
Outdated
slaves := make([]*sql.DB, 0, len(s.slavedsns)) | ||
for _, slavedsn := range s.slavedsns { | ||
slave, err := sql.Open(s.driver, slavedsn) | ||
if s.geterName == "roundrobin" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里最好是初始化这个 MasterSlaveSuite 的地方直接指定好 Slaves 的实现,而不是这么分发
@@ -87,6 +87,7 @@ func TestMasterSlaveDelete(t *testing.T) { | |||
driver: "mysql", | |||
masterdsn: "root:root@tcp(localhost:13307)/integration_test", | |||
slavedsns: []string{"root:root@tcp(localhost:13308)/integration_test"}, | |||
geterName: "roundrobin", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
就是你这里直接传入 Slaves 实例,而不是这样一个 getter name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那么前面的 slavdsns 就可能用不着了
internal/slaves/dns/dns.go
Outdated
ctx, cancel := context.WithTimeout(context.Background(), s.timeout) | ||
err := s.getSlaves(ctx) | ||
cancel() | ||
// 尽最大努力重试,拿到dns的响应 | ||
if err != nil { | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 continue 之前打印一下这个 err 吧,你可以考虑引入一个 log func(msg, args...) 啥的字段,也可以考虑直接用 log.Println。大体上我认为需要告诉一下用户,但是怎么告诉用户就不是特别重要了。
No description provided.