import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
import org.opendaylight.protocol.util.CheckUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path;
import org.opendaylight.yangtools.yang.common.RpcResult;
-public class Stateful07TopologySessionListenerTest extends AbstractPCEPSessionTest<Stateful07TopologySessionListenerFactory> {
+public class Stateful07TopologySessionListenerTest
+ extends AbstractPCEPSessionTest<Stateful07TopologySessionListenerFactory> {
- private final String TUNNEL_NAME = "pcc_" + this.testAddress + "_tunnel_0";
+ private final String tunnelName = "pcc_" + this.testAddress + "_tunnel_0";
private Stateful07TopologySessionListener listener;
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertEquals(1, pcc.getReportedLsp().size());
final ReportedLsp reportedLsp = pcc.getReportedLsp().get(0);
- assertEquals(this.TUNNEL_NAME, reportedLsp.getName());
+ assertEquals(this.tunnelName, reportedLsp.getName());
assertEquals(1, reportedLsp.getPath().size());
final Path path = reportedLsp.getPath().get(0);
assertEquals(1, path.getEro().getSubobject().size());
checkEquals(() -> assertEquals(1, listenerState.getDelegatedLspsCount().intValue()));
checkEquals(() -> assertTrue(this.listener.isSessionSynchronized()));
checkEquals(() -> assertTrue(listenerState.getMessages()
- .getAugmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp() > 0));
+ .augmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp() > 0));
checkEquals(() -> assertEquals(2, listenerState.getMessages()
- .getAugmentation(StatefulMessagesStatsAug.class).getReceivedRptMsgCount().intValue()));
+ .augmentation(StatefulMessagesStatsAug.class).getReceivedRptMsgCount().intValue()));
checkEquals(() -> assertEquals(1, listenerState.getMessages()
- .getAugmentation(StatefulMessagesStatsAug.class).getSentInitMsgCount().intValue()));
+ .augmentation(StatefulMessagesStatsAug.class).getSentInitMsgCount().intValue()));
checkEquals(() -> assertEquals(0, listenerState.getMessages()
- .getAugmentation(StatefulMessagesStatsAug.class).getSentUpdMsgCount().intValue()));
+ .augmentation(StatefulMessagesStatsAug.class).getSentUpdMsgCount().intValue()));
// update-lsp
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.update.lsp.args
- .ArgumentsBuilder updArgsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.
- topology.pcep.rev171025.update.lsp.args.ArgumentsBuilder();
+ .ArgumentsBuilder updArgsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .topology.pcep.rev171025.update.lsp.args.ArgumentsBuilder();
updArgsBuilder.setEro(createEroWithIpPrefixes(Lists.newArrayList(this.eroIpPrefix, this.dstIpPrefix)));
updArgsBuilder.addAugmentation(Arguments3.class, new Arguments3Builder().setLsp(new LspBuilder()
.setDelegate(true).setAdministrative(true).build()).build());
final UpdateLspInput update = new UpdateLspInputBuilder().setArguments(updArgsBuilder.build())
- .setName(this.TUNNEL_NAME).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID))
+ .setName(this.tunnelName).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID))
.setNode(this.nodeId).build();
this.topologyRpcs.updateLsp(update);
assertEquals(2, this.receivedMsgs.size());
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
assertEquals(1, pcc.getReportedLsp().size());
final ReportedLsp reportedLsp = pcc.getReportedLsp().get(0);
- assertEquals(this.TUNNEL_NAME, reportedLsp.getName());
+ assertEquals(this.tunnelName, reportedLsp.getName());
assertEquals(1, reportedLsp.getPath().size());
final Path path = reportedLsp.getPath().get(0);
assertEquals(2, path.getEro().getSubobject().size());
assertEquals(1, listenerState.getDelegatedLspsCount().intValue());
assertTrue(this.listener.isSessionSynchronized());
final StatefulMessagesStatsAug statefulstate = listenerState.getMessages()
- .getAugmentation(StatefulMessagesStatsAug.class);
+ .augmentation(StatefulMessagesStatsAug.class);
assertTrue(statefulstate.getLastReceivedRptMsgTimestamp() > 0);
assertEquals(3, statefulstate.getReceivedRptMsgCount().intValue());
assertEquals(1, statefulstate.getSentInitMsgCount().intValue());
assertTrue(replyTime.getAverageTime() > 0);
assertTrue(replyTime.getMaxTime() > 0);
final StatefulCapabilitiesStatsAug statefulCapabilities = listenerState
- .getPeerCapabilities().getAugmentation(StatefulCapabilitiesStatsAug.class);
+ .getPeerCapabilities().augmentation(StatefulCapabilitiesStatsAug.class);
assertFalse(statefulCapabilities.isActive());
assertTrue(statefulCapabilities.isInstantiation());
assertTrue(statefulCapabilities.isStateful());
});
// ensure-operational
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.ensure.lsp.
- operational.args.ArgumentsBuilder ensureArgs = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.
- xml.ns.yang.topology.pcep.rev171025.ensure.lsp.operational.args.ArgumentsBuilder();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.ensure.lsp
+ .operational.args.ArgumentsBuilder ensureArgs = new org.opendaylight.yang.gen.v1.urn.opendaylight.params
+ .xml.ns.yang.topology.pcep.rev171025.ensure.lsp.operational.args.ArgumentsBuilder();
ensureArgs.addAugmentation(Arguments1.class, new Arguments1Builder().setOperational(OperationalStatus.Active)
.build());
final EnsureLspOperationalInput ensure = new EnsureLspOperationalInputBuilder().setArguments(ensureArgs.build())
- .setName(this.TUNNEL_NAME).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID))
+ .setName(this.tunnelName).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID))
.setNode(this.nodeId).build();
final OperationResult result = this.topologyRpcs.ensureLspOperational(ensure).get().getResult();
//check result
assertNull(result.getFailure());
// remove-lsp
- final RemoveLspInput remove = new RemoveLspInputBuilder().setName(this.TUNNEL_NAME)
+ final RemoveLspInput remove = new RemoveLspInputBuilder().setName(this.tunnelName)
.setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID)).setNode(this.nodeId).build();
this.topologyRpcs.removeLsp(remove);
assertEquals(3, this.receivedMsgs.size());
checkEquals(() -> assertEquals(0, listenerState.getDelegatedLspsCount().intValue()));
checkEquals(() -> assertTrue(this.listener.isSessionSynchronized()));
checkEquals(() -> assertTrue(listenerState.getMessages()
- .getAugmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp() > 0));
+ .augmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp() > 0));
checkEquals(() -> assertEquals(4, listenerState.getMessages()
- .getAugmentation(StatefulMessagesStatsAug.class).getReceivedRptMsgCount().intValue()));
+ .augmentation(StatefulMessagesStatsAug.class).getReceivedRptMsgCount().intValue()));
checkEquals(() -> assertEquals(2, listenerState.getMessages()
- .getAugmentation(StatefulMessagesStatsAug.class).getSentInitMsgCount().intValue()));
+ .augmentation(StatefulMessagesStatsAug.class).getSentInitMsgCount().intValue()));
checkEquals(() -> assertEquals(1, listenerState.getMessages()
- .getAugmentation(StatefulMessagesStatsAug.class).getSentUpdMsgCount().intValue()));
+ .augmentation(StatefulMessagesStatsAug.class).getSentUpdMsgCount().intValue()));
}
@Test
public void testOnUnhandledErrorMessage() {
final Message errorMsg = AbstractMessageParser.createErrorMsg(PCEPErrors.NON_ZERO_PLSPID, Optional.absent());
this.listener.onSessionUp(this.session);
- assertTrue(this.listener.onMessage(Optional.<AbstractTopologySessionListener.MessageContext>absent().orNull(), errorMsg));
+ assertTrue(this.listener.onMessage(Optional.<AbstractTopologySessionListener.MessageContext>absent().orNull(),
+ errorMsg));
}
@Test
}
/**
- * All the pcep session registration should be closed when the session manager is closed
- * @throws InterruptedException
- * @throws ExecutionException
- * @throws TransactionCommitFailedException
+ * All the pcep session registration should be closed when the session manager is closed.
*/
@Test
public void testOnServerSessionManagerDown() throws InterruptedException, ExecutionException,
/**
* 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
- * @throws InterruptedException
- * @throws ExecutionException
- * @throws TransactionCommitFailedException
+ * 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,
}
/**
- * When a session is somehow duplicated in controller, the controller should drop existing session
+ * When a session is somehow duplicated in controller, the controller should drop existing session.
*/
@Test
public void testDuplicatedSession() throws ReadFailedException {
public void testConflictingListeners() throws Exception {
this.listener.onSessionUp(this.session);
assertFalse(this.session.isClosed());
- Stateful07TopologySessionListener conflictingListener = (Stateful07TopologySessionListener) getSessionListener();
+ Stateful07TopologySessionListener conflictingListener =
+ (Stateful07TopologySessionListener) getSessionListener();
conflictingListener.onSessionUp(this.session);
assertTrue(this.session.isClosed());
}
public void testUpdateUnknownLsp() throws InterruptedException, ExecutionException {
this.listener.onSessionUp(this.session);
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.update.lsp.args
- .ArgumentsBuilder updArgsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.
- topology.pcep.rev171025.update.lsp.args.ArgumentsBuilder();
+ .ArgumentsBuilder updArgsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .topology.pcep.rev171025.update.lsp.args.ArgumentsBuilder();
updArgsBuilder.setEro(createEroWithIpPrefixes(Lists.newArrayList(this.eroIpPrefix, this.dstIpPrefix)));
updArgsBuilder.addAugmentation(Arguments3.class, new Arguments3Builder().setLsp(new LspBuilder()
.setDelegate(true).setAdministrative(true).build()).build());
final UpdateLspInput update = new UpdateLspInputBuilder().setArguments(updArgsBuilder.build())
- .setName(this.TUNNEL_NAME).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID)).setNode(this.nodeId)
+ .setName(this.tunnelName).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID)).setNode(this.nodeId)
.build();
final UpdateLspOutput result = this.topologyRpcs.updateLsp(update).get().getResult();
assertEquals(FailureType.Unsent, result.getFailure());
@Test
public void testRemoveUnknownLsp() throws InterruptedException, ExecutionException {
this.listener.onSessionUp(this.session);
- final RemoveLspInput remove = new RemoveLspInputBuilder().setName(this.TUNNEL_NAME).setNetworkTopologyRef(
+ final RemoveLspInput remove = new RemoveLspInputBuilder().setName(this.tunnelName).setNetworkTopologyRef(
new NetworkTopologyRef(TOPO_IID)).setNode(this.nodeId).build();
final OperationResult result = this.topologyRpcs.removeLsp(remove).get().getResult();
assertEquals(FailureType.Unsent, result.getFailure());
}
@Test
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void testPccResponseTimeout() throws Exception {
this.listener.onSessionUp(this.session);
final Future<RpcResult<AddLspOutput>> addLspResult = this.topologyRpcs.addLsp(createAddLspInput());
private AddLspInput createAddLspInput() {
final ArgumentsBuilder argsBuilder = new ArgumentsBuilder();
final Ipv4CaseBuilder ipv4Builder = new Ipv4CaseBuilder();
- ipv4Builder.setIpv4(new Ipv4Builder().setSourceIpv4Address(new Ipv4Address(this.testAddress))
- .setDestinationIpv4Address(new Ipv4Address(this.testAddress)).build());
+ ipv4Builder.setIpv4(new Ipv4Builder().setSourceIpv4Address(new Ipv4AddressNoZone(this.testAddress))
+ .setDestinationIpv4Address(new Ipv4AddressNoZone(this.testAddress)).build());
argsBuilder.setEndpointsObj(new EndpointsObjBuilder().setAddressFamily(ipv4Builder.build()).build());
argsBuilder.setEro(createEroWithIpPrefixes(Lists.newArrayList(this.eroIpPrefix)));
argsBuilder.addAugmentation(Arguments2.class, new Arguments2Builder().setLsp(new LspBuilder()
.setDelegate(true).setAdministrative(true).build()).build());
- return new AddLspInputBuilder().setName(this.TUNNEL_NAME).setArguments(argsBuilder.build())
+ return new AddLspInputBuilder().setName(this.tunnelName).setArguments(argsBuilder.build())
.setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID)).setNode(this.nodeId).build();
}
}