Search in sources :

Example 6 with InstallOneSwitchFlow

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

the class ReplaceInstallFlowTest method installOneSwitchNoneFlow.

@Test
public void installOneSwitchNoneFlow() throws IOException, InterruptedException {
    String value = Resources.toString(getClass().getResource("/install_one_switch_none_flow.json"), Charsets.UTF_8);
    InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
    OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
    OFFlowAdd flowCommand = scheme.oneSwitchNoneFlowMod(data.getInputPort(), data.getOutputPort(), data.getMeterId(), 123L);
    runTest(value, flowCommand, meterCommand, null, null);
}
Also used : InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Example 7 with InstallOneSwitchFlow

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

the class FlowTopologyTest method baseInstallFlowCommand.

private InstallOneSwitchFlow baseInstallFlowCommand(final String flowId) throws IOException {
    System.out.println("TOPOLOGY: Install flow");
    InstallOneSwitchFlow commandData = new InstallOneSwitchFlow(0L, flowId, COOKIE, "switch-id", 1, 2, 0, 0, OutputVlanType.NONE, 10000L, 0L);
    CommandMessage commandMessage = new CommandMessage(commandData, 0, "install-flow", Destination.WFM);
    // sendTopologyEngineMessage(commandMessage);
    // sendSpeakerMessage(commandMessage);
    sendFlowMessage(commandMessage);
    return commandData;
}
Also used : InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 8 with InstallOneSwitchFlow

use of org.openkilda.messaging.command.flow.InstallOneSwitchFlow 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)

Aggregations

InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)8 Test (org.junit.Test)5 OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)4 OFMeterMod (org.projectfloodlight.openflow.protocol.OFMeterMod)4 SwitchOperationException (org.openkilda.floodlight.switchmanager.SwitchOperationException)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)1 InstallEgressFlow (org.openkilda.messaging.command.flow.InstallEgressFlow)1 InstallIngressFlow (org.openkilda.messaging.command.flow.InstallIngressFlow)1 InstallTransitFlow (org.openkilda.messaging.command.flow.InstallTransitFlow)1 InstallMissedFlowsRequest (org.openkilda.messaging.command.switches.InstallMissedFlowsRequest)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 FlowStatusResponse (org.openkilda.messaging.info.flow.FlowStatusResponse)1 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)1 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)1