Search in sources :

Example 26 with QuotaCluster

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

the class QuotaDaoTest method testFetchClusterWithUnlimitedGlobalLimitation.

/**
 * Test scenario when there is a specific limitation on a vds group, and we check if there is enough resources on it.<BR/>
 * The returned value from the query, should be the specific limitation and the global usage on the storage pool.
 */
@Test
public void testFetchClusterWithUnlimitedGlobalLimitation() throws Exception {
    List<QuotaCluster> quotaClusterList = dao.getQuotaClusterByClusterGuid(FixturesTool.CLUSTER_RHEL6_ISCSI, FixturesTool.QUOTA_SPECIFIC);
    // Should be two rows of specific vds group
    assertEquals(1, quotaClusterList.size());
    // Get first specific vds group.
    QuotaCluster quotaCluster = quotaClusterList.get(0);
    assertNotNull(quotaCluster);
    assertEquals(unlimited, quotaCluster.getMemSizeMB());
    assertEquals(10, (int) quotaCluster.getVirtualCpu());
}
Also used : QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Test(org.junit.Test)

Example 27 with QuotaCluster

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

the class QuotaDaoTest method testQuotaClusterByQuotaGuidWithGeneralDefaultWithDefault.

/**
 * Asserts that when {@link QuotaDao#getQuotaClusterByQuotaGuidWithGeneralDefault(Guid)} is called
 * with a non-specific quota, the general is returned
 */
@Test
public void testQuotaClusterByQuotaGuidWithGeneralDefaultWithDefault() {
    List<QuotaCluster> quotaClusterList = dao.getQuotaClusterByQuotaGuidWithGeneralDefault(FixturesTool.QUOTA_GENERAL);
    assertNotNull(quotaClusterList);
    assertEquals("wrong number of quotas returned", 1, quotaClusterList.size());
    for (QuotaCluster group : quotaClusterList) {
        assertEquals("VDS ID should be empty in general mode", Guid.Empty, group.getClusterId());
        assertNull("VDS name should be null in general mode", group.getClusterName());
    }
}
Also used : QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Test(org.junit.Test)

Example 28 with QuotaCluster

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

the class QuotaDaoTest method testFetchAllClusterForQuota.

@Test
public void testFetchAllClusterForQuota() throws Exception {
    List<QuotaCluster> quotaClusterList = dao.getQuotaClusterByClusterGuid(null, FixturesTool.QUOTA_SPECIFIC);
    assertNotNull(quotaClusterList);
    assertEquals(2, quotaClusterList.size());
    for (QuotaCluster quotaCluster : quotaClusterList) {
        if (quotaCluster.getQuotaClusterId().equals(new Guid("68c96e11-0aad-4e3a-9091-12897b7f2388"))) {
            assertEquals(Integer.valueOf(10), quotaCluster.getVirtualCpu());
            assertEquals(unlimited, quotaCluster.getMemSizeMB());
        } else if (quotaCluster.getQuotaClusterId().equals(new Guid("68c96e11-0aad-4e3a-9091-12897b7f2389"))) {
            assertEquals(Integer.valueOf(1000), quotaCluster.getVirtualCpu());
            assertEquals(unlimited, quotaCluster.getMemSizeMB());
        }
    }
}
Also used : QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 29 with QuotaCluster

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

the class QuotaDaoTest method getSpecificQuotaCluster.

private static QuotaCluster getSpecificQuotaCluster(Guid quotaId) {
    QuotaCluster quotaCluster = new QuotaCluster();
    quotaCluster.setQuotaClusterId(Guid.newGuid());
    quotaCluster.setQuotaId(quotaId);
    quotaCluster.setClusterId(FixturesTool.CLUSTER_RHEL6_NFS);
    quotaCluster.setVirtualCpu(2880);
    quotaCluster.setMemSizeMB(16000000L);
    quotaCluster.setVirtualCpuUsage(0);
    quotaCluster.setMemSizeMBUsage(0L);
    return quotaCluster;
}
Also used : QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster)

Example 30 with QuotaCluster

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

the class QuotaDaoTest method testFetchGlobalQuotaUsageForGlobalCluster.

/**
 * Test scenario when there is a global limitation on the storage pool, and we check limitation on the entire
 * storage pool.<BR/>
 * The value that should be returned, is the global limitation and the global usage on the storage pool.
 */
@Test
public void testFetchGlobalQuotaUsageForGlobalCluster() throws Exception {
    List<QuotaCluster> quotaClusterList = dao.getQuotaClusterByClusterGuid(null, FixturesTool.QUOTA_GENERAL);
    QuotaCluster quotaCluster = quotaClusterList.get(0);
    assertEquals(1, quotaClusterList.size());
    assertNotNull(quotaCluster);
    assertTrue(quotaCluster.getMemSizeMBUsage() > 0);
    // Check if the global variable returns when null is initialization.
    assertEquals(Integer.valueOf(100), quotaCluster.getVirtualCpu());
}
Also used : QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Test(org.junit.Test)

Aggregations

QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)36 Quota (org.ovirt.engine.core.common.businessentities.Quota)17 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)14 Test (org.junit.Test)12 Guid (org.ovirt.engine.core.compat.Guid)8 ArrayList (java.util.ArrayList)5 ActionType (org.ovirt.engine.core.common.action.ActionType)3 QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)3 Inject (com.google.inject.Inject)2 HashMap (java.util.HashMap)2 List (java.util.List)2 QuotaClusterLimit (org.ovirt.engine.api.model.QuotaClusterLimit)2 QuotaClusterLimits (org.ovirt.engine.api.model.QuotaClusterLimits)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 IdParameters (org.ovirt.engine.core.common.action.IdParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)2 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)2