Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
a82ebbcd
Commit
a82ebbcd
authored
Dec 28, 2020
by
李志信
Browse files
Options
Downloads
Patches
Plain Diff
fix: add health check test file
parent
45cef6f3
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cluster/router/conncheck/conn_check_route_test.go
+21
-5
21 additions, 5 deletions
cluster/router/conncheck/conn_check_route_test.go
protocol/rpc_status.go
+1
-0
1 addition, 0 deletions
protocol/rpc_status.go
with
22 additions
and
5 deletions
cluster/router/conncheck/conn_check_route_test.go
+
21
−
5
View file @
a82ebbcd
...
@@ -19,8 +19,9 @@ package conncheck
...
@@ -19,8 +19,9 @@ package conncheck
import
(
import
(
"fmt"
"fmt"
"github.com/apache/dubbo-go/protocol/mock"
"github.com/golang/mock/gomock"
"testing"
"testing"
"time"
)
)
import
(
import
(
...
@@ -74,12 +75,27 @@ func TestConnCheckRouterRoute(t *testing.T) {
...
@@ -74,12 +75,27 @@ func TestConnCheckRouterRoute(t *testing.T) {
// now invoker3 invoker1 is healthy
// now invoker3 invoker1 is healthy
assert
.
True
(
t
,
len
(
res
.
ToArray
())
==
2
)
assert
.
True
(
t
,
len
(
res
.
ToArray
())
==
2
)
}
func
TestRecovery
(
t
*
testing
.
T
)
{
// check recover
// check recover
ctrl
:=
gomock
.
NewController
(
t
)
defer
ctrl
.
Finish
()
invoker1
:=
mock
.
NewMockInvoker
(
ctrl
)
invoker2
:=
mock
.
NewMockInvoker
(
ctrl
)
invoker1
.
EXPECT
()
.
GetUrl
()
.
Return
(
&
common
.
URL
{
Path
:
"path1"
})
.
AnyTimes
()
invoker2
.
EXPECT
()
.
GetUrl
()
.
Return
(
&
common
.
URL
{
Path
:
"path2"
})
.
AnyTimes
()
invoker1
.
EXPECT
()
.
IsAvailable
()
.
Return
(
true
)
.
AnyTimes
()
invoker2
.
EXPECT
()
.
IsAvailable
()
.
Return
(
true
)
.
AnyTimes
()
protocol
.
SetInvokerUnhealthyStatus
(
invoker1
)
protocol
.
SetInvokerUnhealthyStatus
(
invoker2
)
assert
.
Equal
(
t
,
len
(
protocol
.
GetBlackListInvokers
(
16
)),
2
)
protocol
.
TryRefreshBlackList
()
protocol
.
TryRefreshBlackList
()
time
.
Sleep
(
time
.
Second
)
assert
.
Equal
(
t
,
len
(
protocol
.
GetBlackListInvokers
(
16
)),
0
)
res
=
hcr
.
Route
(
utils
.
ToBitmap
(
invokers
),
setUpAddrCache
(
hcr
.
(
*
ConnCheckRouter
),
invokers
),
consumerURL
,
inv
)
// now all invokers are healthy
assert
.
True
(
t
,
len
(
res
.
ToArray
())
==
3
)
}
}
func
setUpAddrCache
(
r
router
.
Poolable
,
addrs
[]
protocol
.
Invoker
)
router
.
Cache
{
func
setUpAddrCache
(
r
router
.
Poolable
,
addrs
[]
protocol
.
Invoker
)
router
.
Cache
{
...
...
This diff is collapsed.
Click to expand it.
protocol/rpc_status.go
+
1
−
0
View file @
a82ebbcd
...
@@ -241,6 +241,7 @@ func TryRefreshBlackList() {
...
@@ -241,6 +241,7 @@ func TryRefreshBlackList() {
for
i
:=
0
;
i
<
3
;
i
++
{
for
i
:=
0
;
i
<
3
;
i
++
{
wg
.
Add
(
1
)
wg
.
Add
(
1
)
go
func
(
ivks
[]
Invoker
,
i
int
)
{
go
func
(
ivks
[]
Invoker
,
i
int
)
{
defer
wg
.
Done
()
for
j
,
_
:=
range
ivks
{
for
j
,
_
:=
range
ivks
{
if
j
%
3
-
i
==
0
{
if
j
%
3
-
i
==
0
{
if
ivks
[
j
]
.
(
Invoker
)
.
IsAvailable
()
{
if
ivks
[
j
]
.
(
Invoker
)
.
IsAvailable
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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