use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project bgpcep by opendaylight.
the class GracefulRestartTest method verifySendEORafterRestartTest.
/**
* After graceful restart is performed from peer side we have to re-advertise routes followed by
* End-of-RIB marker.
*
* @throws Exception on reading Rib failure
*/
@Test
public void verifySendEORafterRestartTest() throws Exception {
final SimpleSessionListener listener2 = new SimpleSessionListener();
configurePeer(this.tableRegistry, PEER2, this.ribImpl, this.parameters, PeerRole.Ebgp, this.serverRegistry, afiSafiAdvertised, gracefulAfiSafiAdvertised);
final BGPSessionImpl session2 = createPeerSession(PEER2, this.parameters, listener2);
final List<Ipv4Prefix> ipv4Prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
final List<Ipv4Prefix> ipv4Prefixes2 = Arrays.asList(new Ipv4Prefix(PREFIX2));
final List<Ipv6Prefix> ipv6Prefixes = Collections.singletonList(new Ipv6Prefix(PREFIX3));
insertRoutes(ipv4Prefixes, ipv6Prefixes);
insertRoutes(ipv4Prefixes2, PEER2, null, null, session2, BgpOrigin.Egp);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(1);
org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 3);
// verify sending of Ipv4 EOT, Ipv6 EOT and Ipv4 update with route
checkReceivedMessages(this.listener, 3);
assertTrue(this.listener.getListMsg().get(0) instanceof Update);
assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(0)));
assertTrue(this.listener.getListMsg().get(1) instanceof Update);
assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(1)));
assertTrue(this.listener.getListMsg().get(2) instanceof Update);
assertFalse(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(2)));
this.session.close();
checkIdleState(this.peer);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(0);
// verify nothing new was sent
checkReceivedMessages(this.listener, 3);
this.session = createPeerSession(PEER1, createParameter(false, true, Collections.singletonMap(TABLES_KEY, true)), this.listener);
checkUpState(listener);
checkUpState(this.peer);
org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 6);
// verify sending of Ipv4 update with route, Ipv4 EOT and Ipv6 EOT; order can vary based on ODTC order
final List<Notification> subList = this.listener.getListMsg().subList(3, 6);
int eotCount = 0;
int routeUpdateCount = 0;
for (Notification message : subList) {
if (BgpPeerUtil.isEndOfRib((Update) message)) {
eotCount++;
} else {
routeUpdateCount++;
}
}
assertEquals(2, eotCount);
assertEquals(1, routeUpdateCount);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project bgpcep by opendaylight.
the class OrderTlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
checkArgument(tlv instanceof Order, "OrderTlv is mandatory.");
final Order otlv = (Order) tlv;
final ByteBuf body = Unpooled.buffer();
ByteBufUtils.writeOrZero(body, otlv.getDelete());
ByteBufUtils.writeOrZero(body, otlv.getSetup());
TlvUtil.formatTlv(TYPE, body, buffer);
}
Aggregations