use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class SwitchTrackingServiceTest method prepareAliveSwitchEvent.
private Capture<Message> prepareAliveSwitchEvent(SpeakerSwitchView switchView) throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(dpId).anyTimes();
expect(sw.getInetAddress()).andReturn(new InetSocketAddress("127.0.1.1", 32768)).times(2);
OFConnection connect = createMock(OFConnection.class);
expect(connect.getRemoteInetAddress()).andReturn(new InetSocketAddress("127.0.1.254", 6653)).times(2);
expect(sw.getConnectionByCategory(eq(LogicalOFMessageCategory.MAIN))).andReturn(connect).times(2);
SwitchDescription description = createMock(SwitchDescription.class);
expect(description.getManufacturerDescription()).andReturn("(mock) getManufacturerDescription()").times(2);
expect(description.getHardwareDescription()).andReturn("(mock) getHardwareDescription()");
expect(description.getSoftwareDescription()).andReturn("(mock) getSoftwareDescription()").times(2);
expect(description.getSerialNumber()).andReturn("(mock) getSerialNumber()");
expect(description.getDatapathDescription()).andReturn("(mock) getDatapathDescription()");
expect(sw.getSwitchDescription()).andReturn(description).times(3);
expect(sw.getOFFactory()).andStubReturn(new OFFactoryVer13());
expect(switchManager.lookupSwitch(eq(dpId))).andReturn(sw);
List<OFPortDesc> physicalPorts = new ArrayList<>(switchView.getPorts().size());
int idx = 1;
for (SpeakerSwitchPortView port : switchView.getPorts()) {
physicalPorts.add(makePhysicalPortMock(idx++, port.getState() == SpeakerSwitchPortView.State.UP));
}
expect(switchManager.getPhysicalPorts(sw)).andReturn(physicalPorts);
expect(featureDetector.detectSwitch(sw)).andReturn(ImmutableSet.of(SwitchFeature.METERS));
return prepareSwitchEventCommon(dpId);
}
use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class OfMatchConverterTest method testConvertToRuleManagerMatchExact.
@Test
public void testConvertToRuleManagerMatchExact() {
OFFactoryVer13 factory = new OFFactoryVer13();
Match match = factory.buildMatch().setExact(MatchField.ETH_TYPE, EthType.IPv4).setExact(MatchField.ETH_SRC, MacAddress.of(1)).setExact(MatchField.ETH_DST, MacAddress.of(2)).setExact(MatchField.IP_PROTO, IpProtocol.of((short) 17)).setExact(MatchField.UDP_SRC, TransportPort.of(11)).setExact(MatchField.UDP_DST, TransportPort.of(22)).setExact(MatchField.METADATA, OFMetadata.of(U64.of(333))).setExact(MatchField.IN_PORT, OFPort.of(12)).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(444)).setExact(MatchField.TUNNEL_ID, U64.of(555)).setExact(MatchField.KILDA_VXLAN_VNI, U32.of(666)).build();
Set<FieldMatch> expectedMatches = new HashSet<>();
expectedMatches.add(FieldMatch.builder().value(2048).field(Field.ETH_TYPE).build());
expectedMatches.add(FieldMatch.builder().value(1).field(Field.ETH_SRC).build());
expectedMatches.add(FieldMatch.builder().value(2).field(Field.ETH_DST).build());
expectedMatches.add(FieldMatch.builder().value(17).field(Field.IP_PROTO).build());
expectedMatches.add(FieldMatch.builder().value(11).field(Field.UDP_SRC).build());
expectedMatches.add(FieldMatch.builder().value(22).field(Field.UDP_DST).build());
expectedMatches.add(FieldMatch.builder().value(333).field(Field.METADATA).build());
expectedMatches.add(FieldMatch.builder().value(12).field(Field.IN_PORT).build());
expectedMatches.add(FieldMatch.builder().value(444).field(Field.VLAN_VID).build());
expectedMatches.add(FieldMatch.builder().value(555).field(Field.NOVIFLOW_TUNNEL_ID).build());
expectedMatches.add(FieldMatch.builder().value(666).field(Field.OVS_VXLAN_VNI).build());
Set<FieldMatch> fieldMatches = OfMatchConverter.INSTANCE.convertToRuleManagerMatch(match);
assertEquals(expectedMatches, fieldMatches);
}
use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class OfMatchConverterTest method testConvertToRuleManagerMatchMasked.
@Test
public void testConvertToRuleManagerMatchMasked() {
OFFactoryVer13 factory = new OFFactoryVer13();
Match match = factory.buildMatch().setMasked(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv4).setMasked(MatchField.ETH_SRC, MacAddress.of(1), MacAddress.of(1)).setMasked(MatchField.ETH_DST, MacAddress.of(2), MacAddress.of(2)).setMasked(MatchField.IP_PROTO, IpProtocol.of((short) 17), IpProtocol.of((short) 17)).setMasked(MatchField.UDP_SRC, TransportPort.of(11), TransportPort.of(11)).setMasked(MatchField.UDP_DST, TransportPort.of(22), TransportPort.of(22)).setMasked(MatchField.METADATA, OFMetadata.of(U64.of(333)), OFMetadata.of(U64.of(333))).setMasked(MatchField.IN_PORT, OFPort.of(12), OFPort.of(12)).setMasked(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(444), OFVlanVidMatch.ofVlan(444)).setMasked(MatchField.TUNNEL_ID, U64.of(555), U64.of(555)).build();
Set<FieldMatch> expectedMatches = new HashSet<>();
expectedMatches.add(FieldMatch.builder().value(2048).mask(2048L).field(Field.ETH_TYPE).build());
expectedMatches.add(FieldMatch.builder().value(1).mask(1L).field(Field.ETH_SRC).build());
expectedMatches.add(FieldMatch.builder().value(2).mask(2L).field(Field.ETH_DST).build());
expectedMatches.add(FieldMatch.builder().value(17).mask(17L).field(Field.IP_PROTO).build());
expectedMatches.add(FieldMatch.builder().value(11).mask(11L).field(Field.UDP_SRC).build());
expectedMatches.add(FieldMatch.builder().value(22).mask(22L).field(Field.UDP_DST).build());
expectedMatches.add(FieldMatch.builder().value(333).mask(333L).field(Field.METADATA).build());
expectedMatches.add(FieldMatch.builder().value(12).mask(12L).field(Field.IN_PORT).build());
expectedMatches.add(FieldMatch.builder().value(444).mask(444L).field(Field.VLAN_VID).build());
expectedMatches.add(FieldMatch.builder().value(555).mask(555L).field(Field.NOVIFLOW_TUNNEL_ID).build());
Set<FieldMatch> fieldMatches = OfMatchConverter.INSTANCE.convertToRuleManagerMatch(match);
assertEquals(expectedMatches, fieldMatches);
}
use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class OfInstructionsConverterTest method convertInstructionsTest.
@Test
public void convertInstructionsTest() {
OFFactory factory = new OFFactoryVer13();
Instructions instructions = Instructions.builder().goToTable(OfTable.PRE_INGRESS).goToMeter(new MeterId(2)).writeMetadata(new OfMetadata(123, 234)).applyActions(buildActions()).build();
List<OFInstruction> actual = OfInstructionsConverter.INSTANCE.convertInstructions(instructions, factory);
assertEquals(4, actual.size());
assertTrue(actual.contains(factory.instructions().gotoTable(TableId.of(1))));
assertTrue(actual.contains(factory.instructions().buildMeter().setMeterId(2).build()));
assertTrue(actual.contains(factory.instructions().buildWriteMetadata().setMetadata(U64.of(123)).setMetadataMask(U64.of(234)).build()));
OFInstructionApplyActions applyActionsInstruction = (OFInstructionApplyActions) actual.get(3);
assertEquals(12, applyActionsInstruction.getActions().size());
List<OFAction> expectedActions = buildActions(factory);
assertTrue(applyActionsInstruction.getActions().containsAll(expectedActions));
}
use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class OfTableStatsMapperTest method shouldConvertSuccessfully.
@Test
public void shouldConvertSuccessfully() {
OFFactoryVer13 ofFactoryVer13 = new OFFactoryVer13();
OFTableStatsEntry entry = ofFactoryVer13.buildTableStatsEntry().setTableId(TableId.of(11)).setActiveCount(10).setMatchedCount(U64.of(100001L)).setLookupCount(U64.of(100002L)).build();
TableStatsEntry result = OfTableStatsMapper.INSTANCE.toTableStatsEntry(entry);
assertEquals(result.getTableId(), entry.getTableId().getValue());
assertEquals(result.getActiveEntries(), entry.getActiveCount());
assertEquals(result.getLookupCount(), entry.getLookupCount().getValue());
assertEquals(result.getMatchedCount(), entry.getMatchedCount().getValue());
}
Aggregations