Search in sources :

Example 11 with StrategyPriority

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

the class KvmNonManagedStorageSystemDataMotionTest method canHandleKVMLiveStorageMigrationInterCluster.

@Test
public void canHandleKVMLiveStorageMigrationInterCluster() {
    when(host2.getClusterId()).thenReturn(5L);
    StrategyPriority priority = kvmNonManagedStorageDataMotionStrategy.canHandleKVMNonManagedLiveNFSStorageMigration(migrationMap, host1, host2);
    assertEquals(StrategyPriority.CANT_HANDLE, priority);
}
Also used : StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) Test(org.junit.Test)

Example 12 with StrategyPriority

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

the class KvmNonManagedStorageSystemDataMotionTest method internalCanHandleTestNonManaged.

@Test
public void internalCanHandleTestNonManaged() {
    StoragePoolType[] storagePoolTypeArray = StoragePoolType.values();
    for (int i = 0; i < storagePoolTypeArray.length; i++) {
        Map<VolumeInfo, DataStore> volumeMap = configureTestInternalCanHandle(false, storagePoolTypeArray[i]);
        StrategyPriority strategyPriority = kvmNonManagedStorageDataMotionStrategy.internalCanHandle(volumeMap, new HostVO("sourceHostUuid"), new HostVO("destHostUuid"));
        if (supportStoragePoolType(storagePoolTypeArray[i])) {
            Assert.assertEquals(StrategyPriority.HYPERVISOR, strategyPriority);
        } else {
            Assert.assertEquals(StrategyPriority.CANT_HANDLE, strategyPriority);
        }
    }
}
Also used : StoragePoolType(com.cloud.storage.Storage.StoragePoolType) StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) HostVO(com.cloud.host.HostVO) Test(org.junit.Test)

Example 13 with StrategyPriority

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

the class KvmNonManagedStorageSystemDataMotionTest method testCanHandleLiveMigrationUnmanagedStorage.

@Test
public void testCanHandleLiveMigrationUnmanagedStorage() {
    lenient().when(pool2.isManaged()).thenReturn(false);
    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 14 with StrategyPriority

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

the class CephSnapshotStrategyTest method configureAndVerifyCanHandle.

private void configureAndVerifyCanHandle(Date removed, boolean isSnapshotStoredOnRbdStoragePool) {
    Snapshot snapshot = Mockito.mock(Snapshot.class);
    SnapshotOperation[] snapshotOps = SnapshotOperation.values();
    Mockito.when(snapshot.getVolumeId()).thenReturn(0l);
    VolumeVO volumeVO = Mockito.mock(VolumeVO.class);
    Mockito.when(volumeVO.getRemoved()).thenReturn(removed);
    Mockito.when(volumeDao.findByIdIncludingRemoved(Mockito.anyLong())).thenReturn(volumeVO);
    Mockito.lenient().doReturn(isSnapshotStoredOnRbdStoragePool).when(cephSnapshotStrategy).isSnapshotStoredOnRbdStoragePool(Mockito.any());
    for (int i = 0; i < snapshotOps.length - 1; i++) {
        StrategyPriority strategyPriority = cephSnapshotStrategy.canHandle(snapshot, snapshotOps[i]);
        if (snapshotOps[i] == SnapshotOperation.REVERT && isSnapshotStoredOnRbdStoragePool) {
            Assert.assertEquals(StrategyPriority.HIGHEST, strategyPriority);
        } else {
            Assert.assertEquals(StrategyPriority.CANT_HANDLE, strategyPriority);
        }
    }
}
Also used : Snapshot(com.cloud.storage.Snapshot) SnapshotOperation(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation) VolumeVO(com.cloud.storage.VolumeVO) StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority)

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