Search in sources :

Example 6 with OFFlowAdd

use of org.projectfloodlight.openflow.protocol.OFFlowAdd in project open-kilda by telstra.

the class ReplaceInstallFlowTest method installOneSwitchPushFlow.

@Test
public void installOneSwitchPushFlow() throws IOException, InterruptedException {
    String value = Resources.toString(getClass().getResource("/install_one_switch_push_flow.json"), Charsets.UTF_8);
    InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
    OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
    OFFlowAdd flowCommand = scheme.oneSwitchPushFlowMod(data.getInputPort(), data.getOutputPort(), data.getOutputVlanId(), 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 OFFlowAdd

use of org.projectfloodlight.openflow.protocol.OFFlowAdd in project open-kilda by telstra.

the class ReplaceInstallFlowTest method installEgressReplaceFlow.

@Test
public void installEgressReplaceFlow() throws IOException, InterruptedException {
    String value = Resources.toString(getClass().getResource("/install_egress_replace_flow.json"), Charsets.UTF_8);
    InstallEgressFlow data = (InstallEgressFlow) prepareData(value);
    OFFlowAdd flowCommand = scheme.egressReplaceFlowMod(data.getInputPort(), data.getOutputPort(), data.getTransitVlanId(), data.getOutputVlanId(), 123L);
    runTest(value, flowCommand, null, null, null);
}
Also used : InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Example 8 with OFFlowAdd

use of org.projectfloodlight.openflow.protocol.OFFlowAdd in project open-kilda by telstra.

the class ReplaceInstallFlowTest method installEgressPushFlow.

@Test
public void installEgressPushFlow() throws IOException, InterruptedException {
    String value = Resources.toString(getClass().getResource("/install_egress_push_flow.json"), Charsets.UTF_8);
    InstallEgressFlow data = (InstallEgressFlow) prepareData(value);
    OFFlowAdd flowCommand = scheme.egressPushFlowMod(data.getInputPort(), data.getOutputPort(), data.getTransitVlanId(), data.getOutputVlanId(), 123L);
    runTest(value, flowCommand, null, null, null);
}
Also used : InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Example 9 with OFFlowAdd

use of org.projectfloodlight.openflow.protocol.OFFlowAdd in project open-kilda by telstra.

the class ReplaceInstallFlowTest method installEgressPopFlow.

@Test
public void installEgressPopFlow() throws IOException, InterruptedException {
    String value = Resources.toString(getClass().getResource("/install_egress_pop_flow.json"), Charsets.UTF_8);
    InstallEgressFlow data = (InstallEgressFlow) prepareData(value);
    OFFlowAdd flowCommand = scheme.egressPopFlowMod(data.getInputPort(), data.getOutputPort(), data.getTransitVlanId(), 123L);
    runTest(value, flowCommand, null, null, null);
}
Also used : InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd) Test(org.junit.Test)

Example 10 with OFFlowAdd

use of org.projectfloodlight.openflow.protocol.OFFlowAdd in project open-kilda by telstra.

the class ReplaceInstallFlowTest method runTest.

/**
 * Runs test case.
 *
 * @param value       data string from json resource file
 * @param flowCommand OFFlowAdd instance to compare result with
 * @throws InterruptedException if test was interrupted during run
 */
private void runTest(final String value, final OFFlowAdd flowCommand, final OFMeterMod meterCommand, final OFFlowAdd reverseFlowCommand, final OFMeterMod reverseMeterCommand) throws InterruptedException {
    // construct kafka message
    ConsumerRecord<String, String> record = new ConsumerRecord<>("", 0, 0, "", value);
    // create parser instance
    ConsumerContext kafkaContext = new ConsumerContext(context, collector);
    RecordHandler parseRecord = new RecordHandler(kafkaContext, record, new MeterPool());
    // init test mocks
    Capture<OFFlowAdd> flowAddCapture = flowCommand == null ? null : newCapture(CaptureType.ALL);
    Capture<OFMeterMod> meterAddCapture = meterCommand == null ? null : newCapture(CaptureType.ALL);
    prepareMocks(flowAddCapture, meterAddCapture, reverseFlowCommand != null, reverseMeterCommand != null);
    // run parser and wait for termination or timeout
    parseRecordExecutor.execute(parseRecord);
    parseRecordExecutor.shutdown();
    parseRecordExecutor.awaitTermination(10, TimeUnit.SECONDS);
    // verify results
    if (meterCommand != null) {
        assertEquals(meterCommand, meterAddCapture.getValues().get(0));
        if (reverseMeterCommand != null) {
            assertEquals(reverseMeterCommand, meterAddCapture.getValues().get(1));
        }
    }
    if (flowCommand != null) {
        assertEquals(flowCommand, flowAddCapture.getValues().get(0));
        if (reverseFlowCommand != null) {
            assertEquals(reverseFlowCommand, flowAddCapture.getValues().get(1));
        }
    }
}
Also used : MeterPool(org.openkilda.floodlight.switchmanager.MeterPool) OFMeterMod(org.projectfloodlight.openflow.protocol.OFMeterMod) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd)

Aggregations

OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)14 Test (org.junit.Test)13 OFMeterMod (org.projectfloodlight.openflow.protocol.OFMeterMod)9 InstallEgressFlow (org.openkilda.messaging.command.flow.InstallEgressFlow)4 InstallIngressFlow (org.openkilda.messaging.command.flow.InstallIngressFlow)4 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)4 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 MeterPool (org.openkilda.floodlight.switchmanager.MeterPool)1 InstallTransitFlow (org.openkilda.messaging.command.flow.InstallTransitFlow)1