yumosx commented on code in PR #3046:
URL: https://github.com/apache/dubbo-go/pull/3046#discussion_r2509291931


##########
cluster/loadbalance/p2c/loadbalance_test.go:
##########
@@ -101,28 +91,23 @@ func TestLoadBalance(t *testing.T) {
                url1, _ := 
common.NewURL("dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider")
                url2, _ := 
common.NewURL("dubbo://192.168.1.2:20000/com.ikurento.user.UserProvider")
 
+               // P2C algorithm randomly selects 2 invokers, so we need to 
mock all possible combinations
                m.EXPECT().
-                       GetMethodMetrics(gomock.Eq(url0), 
gomock.Eq(invocation.MethodName()), gomock.Eq(metrics.HillClimbing)).
-                       Times(1).
+                       GetMethodMetrics(gomock.Any(), 
gomock.Eq(invocation.MethodName()), gomock.Eq(metrics.HillClimbing)).
+                       Times(2).
                        Return(uint64(10), nil)
-               m.EXPECT().
-                       GetMethodMetrics(gomock.Eq(url1), 
gomock.Eq(invocation.MethodName()), gomock.Eq(metrics.HillClimbing)).
-                       Times(1).
-                       Return(uint64(5), nil)
 
                ivkArr := []base.Invoker{
                        base.NewBaseInvoker(url0),
                        base.NewBaseInvoker(url1),
                        base.NewBaseInvoker(url2),
                }
 
-               ivk := lb.Select(ivkArr, invocation)
-
-               assert.Equal(t, ivkArr[0].GetURL().String(), 
ivk.GetURL().String())
+               got := lb.Select(ivkArr, invocation)
+               assert.NotNil(t, got)

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to