use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.
the class SessionServiceTest method positive.
@Test
public void positive() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
setupSwitchMock(sw, dpId);
swWriteAlwaysSuccess(sw);
doneWithSetUp(sw);
CompletableFuture<Optional<OFMessage>> future;
OFPacketOut pktOut = makePacketOut(sw.getOFFactory(), 1);
try (Session session = subject.open(context, sw)) {
future = session.write(pktOut);
}
Assert.assertFalse(future.isDone());
List<OFMessage> swActualWrite = swWriteMessages.getValues();
Assert.assertEquals(2, swActualWrite.size());
Assert.assertEquals(pktOut, swActualWrite.get(0));
Assert.assertEquals(OFType.BARRIER_REQUEST, swActualWrite.get(1).getType());
completeSessions(sw);
Assert.assertTrue(future.isDone());
Optional<OFMessage> response = future.get();
Assert.assertFalse(response.isPresent());
}
use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.
the class SessionServiceTest method responseBeforeClose.
@Test
public void responseBeforeClose() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
setupSwitchMock(sw, dpId);
swWriteAlwaysSuccess(sw);
doneWithSetUp(sw);
OFFactory ofFactory = sw.getOFFactory();
CompletableFuture<Optional<OFMessage>> first;
CompletableFuture<Optional<OFMessage>> second;
try (Session session = subject.open(context, sw)) {
OFPacketOut egress = makePacketOut(ofFactory, 100);
first = session.write(egress);
second = session.write(makePacketOut(ofFactory, 1));
// response before close
OFMessage ingress = ofFactory.errorMsgs().buildBadRequestErrorMsg().setXid(egress.getXid()).setCode(OFBadRequestCode.BAD_PORT).build();
subject.handleResponse(dpId, ingress);
}
completeSessions(sw);
// received error response must be reported via future
expectExceptionResponse(first, SessionErrorResponseException.class);
// second request must be marker as completed
expectNoResponse(second);
}
use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.
the class PathVerificationPacketSignTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
final OFPacketOut packetOut = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), true, null);
ofPacketIn = EasyMock.createMock(OFPacketIn.class);
context = new FloodlightContext();
expect(ofPacketIn.getType()).andReturn(OFType.PACKET_IN).anyTimes();
expect(ofPacketIn.getXid()).andReturn(0L).anyTimes();
expect(ofPacketIn.getVersion()).andReturn(packetOut.getVersion()).anyTimes();
expect(ofPacketIn.getCookie()).andReturn(PathVerificationService.OF_CATCH_RULE_COOKIE);
Match match = EasyMock.createMock(Match.class);
expect(match.get(MatchField.IN_PORT)).andReturn(OFPort.of(1)).anyTimes();
replay(match);
expect(ofPacketIn.getMatch()).andReturn(match).anyTimes();
replay(ofPacketIn);
IPacket expected = new Ethernet().deserialize(packetOut.getData(), 0, packetOut.getData().length);
context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, expected);
HashMap<DatapathId, IOFSwitch> switches = new HashMap<>();
switches.put(sw1.getId(), sw1);
switches.put(sw2.getId(), sw2);
mockSwitchManager.setSwitches(switches);
}
use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.
the class PathVerificationPacketSignTest method testSignPacketMissedSign.
@Test
public void testSignPacketMissedSign() {
replay(producerService);
OFPacketOut noSignPacket = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), false, null);
IPacket noSignPacketData = new Ethernet().deserialize(noSignPacket.getData(), 0, noSignPacket.getData().length);
context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, noSignPacketData);
pvs.handlePacketIn(new OfInput(sw2, ofPacketIn, context));
verify(producerService);
}
use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.
the class PathVerificationCommonTests method testRoundTripLatencyTimestampOffset.
@Test
public void testRoundTripLatencyTimestampOffset() {
OFPacketOut packet = pvs.generateDiscoveryPacket(sw, OFPort.of(1), true, null);
assertRoundTripLatencyOffset(packet.getData(), SWITCH_T0_OPTIONAL_TYPE, ROUND_TRIP_LATENCY_T0_OFFSET);
assertRoundTripLatencyOffset(packet.getData(), SWITCH_T1_OPTIONAL_TYPE, ROUND_TRIP_LATENCY_T1_OFFSET);
}
Aggregations