use of org.openkilda.messaging.Utils.CORRELATION_ID 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