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);
}
}
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());
}
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());
}
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);
}
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);
}
}
Aggregations