Search in sources :

Example 11 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class StorageAllocatorTest method testClusterAllocatorWithWrongTag.

@Test
public void testClusterAllocatorWithWrongTag() {
    try {
        createDb();
        StoragePoolDetailVO detailVO = new StoragePoolDetailVO(this.storagePoolId, "high", "true", true);
        poolDetailsDao.persist(detailVO);
        DiskOfferingVO diskOff = this.diskOfferingDao.findById(diskOffering.getId());
        List<String> tags = new ArrayList<String>();
        tags.add("low");
        diskOff.setTagsArray(tags);
        diskOfferingDao.update(diskOff.getId(), diskOff);
        DiskProfile profile = new DiskProfile(volume, diskOff, HypervisorType.XenServer);
        VirtualMachineProfile vmProfile = Mockito.mock(VirtualMachineProfile.class);
        Mockito.when(storageMgr.storagePoolHasEnoughSpace(Matchers.anyListOf(Volume.class), Matchers.any(StoragePool.class))).thenReturn(true);
        DeploymentPlan plan = new DataCenterDeployment(dcId, podId, clusterId, null, null, null);
        int foundAcct = 0;
        for (StoragePoolAllocator allocator : allocators) {
            List<StoragePool> pools = allocator.allocateToPool(profile, vmProfile, plan, new ExcludeList(), 1);
            if (!pools.isEmpty()) {
                foundAcct++;
            }
        }
        if (foundAcct != 0) {
            Assert.fail();
        }
    } catch (Exception e) {
        cleanDb();
        Assert.fail();
    }
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) StoragePool(com.cloud.storage.StoragePool) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) ArrayList(java.util.ArrayList) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) DiskProfile(com.cloud.vm.DiskProfile) Volume(com.cloud.storage.Volume) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DeploymentPlan(com.cloud.deploy.DeploymentPlan) StoragePoolAllocator(org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator) Test(org.junit.Test)

Aggregations

StoragePoolDetailVO (org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)11 StoragePool (com.cloud.storage.StoragePool)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Answer (com.cloud.agent.api.Answer)2 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)2 DeploymentPlan (com.cloud.deploy.DeploymentPlan)2 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)2 HostVO (com.cloud.host.HostVO)2 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)2 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)2 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)2 Volume (com.cloud.storage.Volume)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 DiskProfile (com.cloud.vm.DiskProfile)2 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)2 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)2 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)2 Test (org.junit.Test)2 CreateStoragePoolCommand (com.cloud.agent.api.CreateStoragePoolCommand)1