Search in sources :

Example 76 with ExcludeList

use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cloudstack by apache.

the class ImplicitPlannerTest method checkStrictModeNoHostsAvailable.

@Test
public void checkStrictModeNoHostsAvailable() throws InsufficientServerCapacityException {
    @SuppressWarnings("unchecked") VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    DataCenterDeployment plan = mock(DataCenterDeployment.class);
    ExcludeList avoids = new ExcludeList();
    initializeForTest(vmProfile, plan);
    initializeForImplicitPlannerTest(false);
    // Mark the host 5 and 6 to be in avoid list.
    avoids.addHost(5L);
    avoids.addHost(6L);
    List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    // Validations.
    // Check cluster list is empty.
    assertTrue("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) Test(org.junit.Test)

Example 77 with ExcludeList

use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cloudstack by apache.

the class ImplicitPlannerTest method checkWhenDcInAvoidList.

@Test
public void checkWhenDcInAvoidList() throws InsufficientServerCapacityException {
    DataCenterVO mockDc = mock(DataCenterVO.class);
    ExcludeList avoids = mock(ExcludeList.class);
    VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    VMInstanceVO vm = mock(VMInstanceVO.class);
    DataCenterDeployment plan = mock(DataCenterDeployment.class);
    when(avoids.shouldAvoid(mockDc)).thenReturn(true);
    when(vmProfile.getVirtualMachine()).thenReturn(vm);
    when(vm.getDataCenterId()).thenReturn(1L);
    when(dcDao.findById(1L)).thenReturn(mockDc);
    List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    assertTrue("Cluster list should be null/empty if the dc is in avoid list", (clusterList == null || clusterList.isEmpty()));
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) VMInstanceVO(com.cloud.vm.VMInstanceVO) Test(org.junit.Test)

Example 78 with ExcludeList

use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cloudstack by apache.

the class ImplicitPlannerTest method checkStrictModeHostWithCurrentAccountVmsFull.

@Test
public void checkStrictModeHostWithCurrentAccountVmsFull() throws InsufficientServerCapacityException {
    @SuppressWarnings("unchecked") VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    DataCenterDeployment plan = mock(DataCenterDeployment.class);
    ExcludeList avoids = new ExcludeList();
    initializeForTest(vmProfile, plan);
    initializeForImplicitPlannerTest(false);
    // Mark the host 5 with current account vms to be in avoid list.
    avoids.addHost(5L);
    List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    // Validations.
    // Check cluster 1 and 3 are not in the cluster list.
    // Host 5 and 7 should also be in avoid list.
    assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
    boolean foundNeededCluster = false;
    for (Long cluster : clusterList) {
        if (cluster != 2) {
            fail("Found a cluster that shouldn't have been present, cluster id : " + cluster);
        } else {
            foundNeededCluster = true;
        }
    }
    assertTrue("Didn't find cluster 2 in the list. It should have been present", foundNeededCluster);
    Set<Long> hostsInAvoidList = avoids.getHostsToAvoid();
    assertFalse("Host 6 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(6L));
    Set<Long> hostsThatShouldBeInAvoidList = new HashSet<Long>();
    hostsThatShouldBeInAvoidList.add(5L);
    hostsThatShouldBeInAvoidList.add(7L);
    assertTrue("Hosts 5 and 7 that should have been present were not found in avoid list", hostsInAvoidList.containsAll(hostsThatShouldBeInAvoidList));
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)78 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)45 ArrayList (java.util.ArrayList)32 StoragePool (com.cloud.storage.StoragePool)30 Test (org.junit.Test)30 HashMap (java.util.HashMap)23 Volume (com.cloud.storage.Volume)21 VirtualMachineProfileImpl (com.cloud.vm.VirtualMachineProfileImpl)18 List (java.util.List)18 Host (com.cloud.host.Host)16 HostVO (com.cloud.host.HostVO)16 Pair (com.cloud.utils.Pair)16 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)16 DiskProfile (com.cloud.vm.DiskProfile)15 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)15 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)14 VolumeVO (com.cloud.storage.VolumeVO)14 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)14 Account (com.cloud.user.Account)12 Map (java.util.Map)11