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);
}
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());
}
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);
}
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());
}
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));
}
Aggregations