Skip to content
Snippets Groups Projects
Commit 511f9865 authored by xujianhai666's avatar xujianhai666
Browse files

add forking

parent 21ffbef4
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,8 @@ package config ...@@ -20,6 +20,8 @@ package config
import ( import (
"sync" "sync"
"testing" "testing"
"github.com/apache/dubbo-go/common/constant"
) )
import ( import (
...@@ -82,6 +84,7 @@ func doInit() { ...@@ -82,6 +84,7 @@ func doInit() {
"MockService": { "MockService": {
Params: map[string]string{ Params: map[string]string{
"serviceid": "soa.mock", "serviceid": "soa.mock",
"forks": "5",
}, },
Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2", Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2",
InterfaceName: "com.MockService", InterfaceName: "com.MockService",
...@@ -190,6 +193,23 @@ func Test_Implement(t *testing.T) { ...@@ -190,6 +193,23 @@ func Test_Implement(t *testing.T) {
consumerConfig = nil consumerConfig = nil
} }
func Test_Forking(t *testing.T) {
doInit()
extension.SetProtocol("dubbo", GetProtocol)
extension.SetProtocol("registry", GetProtocol)
m := consumerConfig.References["MockService"]
m.Url = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000"
for _, reference := range consumerConfig.References {
reference.Refer()
forks := int(reference.invoker.GetUrl().GetParamInt(constant.FORKS_KEY, constant.DEFAULT_FORKS))
assert.Equal(t, 5, forks)
assert.NotNil(t, reference.pxy)
assert.NotNil(t, reference.Cluster)
}
consumerConfig = nil
}
func GetProtocol() protocol.Protocol { func GetProtocol() protocol.Protocol {
if regProtocol != nil { if regProtocol != nil {
return regProtocol return regProtocol
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment