Search in sources :

Example 26 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 27 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)

Example 28 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 29 with ExcludeList

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

the class FirstFitPlannerTest method checkClusterReorderingForDeployVMWithThresholdCheckDisabled.

@Test
public void checkClusterReorderingForDeployVMWithThresholdCheckDisabled() throws InsufficientServerCapacityException {
    VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    DataCenterDeployment plan = mock(DataCenterDeployment.class);
    ExcludeList avoids = mock(ExcludeList.class);
    initializeForTest(vmProfile, plan, avoids);
    List<Long> clustersCrossingThreshold = initializeForClusterThresholdDisabled();
    Map<String, String> details = new HashMap<String, String>();
    details.put("deployvm", "true");
    when(vmDetailsDao.listDetailsKeyPairs(vmProfile.getVirtualMachine().getId())).thenReturn(details);
    List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    assertTrue("Reordered cluster list have clusters exceeding threshold", (!clusterList.containsAll(clustersCrossingThreshold)));
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 30 with ExcludeList

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

the class FirstFitPlannerTest method checkClusterListBasedOnHostTag.

@Test
public void checkClusterListBasedOnHostTag() throws InsufficientServerCapacityException {
    VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    DataCenterDeployment plan = mock(DataCenterDeployment.class);
    ExcludeList avoids = mock(ExcludeList.class);
    initializeForTest(vmProfile, plan, avoids);
    List<Long> matchingClusters = initializeForClusterListBasedOnHostTag(vmProfile.getServiceOffering());
    List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    assertTrue("Reordered cluster list have clusters which has hosts with specified host tag on offering", (clusterList.containsAll(matchingClusters)));
    assertTrue("Reordered cluster list does not have clusters which dont have hosts with matching host tag on offering", (!clusterList.contains(2L)));
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) Test(org.junit.Test)

Aggregations

ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)38 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)27 StoragePool (com.cloud.storage.StoragePool)18 Test (org.junit.Test)18 Volume (com.cloud.storage.Volume)14 ArrayList (java.util.ArrayList)14 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)14 DiskProfile (com.cloud.vm.DiskProfile)12 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)11 HashMap (java.util.HashMap)11 VirtualMachineProfileImpl (com.cloud.vm.VirtualMachineProfileImpl)9 List (java.util.List)9 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)9 DeploymentPlan (com.cloud.deploy.DeploymentPlan)8 HostVO (com.cloud.host.HostVO)8 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)8 VolumeVO (com.cloud.storage.VolumeVO)7 Host (com.cloud.host.Host)6 Account (com.cloud.user.Account)6 Pair (com.cloud.utils.Pair)6