Search in sources :

Example 1 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class VxlanGuestNetworkGuruTest method testDesign.

@Test
public void testDesign() {
    PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById(anyLong())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VXLAN" }));
    when(physnet.getId()).thenReturn(42L);
    NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(42L);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    DeploymentPlan plan = mock(DeploymentPlan.class);
    Network network = mock(Network.class);
    Account account = mock(Account.class);
    Network designednetwork = guru.design(offering, plan, network, account);
    assertTrue(designednetwork != null);
    assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Vxlan);
}
Also used : Account(com.cloud.user.Account) NetworkOffering(com.cloud.offering.NetworkOffering) Network(com.cloud.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DeploymentPlan(com.cloud.deploy.DeploymentPlan) Test(org.junit.Test)

Example 2 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class NuageVspGuestNetworkGuruTest method testDesignNoElementOnPhysicalNetwork.

@Test
public void testDesignNoElementOnPhysicalNetwork() {
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList("STT"));
    when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NuageVspDeviceVO>emptyList());
    final NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    final DeploymentPlan plan = mock(DeploymentPlan.class);
    final Network network = mock(Network.class);
    final Account account = mock(Account.class);
    final Network designednetwork = _nuageVspGuestNetworkGuru.design(offering, plan, network, account);
    assertTrue(designednetwork == null);
}
Also used : Account(com.cloud.user.Account) NetworkOffering(com.cloud.offering.NetworkOffering) Network(com.cloud.network.Network) DeploymentPlan(com.cloud.deploy.DeploymentPlan) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 3 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class StorageAllocatorTest method testClusterAllocatorWithTags.

@Test
public void testClusterAllocatorWithTags() {
    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("high");
        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()) {
                Assert.assertEquals(pools.get(0).getId(), storage.getId());
                foundAcct++;
            }
        }
        if (foundAcct > 1 || 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)

Example 4 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class StorageAllocatorTest method testClusterAllocator.

@Test
public void testClusterAllocator() {
    try {
        createDb();
        DiskProfile profile = new DiskProfile(volume, diskOffering, 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()) {
                Assert.assertEquals(pools.get(0).getId(), storage.getId());
                foundAcct++;
            }
        }
        if (foundAcct > 1 || 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) Volume(com.cloud.storage.Volume) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DeploymentPlan(com.cloud.deploy.DeploymentPlan) DiskProfile(com.cloud.vm.DiskProfile) StoragePoolAllocator(org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator) Test(org.junit.Test)

Example 5 with DeploymentPlan

use of com.cloud.deploy.DeploymentPlan in project cloudstack by apache.

the class StorageAllocatorTest method testClusterAllocatorMultiplePools.

@Test
public void testClusterAllocatorMultiplePools() {
    Long newStorageId = null;
    try {
        createDb();
        DataStoreProvider provider = providerMgr.getDataStoreProvider(DataStoreProvider.DEFAULT_PRIMARY);
        storage = new StoragePoolVO();
        storage.setDataCenterId(dcId);
        storage.setPodId(podId);
        storage.setPoolType(StoragePoolType.NetworkFilesystem);
        storage.setClusterId(clusterId);
        storage.setStatus(StoragePoolStatus.Up);
        storage.setScope(ScopeType.CLUSTER);
        storage.setUsedBytes(1000);
        storage.setCapacityBytes(20000);
        storage.setHostAddress(UUID.randomUUID().toString());
        storage.setPath(UUID.randomUUID().toString());
        storage.setStorageProviderName(provider.getName());
        StoragePoolVO newStorage = storagePoolDao.persist(storage);
        newStorageId = newStorage.getId();
        DiskProfile profile = new DiskProfile(volume, diskOffering, 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()) {
                Assert.assertEquals(pools.size(), 1);
                foundAcct++;
            }
        }
        if (foundAcct > 1 || foundAcct == 0) {
            Assert.fail();
        }
    } catch (Exception e) {
        cleanDb();
        if (newStorageId != null) {
            storagePoolDao.remove(newStorageId);
        }
        Assert.fail();
    }
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) StoragePool(com.cloud.storage.StoragePool) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) DataStoreProvider(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider) DiskProfile(com.cloud.vm.DiskProfile) Volume(com.cloud.storage.Volume) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DeploymentPlan(com.cloud.deploy.DeploymentPlan) StoragePoolAllocator(org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator) Test(org.junit.Test)

Aggregations

DeploymentPlan (com.cloud.deploy.DeploymentPlan)22 Test (org.junit.Test)19 Network (com.cloud.network.Network)12 Account (com.cloud.user.Account)12 NetworkOffering (com.cloud.offering.NetworkOffering)11 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)10 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)8 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)8 StoragePool (com.cloud.storage.StoragePool)8 Volume (com.cloud.storage.Volume)8 DiskProfile (com.cloud.vm.DiskProfile)8 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)8 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)8 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)5 NuageTest (com.cloud.NuageTest)3 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)3 ArrayList (java.util.ArrayList)3 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)2 DomainRouterVO (com.cloud.vm.DomainRouterVO)2 StoragePoolDetailVO (org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)2