Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
0963f3bd
Commit
0963f3bd
authored
5 years ago
by
xujianhai666
Browse files
Options
Downloads
Patches
Plain Diff
add invoker test
parent
fa3d2232
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
protocol/dubbo/dubbo_invoker_test.go
+2
-2
2 additions, 2 deletions
protocol/dubbo/dubbo_invoker_test.go
protocol/grpc/grpc_invoker_test.go
+57
-0
57 additions, 0 deletions
protocol/grpc/grpc_invoker_test.go
with
59 additions
and
2 deletions
protocol/dubbo/dubbo_invoker_test.go
+
2
−
2
View file @
0963f3bd
...
...
@@ -40,8 +40,8 @@ func TestDubboInvoker_Invoke(t *testing.T) {
pendingResponses
:
new
(
sync
.
Map
),
conf
:
*
clientConf
,
opts
:
Options
{
ConnectTimeout
:
3
e9
,
RequestTimeout
:
6
e9
,
ConnectTimeout
:
3
*
time
.
Second
,
RequestTimeout
:
6
*
time
.
Second
,
},
}
c
.
pool
=
newGettyRPCClientConnPool
(
c
,
clientConf
.
PoolSize
,
time
.
Duration
(
int
(
time
.
Second
)
*
clientConf
.
PoolTTL
))
...
...
This diff is collapsed.
Click to expand it.
protocol/grpc/grpc_invoker_test.go
0 → 100644
+
57
−
0
View file @
0963f3bd
/*
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
grpc
import
(
"context"
"reflect"
"testing"
)
import
(
"github.com/stretchr/testify/assert"
)
import
(
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/protocol/grpc/internal"
"github.com/apache/dubbo-go/protocol/invocation"
)
func
TestInvoke
(
t
*
testing
.
T
)
{
go
internal
.
InitGrpcServer
()
defer
internal
.
ShutdownGrpcServer
()
var
impl
*
internal
.
GrpcGreeterImpl
url
,
err
:=
common
.
NewURL
(
context
.
Background
(),
"grpc://127.0.0.1:20000/GrpcGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=GrpcGreeterImpl&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=io.grpc.examples.helloworld.GreeterGrpc%24IGreeter&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown®istry.role=3&remote.timestamp=1576923717&retries=&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider×tamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!"
)
assert
.
Nil
(
t
,
err
)
cli
:=
NewClient
(
impl
,
url
)
invoker
:=
NewGrpcInvoker
(
url
,
cli
)
args
:=
[]
reflect
.
Value
{}
args
=
append
(
args
,
reflect
.
ValueOf
(
&
internal
.
HelloRequest
{
Name
:
"request name"
}))
bizReply
:=
&
internal
.
HelloReply
{}
invo
:=
invocation
.
NewRPCInvocationWithOptions
(
invocation
.
WithMethodName
(
"SayHello"
),
invocation
.
WithParameterValues
(
args
),
invocation
.
WithReply
(
bizReply
))
res
:=
invoker
.
Invoke
(
invo
)
assert
.
Nil
(
t
,
res
.
Error
())
assert
.
NotNil
(
t
,
res
.
Result
())
assert
.
Equal
(
t
,
"Hello request name"
,
bizReply
.
Message
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment