Search in sources :

Example 1 with SnapshotOperation

use of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation 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

Snapshot (com.cloud.storage.Snapshot)1 VolumeVO (com.cloud.storage.VolumeVO)1 SnapshotOperation (org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation)1 StrategyPriority (org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority)1