use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testLspObjectWithTLV.
@Test
public void testLspObjectWithTLV() throws IOException, PCEPDeserializerException {
new StatefulActivator().start(ctx);
new SyncOptimizationsActivator().start(ctx);
final SyncOptimizationsLspObjectParser parser = new SyncOptimizationsLspObjectParser(this.ctx.getTlvHandlerRegistry(), this.ctx.getVendorInformationTlvRegistry());
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspObject1WithTLV.bin"));
final LspBuilder builder = new LspBuilder().setProcessingRule(true).setIgnore(true).setAdministrative(true).setDelegate(false).setRemove(true).setSync(false).addAugmentation(new Lsp1Builder().setCreate(false).build()).setOperational(OperationalStatus.GoingDown).setPlspId(new PlspId(Uint32.valueOf(0x12345)));
final LspErrorCode tlv1 = new LspErrorCodeBuilder().setErrorCode(Uint32.valueOf(627610883)).build();
final SymbolicPathName tlv2 = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SymbolicPathName("Med".getBytes())).build();
final LspDbVersion lspDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(DB_VERSION).build();
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.TlvsBuilder().setLspErrorCode(tlv1).setSymbolicPathName(tlv2).addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Tlvs1Builder().setLspDbVersion(lspDbVersion).build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testOpenObjectWithTLV.
@Test
public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException {
new SyncOptimizationsActivator().start(ctx);
final SyncOptimizationsOpenObjectParser parser = new SyncOptimizationsOpenObjectParser(this.ctx.getTlvHandlerRegistry(), this.ctx.getVendorInformationTlvRegistry());
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
final var builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder().setProcessingRule(false).setIgnore(false).setVersion(new ProtocolVersion(Uint8.ONE)).setKeepalive(Uint8.valueOf(30)).setDeadTimer(Uint8.valueOf(120)).setSessionId(Uint8.ONE);
final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).addAugmentation(new Stateful1Builder().build()).build();
final Tlvs1Builder statBuilder = new Tlvs1Builder();
statBuilder.setStateful(tlv1);
final Tlvs3Builder syncOptBuilder = new Tlvs3Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(DB_VERSION).build()).setSpeakerEntityId(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build());
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder().addAugmentation(statBuilder.build()).addAugmentation(syncOptBuilder.build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder in project bgpcep by opendaylight.
the class PCCPeerProposal method setPeerSpecificProposal.
@Override
public void setPeerSpecificProposal(final InetSocketAddress address, final TlvsBuilder openBuilder) {
requireNonNull(address);
openBuilder.addAugmentation(new Tlvs3Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(this.dbVersion).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder in project bgpcep by opendaylight.
the class PCETriggeredInitialSyncProcedureTest method testPcepTriggeredInitialSyncPerformed.
/**
* Test Triggered Initial Sync procedure.
*/
@Test
public void testPcepTriggeredInitialSyncPerformed() throws Exception {
final PCEPTopologySessionListener listener = getSessionListener();
// session up - expect triggered sync (LSP-DBs do not match)
final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(Uint64.ONE).build();
final LspDbVersion localDbVersion2 = new LspDbVersionBuilder().setLspDbVersionValue(Uint64.TWO).build();
final PCEPSession session = getPCEPSession(getOpen(localDbVersion, false), getOpen(localDbVersion2, false));
listener.onSessionUp(session);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check node - not synchronized and TriggeredInitialSync state
assertEquals(PccSyncState.TriggeredInitialSync, pcc.getStateSync());
return pcc;
});
// sync rpt + LSP-DB
final Pcrpt syncMsg = getsyncMsg();
listener.onMessage(session, syncMsg);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
// check reported LSP is empty, LSP state from previous session was purged
assertNull(pcc.getReportedLsp());
return pcc;
});
// report LSP + LSP-DB version number
final Pcrpt pcRpt = getPcrpt();
listener.onMessage(session, pcRpt);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
assertFalse(pcc.nonnullReportedLsp().isEmpty());
return pcc;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder in project bgpcep by opendaylight.
the class IncrementalSynchronizationProcedureTest method testStateSynchronizationPerformed.
@Test
public void testStateSynchronizationPerformed() throws Exception {
PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
listener.onSessionUp(session);
// report LSP + LSP-DB version number
final Pcrpt pcRpt = getPcrpt(Uint32.ONE, "test");
listener.onMessage(session, pcRpt);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
assertFalse(pcc.nonnullReportedLsp().isEmpty());
return pcc;
});
listener.onSessionDown(session, new IllegalArgumentException());
listener = getSessionListener();
// session up - expect sync (LSP-DBs do not match)
final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(Uint64.TWO).build();
session = getPCEPSession(getOpen(localDbVersion), getOpen(null));
listener.onSessionUp(session);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check node - IncrementalSync state
assertEquals(PccSyncState.IncrementalSync, pcc.getStateSync());
// check reported LSP - persisted from previous session
assertFalse(pcc.nonnullReportedLsp().isEmpty());
return pcc;
});
// report LSP2 + LSP-DB version number 2
final Pcrpt pcRpt2 = getPcrpt(Uint32.TWO, "testsecond");
listener.onMessage(session, pcRpt2);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.IncrementalSync, pcc.getStateSync());
// check reported LSP is not empty
assertEquals(2, pcc.nonnullReportedLsp().size());
return pcc;
});
// sync rpt + LSP-DB
final Pcrpt syncMsg = getSyncPcrt();
listener.onMessage(session, syncMsg);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
// check reported LSP is empty, LSP state from previous session was purged
assertEquals(2, pcc.nonnullReportedLsp().size());
return pcc;
});
// report LSP3 + LSP-DB version number 4
final Pcrpt pcRpt3 = getPcrpt(Uint32.valueOf(3), "testthird");
listener.onMessage(session, pcRpt3);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check node - synchronized
assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
assertEquals(3, pcc.nonnullReportedLsp().size());
return pcc;
});
}
Aggregations