|
57 | 57 | import com.globo.globonetwork.cloudstack.commands.ListExpectedHealthchecksCommand; |
58 | 58 | import com.globo.globonetwork.cloudstack.commands.ListPoolLBCommand; |
59 | 59 | import com.globo.globonetwork.cloudstack.commands.RemoveVipFromGloboNetworkCommand; |
60 | | -import com.globo.globonetwork.cloudstack.commands.UpdatePoolCommand; |
61 | 60 | import com.globo.globonetwork.cloudstack.manager.HealthCheckHelper; |
62 | 61 | import com.globo.globonetwork.cloudstack.manager.Protocol; |
63 | 62 | import com.globo.globonetwork.cloudstack.response.GloboNetworkExpectHealthcheckResponse; |
@@ -211,10 +210,10 @@ public void testFindPoolByPorGivenNullVip(){ |
211 | 210 | assertTrue(_resource.findPoolsByPort(80, null).isEmpty()); |
212 | 211 | } |
213 | 212 |
|
214 | | - private PoolV3 mockPoolSave(Long poolId, Long idReturned, Boolean hasPoolMember, Integer vipPort, Integer port, String ip, String healthCheckType, String healthCheck, String expectedHealthCheck, int maxConn, String serviceDAction) throws GloboNetworkException { |
| 213 | + public static PoolV3 mockPoolSave(Long poolId, Long idReturned, Boolean hasPoolMember, Integer vipPort, Integer port, String ip, String healthCheckType, String healthCheck, String expectedHealthCheck, int maxConn, String serviceDAction, GloboNetworkAPI gnAPI) throws GloboNetworkException { |
215 | 214 | PoolV3 expectedPool = new PoolV3(); |
216 | 215 | expectedPool.setId(poolId); |
217 | | - expectedPool.setIdentifier(_resource.buildPoolName("region", "vip.domain.com",vipPort, port)); |
| 216 | + expectedPool.setIdentifier(GloboNetworkResource.buildPoolName("region", "vip.domain.com",vipPort, port)); |
218 | 217 | expectedPool.setLbMethod("round-robin"); |
219 | 218 | expectedPool.setMaxconn(maxConn); |
220 | 219 | expectedPool.setDefaultPort(port); |
@@ -801,43 +800,7 @@ private CreatePoolCommand createMockCreatePoolCommand() { |
801 | 800 | return command; |
802 | 801 | } |
803 | 802 |
|
804 | | - @Test |
805 | | - public void testExecuteUpdatePool() throws GloboNetworkException { |
806 | | - UpdatePoolCommand cmd = new UpdatePoolCommand(Arrays.asList(12L, 13L), "HTTP", "GET /heal HTTP/1.0\\r\\nHost: vip.domain.com\\r\\n\\r\\n", "OK", 5, "vip.domain.com"); |
807 | | - |
808 | | - PoolV3 pool1 = mockPool(12L, "ACS_POOL_vip.domain.com_8080", 8080, "least", "http", "/heal.html", "OK", "*:*", 10); |
809 | | - PoolV3 pool2 = mockPool(13L, "ACS_POOL_vip.domain.com_8443", 8443, "least", "http", "/heal.html", "OK", "*:*", 10); |
810 | | - List<PoolV3> poolsResponse = new ArrayList<>(); |
811 | | - poolsResponse.add(pool1); |
812 | | - poolsResponse.add(pool2); |
813 | | - |
814 | | - when(gnAPI.getPoolAPI().getByIdsV3(Arrays.asList(12L, 13L))).thenReturn(poolsResponse); |
815 | | - |
816 | | - mockPoolSave(12L, 12L, true, 80, 8080, "10.0.0.1", "HTTP", "GET /heal HTTP/1.0\\r\\nHost: vip.domain.com\\r\\n\\r\\n", "OK", 5, "none" ); |
817 | | - mockPoolSave(13L, 13L, true, 443, 8443, "10.0.0.1", "HTTP", "GET /heal HTTP/1.0\\r\\nHost: vip.domain.com\\r\\n\\r\\n", "OK", 5, "none" ); |
818 | | - |
819 | | - Answer answer = _resource.executeRequest(cmd); |
820 | | - |
821 | | - List<GloboNetworkPoolResponse.Pool> pools = ((GloboNetworkPoolResponse)answer).getPools(); |
822 | | - |
823 | | - assertEquals(2, pools.size()); |
824 | | - |
825 | | - GloboNetworkPoolResponse.Pool pool = pools.get(0); |
826 | | - assertEquals((Long) 12L, pool.getId()); |
827 | | - assertEquals((Integer)5, pool.getMaxconn()); |
828 | | - assertEquals("HTTP", pool.getHealthcheckType()); |
829 | | - assertEquals("GET /heal HTTP/1.0\\r\\nHost: vip.domain.com\\r\\n\\r\\n", pool.getHealthcheck()); |
830 | | - assertEquals("OK", pool.getExpectedHealthcheck()); |
831 | | - |
832 | | - pool = pools.get(1); |
833 | | - assertEquals((Long) 13L, pool.getId()); |
834 | | - assertEquals((Integer)5, pool.getMaxconn()); |
835 | | - assertEquals("HTTP", pool.getHealthcheckType()); |
836 | | - assertEquals("GET /heal HTTP/1.0\\r\\nHost: vip.domain.com\\r\\n\\r\\n", pool.getHealthcheck()); |
837 | | - assertEquals("OK", pool.getExpectedHealthcheck()); |
838 | | - } |
839 | | - |
840 | | - private PoolV3 mockPool(Long poolId, String identifier, int port, String lbmethod, String healthheckType, String healthcheck, String expectedHealthcheck, String destination, Integer maxconn) { |
| 803 | + public static PoolV3 mockPool(Long poolId, String identifier, int port, String lbmethod, String healthheckType, String healthcheck, String expectedHealthcheck, String destination, Integer maxconn) { |
841 | 804 | PoolV3.ServiceDownAction action = new PoolV3.ServiceDownAction(); |
842 | 805 | action.setId(3L); |
843 | 806 | action.setName("none"); |
@@ -1013,7 +976,7 @@ public void testSavePoolWithOneReal() throws GloboNetworkException { |
1013 | 976 |
|
1014 | 977 | PoolV3 expectedPool = mockPoolSave(null, 123L, true, 80, 8080, "10.0.0.1", |
1015 | 978 | build.getHealthCheckType(), build.getExpectedHealthCheck(), build.getHealthCheck(), 0, |
1016 | | - cmd.getServiceDownAction()); |
| 979 | + cmd.getServiceDownAction(), gnAPI); |
1017 | 980 |
|
1018 | 981 |
|
1019 | 982 | List<VipPoolMap> vipPoolMaps = _resource.createPools(gnAPI, poolMembers, vipInfo.getEnvironment(), cmd); |
|
0 commit comments