use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class PingRequestCommandAbstractTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
moduleContext.addService(IOFSwitchService.class, switchService);
final DatapathId dpIdAlpha = DatapathId.of(0x0000fffe00000001L);
final DatapathId dpIdBeta = DatapathId.of(0x0000fffe00000002L);
final DatapathId dpIdGamma = DatapathId.of(0x0000fffe00000003L);
final DatapathId dpIdDelta = DatapathId.of(0x0000fffe00000004L);
OFFactory ofFactory = new OFFactoryVer13();
expect(switchAlpha.getId()).andReturn(dpIdAlpha).anyTimes();
expect(switchBeta.getId()).andReturn(dpIdBeta).anyTimes();
expect(switchMissing.getId()).andReturn(dpIdGamma).anyTimes();
expect(switchNotCapable.getId()).andReturn(dpIdDelta).anyTimes();
expect(switchAlpha.getOFFactory()).andReturn(ofFactory).anyTimes();
expect(switchBeta.getOFFactory()).andReturn(ofFactory).anyTimes();
expect(switchNotCapable.getOFFactory()).andReturn(new OFFactoryVer12()).anyTimes();
expect(switchService.getActiveSwitch(dpIdAlpha)).andReturn(switchAlpha).anyTimes();
expect(switchService.getActiveSwitch(dpIdBeta)).andReturn(switchBeta).anyTimes();
expect(switchService.getActiveSwitch(dpIdGamma)).andReturn(null).anyTimes();
expect(switchService.getActiveSwitch(dpIdDelta)).andReturn(switchNotCapable).anyTimes();
}
use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class OfGroupConverterTest method testConvertInstallGroupCommand.
@Test
public void testConvertInstallGroupCommand() {
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();
OFGroupAdd ofGroupAdd = OfGroupConverter.INSTANCE.convertInstallGroupCommand(groupSpeakerData, factory);
assertEquals(OFGroup.of(GROUP_ID), ofGroupAdd.getGroup());
assertEquals(OFGroupType.ALL, ofGroupAdd.getGroupType());
assertEquals(2, ofGroupAdd.getBuckets().size());
List<OFBucket> expectedBuckets = new ArrayList<>();
expectedBuckets.add(factory.buildBucket().setWatchPort(OFPort.ANY).setWatchGroup(OFGroup.ALL).setActions(getActions(factory, 2)).build());
expectedBuckets.add(factory.buildBucket().setWatchPort(OFPort.ANY).setWatchGroup(OFGroup.ALL).setActions(getActions(factory, 1)).build());
assertEquals(expectedBuckets, ofGroupAdd.getBuckets());
}
use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class OfGroupConverterTest method testConvertToGroupSpeakerData.
@Test
public void testConvertToGroupSpeakerData() {
OFFactoryVer13 factory = new OFFactoryVer13();
Builder builder = factory.buildGroupDescStatsReply();
List<OFGroupDescStatsEntry> entries = new ArrayList<>();
entries.add(getOfGroupEntry(factory));
builder.setEntries(entries);
List<GroupSpeakerData> groupSpeakerDataList = OfGroupConverter.INSTANCE.convertToGroupSpeakerData(builder.build());
assertEquals(1, groupSpeakerDataList.size());
GroupSpeakerData groupSpeakerData = groupSpeakerDataList.get(0);
assertEquals(new GroupId(GROUP_ID), groupSpeakerData.getGroupId());
assertEquals(GroupType.ALL, groupSpeakerData.getType());
List<Bucket> buckets = groupSpeakerData.getBuckets();
Set<Bucket> expectedBuckets = new HashSet<>();
expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(2, null)))).build());
expectedBuckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(1, null)))).build());
assertEquals(expectedBuckets, new HashSet<>(buckets));
}
use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class BfdFeatureTest method createSwitchWithDescription.
private static IOFSwitch createSwitchWithDescription(SwitchDescription description) {
OFFactory factory = new OFFactoryVer13();
DatapathId dpid = DatapathId.of("1");
OFConnection connection = new OFConnection(dpid, factory, new LocalChannel(), OFAuxId.MAIN, new MockDebugCounterService(), new HashedWheelTimer());
OFSwitch sw = new OFSwitch(connection, factory, new OFSwitchManager(), dpid);
sw.setSwitchProperties(description);
return sw;
}
use of org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13 in project open-kilda by telstra.
the class PingResponseCommandTest method success.
@Test
public void success() throws Exception {
final PingService realPingService = new PingService();
moduleContext.addService(PingService.class, realPingService);
final ISwitchManager realSwitchManager = new SwitchManager();
moduleContext.addService(ISwitchManager.class, realSwitchManager);
InputService inputService = createMock(InputService.class);
moduleContext.addService(InputService.class, inputService);
inputService.addTranslator(eq(OFType.PACKET_IN), anyObject());
replayAll();
final DatapathId dpIdBeta = DatapathId.of(0x0000fffe000002L);
final Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 8), new NetworkEndpoint(new SwitchId(dpId.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
final PingData payload = PingData.of(ping);
moduleContext.addConfigParam(new PathVerificationService(), "hmac256-secret", "secret");
realPingService.setup(moduleContext);
byte[] signedPayload = realPingService.getSignature().sign(payload);
byte[] wireData = realPingService.wrapData(ping, signedPayload).serialize();
OFFactory ofFactory = new OFFactoryVer13();
OFPacketIn message = ofFactory.buildPacketIn().setReason(OFPacketInReason.ACTION).setXid(1L).setCookie(PingService.OF_CATCH_RULE_COOKIE).setData(wireData).build();
FloodlightContext metadata = new FloodlightContext();
IPacket decodedEthernet = new Ethernet().deserialize(wireData, 0, wireData.length);
Assert.assertTrue(decodedEthernet instanceof Ethernet);
IFloodlightProviderService.bcStore.put(metadata, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet) decodedEthernet);
OfInput input = new OfInput(iofSwitch, message, metadata);
final PingResponseCommand command = makeCommand(input);
command.call();
final List<Message> replies = kafkaMessageCatcher.getValues();
Assert.assertEquals(1, replies.size());
InfoMessage response = (InfoMessage) replies.get(0);
PingResponse pingResponse = (PingResponse) response.getData();
Assert.assertNull(pingResponse.getError());
Assert.assertNotNull(pingResponse.getMeters());
Assert.assertEquals(payload.getPingId(), pingResponse.getPingId());
}
Aggregations