-
Notifications
You must be signed in to change notification settings - Fork 934
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: when the routing policy is not set, the setInvokers() method has…
… a co process leak (#2104) * 非路由策略下,不触发节点变更的数据变更协程消息 * 非路由策略下,不触发节点变更的数据变更协程消息 * 非路由策略下,不触发节点变更的数据变更协程消息 * 非路由策略下,不触发节点变更的数据变更协程消息 * 非路由策略下,不触发节点变更的数据变更协程消息 * 非路由策略下,不触发节点变更的数据变更协程消息 * 非路由策略下,不触发节点变更的数据变更协程消息 * 非路由策略下,不触发节点变更的数据变更协程消息 * 非路由策略下,不触发节点变更的数据变更协程消息 Co-authored-by: zhangping17 <zhangping17@xiaomi.com>
- Loading branch information
1 parent
81c6d19
commit e0b1487
Showing
4 changed files
with
124 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package chain | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
import ( | ||
_ "github.com/apache/dubbo-go/cluster/router" | ||
_ "github.com/apache/dubbo-go/cluster/router/tag" | ||
"github.com/apache/dubbo-go/common" | ||
"github.com/apache/dubbo-go/common/constant" | ||
"github.com/apache/dubbo-go/protocol" | ||
) | ||
|
||
var ( | ||
url, _ = common.NewURL( | ||
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT)) | ||
anyURL, _ = common.NewURL(fmt.Sprintf("condition://%s/com.foo.BarService", constant.ANYHOST_VALUE)) | ||
) | ||
|
||
const ( | ||
test1234IP = "1.2.3.4" | ||
test0000IP = "0.0.0.0" | ||
port20000 = 20000 | ||
|
||
dubboForamt = "dubbo://%s:%d/com.foo.BarService" | ||
anyUrlFormat = "condition://%s/com.foo.BarService" | ||
applicationKey = "test-condition" | ||
applicationField = "application" | ||
forceField = "force" | ||
forceValue = "true" | ||
) | ||
|
||
func TestNewRouterChain(t *testing.T) { | ||
chain, _ := NewRouterChain(getRouteUrl(applicationKey)) | ||
assert.Equal(t, chain.routerStatus.Load(), int32(HasRouter)) | ||
var invokers []protocol.Invoker | ||
dubboURL, _ := common.NewURL(fmt.Sprintf(dubboForamt, test1234IP, port20000)) | ||
invokers = append(invokers, protocol.NewBaseInvoker(dubboURL)) | ||
chain.SetInvokers(invokers) | ||
} | ||
|
||
func getRouteUrl(applicationKey string) *common.URL { | ||
url, _ := common.NewURL(fmt.Sprintf(anyUrlFormat, test0000IP)) | ||
url.AddParam(applicationField, applicationKey) | ||
url.AddParam(forceField, forceValue) | ||
return url | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.