use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnErrorMessage.
@Test
public void testOnErrorMessage() throws InterruptedException, ExecutionException {
final Message errorMsg = MsgBuilderUtil.createErrorMsg(PCEPErrors.NON_ZERO_PLSPID, 1L);
this.listener.onSessionUp(this.session);
final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
this.listener.onMessage(this.session, errorMsg);
final AddLspOutput output = futureOutput.get().getResult();
assertEquals(FailureType.Failed, output.getFailure());
assertEquals(1, output.getError().size());
final ErrorObject err = output.getError().get(0).getErrorObject();
assertEquals(PCEPErrors.NON_ZERO_PLSPID.getErrorType(), err.getType().shortValue());
assertEquals(PCEPErrors.NON_ZERO_PLSPID.getErrorValue(), err.getValue().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnSessionDown.
@Test
public void testOnSessionDown() throws InterruptedException, ExecutionException {
this.listener.onSessionUp(this.session);
// send request
final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
assertFalse(this.session.isClosed());
this.listener.onSessionDown(this.session, new IllegalArgumentException());
assertTrue(this.session.isClosed());
final AddLspOutput output = futureOutput.get().getResult();
// deal with unsent request after session down
assertEquals(FailureType.Unsent, output.getFailure());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnServerSessionManagerUnstarted.
/**
* Verify the PCEP session should not be up when server session manager is down,
* otherwise it would be a problem when the session is up while it's not registered with session manager.
*/
@Test
public void testOnServerSessionManagerUnstarted() throws InterruptedException, ExecutionException, TransactionCommitFailedException, ReadFailedException {
stopSessionManager();
assertFalse(this.session.isClosed());
this.listener.onSessionUp(this.session);
// verify the session was NOT added to topology
checkNotPresentOperational(getDataBroker(), TOPO_IID);
// verify the session is closed due to server session manager is closed
assertTrue(this.session.isClosed());
// send request
final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
final AddLspOutput output = futureOutput.get().getResult();
// deal with unsent request after session down
assertEquals(FailureType.Unsent, output.getFailure());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnServerSessionManagerRestartAndSessionRecovery.
@Test
public void testOnServerSessionManagerRestartAndSessionRecovery() throws Exception {
// close server session manager first
stopSessionManager();
assertFalse(this.session.isClosed());
this.listener.onSessionUp(this.session);
// verify the session was NOT added to topology
checkNotPresentOperational(getDataBroker(), TOPO_IID);
// verify the session is closed due to server session manager is closed
assertTrue(this.session.isClosed());
// send request
final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
final AddLspOutput output = futureOutput.get().getResult();
// deal with unsent request after session down
assertEquals(FailureType.Unsent, output.getFailure());
// PCC client is not there
checkNotPresentOperational(getDataBroker(), this.pathComputationClientIId);
// reset received message queue
this.receivedMsgs.clear();
// now we restart the session manager
startSessionManager();
// try to start the session again
// notice since the session was terminated before, it is not usable anymore.
// we need to get a new session instance. the new session will have the same local / remote preference
this.session = getPCEPSession(getLocalPref(), getRemotePref());
assertFalse(this.session.isClosed());
this.listener.onSessionUp(this.session);
assertFalse(this.session.isClosed());
// create node
this.topologyRpcs.addLsp(createAddLspInput());
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
final long srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
this.listener.onMessage(this.session, pcRpt);
readDataOperational(getDataBroker(), TOPO_IID, topology -> {
assertEquals(1, topology.getNode().size());
return topology;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testAddAlreadyExistingLsp.
@Test
public void testAddAlreadyExistingLsp() throws UnknownHostException, InterruptedException, ExecutionException {
this.listener.onSessionUp(this.session);
this.topologyRpcs.addLsp(createAddLspInput());
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(0) instanceof Pcinitiate);
final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
final long srpId = req.getSrp().getOperationId().getValue();
final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setPlspId(new PlspId(1L)).setSync(false).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
this.listener.onMessage(this.session, pcRpt);
// try to add already existing LSP
final AddLspOutput result = this.topologyRpcs.addLsp(createAddLspInput()).get().getResult();
assertEquals(FailureType.Unsent, result.getFailure());
assertEquals(1, result.getError().size());
final ErrorObject errorObject = result.getError().get(0).getErrorObject();
assertNotNull(errorObject);
assertEquals(PCEPErrors.USED_SYMBOLIC_PATH_NAME, PCEPErrors.forValue(errorObject.getType(), errorObject.getValue()));
}
Aggregations