Skip to content
Snippets Groups Projects
Commit 013b55a3 authored by haohongfan's avatar haohongfan
Browse files

feat: update

parent 666c2f54
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ package filter_impl
import (
"context"
"fmt"
"regexp"
"testing"
)
......@@ -29,6 +30,8 @@ import (
)
import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/invocation"
)
......@@ -147,7 +150,11 @@ func (iv *testMockFailInvoker) Invoke(_ context.Context, _ protocol.Invocation)
func TestHystrixFilterInvokeSuccess(t *testing.T) {
hf := &HystrixFilter{}
result := hf.Invoke(context.Background(), &testMockSuccessInvoker{}, &invocation.RPCInvocation{})
testUrl, err := common.NewURL(
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
assert.NoError(t, err)
testInvoker := testMockSuccessInvoker{*protocol.NewBaseInvoker(testUrl)}
result := hf.Invoke(context.Background(), &testInvoker, &invocation.RPCInvocation{})
assert.NotNil(t, result)
assert.NoError(t, result.Error())
assert.NotNil(t, result.Result())
......@@ -155,7 +162,11 @@ func TestHystrixFilterInvokeSuccess(t *testing.T) {
func TestHystrixFilterInvokeFail(t *testing.T) {
hf := &HystrixFilter{}
result := hf.Invoke(context.Background(), &testMockFailInvoker{}, &invocation.RPCInvocation{})
testUrl, err := common.NewURL(
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
assert.NoError(t, err)
testInvoker := testMockFailInvoker{*protocol.NewBaseInvoker(testUrl)}
result := hf.Invoke(context.Background(), &testInvoker, &invocation.RPCInvocation{})
assert.NotNil(t, result)
assert.Error(t, result.Error())
}
......@@ -167,7 +178,11 @@ func TestHystricFilterInvokeCircuitBreak(t *testing.T) {
resChan := make(chan protocol.Result, 50)
for i := 0; i < 50; i++ {
go func() {
result := hf.Invoke(context.Background(), &testMockFailInvoker{}, &invocation.RPCInvocation{})
testUrl, err := common.NewURL(
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
assert.NoError(t, err)
testInvoker := testMockSuccessInvoker{*protocol.NewBaseInvoker(testUrl)}
result := hf.Invoke(context.Background(), &testInvoker, &invocation.RPCInvocation{})
resChan <- result
}()
}
......@@ -192,7 +207,11 @@ func TestHystricFilterInvokeCircuitBreakOmitException(t *testing.T) {
resChan := make(chan protocol.Result, 50)
for i := 0; i < 50; i++ {
go func() {
result := hf.Invoke(context.Background(), &testMockFailInvoker{}, &invocation.RPCInvocation{})
testUrl, err := common.NewURL(
fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
assert.NoError(t, err)
testInvoker := testMockSuccessInvoker{*protocol.NewBaseInvoker(testUrl)}
result := hf.Invoke(context.Background(), &testInvoker, &invocation.RPCInvocation{})
resChan <- result
}()
}
......
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