Search in sources :

Example 41 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowTopologyTest method updateFlow.

private Flow updateFlow(final String flowId) throws IOException {
    System.out.println("NORTHBOUND: Update flow");
    Flow flowPayload = new Flow(flowId, 10000, false, "", "test-switch", 1, 2, "test-switch", 1, 2);
    FlowUpdateRequest commandData = new FlowUpdateRequest(flowPayload);
    CommandMessage message = new CommandMessage(commandData, 0, "update-flow", Destination.WFM);
    // sendNorthboundMessage(message);
    sendFlowMessage(message);
    return flowPayload;
}
Also used : FlowUpdateRequest(org.openkilda.messaging.command.flow.FlowUpdateRequest) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 42 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowTopologyTest method deleteFlowCommandBoltTest.

@Test
public void deleteFlowCommandBoltTest() 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());
    Flow payload = deleteFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage message = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(message);
    ImmutablePair<Flow, Flow> flow = getFlowPayload(message);
    assertNotNull(flow);
    Flow flowTePayload = flow.getLeft();
    assertEquals(payload.getFlowId(), flowTePayload.getFlowId());
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    System.out.println("record = " + record);
    InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    FlowResponse response = (FlowResponse) infoMessage.getData();
    assertNotNull(response);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 43 with Flow

use of org.openkilda.messaging.model.Flow 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);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 44 with Flow

use of org.openkilda.messaging.model.Flow 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;
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow)

Example 45 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class FlowInfoDataTest method toStringTest.

@Test
public void toStringTest() throws Exception {
    FlowInfoData data = new FlowInfoData("", new ImmutablePair<>(new Flow(), new Flow()), FlowOperation.CREATE, Utils.DEFAULT_CORRELATION_ID);
    String dataString = data.toString();
    assertNotNull(dataString);
    assertFalse(dataString.isEmpty());
    System.out.println(MAPPER.writeValueAsString(data));
}
Also used : FlowInfoData(org.openkilda.messaging.info.flow.FlowInfoData) Flow(org.openkilda.messaging.model.Flow) Test(org.junit.Test)

Aggregations

Flow (org.openkilda.messaging.model.Flow)54 InfoMessage (org.openkilda.messaging.info.InfoMessage)23 Values (org.apache.storm.tuple.Values)14 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)14 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)13 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)13 Test (org.junit.Test)12 CommandMessage (org.openkilda.messaging.command.CommandMessage)8 ImmutablePair (org.openkilda.messaging.model.ImmutablePair)8 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)8 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)6 Then (cucumber.api.java.en.Then)5 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)5 UnroutablePathException (org.openkilda.pce.provider.UnroutablePathException)5 Driver (org.neo4j.driver.v1.Driver)4 MessageException (org.openkilda.messaging.error.MessageException)4 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)4 And (cucumber.api.java.en.And)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3