use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class FlowTopologyTest method installFlowTopologyEngineSpeakerBoltTest.
@Test
public void installFlowTopologyEngineSpeakerBoltTest() throws Exception {
/*
* This test will verify the state transitions of a flow, through the status mechanism.
* It achieves this by doing the following:
* - CreateFlow .. clear both cache and northbound consumers
* - GetStatus .. confirm STATE = FlowState.ALLOCATED
* - baseInstallFlowCommand .. read speaker .. validate data/responsedata
* - GetStatus .. confirm STATE = FlowState.IN_PROGRESS
* - baseInstallRuleCommand ..
* - GetStatus .. confirm STATE = FlowState.UP
*/
String flowId = UUID.randomUUID().toString();
ConsumerRecord<String, String> record;
createFlow(flowId);
record = cacheConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
statusFlow(flowId);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
assertNotNull(infoMessage);
FlowStatusResponse infoData = (FlowStatusResponse) infoMessage.getData();
assertNotNull(infoData);
FlowIdStatusPayload flowNbPayload = infoData.getPayload();
assertNotNull(flowNbPayload);
assertEquals(flowId, flowNbPayload.getId());
assertEquals(FlowState.ALLOCATED, flowNbPayload.getStatus());
InstallOneSwitchFlow data = baseInstallFlowCommand(flowId);
record = ofsConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
CommandMessage response = objectMapper.readValue(record.value(), CommandMessage.class);
assertNotNull(response);
InstallOneSwitchFlow responseData = (InstallOneSwitchFlow) response.getData();
Long transactionId = responseData.getTransactionId();
responseData.setTransactionId(0L);
assertEquals(data, responseData);
responseData.setTransactionId(transactionId);
statusFlow(flowId);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
assertNotNull(infoMessage);
infoData = (FlowStatusResponse) infoMessage.getData();
assertNotNull(infoData);
flowNbPayload = infoData.getPayload();
assertNotNull(flowNbPayload);
assertEquals(flowId, flowNbPayload.getId());
assertEquals(FlowState.IN_PROGRESS, flowNbPayload.getStatus());
response.setDestination(Destination.WFM_TRANSACTION);
baseInstallRuleCommand(response);
statusFlow(flowId);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
assertNotNull(infoMessage);
infoData = (FlowStatusResponse) infoMessage.getData();
assertNotNull(infoData);
flowNbPayload = infoData.getPayload();
assertNotNull(flowNbPayload);
assertEquals(flowId, flowNbPayload.getId());
assertEquals(FlowState.UP, flowNbPayload.getStatus());
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class FlowTopologyTest method dumpFlowsTest.
@Test
public void dumpFlowsTest() throws Exception {
String flowId = UUID.randomUUID().toString();
ConsumerRecord<String, String> record;
createFlow(flowId);
record = cacheConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
dumpFlows(null);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
FlowsResponse infoData = (FlowsResponse) infoMessage.getData();
assertNotNull(infoData);
assertNotNull(infoData.getPayload());
assertFalse(infoData.getPayload().isEmpty());
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class FlowTopologyTest method createFlowCommandBoltTest.
@Test
public void createFlowCommandBoltTest() throws Exception {
ConsumerRecord<String, String> record;
String flowId = UUID.randomUUID().toString();
createFlow(flowId);
record = cacheConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
InfoMessage message = objectMapper.readValue(record.value(), InfoMessage.class);
ImmutablePair<Flow, Flow> flow = getFlowPayload(message);
assertNotNull(flow);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
FlowResponse response = (FlowResponse) infoMessage.getData();
assertNotNull(response);
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class FlowTopologyTest method dumpFlowCommand.
private List<Flow> dumpFlowCommand(final String flowId) throws IOException {
System.out.println("TOPOLOGY: Get flows");
Flow flow = new Flow(flowId, 10000, false, "", "test-switch", 1, 2, "test-switch", 1, 2);
List<Flow> payload = Collections.singletonList(flow);
FlowsResponse infoData = new FlowsResponse(payload);
InfoMessage infoMessage = new InfoMessage(infoData, 0, "dump-flows", Destination.WFM);
sendTopologyEngineMessage(infoMessage);
return payload;
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class StatsTopologyTest method flowStatsTest.
@Test
public void flowStatsTest() throws Exception {
List<FlowStatsEntry> entries = Collections.singletonList(new FlowStatsEntry((short) 1, cookie, 1500L, 3000L));
final List<FlowStatsReply> stats = Collections.singletonList(new FlowStatsReply(3, entries));
InfoMessage message = new InfoMessage(new FlowStatsData(switchId, stats), 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();
Map result = Testing.completeTopology(cluster, stormTopology, completeTopologyParam);
// verify results which were sent to Kafka bolt
ArrayList<FixedTuple> tuples = (ArrayList<FixedTuple>) result.get(StatsComponentType.FLOW_STATS_METRIC_GEN.name());
assertThat(tuples.size(), is(6));
tuples.stream().map(this::readFromJson).forEach(datapoint -> {
if (datapoint.getMetric().equals("pen.flow.packets")) {
assertThat(datapoint.getTags().get("direction"), is("forward"));
}
assertThat(datapoint.getTags().get("flowid"), is(flowId));
assertThat(datapoint.getTime(), is(timestamp));
});
});
}
Aggregations