Search in sources :

Example 1 with MetricValue

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

the class ControlPlaneMonitorTest method testMemoryMetric.

/**
 * Tests memory metric update and load function.
 */
@Test
public void testMemoryMetric() {
    MetricValue mv = new MetricValue.Builder().load(40).add();
    MEMORY_METRICS.forEach(cmt -> testUpdateMetricWithoutId(cmt, mv));
    MEMORY_METRICS.forEach(cmt -> testLoadMetric(nodeId, cmt, mv));
}
Also used : MetricValue(org.onosproject.cpman.MetricValue) Test(org.junit.Test)

Example 2 with MetricValue

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

the class ControlPlaneMonitorTest method testControlMessage.

/**
 * Tests control message update and load function.
 */
@Test
public void testControlMessage() {
    MetricValue mv = new MetricValue.Builder().load(10).add();
    Set<DeviceId> set = ImmutableSet.of(DeviceId.deviceId("of:0000000000000001"), DeviceId.deviceId("of:0000000000000002"));
    set.forEach(devId -> CONTROL_MESSAGE_METRICS.forEach(cmt -> testUpdateMetricWithId(cmt, mv, devId)));
    set.forEach(devId -> CONTROL_MESSAGE_METRICS.forEach(cmt -> testLoadMetricWithId(nodeId, cmt, mv, devId)));
}
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) DeviceId(org.onosproject.net.DeviceId) Test(org.junit.Test)

Example 3 with MetricValue

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

the class ControlPlaneMonitorTest method testDiskMetric.

/**
 * Tests disk metric update and load function.
 */
@Test
public void testDiskMetric() {
    MetricValue mv = new MetricValue.Builder().load(50).add();
    Set<String> set = ImmutableSet.of("disk1", "disk2");
    set.forEach(disk -> DISK_METRICS.forEach(cmt -> testUpdateMetricWithResource(cmt, mv, disk)));
    set.forEach(disk -> DISK_METRICS.forEach(cmt -> testLoadMetricWithResource(nodeId, cmt, mv, disk)));
}
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)

Example 4 with MetricValue

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

the class ControlPlaneMonitorTest method testNetworkMetric.

/**
 * Tests network metric update and load function.
 */
@Test
public void testNetworkMetric() {
    MetricValue mv = new MetricValue.Builder().load(10).add();
    Set<String> set = ImmutableSet.of("eth0", "eth1");
    set.forEach(network -> NETWORK_METRICS.forEach(cmt -> testUpdateMetricWithResource(cmt, mv, network)));
    set.forEach(network -> NETWORK_METRICS.forEach(cmt -> testLoadMetricWithResource(nodeId, cmt, mv, network)));
}
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)

Example 5 with MetricValue

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

the class ControlPlaneMonitorTest method testCpuMetric.

/**
 * Tests cpu metric update and load function.
 */
@Test
public void testCpuMetric() {
    MetricValue mv = new MetricValue.Builder().load(30).add();
    CPU_METRICS.forEach(cmt -> testUpdateMetricWithoutId(cmt, mv));
    CPU_METRICS.forEach(cmt -> testLoadMetric(nodeId, cmt, mv));
}
Also used : 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