use of org.opendaylight.protocol.pcep.PCEPSession in project bgpcep by opendaylight.
the class TopologyProgrammingTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
doReturn(true).when(this.instruction).checkedExecutionStart();
doNothing().when(this.instruction).executionCompleted(InstructionStatus.Failed, null);
doAnswer(invocation -> {
final Runnable callback = (Runnable) invocation.getArguments()[0];
callback.run();
return null;
}).when(this.instructionFuture).addListener(any(Runnable.class), any(Executor.class));
doAnswer(invocation -> {
final Runnable callback = (Runnable) invocation.getArguments()[0];
callback.run();
return null;
}).when(this.futureAddLspOutput).addListener(any(Runnable.class), any(Executor.class));
doAnswer(invocation -> {
final Runnable callback = (Runnable) invocation.getArguments()[0];
callback.run();
return null;
}).when(this.futureUpdateLspOutput).addListener(any(Runnable.class), any(Executor.class));
doAnswer(invocation -> {
final Runnable callback = (Runnable) invocation.getArguments()[0];
callback.run();
return null;
}).when(this.futureRemoveLspOutput).addListener(any(Runnable.class), any(Executor.class));
doAnswer(invocation -> {
final Runnable callback = (Runnable) invocation.getArguments()[0];
callback.run();
return null;
}).when(this.futureTriggerSyncOutput).addListener(any(Runnable.class), any(Executor.class));
doAnswer(invocation -> {
final Runnable callback = (Runnable) invocation.getArguments()[0];
callback.run();
return null;
}).when(this.futureEnsureLspOutput).addListener(any(Runnable.class), any(Executor.class));
doAnswer(invocation -> {
TopologyProgrammingTest.this.addLspArgs = (AddLspArgs) invocation.getArguments()[0];
return TopologyProgrammingTest.this.futureAddLspOutput;
}).when(listener).addLsp(any(AddLspInput.class));
doAnswer(invocation -> {
TopologyProgrammingTest.this.updateLspArgs = (UpdateLspArgs) invocation.getArguments()[0];
return TopologyProgrammingTest.this.futureUpdateLspOutput;
}).when(listener).updateLsp(any(UpdateLspInput.class));
doAnswer(invocation -> {
TopologyProgrammingTest.this.removeLspArgs = (RemoveLspArgs) invocation.getArguments()[0];
return TopologyProgrammingTest.this.futureRemoveLspOutput;
}).when(listener).removeLsp(any(RemoveLspInput.class));
doAnswer(invocation -> {
TopologyProgrammingTest.this.triggerSyncArgs = (TriggerSyncArgs) invocation.getArguments()[0];
return TopologyProgrammingTest.this.futureTriggerSyncOutput;
}).when(listener).triggerSync(any(TriggerSyncInput.class));
doAnswer(invocation -> {
TopologyProgrammingTest.this.ensureLspInput = (EnsureLspOperationalInput) invocation.getArguments()[0];
return TopologyProgrammingTest.this.futureEnsureLspOutput;
}).when(listener).ensureLspOperational(any(EnsureLspOperationalInput.class));
doNothing().when(listener).close();
doReturn(this.instruction).when(this.instructionFuture).get();
doReturn(true).when(this.instructionFuture).isDone();
doNothing().when(this.instruction).executionCompleted(any(InstructionStatus.class), any(Details.class));
doReturn(this.instructionFuture).when(this.scheduler).scheduleInstruction(any(SubmitInstructionInput.class));
this.topologyProgramming = new TopologyProgramming(this.scheduler, this.manager);
final PCEPSession session = getPCEPSession(getLocalPref(), getRemotePref());
listener.onSessionUp(session);
}
use of org.opendaylight.protocol.pcep.PCEPSession in project bgpcep by opendaylight.
the class PCCMockCommon method checkSynchronizedSession.
static void checkSynchronizedSession(final int numberOfLsp, final TestingSessionListener pceSessionListener, final BigInteger expectedeInitialDb) throws Exception {
assertTrue(pceSessionListener.isUp());
// Send Open with LspDBV = 1
final int numberOfSyncMessage = 1;
int numberOfLspExpected = numberOfLsp;
if (!expectedeInitialDb.equals(BigInteger.ZERO)) {
checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedeInitialDb));
numberOfLspExpected += numberOfSyncMessage;
}
checkReceivedMessages(pceSessionListener, numberOfLspExpected);
final PCEPSession session = pceSessionListener.getSession();
checkSession(session, DEAD_TIMER, KEEP_ALIVE);
assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful().getAugmentation(Stateful1.class).isInitiation());
assertNull(session.getLocalTlvs().getAugmentation(Tlvs3.class).getLspDbVersion().getLspDbVersionValue());
}
use of org.opendaylight.protocol.pcep.PCEPSession in project bgpcep by opendaylight.
the class PCCTriggeredLspResyncTest method testSessionTriggeredLspReSync.
@Test
public void testSessionTriggeredLspReSync() throws Exception {
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
final int lspQuantity = 3;
final BigInteger numberOflspAndDBv = BigInteger.valueOf(lspQuantity);
final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
final PCEPSession session = createPCCSession(numberOflspAndDBv).get();
assertNotNull(session);
final TestingSessionListener pceSessionListener = getListener(factory);
assertNotNull(pceSessionListener);
checkSynchronizedSession(lspQuantity, pceSessionListener, numberOflspAndDBv);
this.pccSessionListener.onMessage(session, createTriggerLspResync());
final TestingSessionListener sessionListenerAfterReconnect = getListener(factory);
checkResyncSession(Optional.of(lspQuantity), 2, 6, null, numberOflspAndDBv, sessionListenerAfterReconnect);
channel.close().get();
}
Aggregations