From 42f9947fde5a2fe6cebebc550ba5154a7555d6d4 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Wed, 3 Feb 2021 19:33:01 +0800 Subject: [PATCH] fix: range --- cluster/router/condition/app_router_test.go | 9 ++--- cluster/router/condition/factory_test.go | 36 +++++++------------ cluster/router/condition/router_test.go | 3 +- .../router/conncheck/conn_check_route_test.go | 3 +- .../healthcheck/health_check_route_test.go | 6 ++-- cluster/router/tag/factory_test.go | 3 +- cluster/router/tag/tag_router_test.go | 21 ++++------- 7 files changed, 27 insertions(+), 54 deletions(-) diff --git a/cluster/router/condition/app_router_test.go b/cluster/router/condition/app_router_test.go index b4c3056f8..5fb776a44 100644 --- a/cluster/router/condition/app_router_test.go +++ b/cluster/router/condition/app_router_test.go @@ -83,8 +83,7 @@ conditions: appRouteURL := getAppRouteURL(routerKey) notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() appRouter, err := NewAppRouter(appRouteURL, notify) @@ -140,8 +139,7 @@ conditions: appRouteURL := getAppRouteURL(routerKey) notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() appRouter, err := NewAppRouter(appRouteURL, notify) @@ -188,8 +186,7 @@ conditions: appRouteURL := getAppRouteURL(routerKey) notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() appRouter, err := NewAppRouter(appRouteURL, notify) diff --git a/cluster/router/condition/factory_test.go b/cluster/router/condition/factory_test.go index efbc4057b..e08016d13 100644 --- a/cluster/router/condition/factory_test.go +++ b/cluster/router/condition/factory_test.go @@ -134,8 +134,7 @@ func TestRoute_matchWhen(t *testing.T) { rule := base64.URLEncoding.EncodeToString([]byte("=> host = 1.2.3.4")) notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() router, _ := newConditionRouterFactory().NewPriorityRouter(getRouteUrl(rule), notify) @@ -171,8 +170,7 @@ func TestRoute_matchWhen(t *testing.T) { func TestRoute_matchFilter(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() localIP := common.GetLocalIp() @@ -212,8 +210,7 @@ func TestRoute_matchFilter(t *testing.T) { func TestRoute_methodRoute(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() inv := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("getFoo"), invocation.WithParameterTypes([]reflect.Type{}), invocation.WithArguments([]interface{}{})) @@ -241,8 +238,7 @@ func TestRoute_methodRoute(t *testing.T) { func TestRoute_ReturnFalse(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() url, _ := common.NewURL("") @@ -259,8 +255,7 @@ func TestRoute_ReturnFalse(t *testing.T) { func TestRoute_ReturnEmpty(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() localIP := common.GetLocalIp() @@ -277,8 +272,7 @@ func TestRoute_ReturnEmpty(t *testing.T) { func TestRoute_ReturnAll(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() localIP := common.GetLocalIp() @@ -303,8 +297,7 @@ func TestRoute_HostFilter(t *testing.T) { url3, _ := common.NewURL(fmt.Sprintf(factoryDubboFormat, localIP)) notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() invoker1 := NewMockInvoker(url1, 1) @@ -324,8 +317,7 @@ func TestRoute_HostFilter(t *testing.T) { func TestRoute_Empty_HostFilter(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() localIP := common.GetLocalIp() @@ -349,8 +341,7 @@ func TestRoute_Empty_HostFilter(t *testing.T) { func TestRoute_False_HostFilter(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() localIP := common.GetLocalIp() @@ -374,8 +365,7 @@ func TestRoute_False_HostFilter(t *testing.T) { func TestRoute_Placeholder(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() localIP := common.GetLocalIp() @@ -399,8 +389,7 @@ func TestRoute_Placeholder(t *testing.T) { func TestRoute_NoForce(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() localIP := common.GetLocalIp() @@ -422,8 +411,7 @@ func TestRoute_NoForce(t *testing.T) { func TestRoute_Force(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() localIP := common.GetLocalIp() diff --git a/cluster/router/condition/router_test.go b/cluster/router/condition/router_test.go index 15bf76f08..2895703db 100644 --- a/cluster/router/condition/router_test.go +++ b/cluster/router/condition/router_test.go @@ -60,8 +60,7 @@ func TestParseRule(t *testing.T) { func TestNewConditionRouter(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() url, _ := common.NewURL(`condition://0.0.0.0:?application=mock-app&category=routers&force=true&priority=1&router=condition&rule=YSAmIGMgPT4gYiAmIGQ%3D`) diff --git a/cluster/router/conncheck/conn_check_route_test.go b/cluster/router/conncheck/conn_check_route_test.go index 80ec1c8ea..fec733167 100644 --- a/cluster/router/conncheck/conn_check_route_test.go +++ b/cluster/router/conncheck/conn_check_route_test.go @@ -50,8 +50,7 @@ func TestConnCheckRouterRoute(t *testing.T) { defer protocol.CleanAllStatus() notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() consumerURL, _ := common.NewURL(connCheck1001URL) diff --git a/cluster/router/healthcheck/health_check_route_test.go b/cluster/router/healthcheck/health_check_route_test.go index 1d44eb1a3..f499c85c0 100644 --- a/cluster/router/healthcheck/health_check_route_test.go +++ b/cluster/router/healthcheck/health_check_route_test.go @@ -51,8 +51,7 @@ func TestHealthCheckRouterRoute(t *testing.T) { defer protocol.CleanAllStatus() notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() consumerURL, _ := common.NewURL(healthCheck1001URL) @@ -120,8 +119,7 @@ func TestNewHealthCheckRouter(t *testing.T) { defer protocol.CleanAllStatus() notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() url, _ := common.NewURL(fmt.Sprintf(healthCheckDubboUrlFormat, healthCheckDubbo1010IP)) diff --git a/cluster/router/tag/factory_test.go b/cluster/router/tag/factory_test.go index ea5ff63fa..2a8eac20b 100644 --- a/cluster/router/tag/factory_test.go +++ b/cluster/router/tag/factory_test.go @@ -41,8 +41,7 @@ func TestTagRouterFactoryNewRouter(t *testing.T) { factory := NewTagRouterFactory() notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() tagRouter, e := factory.NewPriorityRouter(u1, notify) diff --git a/cluster/router/tag/tag_router_test.go b/cluster/router/tag/tag_router_test.go index 8dccc3420..efee5bd68 100644 --- a/cluster/router/tag/tag_router_test.go +++ b/cluster/router/tag/tag_router_test.go @@ -121,8 +121,7 @@ func TestTagRouterPriority(t *testing.T) { u1, err := common.NewURL(tagRouterTestUserConsumerTag) notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() assert.Nil(t, err) @@ -135,8 +134,7 @@ func TestTagRouterPriority(t *testing.T) { func TestTagRouterRouteForce(t *testing.T) { notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() u1, e1 := common.NewURL(tagRouterTestUserConsumerTag) @@ -175,8 +173,7 @@ func TestTagRouterRouteNoForce(t *testing.T) { assert.Nil(t, e1) notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() tagRouter, e := NewTagRouter(u1, notify) @@ -244,8 +241,7 @@ func TestRouteBeijingInvoker(t *testing.T) { url, _ := common.NewURL(tagRouterTestBeijingUrl) notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() tagRouter, _ := NewTagRouter(url, notify) @@ -326,8 +322,7 @@ tags: notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() tagRouter, err := NewTagRouter(url, notify) @@ -397,8 +392,7 @@ func TestProcess(t *testing.T) { assert.Nil(t, err) notify := make(chan struct{}) go func() { - for { - <-notify + for range notify { } }() tagRouter, e := NewTagRouter(u1, notify) @@ -420,8 +414,7 @@ tags: addresses: [192.168.1.3, 192.168.1.4] ` go func() { - for { - <-notify + for range notify { } }() tagRouter.Process(&config_center.ConfigChangeEvent{Value: testYML, ConfigType: remoting.EventTypeAdd}) -- GitLab