Skip to content

Commit

Permalink
Merge pull request #637 from jinjiangcc/develop
Browse files Browse the repository at this point in the history
Mod: code linter warnings
  • Loading branch information
AlexStocks authored Jun 30, 2020
2 parents a28a34d + 57019b7 commit 72901ee
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
4 changes: 2 additions & 2 deletions remoting/etcdv3/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (suite *ClientTestSuite) TestClientValid() {
c := suite.client
t := suite.T()

if c.Valid() != true {
if !c.Valid() {
t.Fatal("client is not valid")
}
c.Close()
Expand All @@ -174,7 +174,7 @@ func (suite *ClientTestSuite) TestClientDone() {

c.Wait.Wait()

if c.Valid() == true {
if c.Valid() {
suite.T().Fatal("client should be invalid then")
}
}
Expand Down
6 changes: 2 additions & 4 deletions remoting/etcdv3/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ LOOP:
)
logger.Infof("ETCDV3ProviderRegistry.validateETCDV3Client(etcd Addr{%s}) = error{%#v}",
endpoint, perrors.WithStack(err))
if err == nil {
if r.RestartCallBack() {
break
}
if err == nil && r.RestartCallBack() {
break
}
failTimes++
if MaxFailTimes <= failTimes {
Expand Down
15 changes: 9 additions & 6 deletions remoting/kubernetes/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ var tests = []struct {
// test dataset prefix
const prefix = "name"

var (
watcherStopLog = "the watcherSet watcher was stopped"
)
var clientPodListJsonData = `{
"apiVersion": "v1",
"items": [
Expand Down Expand Up @@ -258,12 +261,12 @@ func TestClientValid(t *testing.T) {
client := getTestClient(t)
defer client.Close()

if client.Valid() != true {
if !client.Valid() {
t.Fatal("client is not valid")
}

client.Close()
if client.Valid() != false {
if client.Valid() {
t.Fatal("client is valid")
}
}
Expand All @@ -278,7 +281,7 @@ func TestClientDone(t *testing.T) {

<-client.Done()

if client.Valid() == true {
if client.Valid() {
t.Fatal("client should be invalid")
}
}
Expand Down Expand Up @@ -331,7 +334,7 @@ func TestClientGetChildrenKVList(t *testing.T) {
return
}
case <-done:
t.Log("the watcherSet watcher was stopped")
t.Log(watcherStopLog)
return
}
}
Expand Down Expand Up @@ -399,7 +402,7 @@ func TestClientWatchPrefix(t *testing.T) {
case e := <-wc:
t.Logf("got event %v k %s v %s", e.EventType, e.Key, e.Value)
case <-done:
t.Log("the watcherSet watcher was stopped")
t.Log(watcherStopLog)
return
}
}
Expand Down Expand Up @@ -441,7 +444,7 @@ func TestClientWatch(t *testing.T) {
case e := <-wc:
t.Logf("got event %v k %s v %s", e.EventType, e.Key, e.Value)
case <-done:
t.Log("the watcherSet watcher was stopped")
t.Log(watcherStopLog)
return
}
}
Expand Down
1 change: 1 addition & 0 deletions remoting/kubernetes/facade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (r *mockFacade) GetUrl() common.URL {
}

func (r *mockFacade) Destroy() {
// TODO implementation me
}

func (r *mockFacade) RestartCallBack() bool {
Expand Down
6 changes: 2 additions & 4 deletions remoting/zookeeper/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ LOOP:
err = ValidateZookeeperClient(r, WithZkName(zkName))
logger.Infof("ZkProviderRegistry.validateZookeeperClient(zkAddr{%s}) = error{%#v}",
zkAddress, perrors.WithStack(err))
if err == nil {
if r.RestartCallBack() {
break
}
if err == nil && r.RestartCallBack() {
break
}
failTimes++
if MaxFailTimes <= failTimes {
Expand Down
10 changes: 7 additions & 3 deletions remoting/zookeeper/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import (
"github.com/apache/dubbo-go/remoting"
)

var (
dubboPropertiesPath = "/dubbo/dubbo.properties"
)

func initZkData(t *testing.T) (*zk.TestCluster, *ZookeeperClient, <-chan zk.Event) {
ts, client, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
Expand All @@ -58,10 +62,10 @@ func initZkData(t *testing.T) (*zk.TestCluster, *ZookeeperClient, <-chan zk.Even
dubbo.service.com.ikurento.user.UserProvider.cluster=failover
`

err = client.Create("/dubbo/dubbo.properties")
err = client.Create(dubboPropertiesPath)
assert.NoError(t, err)

_, err = client.Conn.Set("/dubbo/dubbo.properties", []byte(data), 0)
_, err = client.Conn.Set(dubboPropertiesPath, []byte(data), 0)
assert.NoError(t, err)

return ts, client, event
Expand Down Expand Up @@ -99,7 +103,7 @@ func TestListener(t *testing.T) {
dataListener := &mockDataListener{client: client, changedData: changedData, wait: &wait}
listener.ListenServiceEvent(nil, "/dubbo", dataListener)
time.Sleep(1 * time.Second)
_, err := client.Conn.Set("/dubbo/dubbo.properties", []byte(changedData), 1)
_, err := client.Conn.Set(dubboPropertiesPath, []byte(changedData), 1)
assert.NoError(t, err)
wait.Wait()
assert.Equal(t, changedData, dataListener.eventList[1].Content)
Expand Down

0 comments on commit 72901ee

Please sign in to comment.