You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/03/22 00:44:08 UTC

[GitHub] wujimin commented on a change in pull request #613: [SCB-416]For load balance rule configurations, we need provider service level configuration

wujimin commented on a change in pull request #613: [SCB-416]For load balance rule configurations, we need provider service level configuration
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/613#discussion_r176282128
 
 

 ##########
 File path: handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalancer.java
 ##########
 @@ -146,4 +148,41 @@ public void testGetAllServers() {
     Mockito.when(filter.getFilteredListOfServers(servers)).thenReturn(servers);
     Assert.assertEquals(servers, loadBalancer.getAllServers());
   }
+  
+  @Test
+  public void testLoadBalanceWithSessionSticknessRule() {
+    SessionStickinessRule rule = new SessionStickinessRule();
+    LoadBalancer lb = new LoadBalancer("lb1", rule, "service");
+    Assert.assertEquals(lb.getMicroServiceName(), "service");
+    Assert.assertEquals("service", Deencapsulation.getField(rule, "microserviceName"));
+    
+    List<Server> servers = new ArrayList<>();
+    Server server = new Server("host1", 80);
+    server.setAlive(true);
+    Server server2 = new Server("host2", 80);
+    server2.setAlive(true);
+    servers.add(server);
+    servers.add(server2);
+    lb.setServerList(servers);
+    
+    Server s = lb.chooseServer("test");
+    Assert.assertEquals(server2, s);
+    s = lb.chooseServer("test");
+    Assert.assertEquals(server2, s);
+    
+    long time =  Deencapsulation.getField(rule, "lastAccessedTime");
+    Deencapsulation.setField(rule, "lastAccessedTime", time - 1000 * 10);
+    Utils.updateProperty("cse.loadbalance.service.SessionStickinessRule.sessionTimeoutInSeconds", 9);
 
 Review comment:
   is it possible to use: org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils.setProperty(String, Object)
   if can not use it, is it possible to add a new method in it.
   so that we can reuse the capability in other test case.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services