Search in sources :

Example 61 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class RefreshLunsSizeCommandTest method validate.

@Test
public void validate() {
    LUNs lun1 = new LUNs();
    lun1.setLUNId("1");
    lun1.setStorageDomainId(sdId);
    LUNs lun2 = new LUNs();
    lun2.setLUNId("2");
    lun2.setStorageDomainId(sdId);
    when(lunsDao.getAllForVolumeGroup(STORAGE)).thenReturn(Arrays.asList(lun1, lun2));
    ValidateTestUtils.runAndAssertValidateSuccess(cmd);
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 62 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class RefreshLunsSizeCommandTest method setUp.

@Before
public void setUp() {
    StorageDomainStatic sdStatic = createStorageDomain();
    spId = Guid.newGuid();
    sd = new StorageDomain();
    sd.setStorageStaticData(sdStatic);
    sd.setStatus(StorageDomainStatus.Active);
    sd.setStoragePoolId(spId);
    StoragePool sp = new StoragePool();
    sp.setId(spId);
    sp.setStatus(StoragePoolStatus.Up);
    sp.setIsLocal(false);
    sp.setCompatibilityVersion(Version.v3_6);
    doReturn(sd).when(cmd).getStorageDomain();
    doReturn(sp).when(cmd).getStoragePool();
    when(sdsDao.get(sdId)).thenReturn(sdStatic);
    LUNs lun1 = new LUNs();
    lun1.setLUNId("1");
    lun1.setStorageDomainId(sdId);
    LUNs lun2 = new LUNs();
    lun2.setLUNId("2");
    lun2.setStorageDomainId(sdId);
    when(lunsDao.getAll()).thenReturn(Arrays.asList(lun1, lun2));
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Before(org.junit.Before)

Example 63 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class RefreshLunsSizeCommandTest method validateLunsNotPartOfStorageDomain.

@Test
public void validateLunsNotPartOfStorageDomain() {
    LUNs lun1 = new LUNs();
    lun1.setLUNId("111");
    lun1.setStorageDomainId(sdId);
    LUNs lun2 = new LUNs();
    lun2.setLUNId("222");
    lun2.setStorageDomainId(sdId);
    when(lunsDao.getAllForVolumeGroup(STORAGE)).thenReturn(Arrays.asList(lun1, lun2));
    ValidateTestUtils.runAndAssertValidateFailure(cmd, EngineMessage.ACTION_TYPE_FAILED_LUNS_NOT_PART_OF_STORAGE_DOMAIN);
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 64 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class RefreshLunsSizeCommandTest method createLunMap.

private Map<String, List<Pair<VDS, LUNs>>> createLunMap(boolean sameLunSizesPerHost) {
    RandomUtils rnd = RandomUtils.instance();
    String lunId = rnd.nextString(34);
    int lunSize = rnd.nextInt();
    List<Pair<VDS, LUNs>> lunList = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        LUNs lun = new LUNs();
        if (!sameLunSizesPerHost) {
            lunSize++;
        }
        lun.setDeviceSize(lunSize);
        lunList.add(new Pair<>(new VDS(), lun));
    }
    return Collections.singletonMap(lunId, lunList);
}
Also used : RandomUtils(org.ovirt.engine.core.utils.RandomUtils) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 65 with LUNs

use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.

the class SyncLunsInfoForBlockStorageDomainCommandTest method testGetLunsToUpdateInDbSameLunIdDiffPvId.

@Test
public void testGetLunsToUpdateInDbSameLunIdDiffPvId() {
    Guid lunId = Guid.newGuid();
    Map<LunHandler, List<LUNs>> lunsToUpdateInDb = getLunsToUpdateInDb(lunId, lunId, Guid.newGuid(), Guid.newGuid());
    List<LUNs> existingLunsToUpdateInDb = lunsToUpdateInDb.get(command.updateLunsHandler);
    assertEquals(Collections.singleton(command.updateLunsHandler), lunsToUpdateInDb.keySet());
    assertLunIdInList(existingLunsToUpdateInDb, lunId);
}
Also used : List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) LunHandler(org.ovirt.engine.core.bll.storage.domain.SyncLunsInfoForBlockStorageDomainCommand.LunHandler) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Aggregations

LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)105 ArrayList (java.util.ArrayList)40 Test (org.junit.Test)33 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)26 Guid (org.ovirt.engine.core.compat.Guid)18 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)17 List (java.util.List)16 HashMap (java.util.HashMap)14 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)13 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)12 VM (org.ovirt.engine.core.common.businessentities.VM)7 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)7 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)7 Map (java.util.Map)6 LUNStorageServerConnectionMap (org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)6 LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)5 Pair (org.ovirt.engine.core.common.utils.Pair)5 GetDeviceListVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters)5 HashSet (java.util.HashSet)4