summaryrefslogtreecommitdiffstats
path: root/mpls/impl/src/test/java/io
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-01-31 14:39:29 +0100
committerMarek Gradzki <mgradzki@cisco.com>2018-01-31 15:15:16 +0100
commit710a7932be189a6bfc342b471efa1044f8a9798a (patch)
treee0ee6535bc35a9d4ad2a1b6672d3f67c32382876 /mpls/impl/src/test/java/io
parent9f215a89a3d600c79ec44862abcbaede1f94a857 (diff)
HC2VPP-280: make next-hop optional for impose-and-forward
Next hop address is not mandatory in VPP CLI, e.g. ip route add 192.0.2.11/32 via loop0 out-labels 3 Also hc2vpp-ietf-routing-types@2017-02-27.yang defines it as optional. Change-Id: I6bd63a3ac75d40b14ae553e128b7ebe43dee5118 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'mpls/impl/src/test/java/io')
-rw-r--r--mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java
index a4689a74c..c1ced8e1d 100644
--- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java
+++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java
@@ -32,6 +32,7 @@ import java.util.Arrays;
import java.util.Collections;
import org.junit.Test;
import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.Mpls1;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.StaticLspConfig;
@@ -68,6 +69,10 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa
private StaticLspCustomizer customizer;
private static StaticLsp getSimpleLsp(final long label) {
+ return getSimpleLsp(label, IpAddressBuilder.getDefaultInstance("5.6.7.8"));
+ }
+ private static StaticLsp getSimpleLsp(final long label,
+ final IpAddress nextHop) {
return new StaticLspBuilder()
.setName(LSP_NAME)
.setConfig(new ConfigBuilder()
@@ -78,7 +83,7 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa
)
.setOperation(StaticLspConfig.Operation.ImposeAndForward)
.setOutSegment(new SimplePathBuilder()
- .setNextHop(IpAddressBuilder.getDefaultInstance("5.6.7.8"))
+ .setNextHop(nextHop)
.setOutgoingInterface(IF_NAME)
.setOutgoingLabel(new MplsLabel(label))
.build())
@@ -122,6 +127,12 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa
}
@Test
+ public void testWriteSimpleWithoutNextHop() throws WriteFailedException {
+ customizer.writeCurrentAttributes(IID, getSimpleLsp((long) LABEL, null), writeContext);
+ verify(jvpp).ipAddDelRoute(getRequestForSimpleLsp(true, new byte[0]));
+ }
+
+ @Test
public void testWriteComplex() throws WriteFailedException {
customizer.writeCurrentAttributes(IID, COMPLEX_LSP, writeContext);
verify(jvpp).ipAddDelRoute(getRequestForComplexLsp(true));
@@ -151,14 +162,22 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa
return getRequestForSimpleLsp(add, LABEL);
}
+ private IpAddDelRoute getRequestForSimpleLsp(final boolean add, final byte[] nextHop) {
+ return getRequestForSimpleLsp(add, LABEL, nextHop);
+ }
+
private IpAddDelRoute getRequestForSimpleLsp(final boolean add, final int label) {
+ return getRequestForSimpleLsp(add, label, new byte[] {5, 6, 7, 8});
+ }
+
+ private IpAddDelRoute getRequestForSimpleLsp(final boolean add, final int label, final byte[] nextHop) {
final IpAddDelRoute request = new IpAddDelRoute();
request.nextHopSwIfIndex = IF_INDEX;
request.isAdd = booleanToByte(add);
request.nextHopWeight = 1;
request.dstAddressLength = (byte) 24;
request.dstAddress = new byte[] {1, 2, 3, 4};
- request.nextHopAddress = new byte[] {5, 6, 7, 8};
+ request.nextHopAddress = nextHop;
request.nextHopNOutLabels = 1;
request.nextHopViaLabel = LspWriter.MPLS_LABEL_INVALID;
request.nextHopOutLabelStack = new int[] {label};