use of com.cloud.api.command.user.loadbalancer.AssignToLoadBalancerRuleCmd in project cosmic by MissionCriticalCloud.
the class AssignLoadBalancerTest method tesSecIpNotSetToVm.
@Test(expected = InvalidParameterValueException.class)
public void tesSecIpNotSetToVm() throws ResourceAllocationException, ResourceUnavailableException, InsufficientCapacityException {
final AssignToLoadBalancerRuleCmd assignLbRuleCmd = Mockito.mock(AssignToLoadBalancerRuleCmd.class);
final Map<Long, List<String>> vmIdIpMap = new HashMap<>();
final List<String> secIp = new ArrayList<>();
secIp.add("10.1.1.175");
vmIdIpMap.put(1L, secIp);
final List<Long> vmIds = new ArrayList<>();
vmIds.add(2L);
final LoadBalancerVO lbVO = new LoadBalancerVO("1", "L1", "Lbrule", 1, 22, 22, "rb", 204, 0, 0, "tcp", 60000, 60000);
final LoadBalancerDao lbDao = Mockito.mock(LoadBalancerDao.class);
final LoadBalancerVMMapDao lb2VmMapDao = Mockito.mock(LoadBalancerVMMapDao.class);
final UserVmDao userVmDao = Mockito.mock(UserVmDao.class);
final NicSecondaryIpDao nicSecIpDao = Mockito.mock(NicSecondaryIpDao.class);
_lbMgr._lbDao = lbDao;
_lbMgr._lb2VmMapDao = lb2VmMapDao;
_lbMgr._vmDao = userVmDao;
_lbMgr._nicSecondaryIpDao = nicSecIpDao;
_lbvmMapList = new ArrayList<>();
_lbMgr._rulesMgr = _rulesMgr;
_lbMgr._networkModel = _networkModel;
when(lbDao.findById(anyLong())).thenReturn(lbVO);
when(userVmDao.findById(anyLong())).thenReturn(Mockito.mock(UserVmVO.class));
when(lb2VmMapDao.listByLoadBalancerId(anyLong(), anyBoolean())).thenReturn(_lbvmMapList);
when(nicSecIpDao.findByIp4AddressAndNicId(anyString(), anyLong())).thenReturn(null);
_lbMgr.assignToLoadBalancer(1L, null, vmIdIpMap);
}
use of com.cloud.api.command.user.loadbalancer.AssignToLoadBalancerRuleCmd in project cosmic by MissionCriticalCloud.
the class AssignLoadBalancerTest method testVmIdAlreadyExist.
@Test(expected = InvalidParameterValueException.class)
public void testVmIdAlreadyExist() throws ResourceAllocationException, ResourceUnavailableException, InsufficientCapacityException {
final AssignToLoadBalancerRuleCmd assignLbRuleCmd = Mockito.mock(AssignToLoadBalancerRuleCmd.class);
final Map<Long, List<String>> vmIdIpMap = new HashMap<>();
final List<String> secIp = new ArrayList<>();
secIp.add("10.1.1.175");
vmIdIpMap.put(1L, secIp);
final List<Long> vmIds = new ArrayList<>();
vmIds.add(2L);
final LoadBalancerVO lbVO = new LoadBalancerVO("1", "L1", "Lbrule", 1, 22, 22, "rb", 204, 0, 0, "tcp", 60000, 60000);
final LoadBalancerDao lbDao = Mockito.mock(LoadBalancerDao.class);
final LoadBalancerVMMapDao lb2VmMapDao = Mockito.mock(LoadBalancerVMMapDao.class);
final UserVmDao userVmDao = Mockito.mock(UserVmDao.class);
final NicSecondaryIpDao nicSecIpDao = Mockito.mock(NicSecondaryIpDao.class);
final LoadBalancerVMMapVO lbVmMapVO = new LoadBalancerVMMapVO(1L, 1L, "10.1.1.175", false);
_lbMgr._lbDao = lbDao;
_lbMgr._lb2VmMapDao = lb2VmMapDao;
_lbMgr._vmDao = userVmDao;
_lbMgr._nicSecondaryIpDao = nicSecIpDao;
_lbvmMapList = new ArrayList<>();
_lbvmMapList.add(lbVmMapVO);
_lbMgr._rulesMgr = _rulesMgr;
_lbMgr._networkModel = _networkModel;
when(lbDao.findById(anyLong())).thenReturn(lbVO);
when(userVmDao.findById(anyLong())).thenReturn(Mockito.mock(UserVmVO.class));
when(lb2VmMapDao.listByLoadBalancerId(anyLong(), anyBoolean())).thenReturn(_lbvmMapList);
when(nicSecIpDao.findByIp4AddressAndNicId(anyString(), anyLong())).thenReturn(null);
_lbMgr.assignToLoadBalancer(1L, null, vmIdIpMap);
}
use of com.cloud.api.command.user.loadbalancer.AssignToLoadBalancerRuleCmd in project cosmic by MissionCriticalCloud.
the class AssignLoadBalancerTest method setUp.
@Before
public void setUp() {
assignToLbRuleCmd = new AssignToLoadBalancerRuleCmd() {
};
// ComponentContext.initComponentsLifeCycle();
final AccountVO account = new AccountVO(accountName, domainId, "networkDomain", Account.ACCOUNT_TYPE_NORMAL, "uuid");
final DomainVO domain = new DomainVO("rootDomain", 5L, 5L, "networkDomain");
final UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account);
}
Aggregations