Search in sources :

Example 46 with CommandMessage

use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.

the class FlowTopologyTest method getFlow.

private FlowIdStatusPayload getFlow(final String flowId) throws IOException {
    System.out.println("NORTHBOUND: Get flow");
    FlowIdStatusPayload payload = new FlowIdStatusPayload(flowId);
    FlowGetRequest commandData = new FlowGetRequest(payload);
    CommandMessage message = new CommandMessage(commandData, 0, "get-flow", Destination.WFM);
    // sendNorthboundMessage(message);
    sendFlowMessage(message);
    return payload;
}
Also used : FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowGetRequest(org.openkilda.messaging.command.flow.FlowGetRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 47 with CommandMessage

use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.

the class FlowTopologyTest method statusFlow.

private FlowIdStatusPayload statusFlow(final String flowId) throws IOException {
    System.out.println("NORTHBOUND: Status flow");
    FlowIdStatusPayload payload = new FlowIdStatusPayload(flowId);
    FlowStatusRequest commandData = new FlowStatusRequest(payload);
    CommandMessage message = new CommandMessage(commandData, 0, "status-flow", Destination.WFM);
    // sendNorthboundMessage(message);
    sendFlowMessage(message);
    return payload;
}
Also used : FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowStatusRequest(org.openkilda.messaging.command.flow.FlowStatusRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 48 with CommandMessage

use of org.openkilda.messaging.command.CommandMessage 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 49 with CommandMessage

use of org.openkilda.messaging.command.CommandMessage 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());
}
Also used : FlowStatusResponse(org.openkilda.messaging.info.flow.FlowStatusResponse) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 50 with CommandMessage

use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.

the class FlowTopologyTest method removeFlowCommand.

private RemoveFlow removeFlowCommand(final String flowId) throws IOException {
    System.out.println("TOPOLOGY: Remove flow");
    RemoveFlow commandData = new RemoveFlow(0L, flowId, COOKIE, "switch-id", 0L);
    CommandMessage commandMessage = new CommandMessage(commandData, 0, "remove-flow", Destination.WFM);
    // sendTopologyEngineMessage(commandMessage);
    sendFlowMessage(commandMessage);
    return commandData;
}
Also used : RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

CommandMessage (org.openkilda.messaging.command.CommandMessage)70 Message (org.openkilda.messaging.Message)36 InfoMessage (org.openkilda.messaging.info.InfoMessage)32 Test (org.junit.Test)19 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)18 Values (org.apache.storm.tuple.Values)11 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)11 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)8 Flow (org.openkilda.messaging.model.Flow)8 IOException (java.io.IOException)7 CommandData (org.openkilda.messaging.command.CommandData)7 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)7 HashSet (java.util.HashSet)6 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)6 CommandWithReplyToMessage (org.openkilda.messaging.command.CommandWithReplyToMessage)5 NetworkCommandData (org.openkilda.messaging.command.discovery.NetworkCommandData)5 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)5 FlowDeleteRequest (org.openkilda.messaging.command.flow.FlowDeleteRequest)4 FlowPathRequest (org.openkilda.messaging.command.flow.FlowPathRequest)4 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)4