Search in sources :

Example 6 with StrategyPriority

use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.

the class KvmNonManagedStorageSystemDataMotionTest method canHandleKVMLiveStorageMigrationMultipleSources.

@Test
public void canHandleKVMLiveStorageMigrationMultipleSources() {
    lenient().when(volumeInfo1.getDataStore()).thenReturn(dataStore2);
    StrategyPriority priority = kvmNonManagedStorageDataMotionStrategy.canHandleKVMNonManagedLiveNFSStorageMigration(migrationMap, host1, host2);
    assertEquals(StrategyPriority.HYPERVISOR, priority);
}
Also used : StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) Test(org.junit.Test)

Example 7 with StrategyPriority

use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.

the class KvmNonManagedStorageSystemDataMotionTest method canHandleKVMLiveStorageMigrationMultipleDestination.

@Test
public void canHandleKVMLiveStorageMigrationMultipleDestination() {
    migrationMap.put(volumeInfo2, dataStore3);
    StrategyPriority priority = kvmNonManagedStorageDataMotionStrategy.canHandleKVMNonManagedLiveNFSStorageMigration(migrationMap, host1, host2);
    assertEquals(StrategyPriority.HYPERVISOR, priority);
}
Also used : StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) Test(org.junit.Test)

Example 8 with StrategyPriority

use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.

the class VmwareStorageMotionStrategyTest method testStrategyDoesnotHandlesNonVmwareHosts.

@Test
public void testStrategyDoesnotHandlesNonVmwareHosts() throws Exception {
    Host srcHost = mock(Host.class);
    Host destHost = mock(Host.class);
    when(srcHost.getHypervisorType()).thenReturn(HypervisorType.XenServer);
    when(destHost.getHypervisorType()).thenReturn(HypervisorType.XenServer);
    Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
    StrategyPriority canHandle = strategy.canHandle(volumeMap, srcHost, destHost);
    assertFalse("The strategy is only supposed to handle vmware hosts", canHandle == StrategyPriority.HYPERVISOR);
}
Also used : HashMap(java.util.HashMap) StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) Host(com.cloud.host.Host) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) Test(org.junit.Test)

Example 9 with StrategyPriority

use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.

the class VmwareStorageMotionStrategyTest method testStrategyHandlesVmwareHosts.

@Test
public void testStrategyHandlesVmwareHosts() throws Exception {
    Host srcHost = mock(Host.class);
    Host destHost = mock(Host.class);
    when(srcHost.getHypervisorType()).thenReturn(HypervisorType.VMware);
    when(destHost.getHypervisorType()).thenReturn(HypervisorType.VMware);
    Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
    StrategyPriority canHandle = strategy.canHandle(volumeMap, srcHost, destHost);
    assertTrue("The strategy is only supposed to handle vmware hosts", canHandle == StrategyPriority.HYPERVISOR);
}
Also used : HashMap(java.util.HashMap) StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) Host(com.cloud.host.Host) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) Test(org.junit.Test)

Example 10 with StrategyPriority

use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.

the class StorageSystemDataMotionStrategyTest method configureAndTestInternalCanHandle.

private void configureAndTestInternalCanHandle(boolean sPool0IsManaged, boolean sPool1IsManaged, StrategyPriority expectedStrategyPriority) {
    VolumeObject volumeInfo = Mockito.spy(new VolumeObject());
    Mockito.doReturn(0l).when(volumeInfo).getPoolId();
    DataStore ds = Mockito.spy(new PrimaryDataStoreImpl());
    Mockito.doReturn(1l).when(ds).getId();
    Map<VolumeInfo, DataStore> volumeMap = new HashMap<>();
    volumeMap.put(volumeInfo, ds);
    StoragePoolVO storagePool0 = Mockito.spy(new StoragePoolVO());
    Mockito.doReturn(sPool0IsManaged).when(storagePool0).isManaged();
    StoragePoolVO storagePool1 = Mockito.spy(new StoragePoolVO());
    Mockito.doReturn(sPool1IsManaged).when(storagePool1).isManaged();
    Mockito.doReturn(storagePool0).when(primaryDataStoreDao).findById(0l);
    Mockito.doReturn(storagePool1).when(primaryDataStoreDao).findById(1l);
    StrategyPriority strategyPriority = strategy.internalCanHandle(volumeMap, new HostVO("srcHostUuid"), new HostVO("destHostUuid"));
    Assert.assertEquals(expectedStrategyPriority, strategyPriority);
}
Also used : HashMap(java.util.HashMap) PrimaryDataStoreImpl(org.apache.cloudstack.storage.datastore.PrimaryDataStoreImpl) StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) PrimaryDataStore(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) VolumeObject(org.apache.cloudstack.storage.volume.VolumeObject) HostVO(com.cloud.host.HostVO)

Aggregations

StrategyPriority (org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority)14 Test (org.junit.Test)10 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)5 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)5 HostVO (com.cloud.host.HostVO)3 HashMap (java.util.HashMap)3 Host (com.cloud.host.Host)2 StoragePoolType (com.cloud.storage.Storage.StoragePoolType)2 Snapshot (com.cloud.storage.Snapshot)1 VolumeVO (com.cloud.storage.VolumeVO)1 PrimaryDataStore (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore)1 SnapshotOperation (org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation)1 PrimaryDataStoreImpl (org.apache.cloudstack.storage.datastore.PrimaryDataStoreImpl)1 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)1 VolumeObject (org.apache.cloudstack.storage.volume.VolumeObject)1