Search in sources :

Example 1 with Statistic

use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.

the class BackendStatisticsResourceTest method verifyCollection.

@Override
protected void verifyCollection(List<Statistic> collection) throws Exception {
    assertNotNull(collection);
    assertEquals(STATISTICS.length, collection.size());
    for (int i = 0; i < STATISTICS.length; i++) {
        Statistic statistic = collection.get(i);
        verify(statistic, STATISTICS[i]);
        verifyLinks(statistic);
    }
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic)

Example 2 with Statistic

use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.

the class BackendHostNicResourceTest method verifyQuery.

protected void verifyQuery(AbstractStatisticalQuery<HostNic, VdsNetworkInterface> query, VdsNetworkInterface entity) throws Exception {
    assertEquals(HostNic.class, query.getParentType());
    assertSame(entity, query.resolve(NIC_ID));
    List<Statistic> statistics = query.getStatistics(entity);
    verifyStatistics(statistics, new String[] { "data.current.rx", "data.current.tx", "data.current.rx.bps", "data.current.tx.bps", "errors.total.rx", "errors.total.tx", "data.total.rx", "data.total.tx" }, new BigDecimal[] { asDec(RxTxCalculator.percent2bytes(SPEED, RECEIVE_RATE)), asDec(RxTxCalculator.percent2bytes(SPEED, TRANSMIT_RATE)), asDec(RxTxCalculator.percent2bits(SPEED, RECEIVE_RATE)), asDec(RxTxCalculator.percent2bits(SPEED, TRANSMIT_RATE)), asDec(RECEIVE_DROP_RATE), asDec(TRANSMIT_DROP_RATE), asDec(RECEIVED_BYTES), asDec(TRANSMITTED_BYTES) });
    Statistic adopted = query.adopt(new Statistic());
    assertTrue(adopted.isSetHostNic());
    assertEquals(NIC_ID.toString(), adopted.getHostNic().getId());
    assertTrue(adopted.getHostNic().isSetHost());
    assertEquals(GUIDS[0].toString(), adopted.getHostNic().getHost().getId());
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic)

Example 3 with Statistic

use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.

the class BackendHostResourceTest method verifyQuery.

protected void verifyQuery(AbstractStatisticalQuery<Host, VDS> query, VDS entity) throws Exception {
    assertEquals(Host.class, query.getParentType());
    assertSame(entity, query.resolve(GUIDS[0]));
    List<Statistic> statistics = query.getStatistics(entity);
    verifyStatistics(statistics, new String[] { "memory.total", "memory.used", "memory.free", "memory.shared", "memory.buffers", "memory.cached", "swap.total", "swap.free", "swap.used", "swap.cached", "ksm.cpu.current", "cpu.current.user", "cpu.current.system", "cpu.current.idle", "cpu.load.avg.5m", "boot.time" }, new BigDecimal[] { asDec(5120 * Mb), asDec(1024 * Mb), asDec(4096 * Mb), asDec(38 * Mb), asDec(0), asDec(0), asDec(30 * Mb), asDec(25 * Mb), asDec(5 * Mb), asDec(0), asDec(40), asDec(45), asDec(50), asDec(55), new BigDecimal(0.0060, new MathContext(2)), asDec(0) });
    Statistic adopted = query.adopt(new Statistic());
    assertTrue(adopted.isSetHost());
    assertEquals(GUIDS[0].toString(), adopted.getHost().getId());
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) BigDecimal(java.math.BigDecimal) MathContext(java.math.MathContext)

Example 4 with Statistic

use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.

the class BackendStatisticResourceTest method testGet.

@Test
public void testGet() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpQueryExpectations(STATISTICS, true);
    Statistic statistic = resource.get();
    verify(statistic, STATISTICS[1]);
    verifyLinks(statistic);
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) Test(org.junit.Test)

Example 5 with Statistic

use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.

the class BackendStatisticResourceTest method setUpQueryExpectations.

private void setUpQueryExpectations(String[] names, boolean link) throws Exception {
    VDS entity = getEntity(0);
    when(query.resolve(eq(GUIDS[1]))).thenReturn(entity);
    List<Statistic> statistics = new ArrayList<>();
    for (String name : names) {
        statistics.add(getPrototype(name));
    }
    when(query.getStatistics(same(entity))).thenReturn(statistics);
    if (link) {
        when(query.getParentType()).thenReturn(Host.class);
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) Statistic(org.ovirt.engine.api.model.Statistic) ArrayList(java.util.ArrayList)

Aggregations

Statistic (org.ovirt.engine.api.model.Statistic)27 Statistics (org.ovirt.engine.api.model.Statistics)6 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Values (org.ovirt.engine.api.model.Values)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 BigDecimal (java.math.BigDecimal)1 MathContext (java.math.MathContext)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Host (org.ovirt.engine.api.model.Host)1 Value (org.ovirt.engine.api.model.Value)1 Vm (org.ovirt.engine.api.model.Vm)1 V3Statistic (org.ovirt.engine.api.v3.types.V3Statistic)1 V3Values (org.ovirt.engine.api.v3.types.V3Values)1 VdsStatistics (org.ovirt.engine.core.common.businessentities.VdsStatistics)1 GlusterVolumeTaskStatusForHost (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusForHost)1 Guid (org.ovirt.engine.core.compat.Guid)1