use of org.openkilda.messaging.info.Datapoint in project open-kilda by telstra.
the class OpenTSDBTopologyTest method shouldSendDatapointRequestsOnlyOnce.
@Ignore
@Test
public void shouldSendDatapointRequestsOnlyOnce() throws Exception {
Datapoint datapoint = new Datapoint("metric", timestamp, Collections.emptyMap(), 123);
String jsonDatapoint = MAPPER.writeValueAsString(datapoint);
MockedSources sources = new MockedSources();
sources.addMockData(Topic.OTSDB + "-spout", new Values(jsonDatapoint), new Values(jsonDatapoint));
completeTopologyParam.setMockedSources(sources);
Testing.withTrackedCluster(clusterParam, (cluster) -> {
OpenTSDBTopology topology = new TestingTargetTopology(new TestingKafkaBolt());
StormTopology stormTopology = topology.createTopology();
Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
});
// verify that request is sent to OpenTSDB server once
mockServer.verify(HttpRequest.request(), VerificationTimes.exactly(1));
}
use of org.openkilda.messaging.info.Datapoint in project open-kilda by telstra.
the class OpenTSDBTopologyTest method shouldSuccessfulSendDatapoint.
@Ignore
@Test
public void shouldSuccessfulSendDatapoint() throws Exception {
Datapoint datapoint = new Datapoint("metric", timestamp, Collections.emptyMap(), 123);
MockedSources sources = new MockedSources();
// TODO: rather than use Topic.OTSDB, grab it from the TopologyConfig object (which does
// not exist at this point in the code.
sources.addMockData(Topic.OTSDB + "-spout", new Values(MAPPER.writeValueAsString(datapoint)));
completeTopologyParam.setMockedSources(sources);
Testing.withTrackedCluster(clusterParam, (cluster) -> {
OpenTSDBTopology topology = new TestingTargetTopology(new TestingKafkaBolt());
StormTopology stormTopology = topology.createTopology();
Map result = Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
});
// verify that request is sent to OpenTSDB server
mockServer.verify(HttpRequest.request(), VerificationTimes.exactly(1));
}
use of org.openkilda.messaging.info.Datapoint in project open-kilda by telstra.
the class OpenTSDBFilterBoltTest method mockTuple.
private void mockTuple(long timestamp) throws Exception {
InfoData infoData = new Datapoint(METRIC, timestamp, Collections.emptyMap(), VALUE);
when(tuple.contains(eq("datapoint"))).thenReturn(true);
when(tuple.getValueByField(eq("datapoint"))).thenReturn(infoData);
}
use of org.openkilda.messaging.info.Datapoint in project open-kilda by telstra.
the class StatsTopologyTest method portStatsTest.
@Ignore
@Test
public void portStatsTest() throws Exception {
final String switchId = "00:00:00:00:00:00:00:01";
final List<PortStatsEntry> entries = IntStream.range(1, 53).boxed().map(port -> {
int baseCount = port * 20;
return new PortStatsEntry(port, baseCount, baseCount + 1, baseCount + 2, baseCount + 3, baseCount + 4, baseCount + 5, baseCount + 6, baseCount + 7, baseCount + 8, baseCount + 9, baseCount + 10, baseCount + 11);
}).collect(toList());
final List<PortStatsReply> replies = Collections.singletonList(new PortStatsReply(1, entries));
InfoMessage message = new InfoMessage(new PortStatsData(switchId, replies), timestamp, CORRELATION_ID, Destination.WFM_STATS);
// mock kafka spout
MockedSources sources = new MockedSources();
sources.addMockData(StatsComponentType.STATS_OFS_KAFKA_SPOUT.toString(), new Values(MAPPER.writeValueAsString(message)));
completeTopologyParam.setMockedSources(sources);
// execute topology
Testing.withTrackedCluster(clusterParam, (cluster) -> {
StatsTopology topology = new TestingTargetTopology(new TestingKafkaBolt());
StormTopology stormTopology = topology.createTopology();
// verify results
Map result = Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
ArrayList<FixedTuple> tuples = (ArrayList<FixedTuple>) result.get(StatsComponentType.PORT_STATS_METRIC_GEN.name());
assertThat(tuples.size(), is(728));
tuples.stream().map(this::readFromJson).forEach(datapoint -> {
assertThat(datapoint.getTags().get("switchId"), is(switchId.replaceAll(":", "")));
assertThat(datapoint.getTime(), is(timestamp));
assertThat(datapoint.getMetric(), startsWith("pen.switch"));
});
});
}
Aggregations