Search in sources :

Example 6 with MetricValue

use of org.onosproject.cpman.MetricValue in project onos by opennetworkinglab.

the class ControlPlaneMonitorTest method testAvailableResources.

/**
 * Tests available resource update and load function.
 */
@Test
public void testAvailableResources() {
    MetricValue mv = new MetricValue.Builder().load(50).add();
    Set<String> diskSet = ImmutableSet.of("disk1", "disk2");
    diskSet.forEach(disk -> DISK_METRICS.forEach(cmt -> testUpdateMetricWithResource(cmt, mv, disk)));
    Set<String> networkSet = ImmutableSet.of("eth0", "eth1");
    networkSet.forEach(network -> NETWORK_METRICS.forEach(cmt -> testUpdateMetricWithResource(cmt, mv, network)));
    assertThat(monitor.availableResourcesSync(nodeId, Type.DISK), is(diskSet));
    assertThat(monitor.availableResourcesSync(nodeId, Type.NETWORK), is(networkSet));
}
Also used : CONTROL_MESSAGE_METRICS(org.onosproject.cpman.ControlResource.CONTROL_MESSAGE_METRICS) ControllerNode(org.onosproject.cluster.ControllerNode) Assert.assertThat(org.junit.Assert.assertThat) ControlMetric(org.onosproject.cpman.ControlMetric) ClusterCommunicationServiceAdapter(org.onosproject.store.cluster.messaging.ClusterCommunicationServiceAdapter) MEMORY_METRICS(org.onosproject.cpman.ControlResource.MEMORY_METRICS) Type(org.onosproject.cpman.ControlResource.Type) EasyMock.replay(org.easymock.EasyMock.replay) EasyMock.createMock(org.easymock.EasyMock.createMock) MetricValue(org.onosproject.cpman.MetricValue) Before(org.junit.Before) IpAddress(org.onlab.packet.IpAddress) CPU_METRICS(org.onosproject.cpman.ControlResource.CPU_METRICS) NodeId(org.onosproject.cluster.NodeId) EasyMock.anyObject(org.easymock.EasyMock.anyObject) ImmutableSet(com.google.common.collect.ImmutableSet) ControlMetricType(org.onosproject.cpman.ControlMetricType) NETWORK_METRICS(org.onosproject.cpman.ControlResource.NETWORK_METRICS) Set(java.util.Set) Test(org.junit.Test) EasyMock.expect(org.easymock.EasyMock.expect) ExecutionException(java.util.concurrent.ExecutionException) ClusterCommunicationService(org.onosproject.store.cluster.messaging.ClusterCommunicationService) Optional(java.util.Optional) DISK_METRICS(org.onosproject.cpman.ControlResource.DISK_METRICS) ClusterService(org.onosproject.cluster.ClusterService) Matchers.is(org.hamcrest.Matchers.is) DeviceId(org.onosproject.net.DeviceId) MetricValue(org.onosproject.cpman.MetricValue) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 MetricValue (org.onosproject.cpman.MetricValue)6 ImmutableSet (com.google.common.collect.ImmutableSet)4 Optional (java.util.Optional)4 Set (java.util.Set)4 ExecutionException (java.util.concurrent.ExecutionException)4 EasyMock.anyObject (org.easymock.EasyMock.anyObject)4 EasyMock.createMock (org.easymock.EasyMock.createMock)4 EasyMock.expect (org.easymock.EasyMock.expect)4 EasyMock.replay (org.easymock.EasyMock.replay)4 Matchers.is (org.hamcrest.Matchers.is)4 Assert.assertThat (org.junit.Assert.assertThat)4 Before (org.junit.Before)4 IpAddress (org.onlab.packet.IpAddress)4 ClusterService (org.onosproject.cluster.ClusterService)4 ControllerNode (org.onosproject.cluster.ControllerNode)4 NodeId (org.onosproject.cluster.NodeId)4 ControlMetric (org.onosproject.cpman.ControlMetric)4 ControlMetricType (org.onosproject.cpman.ControlMetricType)4 CONTROL_MESSAGE_METRICS (org.onosproject.cpman.ControlResource.CONTROL_MESSAGE_METRICS)4