Skip to content
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

Fix:zk too many tcp conn #1010

Merged
merged 41 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2aa489a
Merge pull request #981 from lzp0412/develop
AlexStocks Jan 6, 2021
3120a22
Merge remote-tracking branch 'upstream/develop' into fix_zk_too_many_…
wenxuwan Jan 23, 2021
33dc7d4
try to fix zk too many connections
wenxuwan Jan 23, 2021
984a1ae
remove close function in service_discovery
wenxuwan Jan 23, 2021
06b1cd1
remove unused code
wenxuwan Jan 23, 2021
16a43ac
try to fix lint
wenxuwan Jan 23, 2021
186a8e7
fix imports format and ut
wenxuwan Jan 23, 2021
a53ed2b
fix import fmt
wenxuwan Jan 23, 2021
bd59cfc
fix ut error
wenxuwan Jan 24, 2021
ead5951
fix ut error
wenxuwan Jan 24, 2021
55f40f7
Merge remote-tracking branch 'upstream/develop' into fix_zk_too_many_…
wenxuwan Jan 24, 2021
bb84695
fix ut
wenxuwan Jan 24, 2021
394cbb2
fix lint
wenxuwan Jan 24, 2021
930a15b
try to fix ut
wenxuwan Jan 25, 2021
7df6426
fix ut
wenxuwan Jan 25, 2021
93ae337
fix ut
wenxuwan Jan 25, 2021
2cb436b
so tired to fix the ut
wenxuwan Jan 25, 2021
543721c
fix lint
wenxuwan Jan 25, 2021
2bc815a
remove client close from registry
wenxuwan Jan 26, 2021
0a215ac
fix provider not started
wenxuwan Jan 26, 2021
f1c5ee4
Merge remote-tracking branch 'upstream/1.5' into fix_zk_too_many_tcp_…
wenxuwan Feb 23, 2021
43280d7
change some comments
wenxuwan Feb 25, 2021
6fa3fea
fix facade ut
wenxuwan Feb 25, 2021
132ca25
Merge remote-tracking branch 'upstream/1.5' into fix_zk_too_many_tcp_…
wenxuwan Feb 25, 2021
93374a2
fix glint
wenxuwan Feb 25, 2021
991ef61
Merge remote-tracking branch 'upstream/1.5' into fix_zk_too_many_tcp_…
wenxuwan Feb 25, 2021
cb8b665
fix restart can't find provider error
wenxuwan Feb 26, 2021
3fdbb01
try to fix provider lost
wenxuwan Feb 26, 2021
ef8966c
try to fix provider lost
wenxuwan Feb 27, 2021
ca647ab
try to fix provider can't find error
wenxuwan Feb 27, 2021
3a05f71
fix compile error
wenxuwan Feb 27, 2021
ae6a138
change type error
wenxuwan Feb 27, 2021
a8bc4e1
fix comments
wenxuwan Feb 28, 2021
972a91a
move zk to gost
wenxuwan Mar 2, 2021
0ebe79c
fix lint
wenxuwan Mar 2, 2021
46801c3
replace grpc version
wenxuwan Mar 2, 2021
364be20
update gost version
wenxuwan Mar 3, 2021
786e843
fix compile error
wenxuwan Mar 3, 2021
9d8c910
fix comments
wenxuwan Mar 4, 2021
98ba75e
fix comments
wenxuwan Mar 6, 2021
a231789
upgrade hession version
wenxuwan Mar 15, 2021
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
Prev Previous commit
Next Next commit
so tired to fix the ut
  • Loading branch information
wenxuwan committed Jan 25, 2021
commit 2cb436bf36e0ff1376f04c89a11e21986b273bed
43 changes: 18 additions & 25 deletions cluster/router/chain/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
)

import (
zk "github.com/dubbogo/go-zookeeper/zk"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -53,16 +54,19 @@ const (
consumerFormat = "consumer://%s/com.foo.BarService"
dubboForamt = "dubbo://%s:%d/com.foo.BarService"
anyUrlFormat = "condition://%s/com.foo.BarService"
zk = "zookeeper"
zkName = "zookeeper"
applicationKey = "test-condition"
applicationField = "application"
forceField = "force"
forceValue = "true"
)

var zkCluster *zk.TestCluster

func TestNewRouterChain(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
zkCluster = ts
err = z.Create(path)
assert.NoError(t, err)
testyml := `scope: application
Expand All @@ -77,12 +81,11 @@ conditions:
_, err = z.Conn.Set(path, []byte(testyml), 0)
assert.NoError(t, err)
defer func() {
_ = ts.Stop()
z.Close()
z.Delete(path)
}()

zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
config.GetEnvInstance().SetDynamicConfiguration(configuration)

assert.Nil(t, err)
Expand Down Expand Up @@ -114,7 +117,7 @@ func TestNewRouterChainURLNil(t *testing.T) {
}

func TestRouterChainAddRouters(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
_, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second, zookeeper.WithTestCluster(zkCluster))
assert.NoError(t, err)
err = z.Create(path)
assert.NoError(t, err)
Expand All @@ -131,13 +134,11 @@ conditions:
_, err = z.Conn.Set(path, []byte(testyml), 0)
assert.NoError(t, err)
defer func() {
_ = ts.Stop()
assert.NoError(t, err)
z.Close()
z.Delete(path)
}()

zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, zkCluster.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
assert.NoError(t, err)
config.GetEnvInstance().SetDynamicConfiguration(configuration)

Expand All @@ -159,15 +160,9 @@ conditions:
}

func TestRouterChainRoute(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
defer func() {
err = ts.Stop()
assert.NoError(t, err)
z.Close()
}()

ts, _, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second, zookeeper.WithTestCluster(zkCluster))
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
assert.NoError(t, err)
config.GetEnvInstance().SetDynamicConfiguration(configuration)

Expand All @@ -192,7 +187,7 @@ func TestRouterChainRoute(t *testing.T) {
}

func TestRouterChainRouteAppRouter(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second, zookeeper.WithTestCluster(zkCluster))
assert.NoError(t, err)
err = z.Create(path)
assert.NoError(t, err)
Expand All @@ -209,13 +204,11 @@ conditions:
_, err = z.Conn.Set(path, []byte(testyml), 0)
assert.NoError(t, err)
defer func() {
_ = ts.Stop()
assert.NoError(t, err)
z.Close()
z.Delete(path)
}()

zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
assert.NoError(t, err)
config.GetEnvInstance().SetDynamicConfiguration(configuration)

Expand All @@ -237,7 +230,7 @@ conditions:
}

func TestRouterChainRouteNoRoute(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second, zookeeper.WithTestCluster(zkCluster))
assert.Nil(t, err)
defer func() {
_ = ts.Stop()
Expand All @@ -246,7 +239,7 @@ func TestRouterChainRouteNoRoute(t *testing.T) {
}()

zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
assert.Nil(t, err)

Expand Down
20 changes: 10 additions & 10 deletions cluster/router/condition/app_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ conditions:

_, err = z.Conn.Set(routerPath, []byte(testYML), 0)
assert.NoError(t, err)
defer func() {
err = ts.Stop()
assert.NoError(t, err)
z.Close()
}()
//defer func() {
wenxuwan marked this conversation as resolved.
Show resolved Hide resolved
// err = ts.Stop()
// assert.NoError(t, err)
// z.Close()
//}()

zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, routerLocalIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(routerZk).GetDynamicConfiguration(zkUrl)
Expand Down Expand Up @@ -118,11 +118,11 @@ conditions:

_, err = z.Conn.Set(routerPath, []byte(testYML), 0)
assert.NoError(t, err)
defer func() {
err = ts.Stop()
assert.NoError(t, err)
z.Close()
}()
//defer func() {
wenxuwan marked this conversation as resolved.
Show resolved Hide resolved
// err = ts.Stop()
// assert.NoError(t, err)
// z.Close()
//}()

zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, routerLocalIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(routerZk).GetDynamicConfiguration(zkUrl)
Expand Down
16 changes: 8 additions & 8 deletions remoting/zookeeper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,11 @@ func (z *ZookeeperClient) Close() {
z.Conn.Close()
}

func CloseZookeeperClient() {
if atomic.LoadUint32(&clientHaveCreated) == 1 {
mux.Lock()
defer mux.Unlock()
zkClient.Conn.Close()
zkClient = nil
}
}
//func closeZookeeperClient() {
// if atomic.LoadUint32(&clientHaveCreated) == 1 {
// mux.Lock()
// defer mux.Unlock()
// zkClient.Conn.Close()
// zkClient = nil
// }
//}