Search in sources :

Example 1 with OFFactoryVer13

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

the class PingRequestCommandWriteOkTest method writeError.

@Test
public void writeError() throws Exception {
    final DatapathId dpIdWriteError = DatapathId.of(0x0000fffe00000005L);
    IOFSwitch switchWriteError = createMock(IOFSwitch.class);
    expect(switchService.getActiveSwitch(dpIdWriteError)).andReturn(switchWriteError).anyTimes();
    expect(switchWriteError.getId()).andReturn(dpIdWriteError).anyTimes();
    expect(switchWriteError.getOFFactory()).andReturn(new OFFactoryVer13()).anyTimes();
    expect(switchWriteError.getLatency()).andReturn(U64.of(5)).anyTimes();
    expect(switchWriteError.write(anyObject(OFMessage.class))).andReturn(false);
    switchIntoTestMode();
    Ping ping = makePing(switchWriteError, switchBeta);
    PingRequestCommand command = makeCommand(ping);
    command.call();
    verifySentErrorResponse(ping, Errors.WRITE_FAILURE);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) Ping(org.openkilda.messaging.model.Ping) DatapathId(org.projectfloodlight.openflow.types.DatapathId) Test(org.junit.Test)

Example 2 with OFFactoryVer13

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

the class OfMeterStatsMapperTest method testToPortStatsDataV13.

@Test
public void testToPortStatsDataV13() {
    OFFactoryVer13 factory = new OFFactoryVer13();
    OFMeterBandStats bandStats = factory.meterBandStats(U64.of(bandPacketCount), U64.of(bandByteCount));
    OFMeterStats meterStats = factory.buildMeterStats().setMeterId(meterId).setByteInCount(// we will put meter byte/packet count
    U64.of(meterByteCount)).setPacketInCount(// but we will expect to get band byte/packet count
    U64.of(meterPacketCount)).setBandStats(Collections.singletonList(bandStats)).build();
    OFMeterStatsReply reply = factory.buildMeterStatsReply().setEntries(Collections.singletonList(meterStats)).build();
    MeterStatsData data = OfMeterStatsMapper.INSTANCE.toMeterStatsData(Collections.singletonList(reply), switchId);
    assertEquals(switchId, data.getSwitchId());
    assertEquals(1, data.getStats().size());
    MeterStatsEntry statsEntry = data.getStats().get(0);
    // expected band byte/packet count instead of
    assertEquals(bandByteCount, statsEntry.getByteInCount());
    // meter byte/packet count
    assertEquals(bandPacketCount, statsEntry.getPacketsInCount());
}
Also used : OFMeterBandStats(org.projectfloodlight.openflow.protocol.OFMeterBandStats) MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) OFMeterStats(org.projectfloodlight.openflow.protocol.OFMeterStats) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFMeterStatsReply(org.projectfloodlight.openflow.protocol.OFMeterStatsReply) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry) Test(org.junit.Test)

Example 3 with OFFactoryVer13

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

the class OfPortStatsMapperTest method testToPortStatsDataV13.

@Test
public void testToPortStatsDataV13() {
    OFFactoryVer13 ofFactoryVer13 = new OFFactoryVer13();
    OFPortStatsEntry ofPortStatsEntry = prebuildPortStatsEntry(ofFactoryVer13.buildPortStatsEntry()).setRxFrameErr(U64.of(rxFrameErr)).setRxOverErr(U64.of(rxOverErr)).setRxCrcErr(U64.of(rxCrcErr)).setCollisions(U64.of(collisions)).build();
    OFPortStatsReply ofPortStatsReply = ofFactoryVer13.buildPortStatsReply().setXid(xId).setEntries(Collections.singletonList(ofPortStatsEntry)).build();
    PortStatsData data = OfPortStatsMapper.INSTANCE.toPostStatsData(Collections.singletonList(ofPortStatsReply), switchId);
    assertPortStatsData(data);
}
Also used : OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFPortStatsReply(org.projectfloodlight.openflow.protocol.OFPortStatsReply) OFPortStatsEntry(org.projectfloodlight.openflow.protocol.OFPortStatsEntry) PortStatsData(org.openkilda.messaging.info.stats.PortStatsData) Test(org.junit.Test)

Example 4 with OFFactoryVer13

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

the class OfGroupConverterTest method testConvertDeleteGroupCommand.

@Test
public void testConvertDeleteGroupCommand() {
    List<Bucket> buckets = new ArrayList<>();
    buckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(2, null)))).build());
    buckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(1, null)))).build());
    GroupSpeakerData groupSpeakerData = GroupSpeakerData.builder().groupId(new GroupId(GROUP_ID)).type(GroupType.ALL).buckets(buckets).build();
    OFFactoryVer13 factory = new OFFactoryVer13();
    OFGroupDelete ofGroupDelete = OfGroupConverter.INSTANCE.convertDeleteGroupCommand(groupSpeakerData, factory);
    assertEquals(OFGroup.of(GROUP_ID), ofGroupDelete.getGroup());
    assertEquals(OFGroupType.ALL, ofGroupDelete.getGroupType());
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) Bucket(org.openkilda.rulemanager.group.Bucket) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) ArrayList(java.util.ArrayList) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) OFGroupDelete(org.projectfloodlight.openflow.protocol.OFGroupDelete) GroupId(org.openkilda.model.GroupId) Test(org.junit.Test)

Example 5 with OFFactoryVer13

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

the class OfInstructionsConverterTest method convertToRuleManagerInstructionsTest.

@Test
public void convertToRuleManagerInstructionsTest() {
    OFFactory factory = new OFFactoryVer13();
    List<OFInstruction> instructions = new ArrayList<>();
    instructions.add(factory.instructions().gotoTable(TableId.of(1)));
    instructions.add(factory.instructions().meter(2));
    instructions.add(factory.instructions().writeMetadata(U64.of(123), U64.of(234)));
    List<OFAction> actions = buildActions(factory);
    instructions.add(factory.instructions().applyActions(actions));
    Instructions actual = OfInstructionsConverter.INSTANCE.convertToRuleManagerInstructions(instructions);
    assertEquals(OfTable.PRE_INGRESS, actual.getGoToTable());
    assertEquals(new MeterId(2), actual.getGoToMeter());
    assertEquals(new OfMetadata(123, 234), actual.getWriteMetadata());
    assertEquals(12, actual.getApplyActions().size());
    List<Action> expectedActions = buildActions();
    assertTrue(actual.getApplyActions().containsAll(expectedActions));
}
Also used : OfMetadata(org.openkilda.rulemanager.OfMetadata) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) SwapFieldAction(org.openkilda.rulemanager.action.SwapFieldAction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) ArrayList(java.util.ArrayList) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) Instructions(org.openkilda.rulemanager.Instructions) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Aggregations

OFFactoryVer13 (org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13)22 Test (org.junit.Test)16 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 Match (org.projectfloodlight.openflow.protocol.match.Match)5 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)5 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)4 OFSwitch (net.floodlightcontroller.core.internal.OFSwitch)4 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)4 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)4 DatapathId (org.projectfloodlight.openflow.types.DatapathId)4 OFConnection (net.floodlightcontroller.core.internal.OFConnection)3 GroupId (org.openkilda.model.GroupId)3 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)3 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)3 U64 (org.projectfloodlight.openflow.types.U64)3 InetSocketAddress (java.net.InetSocketAddress)2 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)2 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)2