diff options
author | Michal Cmarada <michal.cmarada@pantheon.tech> | 2018-05-04 16:13:09 +0200 |
---|---|---|
committer | Michal Cmarada <michal.cmarada@pantheon.tech> | 2018-05-09 14:36:21 +0200 |
commit | 8f9fe3ca424abc56d212a96af4ec5750a29e7673 (patch) | |
tree | c3472885ef0fb57452b88b4ea76f2935f81ca39f /routing/routing-impl/src/test/java/io | |
parent | d5883157bff11ee89b95bc1abe7f62fca3509950 (diff) |
HC2VPP-253 - Bump routing models
This patch updates (for support of SRv6 and MPLS) routing models to:
- hc2vpp-ietf-routing@2018-03-13.yang
(RFC 8349, https://tools.ietf.org/html/rfc8349)
- hc2vpp-ietf-ipv4-unicast-routing@2018-03-13.yang (RFC 8349)
- hc2vpp-ietf-ipv6-unicast-routing@2018-03-13.yang (RFC 8349)
- hc2vpp-ietf-ipv6-router-advertisements@2018-03-13 (RFC 8349)
- hc2vpp-ietf-routing-types@2017-12-04
(RFC 8294 ,https://tools.ietf.org/html/rfc8294)
Due to odl bugs these models were changed,
see HC2VPP-298 for more details.
Significant changes in updated models:
- Routing instance was removed, we used vpp-routing-instance
as single instance before, which is no longer needed.
- Routing-protocol and Routing-protocols were refactored to
Control-plane-protocol/s. Control-protocol now uses type and name as key
- Route Key was changed from id to ipPrefix
- Next-hop and Next-Hop-list were refactored
See attached routing_postman_collection.json for updated data structures
and examples for both IPv4 and IPv6 routes.
For router advertisements see routing_advertisments_postman_collection.json
Another fixes in this patch:
- fixes in MPLS module due to Routing model updates
- fixes doc module due to changes in Routing model
Change-Id: I33704a50061aef97dfbd73a7701ff6fe5274d6f0
Signed-off-by: Michal Cmarada <michal.cmarada@pantheon.tech>
Diffstat (limited to 'routing/routing-impl/src/test/java/io')
23 files changed, 541 insertions, 651 deletions
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java index 3e0c311df..25a1f5640 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java @@ -34,8 +34,13 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; 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.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentationBuilder; @RunWith(HoneycombTestRunner.class) public class Ipv4RouteNamesFactoryTest @@ -73,19 +78,27 @@ public class Ipv4RouteNamesFactoryTest @Test public void testUniqueRouteName( @InjectTestData(resourcePath = "/ipv4/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) - StaticRoutes data) { - assertEquals("tst-protocol_19216821_24", - factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, getIpv4RouteWithId(data, 1L))); - assertEquals("tst-protocol_19216821_24", factory.uniqueRouteName(vppRoute, mappingContext)); + StaticRoutes data) { + assertEquals("tst-protocol_192-168-2-1_24", + factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, + getIpv4RouteWithId(data, new Ipv4Prefix("192.168.2.1/24")))); + assertEquals("tst-protocol_192-168-2-1_24", factory.uniqueRouteName(vppRoute, mappingContext)); } @Test public void testUniqueRouteHopName() { - assertEquals("iface_19216821_3", factory.uniqueRouteHopName(new NextHopBuilder() - .setAddress(new Ipv4Address("192.168.2.1")) - .setWeight((short) 3) + assertEquals("iface_192-168-2-1_3", factory.uniqueRouteHopName( + new NextHopBuilder() .setOutgoingInterface("iface") + .addAugmentation(NextHop1.class, + new NextHop1Builder() + .setNextHopAddress(new Ipv4Address("192.168.2.1")) + .build()) + .addAugmentation(VppIpv4NextHopAugmentation.class, + new VppIpv4NextHopAugmentationBuilder() + .setWeight((short) 3) + .build()) .build())); - assertEquals("iface_19216821_3", factory.uniqueRouteHopName(vppPath, mappingContext)); + assertEquals("iface_192-168-2-1_3", factory.uniqueRouteHopName(vppPath, mappingContext)); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java index 0e5ecd942..098055812 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java @@ -18,8 +18,8 @@ package io.fd.hc2vpp.routing; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteBuilder; public class Ipv6RouteData { diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java index c7e5a0bd4..2acf9fe4f 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java @@ -35,8 +35,13 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentationBuilder; @RunWith(HoneycombTestRunner.class) public class Ipv6RouteNamesFactoryTest implements RoutingRequestTestHelper, SchemaContextTestHelper, @@ -73,20 +78,30 @@ public class Ipv6RouteNamesFactoryTest implements RoutingRequestTestHelper, Sche @Test public void testUniqueRouteName( @InjectTestData(resourcePath = "/ipv6/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) - StaticRoutes data) { - assertEquals("tst-protocol_2001db8a0b12f01_64", - factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, getIpv6RouteWithId(data, 1L))); - assertEquals("tst-protocol_2001db8a0b12f01_64", factory.uniqueRouteName(vppRoute, mappingContext)); + StaticRoutes data) { + assertEquals("tst-protocol_2001-db8-a0b-12f0--1_64", + factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, + getIpv6RouteWithId(data, + new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64")))); + assertEquals("tst-protocol_2001-db8-a0b-12f0--1_64", factory.uniqueRouteName(vppRoute, mappingContext)); } @Test public void testUniqueRouteHopName() { - assertEquals("iface_2001db8a0b12f01_3", factory.uniqueRouteHopName(new NextHopBuilder() - .setAddress(new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001")) - .setWeight((short) 3) + assertEquals("iface_2001-db8-a0b-12f0--1_3", factory.uniqueRouteHopName( + new NextHopBuilder() .setOutgoingInterface("iface") - .build())); - assertEquals("iface_2001db8a0b12f01_3", + .setIndex("1") + .addAugmentation(NextHop1.class, + new NextHop1Builder() + .setNextHopAddress(new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001")) + .build()) + .addAugmentation(VppIpv6NextHopAugmentation.class, + new VppIpv6NextHopAugmentationBuilder() + .setWeight((short) 3) + .build()) + .build())); + assertEquals("iface_2001-db8-a0b-12f0--1_3", factory.uniqueRouteHopName(vppPath, mappingContext)); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java index d8159818b..679b90316 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java @@ -31,7 +31,7 @@ import com.google.inject.name.Named; import com.google.inject.testing.fieldbinder.Bind; import com.google.inject.testing.fieldbinder.BoundFieldModule; import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.routing.read.RoutingStateReaderFactory; +import io.fd.hc2vpp.routing.read.RoutingReaderFactory; import io.fd.hc2vpp.routing.write.RoutingWriterFactory; import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder; @@ -94,7 +94,7 @@ public class RoutingModuleTest { readerFactories.stream().forEach(factory -> factory.init(registryBuilder)); assertNotNull(registryBuilder.build()); assertEquals(1, readerFactories.size()); - assertTrue(readerFactories.iterator().next() instanceof RoutingStateReaderFactory); + assertTrue(readerFactories.iterator().next() instanceof RoutingReaderFactory); } @Test diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java index 6ca6bdd8b..fa166cb44 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java @@ -17,7 +17,7 @@ package io.fd.hc2vpp.routing.helpers; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -32,10 +32,13 @@ import io.fd.vpp.jvpp.core.dto.IpAddDelRouteReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.List; import org.mockito.ArgumentCaptor; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProducer, RouteMapper { @@ -43,9 +46,9 @@ public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProd String ROUTE_PROTOCOL_NAME_2 = "tst-protocol-2"; String ROUTE_NAME = "tst-route"; String STATIC_ROUTE_PATH = "/hc2vpp-ietf-routing:routing" + - "/hc2vpp-ietf-routing:routing-instance[hc2vpp-ietf-routing:name='" + ROUTE_PROTOCOL_NAME + "']" + - "/hc2vpp-ietf-routing:routing-protocols" + - "/hc2vpp-ietf-routing:routing-protocol[hc2vpp-ietf-routing:name='" + ROUTE_NAME + "']" + + "/hc2vpp-ietf-routing:control-plane-protocols" + + "/hc2vpp-ietf-routing:control-plane-protocol" + + "[hc2vpp-ietf-routing:name='" + ROUTE_NAME + "'][hc2vpp-ietf-routing:type='static']" + "/hc2vpp-ietf-routing:static-routes"; default IpAddDelRoute desiredFlaglessResult(final int add, final int ipv6, final int isMultipath, @@ -75,8 +78,9 @@ public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProd final int protocolTableId, final int secondaryTableId) { // verifiaction of special request that has only destination address and flag - return desiredResult(add, ipv6, 0, destinationAddress, destinationPrefixLength, null, 0, 0, protocolTableId, secondaryTableId, 0, 0, - isDrop, isReceive, isUnreach, isProhibit); + return desiredResult(add, ipv6, 0, destinationAddress, destinationPrefixLength, null, 0, 0, + protocolTableId, secondaryTableId, 0, 0, isDrop, + isReceive, isUnreach, isProhibit); } default IpAddDelRoute desiredResult(final int add, final int ipv6, final int isMultipath, @@ -136,34 +140,33 @@ public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProd when(api.ipAddDelRoute(any())).thenReturn(future(new IpAddDelRouteReply())); } - default Route getIpv4RouteWithId(final StaticRoutes staticRoutes, final long id) { + default Route getIpv4RouteWithId(final StaticRoutes staticRoutes, final Ipv4Prefix id) { return staticRoutes.getAugmentation(StaticRoutes1.class) .getIpv4() .getRoute() .stream() - .filter(route -> route.getId() == id) + .filter(route -> route.getDestinationPrefix().getValue().equals(id.getValue())) .collect(RWUtils.singleItemCollector()); } default NextHop getHopWithId( final Route route, final int id) { - return org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList.class - .cast(route.getNextHopOptions()) - .getNextHopList() - .getNextHop() + return NextHopList.class + .cast(route.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop() .stream() - .filter(nextHop -> nextHop.getKey().getId().intValue() == id) + .filter(nextHop -> Integer.valueOf(nextHop.getKey().getIndex()) == id) .collect(RWUtils.singleItemCollector()); } - default org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route getIpv6RouteWithId( - final StaticRoutes staticRoutes, final long id) { + default org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route getIpv6RouteWithId( + final StaticRoutes staticRoutes, final Ipv6Prefix id) { return staticRoutes.getAugmentation( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1.class) + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1.class) .getIpv6() .getRoute() .stream() - .filter(route -> route.getId() == id) + .filter(route -> route.getDestinationPrefix().getValue().equals(id.getValue())) .collect(RWUtils.singleItemCollector()); } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java index 7ae84854d..9a0073580 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java @@ -26,26 +26,33 @@ public interface SchemaContextTestHelper extends InjectablesProcessor { @SchemaContextProvider default ModuleInfoBackedContext getSchemaContext() { return provideSchemaContextFor(ImmutableSet.of( + // Default interfaces + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.$YangModuleInfoImpl + .getInstance(), // Default ietf-ip org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.$YangModuleInfoImpl - .getInstance(), + .getInstance(), // Default ietf-routing - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.$YangModuleInfoImpl - .getInstance(), - // Ipv4 augmentations - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.$YangModuleInfoImpl - .getInstance(), + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.$YangModuleInfoImpl + .getInstance(), // Ipv4 augmentations - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.$YangModuleInfoImpl - .getInstance(), + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.$YangModuleInfoImpl + .getInstance(), + // Ipv6 augmentations + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.$YangModuleInfoImpl + .getInstance(), // Vpp routing - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.$YangModuleInfoImpl - .getInstance(), - // Vpp routing RA - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev170502.$YangModuleInfoImpl + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.$YangModuleInfoImpl + .getInstance(), + // Vpp IPv4 augmentations + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.$YangModuleInfoImpl .getInstance(), - // Table lookup - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.table.lookup.rev170917.$YangModuleInfoImpl.getInstance() + // Vpp IPv6 augmentations + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.$YangModuleInfoImpl + .getInstance(), + // Vpp routing RA + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.ra.rev180319.$YangModuleInfoImpl + .getInstance() )); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizerTest.java index 1d0057cf2..43ec73bd1 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/ControlPlaneProtocolCustomizerTest.java @@ -41,16 +41,16 @@ import java.util.Arrays; import java.util.List; import org.junit.Test; import org.mockito.Mock; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Static; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocolsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocolsBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class RoutingProtocolCustomizerTest - extends ListReaderCustomizerTest<RoutingProtocol, RoutingProtocolKey, RoutingProtocolBuilder> +public class ControlPlaneProtocolCustomizerTest + extends ListReaderCustomizerTest<ControlPlaneProtocol, ControlPlaneProtocolKey, ControlPlaneProtocolBuilder> implements ByteDataTranslator { private static final String VPP_PROTOCOL_PREFIX = "vpp-protocol"; @@ -65,8 +65,7 @@ public class RoutingProtocolCustomizerTest private NamingContext routingProtocolContext; - public RoutingProtocolCustomizerTest() { - super(RoutingProtocol.class, RoutingProtocolsBuilder.class); + public ControlPlaneProtocolCustomizerTest() { super(ControlPlaneProtocol.class, ControlPlaneProtocolsBuilder.class); } @Override @@ -93,20 +92,22 @@ public class RoutingProtocolCustomizerTest @Test public void getAllIds() throws Exception { - final List<RoutingProtocolKey> keys = - getCustomizer().getAllIds(InstanceIdentifier.create(RoutingProtocol.class), ctx); + final List<ControlPlaneProtocolKey> keys = + getCustomizer().getAllIds(InstanceIdentifier.create(ControlPlaneProtocol.class), ctx); assertThat(keys, hasSize(3)); - assertThat(keys, hasItems(new RoutingProtocolKey(ROUTE_PROTOCOL_NAME), new RoutingProtocolKey("tst-protocol-2"), - new RoutingProtocolKey("tst-protocol-3"))); + assertThat(keys, hasItems(new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class), + new ControlPlaneProtocolKey("tst-protocol-2", Static.class), + new ControlPlaneProtocolKey("tst-protocol-3", Static.class))); } @Test public void readCurrentAttributes() throws Exception { - final InstanceIdentifier<RoutingProtocol> identifier = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)); + final InstanceIdentifier<ControlPlaneProtocol> identifier = + InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)); - final RoutingProtocolBuilder builder = new RoutingProtocolBuilder(); + final ControlPlaneProtocolBuilder builder = new ControlPlaneProtocolBuilder(); getCustomizer().readCurrentAttributes(identifier, builder, ctx); assertEquals(ROUTE_PROTOCOL_NAME, builder.getName()); @@ -115,8 +116,8 @@ public class RoutingProtocolCustomizerTest } @Override - protected ReaderCustomizer<RoutingProtocol, RoutingProtocolBuilder> initCustomizer() { - return new RoutingProtocolCustomizer(routingProtocolContext, ipv4RoutesDumpManager, ipv6RoutesDumpManager); + protected ReaderCustomizer<ControlPlaneProtocol, ControlPlaneProtocolBuilder> initCustomizer() { + return new ControlPlaneProtocolCustomizer(routingProtocolContext, ipv4RoutesDumpManager, ipv6RoutesDumpManager); } private Ip6FibDetailsReplyDump replyDumpIpv6() { @@ -222,4 +223,4 @@ public class RoutingProtocolCustomizerTest replyDump.ipFibDetails = Arrays.asList(detail1, detail2, detail3); return replyDump; } -}
\ No newline at end of file +} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java index a0c890b9b..5e319e370 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java @@ -16,13 +16,24 @@ package io.fd.hc2vpp.routing.read; +import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Receive; + import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.Ipv4RouteData; import io.fd.hc2vpp.routing.RoutingConfiguration; +import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper; import io.fd.hc2vpp.routing.naming.Ipv4RouteNamesFactory; import io.fd.hc2vpp.routing.trait.RouteMapper; +import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; @@ -30,49 +41,46 @@ import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; import io.fd.vpp.jvpp.core.dto.IpFibDetails; import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; import io.fd.vpp.jvpp.core.types.FibPath; +import java.util.Arrays; +import java.util.List; import org.apache.commons.lang3.builder.EqualsBuilder; import org.junit.Test; import org.mockito.Mock; 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.Ipv4Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes2; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.NextHopOptions; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SimpleNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SpecialNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.next.hop.SimpleNextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.NextHopOptions; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv4.unicast.routing.rev180319.VppIpv4NextHopAugmentationBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import java.util.Arrays; -import java.util.List; - -import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest<Route, RouteKey, RouteBuilder> - implements RouteMapper { + implements RouteMapper, ClassifyTableTestHelper { - private final InstanceIdentifier<Ipv4> ipv4InstanceIdentifier = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)) + private final InstanceIdentifier<Ipv4> ipv4InstanceIdentifier = + InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)) .child(StaticRoutes.class) - .augmentation(StaticRoutes2.class) + .augmentation(StaticRoutes1.class) .child(Ipv4.class); private DumpCacheManager<IpFibDetailsReplyDump, Void> manager; @Mock @@ -81,12 +89,18 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou private MultiNamingContext routeHopContext; @Mock private EntityDumpExecutor<IpFibDetailsReplyDump, Void> executor; + @Mock + private VppClassifierContextManager classifyManager; + private NamingContext interfaceContext = new NamingContext("ifaces", "interface-context"); private NamingContext routesContext = new NamingContext("routes", "route-context"); private NamingContext routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context"); - private InstanceIdentifier<Route> routeIdSpecialHop = ipv4InstanceIdentifier.child(Route.class, new RouteKey(1L)); - private InstanceIdentifier<Route> routeIdSimpleHop = ipv4InstanceIdentifier.child(Route.class, new RouteKey(2L)); - private InstanceIdentifier<Route> routeIdListHop = ipv4InstanceIdentifier.child(Route.class, new RouteKey(3L)); + private InstanceIdentifier<Route> routeIdSpecialHop = + ipv4InstanceIdentifier.child(Route.class, new RouteKey(new Ipv4Prefix("192.168.2.1/24"))); + private InstanceIdentifier<Route> routeIdSimpleHop = + ipv4InstanceIdentifier.child(Route.class, new RouteKey(new Ipv4Prefix("192.168.2.2/22"))); + private InstanceIdentifier<Route> routeIdListHop = + ipv4InstanceIdentifier.child(Route.class, new RouteKey(new Ipv4Prefix("192.168.2.2/16"))); public Ipv4RouteCustomizerTest() { @@ -118,6 +132,9 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou String listRouteName = factory.uniqueRouteName(listRoute, mappingContext); defineMapping(mappingContext, listRouteName, 3, "route-context"); + addMapping(classifyManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext); + + when(routeHopContext.getChildIndex(listRouteName, factory.uniqueRouteHopName(listRoute.path[0], mappingContext), mappingContext)).thenReturn(0); when(routeHopContext.getChildIndex(listRouteName, factory.uniqueRouteHopName(listRoute.path[1], mappingContext), @@ -181,7 +198,9 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou final List<RouteKey> keys = getCustomizer().getAllIds(routeIdSpecialHop, ctx); assertThat(keys, hasSize(3)); - assertThat(keys, hasItems(new RouteKey(1L), new RouteKey(2L), new RouteKey(3L))); + assertThat(keys, hasItems(new RouteKey(new Ipv4Prefix("192.168.2.1/24")), + new RouteKey(new Ipv4Prefix("192.168.2.2/22")), + new RouteKey(new Ipv4Prefix("192.168.2.2/16")))); } @Test @@ -189,15 +208,13 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou final RouteBuilder builder = new RouteBuilder(); getCustomizer().readCurrentAttributes(routeIdSpecialHop, builder, ctx); - assertEquals(1, builder.getId().intValue()); - assertEquals(1, builder.getKey().getId().intValue()); assertEquals(new Ipv4Prefix("192.168.2.1/24"), builder.getDestinationPrefix()); - NextHopOptions hopOptions = builder.getNextHopOptions(); + NextHopOptions hopOptions = builder.getNextHop().getNextHopOptions(); assertTrue(hopOptions instanceof SpecialNextHop); SpecialNextHop hop = SpecialNextHop.class.cast(hopOptions); - assertEquals(SpecialNextHopGrouping.SpecialNextHop.Receive, hop.getSpecialNextHop()); + assertEquals(Receive, hop.getSpecialNextHopEnum()); } @Test @@ -205,15 +222,13 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou final RouteBuilder builder = new RouteBuilder(); getCustomizer().readCurrentAttributes(routeIdSimpleHop, builder, ctx); - assertEquals(2, builder.getId().intValue()); - assertEquals(2, builder.getKey().getId().intValue()); assertEquals(new Ipv4Prefix("192.168.2.2/22"), builder.getDestinationPrefix()); - NextHopOptions hopOptions = builder.getNextHopOptions(); + NextHopOptions hopOptions = builder.getNextHop().getNextHopOptions(); assertTrue(hopOptions instanceof SimpleNextHop); SimpleNextHop hop = SimpleNextHop.class.cast(hopOptions); - assertEquals("192.168.2.1", hop.getNextHop().getValue()); + assertEquals("192.168.2.1", hop.getAugmentation(SimpleNextHop1.class).getNextHopAddress().getValue()); assertEquals("iface-1", hop.getOutgoingInterface()); } @@ -223,11 +238,9 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou final RouteBuilder builder = new RouteBuilder(); getCustomizer().readCurrentAttributes(routeIdListHop, builder, ctx); - assertEquals(3, builder.getId().intValue()); - assertEquals(3, builder.getKey().getId().intValue()); assertEquals(new Ipv4Prefix("192.168.2.2/16"), builder.getDestinationPrefix()); - NextHopOptions hopOptions = builder.getNextHopOptions(); + NextHopOptions hopOptions = builder.getNextHop().getNextHopOptions(); assertTrue(hopOptions instanceof NextHopList); NextHopList hop = NextHopList.class.cast(hopOptions); @@ -235,32 +248,34 @@ public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou assertThat(hops, hasSize(2)); - assertTrue(areEqual(hops.get(0), desiredHop(0L, "192.168.2.1", 1, "iface-1"))); - assertTrue(areEqual(hops.get(1), desiredHop(1L, "192.168.2.2", 2, "iface-1"))); + assertTrue(areEqual(hops.get(0), desiredHop("0", "192.168.2.1", 1, "iface-1"))); + assertTrue(areEqual(hops.get(1), desiredHop("1", "192.168.2.2", 2, "iface-1"))); } private boolean areEqual(final NextHop first, final NextHop second) { return new EqualsBuilder() - .append(true, first.getAddress().getValue().equals(second.getAddress().getValue())) - .append(true, first.getId().equals(second.getId())) + .append(true, first.getAugmentation(NextHop1.class).getNextHopAddress().getValue() + .equals(second.getAugmentation(NextHop1.class).getNextHopAddress().getValue())) + .append(true, first.getIndex().equals(second.getIndex())) .append(true, first.getKey().equals(second.getKey())) .append(true, first.getOutgoingInterface().equals(second.getOutgoingInterface())) .isEquals(); } - private NextHop desiredHop(final long id, final String address, final int weight, final String iface) { + private NextHop desiredHop(final String id, final String address, final int weight, final String iface) { return new NextHopBuilder() - .setAddress(new Ipv4Address(address)) - .setWeight((short) weight) - .setOutgoingInterface(iface) - .setId(id) - .setKey(new NextHopKey(id)) - .build(); + .setOutgoingInterface(iface) + .setIndex(id) + .setKey(new NextHopKey(id)) + .addAugmentation(VppIpv4NextHopAugmentation.class, + new VppIpv4NextHopAugmentationBuilder().setWeight((short) weight).build()) + .addAugmentation(NextHop1.class, new NextHop1Builder().setNextHopAddress(new Ipv4Address(address)).build()) + .build(); } @Override protected ReaderCustomizer<Route, RouteBuilder> initCustomizer() { return new Ipv4RouteCustomizer(manager, configuration, routeHopContext, interfaceContext, - routesContext, routingProtocolContext); + routesContext, routingProtocolContext); } }
\ No newline at end of file diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java index 3626056b8..503c01914 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java @@ -23,14 +23,17 @@ import static org.hamcrest.collection.IsCollectionWithSize.hasSize; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Receive; import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.Ipv6RouteData; import io.fd.hc2vpp.routing.RoutingConfiguration; +import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper; import io.fd.hc2vpp.routing.naming.Ipv6RouteNamesFactory; import io.fd.hc2vpp.routing.trait.RouteMapper; +import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager; import io.fd.honeycomb.translate.ModificationCache; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; @@ -45,28 +48,34 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes2; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6Builder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.NextHopOptions; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SimpleNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SpecialNextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.NextHop1Builder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.next.hop.SimpleNextHop1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.NextHopOptions; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SimpleNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.SpecialNextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHopKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentation; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.ipv6.unicast.routing.rev180319.VppIpv6NextHopAugmentationBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, RouteKey, RouteBuilder> - implements RouteMapper { + implements RouteMapper, ClassifyTableTestHelper { private static final String ROUTING_PROTOCOL_PREFIX = "route-p-"; private DumpCacheManager<Ip6FibDetailsReplyDump, Void> manager; @@ -83,6 +92,9 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou @Mock private ModificationCache cache; + @Mock + private VppClassifierContextManager classifyManager; + private NamingContext interfaceContext; private NamingContext routesContext; private NamingContext routingProtocolContext; @@ -107,15 +119,18 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou routesContext = new NamingContext("routes", "route-context"); routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context"); - final InstanceIdentifier<Ipv6> ipv6InstanceIdentifier = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)) + final InstanceIdentifier<Ipv6> ipv6InstanceIdentifier = InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)) .child(StaticRoutes.class) - .augmentation(StaticRoutes2.class) + .augmentation(StaticRoutes1.class) .child(Ipv6.class); - routeIdSpecialHop = ipv6InstanceIdentifier.child(Route.class, new RouteKey(1L)); - routeIdSimpleHop = ipv6InstanceIdentifier.child(Route.class, new RouteKey(2L)); - routeIdListHop = ipv6InstanceIdentifier.child(Route.class, new RouteKey(3L)); + routeIdSpecialHop = + ipv6InstanceIdentifier.child(Route.class, new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::1/24"))); + routeIdSimpleHop = + ipv6InstanceIdentifier.child(Route.class, new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::2/22"))); + routeIdListHop = + ipv6InstanceIdentifier.child(Route.class, new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::2/16"))); factory = new Ipv6RouteNamesFactory(interfaceContext, routingProtocolContext); @@ -136,6 +151,8 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou String listRouteName = factory.uniqueRouteName(listRoute, mappingContext); defineMapping(mappingContext, listRouteName, 3, "route-context"); + addMapping(classifyManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext); + when(routeHopContext.getChildIndex(listRouteName, factory.uniqueRouteHopName(listRoute.path[0], mappingContext), mappingContext)) .thenReturn(0); @@ -201,7 +218,9 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou final List<RouteKey> keys = getCustomizer().getAllIds(routeIdSpecialHop, ctx); assertThat(keys, hasSize(3)); - assertThat(keys, hasItems(new RouteKey(1L), new RouteKey(2L), new RouteKey(3L))); + assertThat(keys, hasItems(new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::1/24")), + new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::2/22")), + new RouteKey(new Ipv6Prefix("2001:db8:a0b:12f0::2/16")))); } @Test @@ -209,15 +228,14 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou final RouteBuilder builder = new RouteBuilder(); getCustomizer().readCurrentAttributes(routeIdSpecialHop, builder, ctx); - assertEquals(1, builder.getId().intValue()); - assertEquals(1, builder.getKey().getId().intValue()); + assertEquals(new Ipv6Prefix("2001:db8:a0b:12f0::1/24"), builder.getDestinationPrefix()); assertEquals("2001:db8:a0b:12f0::1/24", builder.getDestinationPrefix().getValue()); - NextHopOptions hopOptions = builder.getNextHopOptions(); + NextHopOptions hopOptions = builder.getNextHop().getNextHopOptions(); assertTrue(hopOptions instanceof SpecialNextHop); SpecialNextHop hop = SpecialNextHop.class.cast(hopOptions); - assertEquals(SpecialNextHopGrouping.SpecialNextHop.Receive, hop.getSpecialNextHop()); + assertEquals(Receive, hop.getSpecialNextHopEnum()); } @Test @@ -225,15 +243,15 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou final RouteBuilder builder = new RouteBuilder(); getCustomizer().readCurrentAttributes(routeIdSimpleHop, builder, ctx); - assertEquals(2, builder.getId().intValue()); - assertEquals(2, builder.getKey().getId().intValue()); + assertEquals(new Ipv6Prefix("2001:db8:a0b:12f0::2/22"), builder.getDestinationPrefix()); assertEquals("2001:db8:a0b:12f0::2/22", builder.getDestinationPrefix().getValue()); - NextHopOptions hopOptions = builder.getNextHopOptions(); + NextHopOptions hopOptions = builder.getNextHop().getNextHopOptions(); assertTrue(hopOptions instanceof SimpleNextHop); SimpleNextHop hop = SimpleNextHop.class.cast(hopOptions); - assertEquals("2001:db8:a0b:12f0::1", hop.getNextHop().getValue()); + assertEquals("2001:db8:a0b:12f0::1", hop.getAugmentation(SimpleNextHop1.class) + .getNextHopAddress().getValue()); assertEquals("iface-1", hop.getOutgoingInterface()); } @@ -244,11 +262,10 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou final RouteBuilder builder = new RouteBuilder(); getCustomizer().readCurrentAttributes(routeIdListHop, builder, ctx); - assertEquals(3, builder.getId().intValue()); - assertEquals(3, builder.getKey().getId().intValue()); + assertEquals(new Ipv6Prefix("2001:db8:a0b:12f0::2/16"), builder.getDestinationPrefix()); assertEquals("2001:db8:a0b:12f0::2/16", builder.getDestinationPrefix().getValue()); - NextHopOptions hopOptions = builder.getNextHopOptions(); + NextHopOptions hopOptions = builder.getNextHop().getNextHopOptions(); assertTrue(hopOptions instanceof NextHopList); NextHopList hop = NextHopList.class.cast(hopOptions); @@ -256,32 +273,34 @@ public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, Rou assertThat(hops, hasSize(2)); - assertTrue(areEqual(hops.get(0), desiredHop(0L, "2001:db8:a0b:12f0::1", 1, "iface-1"))); - assertTrue(areEqual(hops.get(1), desiredHop(1L, "2001:db8:a0b:12f0::2", 2, "iface-1"))); + assertTrue(areEqual(hops.get(0), desiredHop("0", "2001:db8:a0b:12f0::1", 1, "iface-1"))); + assertTrue(areEqual(hops.get(1), desiredHop("1", "2001:db8:a0b:12f0::2", 2, "iface-1"))); } private boolean areEqual(final NextHop first, final NextHop second) { return new EqualsBuilder() - .append(true, first.getAddress().getValue().equals(second.getAddress().getValue())) - .append(true, first.getId().equals(second.getId())) + .append(true, first.getAugmentation(NextHop1.class).getNextHopAddress().getValue() + .equals(second.getAugmentation(NextHop1.class).getNextHopAddress().getValue())) + .append(true, first.getIndex().equals(second.getIndex())) .append(true, first.getKey().equals(second.getKey())) .append(true, first.getOutgoingInterface().equals(second.getOutgoingInterface())) .isEquals(); } - private NextHop desiredHop(final long id, final String address, final int weight, final String iface) { + private NextHop desiredHop(final String id, final String address, final int weight, final String iface) { return new NextHopBuilder() - .setAddress(new Ipv6Address(address)) - .setWeight((short) weight) - .setOutgoingInterface(iface) - .setId(id) - .setKey(new NextHopKey(id)) - .build(); + .setOutgoingInterface(iface) + .setIndex(id) + .setKey(new NextHopKey(id)) + .addAugmentation(NextHop1.class, new NextHop1Builder().setNextHopAddress(new Ipv6Address(address)).build()) + .addAugmentation(VppIpv6NextHopAugmentation.class, + new VppIpv6NextHopAugmentationBuilder().setWeight((short) weight).build()) + .build(); } @Override protected ReaderCustomizer<Route, RouteBuilder> initCustomizer() { return new Ipv6RouteCustomizer(manager, configuration, routeHopContext, - interfaceContext, routesContext, routingProtocolContext); + interfaceContext, routesContext, routingProtocolContext); } }
\ No newline at end of file diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java deleted file mode 100644 index 7bece735b..000000000 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.read; - - -import static org.junit.Assert.assertEquals; - -import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper; -import io.fd.honeycomb.test.tools.HoneycombTestRunner; -import io.fd.honeycomb.test.tools.annotations.InjectTestData; -import io.fd.honeycomb.translate.read.ReadContext; -import io.fd.honeycomb.translate.spi.read.Initialized; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.RoutingState; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@RunWith(HoneycombTestRunner.class) -public class RoutingStateCustomizerTest implements SchemaContextTestHelper { - - @InjectTestData(resourcePath = "/init/config-data.json") - private Routing config; - - @InjectTestData(resourcePath = "/init/state-data.json") - private RoutingState state; - - @Mock - private ReadContext readContext; - - @Before - public void init() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testInit() { - final InstanceIdentifier<RoutingState> identifier = InstanceIdentifier.create(RoutingState.class); - final Initialized<? extends DataObject> initilized = - new RoutingStateCustomizer().init(identifier, state, readContext); - - final Routing initializedRouting = Routing.class.cast(initilized.getData()); - - assertEquals(config, initializedRouting); - } -} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java index c283ac726..fa25520ca 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java @@ -26,29 +26,29 @@ import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; import org.junit.Before; import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Direct; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Static; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolVppAttr; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.RoutingProtocolVppAttrBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol.VppProtocolAttributesBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Direct; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.RoutingProtocolVppAttr; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.RoutingProtocolVppAttrBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev180319.routing.control.plane.protocols.control.plane.protocol.VppProtocolAttributesBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class RoutingProtocolCustomizerTest extends WriterCustomizerTest { +public class ControlPlaneProtocolCustomizerTest extends WriterCustomizerTest { - private InstanceIdentifier<RoutingProtocol> validId; - private RoutingProtocol validData; - private RoutingProtocol validData2; - private RoutingProtocol invalidData; - private RoutingProtocolCustomizer customizer; + private InstanceIdentifier<ControlPlaneProtocol> validId; + private ControlPlaneProtocol validData; + private ControlPlaneProtocol validData2; + private ControlPlaneProtocol invalidData; + private ControlPlaneProtocolCustomizer customizer; private NamingContext routingProtocolContext; @Before public void init() { - validId = InstanceIdentifier.create(RoutingProtocol.class); - validData = new RoutingProtocolBuilder() + validId = InstanceIdentifier.create(ControlPlaneProtocol.class); + validData = new ControlPlaneProtocolBuilder() .setName(ROUTE_PROTOCOL_NAME) .setType(Static.class) .addAugmentation(RoutingProtocolVppAttr.class, new RoutingProtocolVppAttrBuilder() @@ -58,7 +58,7 @@ public class RoutingProtocolCustomizerTest extends WriterCustomizerTest { .build()) .build(); - validData2= new RoutingProtocolBuilder() + validData2= new ControlPlaneProtocolBuilder() .setName(ROUTE_PROTOCOL_NAME_2) .setType(Static.class) .addAugmentation(RoutingProtocolVppAttr.class, new RoutingProtocolVppAttrBuilder() @@ -68,12 +68,12 @@ public class RoutingProtocolCustomizerTest extends WriterCustomizerTest { .build()) .build(); - invalidData = new RoutingProtocolBuilder() + invalidData = new ControlPlaneProtocolBuilder() .setType(Direct.class) .build(); routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context"); - customizer = new RoutingProtocolCustomizer(routingProtocolContext); + customizer = new ControlPlaneProtocolCustomizer(routingProtocolContext); } @Test diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java index b97658669..41a1ae6d1 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java @@ -16,6 +16,14 @@ package io.fd.hc2vpp.routing.write; +import static io.fd.hc2vpp.routing.Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; +import static io.fd.hc2vpp.routing.Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; +import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_INDEX; +import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_NAME; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import com.google.common.collect.ImmutableList; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; @@ -36,32 +44,21 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.TableLookupBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.table.lookup.TableLookupParamsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; - - - +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv4; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.route.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.TableLookupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import static io.fd.hc2vpp.routing.Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; -import static io.fd.hc2vpp.routing.Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; -import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_INDEX; -import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_NAME; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - @RunWith(HoneycombTestRunner.class) public class Ipv4RouteCustomizerTest extends WriterCustomizerTest implements ClassifyTableTestHelper, RoutingRequestTestHelper, SchemaContextTestHelper { @@ -89,8 +86,8 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest new NamingContext("route", "route-context"), routingProtocolContext, routeHopContext, classifyManager); - validId = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)) + validId = InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)) .child(StaticRoutes.class) .augmentation(StaticRoutes1.class) .child(Ipv4.class) @@ -108,7 +105,7 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest public void testWriteSingleHop( @InjectTestData(resourcePath = "/ipv4/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - final Route route1 = getIpv4RouteWithId(route, 1L); + final Route route1 = getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context"); customizer.writeCurrentAttributes(validId, route1, writeContext); @@ -123,13 +120,12 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest @Test public void testWriteTableLookup() throws WriteFailedException { final Route route = new RouteBuilder() - .setKey(new RouteKey(2L)) + .setKey(new RouteKey(new Ipv4Prefix("192.168.2.1/24"))) .setDestinationPrefix(new Ipv4Prefix("192.168.2.1/24")) - .setNextHopOptions(new TableLookupBuilder() - .setTableLookupParams(new TableLookupParamsBuilder() - .setSecondaryVrf(new VniReference(4L)) - .build()) - .build()) + .setNextHop(new NextHopBuilder().setNextHopOptions( + new TableLookupCaseBuilder() + .setSecondaryVrf(new VniReference(4L)) + .build()).build()) .build(); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route), "route-context"); customizer.writeCurrentAttributes(validId, route, writeContext); @@ -142,9 +138,10 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest @Test public void testWriteHopList( - @InjectTestData(resourcePath = "/ipv4/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) + @InjectTestData(resourcePath = "/ipv4/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) + StaticRoutes route) throws WriteFailedException { - final Route route1 = getIpv4RouteWithId(route, 1L); + final Route route1 = getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context"); customizer.writeCurrentAttributes(validId, route1, writeContext); @@ -174,21 +171,24 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest public void testWriteSpecialHop( @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - final Route route1 = getIpv4RouteWithId(route, 1L); + final Route route1 = getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context"); customizer.writeCurrentAttributes(validId, route1, writeContext); verifyInvocation(1, ImmutableList - .of(desiredSpecialResult(1, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, - requestCaptor); + .of(desiredSpecialResult(1, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, + ROUTE_PROTOCOL_INDEX, 0)), + api, requestCaptor); } @Test public void testUpdate( @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) { try { - customizer.updateCurrentAttributes(validId, new RouteBuilder().build(), getIpv4RouteWithId(route, 1L), - writeContext); + customizer.updateCurrentAttributes(validId, + new RouteBuilder().build(), + getIpv4RouteWithId(route, + new Ipv4Prefix("192.168.2.1/24")), writeContext); } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof UnsupportedOperationException); verifyNotInvoked(api); @@ -202,18 +202,21 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest public void testDeleteSingleHop( @InjectTestData(resourcePath = "/ipv4/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - customizer.deleteCurrentAttributes(validId, getIpv4RouteWithId(route, 1L), writeContext); + customizer.deleteCurrentAttributes(validId, + getIpv4RouteWithId(route, + new Ipv4Prefix("192.168.2.1/24")), writeContext); verifyInvocation(1, ImmutableList .of(desiredFlaglessResult(0, 0, 0, FIRST_ADDRESS_AS_ARRAY, 24, SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, - 0, ROUTE_PROTOCOL_INDEX, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor); + 0, ROUTE_PROTOCOL_INDEX, 0, CLASSIFY_TABLE_INDEX, 1)), + api, requestCaptor); } @Test public void testDeleteHopList( @InjectTestData(resourcePath = "/ipv4/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - final Route route1 = getIpv4RouteWithId(route, 1L); + final Route route1 = getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context"); customizer.deleteCurrentAttributes(validId, route1, writeContext); @@ -242,10 +245,11 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest public void testDeleteSpecialHop( @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { - customizer.deleteCurrentAttributes(validId, getIpv4RouteWithId(route, 1L), writeContext); + customizer.deleteCurrentAttributes(validId, getIpv4RouteWithId(route, new Ipv4Prefix("192.168.2.1/24")), writeContext); verifyInvocation(1, - ImmutableList.of(desiredSpecialResult(0, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, - requestCaptor); + ImmutableList.of(desiredSpecialResult(0, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, + ROUTE_PROTOCOL_INDEX, 0)), + api, requestCaptor); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java index a68fa57c4..171b59786 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java @@ -16,6 +16,9 @@ package io.fd.hc2vpp.routing.write; +import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_INDEX; +import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_NAME; + import com.google.common.collect.ImmutableList; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; @@ -36,28 +39,27 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.TableLookupBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.table.lookup.TableLookupParamsBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.RoutingProtocols; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev170917.VniReference; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.RouteKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.route.NextHopBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Static; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.TableLookupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.ControlPlaneProtocols; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocol; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.ControlPlaneProtocolKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.types.rev180406.VniReference; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_INDEX; -import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_NAME; - @RunWith(HoneycombTestRunner.class) public class Ipv6RouteCustomizerTest extends WriterCustomizerTest implements RoutingRequestTestHelper, ClassifyTableTestHelper, SchemaContextTestHelper { private static final int ROUTE_PROTOCOL_INDEX = 1; + public static final Ipv6Prefix IPV_6_PREFIX = new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64"); @Captor private ArgumentCaptor<IpAddDelRoute> requestCaptor; @@ -84,8 +86,8 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest new Ipv6RouteCustomizer(api, interfaceContext, routeContext, routingProtocolContext, routeHopContext, classifyManager); - validId = InstanceIdentifier.create(RoutingProtocols.class) - .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME)) + validId = InstanceIdentifier.create(ControlPlaneProtocols.class) + .child(ControlPlaneProtocol.class, new ControlPlaneProtocolKey(ROUTE_PROTOCOL_NAME, Static.class)) .child(StaticRoutes.class) .augmentation(StaticRoutes1.class) .child(Ipv6.class) @@ -103,7 +105,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); + customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(1, ImmutableList .of(desiredFlaglessResult(1, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, ROUTE_PROTOCOL_INDEX, @@ -114,19 +116,17 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @Test public void testWriteTableLookup() throws WriteFailedException { final Route route = new RouteBuilder() - .setKey(new RouteKey(2L)) - .setDestinationPrefix(new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/24")) - .setNextHopOptions(new TableLookupBuilder() - .setTableLookupParams(new TableLookupParamsBuilder() - .setSecondaryVrf(new VniReference(4L)) - .build()) - .build()) + .setKey(new RouteKey(IPV_6_PREFIX)) + .setDestinationPrefix(IPV_6_PREFIX) + .setNextHop(new NextHopBuilder().setNextHopOptions(new TableLookupCaseBuilder() + .setSecondaryVrf(new VniReference(4L)) + .build()).build()) .build(); whenAddRouteThenSuccess(api); noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route), "route-context"); customizer.writeCurrentAttributes(validId, route, writeContext); verifyInvocation(1, ImmutableList - .of(desiredFlaglessResult(1, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, + .of(desiredFlaglessResult(1, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, new byte[4], ~0, 0, ROUTE_PROTOCOL_INDEX, 4, 0, 0)), api, requestCaptor); @@ -137,7 +137,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); + customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(2, ImmutableList.of( desiredFlaglessResult(1, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, @@ -160,11 +160,12 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), + customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(1, ImmutableList - .of(desiredSpecialResult(0, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, - requestCaptor); + .of(desiredSpecialResult(0, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, + 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), + api, requestCaptor); } @Test @@ -172,7 +173,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); + customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(1, ImmutableList .of(desiredFlaglessResult(0, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, @@ -184,7 +185,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/multihop/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); + customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(2, ImmutableList.of( desiredFlaglessResult(0, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, @@ -201,10 +202,11 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) throws WriteFailedException { whenAddRouteThenSuccess(api); - customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), + customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, IPV_6_PREFIX), writeContext); verifyInvocation(1, ImmutableList - .of(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, - requestCaptor); + .of(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, + 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), + api, requestCaptor); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java index 86c2df115..7321acde5 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java @@ -31,41 +31,43 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaPrefix; import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaPrefixReply; import org.junit.Test; import org.junit.runner.RunWith; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.Interface1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.Ipv6RouterAdvertisements; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.PrefixList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.ipv6.router.advertisements.prefix.list.Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.Interfaces; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.Ipv61; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.Ipv6RouterAdvertisements; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.PrefixList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.ipv6.router.advertisements.prefix.list.Prefix; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @RunWith(HoneycombTestRunner.class) public class PrefixCustomizerTest extends WriterCustomizerTest implements SchemaContextTestHelper { - private static final String INSTANCE_NAME = "tst-protocol"; private static final String CTX_NAME = "interface-context"; private static final String IFC_NAME = "eth0"; private static final int IFC_INDEX = 1; - private static final InstanceIdentifier<Prefix> IID = InstanceIdentifier.create(Routing.class) - .child(RoutingInstance.class, new RoutingInstanceKey(INSTANCE_NAME)).child(Interfaces.class) - .child(Interface.class, new InterfaceKey(IFC_NAME)).augmentation( - Interface1.class).child(Ipv6RouterAdvertisements.class).child(PrefixList.class).child(Prefix.class); + private static final InstanceIdentifier<Prefix> IID = InstanceIdentifier + .create(Interfaces.class) + .child(Interface.class, new InterfaceKey(IFC_NAME)) + .augmentation(Interface1.class) + .child(Ipv6.class) + .augmentation(Ipv61.class) + .child(Ipv6RouterAdvertisements.class) + .child(PrefixList.class) + .child(Prefix.class); - private static final String RA_PATH = "/hc2vpp-ietf-routing:routing" + - "/hc2vpp-ietf-routing:routing-instance[hc2vpp-ietf-routing:name='" + INSTANCE_NAME + "']" + - "/hc2vpp-ietf-routing:interfaces" + - "/hc2vpp-ietf-routing:interface[hc2vpp-ietf-routing:name='" + IFC_NAME + "']" + + private static final String RA_PATH = "/ietf-interfaces:interfaces" + + "/ietf-interfaces:interface[ietf-interfaces:name='" + IFC_NAME + "']" + + "/ietf-ip:ipv6" + "/hc2vpp-ietf-ipv6-unicast-routing:ipv6-router-advertisements/hc2vpp-ietf-ipv6-unicast-routing:prefix-list"; private PrefixCustomizer customizer; private NamingContext interfaceContext = new NamingContext("ifaces", CTX_NAME); @Override - protected void setUpTest() throws Exception { + protected void setUpTest() { customizer = new PrefixCustomizer(api, interfaceContext); defineMapping(mappingContext, IFC_NAME, IFC_INDEX, CTX_NAME); when(api.swInterfaceIp6NdRaPrefix(any())).thenReturn(future(new SwInterfaceIp6NdRaPrefixReply())); @@ -80,7 +82,8 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema request.swIfIndex = IFC_INDEX; // 2001:0db8:0a0b:12f0:0000:0000:0000:0002/64 - request.address = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; + request.address = + new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; request.addressLength = 64; request.valLifetime = 2592000; // default value request.prefLifetime = 604800; // default value @@ -96,7 +99,8 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema request.swIfIndex = IFC_INDEX; // 2001:0db8:0a0b:12f0:0000:0000:0000:0002/64 - request.address = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; + request.address = + new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; request.addressLength = 64; request.noAdvertise = 1; request.noAutoconfig = 1; @@ -113,7 +117,8 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema final SwInterfaceIp6NdRaPrefix request = new SwInterfaceIp6NdRaPrefix(); request.swIfIndex = IFC_INDEX; // 2001:0db8:0a0b:12f0:0000:0000:0000:0002/64 - request.address = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; + request.address = + new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02}; request.addressLength = 64; request.isNo = 1; verify(api).swInterfaceIp6NdRaPrefix(request); @@ -122,4 +127,4 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema private static Prefix getPrefix(final PrefixList prefixList) { return prefixList.getPrefix().get(0); } -}
\ No newline at end of file +} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizerTest.java index dc7dddbca..7e92d1654 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RouterAdvertisementsCustomizerTest.java @@ -31,38 +31,37 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaConfig; import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaConfigReply; import org.junit.Test; import org.junit.runner.RunWith; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.Interface1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.interfaces._interface.Ipv6RouterAdvertisements; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.Interfaces; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.Ipv61; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.interfaces._interface.ipv6.Ipv6RouterAdvertisements; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @RunWith(HoneycombTestRunner.class) public class RouterAdvertisementsCustomizerTest extends WriterCustomizerTest implements SchemaContextTestHelper { - private static final String INSTANCE_NAME = "tst-protocol"; private static final String CTX_NAME = "interface-context"; private static final String IFC_NAME = "eth0"; private static final int IFC_INDEX = 1; - private static final InstanceIdentifier<Ipv6RouterAdvertisements> IID = InstanceIdentifier.create(Routing.class) - .child(RoutingInstance.class, new RoutingInstanceKey(INSTANCE_NAME)).child(Interfaces.class) - .child(Interface.class, new InterfaceKey(IFC_NAME)).augmentation( - Interface1.class).child(Ipv6RouterAdvertisements.class); + private static final InstanceIdentifier<Ipv6RouterAdvertisements> IID = InstanceIdentifier + .create(Interfaces.class) + .child(Interface.class, new InterfaceKey(IFC_NAME)) + .augmentation(Interface1.class) + .child(Ipv6.class) + .augmentation(Ipv61.class) + .child(Ipv6RouterAdvertisements.class); - private static final String RA_PATH = "/hc2vpp-ietf-routing:routing" + - "/hc2vpp-ietf-routing:routing-instance[hc2vpp-ietf-routing:name='" + INSTANCE_NAME + "']" + - "/hc2vpp-ietf-routing:interfaces"; + private static final String RA_PATH = "/ietf-interfaces:interfaces"; private RouterAdvertisementsCustomizer customizer; private NamingContext interfaceContext = new NamingContext("ifaces", CTX_NAME); @Override - protected void setUpTest() throws Exception { + protected void setUpTest() { customizer = new RouterAdvertisementsCustomizer(api, interfaceContext); defineMapping(mappingContext, IFC_NAME, IFC_INDEX, CTX_NAME); when(api.swInterfaceIp6NdRaConfig(any())).thenReturn(future(new SwInterfaceIp6NdRaConfigReply())); @@ -106,6 +105,11 @@ public class RouterAdvertisementsCustomizerTest extends WriterCustomizerTest imp } private static Ipv6RouterAdvertisements getRA(final Interfaces ifc) { - return ifc.getInterface().get(0).getAugmentation(Interface1.class).getIpv6RouterAdvertisements(); + return ifc.getInterface() + .get(0) + .getAugmentation(Interface1.class) + .getIpv6() + .getAugmentation(Ipv61.class) + .getIpv6RouterAdvertisements(); } -}
\ No newline at end of file +} diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java deleted file mode 100644 index 2e073d726..000000000 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.fd.hc2vpp.routing.write; - -import static org.junit.Assert.fail; -import static org.mockito.Mockito.when; - -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; -import io.fd.hc2vpp.routing.RoutingConfiguration; -import org.junit.Test; -import org.mockito.Mock; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class RoutingInstanceCustomizerTest extends WriterCustomizerTest { - - private static final String VALID_NAME = "valid-name"; - private static final String INVALID_NAME = "invalid-name"; - - @Mock - private RoutingConfiguration configuration; - - private RoutingInstanceCustomizer customizer; - private InstanceIdentifier<RoutingInstance> id; - - private RoutingInstance validData; - private RoutingInstance invalidData; - - @Override - protected void setUpTest() throws Exception { - customizer = new RoutingInstanceCustomizer(configuration); - - when(configuration.getDefaultRoutingInstanceName()).thenReturn(VALID_NAME); - - id = InstanceIdentifier.create(RoutingInstance.class); - validData = new RoutingInstanceBuilder().setName(VALID_NAME).build(); - invalidData = new RoutingInstanceBuilder().setName(INVALID_NAME).build(); - } - - @Test - public void writeCurrentAttributesValid() throws Exception { - try { - customizer.writeCurrentAttributes(id, validData, writeContext); - } catch (Exception e) { - fail("Test should passed without exception"); - } - } - - @Test(expected = IllegalArgumentException.class) - public void writeCurrentAttributesInvalid() throws Exception { - customizer.writeCurrentAttributes(id, invalidData, writeContext); - } - - @Test(expected = UnsupportedOperationException.class) - public void updateCurrentAttributes() throws Exception { - customizer.updateCurrentAttributes(id, validData, validData, writeContext); - } - - @Test - public void deleteCurrentAttributesValid() throws Exception { - try { - customizer.deleteCurrentAttributes(id, validData, writeContext); - } catch (Exception e) { - fail("Test should passed without exception"); - } - } - - @Test(expected = IllegalArgumentException.class) - public void deleteCurrentAttributesInvalid() throws Exception { - customizer.deleteCurrentAttributes(id, invalidData, writeContext); - } - -}
\ No newline at end of file diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizerTest.java deleted file mode 100644 index 608e727e5..000000000 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInterfaceCustomizerTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.hc2vpp.routing.write; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -import com.google.common.base.Optional; -import io.fd.honeycomb.translate.write.WriteContext; -import io.fd.honeycomb.translate.write.WriteFailedException; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.Interfaces; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.interfaces.InterfaceKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; - -public class RoutingInterfaceCustomizerTest { - private static final String IFC_NAME = "eth0"; - - @Mock - private WriteContext ctx; - private RoutingInterfaceCustomizer customizer; - - @Before - public final void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - customizer = new RoutingInterfaceCustomizer(); - - when(ctx.readAfter(any())).thenReturn(Optional.absent()); - final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey> - id = InstanceIdentifier.create( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces.class) - .child( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface.class, - new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey( - IFC_NAME)); - when(ctx.readAfter(id)).thenReturn(Optional.of(mock(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface.class))); - } - - @Test(expected = IllegalArgumentException.class) - public void testWriteIfcNotConfigured() throws WriteFailedException { - final String nonExistingIfcName = "someIfc"; - final Interface ifc = mock(Interface.class); - when(ifc.getName()).thenReturn(nonExistingIfcName); - customizer.writeCurrentAttributes(getId(nonExistingIfcName), ifc, ctx); - } - - @Test - public void testUpdate() throws WriteFailedException { - final Interface ifc = mock(Interface.class); - when(ifc.getName()).thenReturn(IFC_NAME); - customizer.updateCurrentAttributes(getId(IFC_NAME), ifc, ifc, ctx); - } - - @Test - public void testDelete() throws WriteFailedException { - final Interface ifc = mock(Interface.class); - when(ifc.getName()).thenReturn(IFC_NAME); - customizer.deleteCurrentAttributes(getId(IFC_NAME), ifc, ctx); - verifyZeroInteractions(ctx); - } - - private InstanceIdentifier<Interface> getId(final String ifcName) { - return InstanceIdentifier.create(Routing.class) - .child(RoutingInstance.class, new RoutingInstanceKey("routingInstance")).child(Interfaces.class) - .child(Interface.class, new InterfaceKey(ifcName)); - } -}
\ No newline at end of file diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java index a17dfa3fb..b4ec3d91d 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java @@ -16,7 +16,6 @@ package io.fd.hc2vpp.routing.write.factory; - import static org.junit.Assert.assertEquals; import io.fd.hc2vpp.common.translate.util.NamingContext; @@ -36,10 +35,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class MultipathHopRequestFactoryIpv4Test @@ -85,26 +85,32 @@ public class MultipathHopRequestFactoryIpv4Test defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context"); defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); - ipv4MutlipathRouteWithClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithClassifier, 1L); + ipv4MutlipathRouteWithClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithClassifier, + new Ipv4Prefix("192.168.2.1/24")); final List<NextHop> ipv4HopsClassified = - NextHopList.class.cast(ipv4MutlipathRouteWithClassifier.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv4MutlipathRouteWithClassifier.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); ipv4nextHopWithClassifier = - ipv4HopsClassified.stream().filter(nextHop -> nextHop.getId() == 1L).findFirst().get(); + ipv4HopsClassified.stream().filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) + .findFirst().get(); - ipv4MutlipathRouteWithoutClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithoutClassifier, 1L); + ipv4MutlipathRouteWithoutClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithoutClassifier, + new Ipv4Prefix("192.168.2.1/24")); final List<NextHop> ipv4HopsNonClassified = - NextHopList.class.cast(ipv4MutlipathRouteWithoutClassifier.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv4MutlipathRouteWithoutClassifier.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); ipv4nextHopWithoutClassifier = - ipv4HopsNonClassified.stream().filter(nextHop -> nextHop.getId() == 1L).findFirst().get(); + ipv4HopsNonClassified.stream().filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) + .findFirst().get(); - ipv4MutlipathRouteWithoutRouteAtts = getIpv4RouteWithId(ipv4StaticRoutesWithoutRouteAttrs, 1L); + ipv4MutlipathRouteWithoutRouteAtts = getIpv4RouteWithId(ipv4StaticRoutesWithoutRouteAttrs, + new Ipv4Prefix("192.168.2.1/24")); final List<NextHop> ipv4HopsNonRouteAttrs = - NextHopList.class.cast(ipv4MutlipathRouteWithoutRouteAtts.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv4MutlipathRouteWithoutRouteAtts.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); ipv4nextHopWithoutRouteAtts = - ipv4HopsNonClassified.stream().filter(nextHop -> nextHop.getId() == 1L).findFirst().get(); + ipv4HopsNonClassified.stream().filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) + .findFirst().get(); } @Test diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java index 50bd106ed..50ada6ef3 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java @@ -35,10 +35,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.NextHopList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.next.hop.content.next.hop.options.next.hop.list.next.hop.list.NextHop; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class MultipathHopRequestFactoryIpv6Test @@ -78,22 +79,26 @@ public class MultipathHopRequestFactoryIpv6Test defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context"); defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); - ipv6MultipathRouteWithClassifier = getIpv6RouteWithId(ipv6StaticRoutesWithClassifier, 1L); - ipv6MultipathRouteWithoutClassifier = getIpv6RouteWithId(ipv6StaticRoutesWithoutClassifier, 1L); + ipv6MultipathRouteWithClassifier = + getIpv6RouteWithId(ipv6StaticRoutesWithClassifier, + new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64")); + ipv6MultipathRouteWithoutClassifier = + getIpv6RouteWithId(ipv6StaticRoutesWithoutClassifier, + new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64")); final List<NextHop> ipv6HopsClassified = - NextHopList.class.cast(ipv6MultipathRouteWithClassifier.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv6MultipathRouteWithClassifier.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); final List<NextHop> ipv6HopsNonClassified = - NextHopList.class.cast(ipv6MultipathRouteWithoutClassifier.getNextHopOptions()).getNextHopList() - .getNextHop(); + NextHopList.class.cast(ipv6MultipathRouteWithoutClassifier.getNextHop().getNextHopOptions()) + .getNextHopList().getNextHop(); ipv6nextHopForClassified = ipv6HopsClassified.stream() - .filter(nextHop -> nextHop.getId() == 1L) + .filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) .findFirst().get(); ipv6nextHopForNonClassified = ipv6HopsNonClassified.stream() - .filter(nextHop -> nextHop.getId() == 1L) + .filter(nextHop -> Integer.valueOf(nextHop.getIndex()) == 1L) .findFirst().get(); } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java index 15951f48e..6457feba2 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java @@ -34,8 +34,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class SimpleHopRequestFactoryIpv4Test @@ -66,10 +67,10 @@ public class SimpleHopRequestFactoryIpv4Test @Test public void testIpv4WithClassifier( @InjectTestData(resourcePath = "/ipv4/simplehop/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) - StaticRoutes ipv4StaticRouteWithClassifier) { + StaticRoutes ipv4StaticRouteWithClassifier) { final IpAddDelRoute request = factory.createIpv4SimpleHopRequest(false, ROUTE_PROTOCOL_NAME, - getIpv4RouteWithId(ipv4StaticRouteWithClassifier, 1L), + getIpv4RouteWithId(ipv4StaticRouteWithClassifier, new Ipv4Prefix("192.168.2.1/24")), mappingContext); assertEquals(desiredFlaglessResult(0, 0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, @@ -88,7 +89,8 @@ public class SimpleHopRequestFactoryIpv4Test assertEquals( desiredFlaglessResult(0, 0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 0, 0, 0), request); + Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 0, 0, 0), + request); } @Test @@ -102,6 +104,7 @@ public class SimpleHopRequestFactoryIpv4Test assertEquals( desiredFlaglessResult(0, 0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 0, 0, 0), request); + Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 0, 0, 0), + request); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java index c50a14ab4..eadb3995d 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java @@ -34,8 +34,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class SimpleHopRequestFactoryIpv6Test diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java index 7fcc77737..bce1b5167 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java @@ -18,9 +18,10 @@ package io.fd.hc2vpp.routing.write.factory; import static io.fd.hc2vpp.routing.write.factory.SpecialNextHopRequestFactory.forContexts; import static org.junit.Assert.assertEquals; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Prohibit; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Receive; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Unreachable; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Blackhole; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Prohibit; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Receive; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Unreachable; import io.fd.hc2vpp.common.test.util.NamingContextHelper; import io.fd.hc2vpp.common.translate.util.NamingContext; @@ -40,10 +41,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv4.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class SpecialNextHopRequestFactoryIpv4Test @@ -52,6 +53,8 @@ public class SpecialNextHopRequestFactoryIpv4Test private static final String PARENT_PROTOCOL_4 = "parent-protocol-4"; private static final int PARENT_PROTOCOL_4_INDEX = 4; + public static final Ipv4Prefix IPV_4_PREFIX = new Ipv4Prefix("192.168.2.1/24"); + public static final int DST_PREFIX = 24; @Mock private VppClassifierContextManager classifierContextManager; @@ -79,12 +82,14 @@ public class SpecialNextHopRequestFactoryIpv4Test @Test public void testIpv4WithClassifierBlackhole( @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) - StaticRoutes routes) { + StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, - SpecialNextHopGrouping.SpecialNextHop.Blackhole); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, IPV_4_PREFIX), + mappingContext, Blackhole); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 1, 0, 0, 0, + PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), + request); } @Test @@ -92,9 +97,12 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteReceive.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, Receive); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, IPV_4_PREFIX), + mappingContext, Receive); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 1, 0, 0, + PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), + request); } @Test @@ -102,9 +110,12 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteUnreachable.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, Unreachable); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, IPV_4_PREFIX), + mappingContext, Unreachable); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 0, 1, 0, + PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), + request); } @Test @@ -112,14 +123,17 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteProhibited.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true,PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, Prohibit); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, IPV_4_PREFIX), + mappingContext, Prohibit); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 0, 0, 1, + PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), + request); } - private Route extractSingleRoute(final StaticRoutes staticRoutes, final long id) { + private Route extractSingleRoute(final StaticRoutes staticRoutes, final Ipv4Prefix id) { return staticRoutes.getAugmentation(StaticRoutes1.class).getIpv4().getRoute().stream() - .filter(route -> route.getId() == id) + .filter(route -> route.getDestinationPrefix().getValue().equals(id.getValue())) .collect(RWUtils.singleItemCollector()); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java index 9ebe1145f..4e0a0efd5 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java @@ -18,10 +18,10 @@ package io.fd.hc2vpp.routing.write.factory; import static io.fd.hc2vpp.routing.write.trait.RouteRequestProducer.DEFAULT_VNI; import static org.junit.Assert.assertEquals; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Blackhole; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Prohibit; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Receive; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Unreachable; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Blackhole; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Prohibit; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Receive; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.SpecialNextHop.SpecialNextHopEnum.Unreachable; import io.fd.hc2vpp.common.test.util.NamingContextHelper; import io.fd.hc2vpp.common.translate.util.NamingContext; @@ -40,9 +40,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.StaticRoutes1; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev170917.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.StaticRoutes1; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev180313.routing.control.plane.protocols.control.plane.protocol._static.routes.ipv6.Route; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.routing.control.plane.protocols.control.plane.protocol.StaticRoutes; @RunWith(HoneycombTestRunner.class) public class SpecialNextHopRequestFactoryIpv6Test @@ -50,6 +51,8 @@ public class SpecialNextHopRequestFactoryIpv6Test private static final String PARENT_PROTOCOL_6 = "parent-protocol-6"; private static final int PARENT_PROTOCOL_6_INDEX = 6; + public static final Ipv6Prefix IPV_6_PREFIX = new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64"); + public static final int DST_PREFIX = 64; @Mock private VppClassifierContextManager classifierContextManager; @@ -66,8 +69,10 @@ public class SpecialNextHopRequestFactoryIpv6Test public void init() { MockitoAnnotations.initMocks(this); interfaceContext = new NamingContext("iface", "interface-context"); - routingProtocolContextContext = new NamingContext("routingProtocol", "routing-protocol-context"); - factory = SpecialNextHopRequestFactory.forContexts(classifierContextManager, interfaceContext, routingProtocolContextContext); + routingProtocolContextContext = + new NamingContext("routingProtocol", "routing-protocol-context"); + factory = SpecialNextHopRequestFactory.forContexts(classifierContextManager, interfaceContext, + routingProtocolContextContext); addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext); defineMapping(mappingContext, PARENT_PROTOCOL_6, PARENT_PROTOCOL_6_INDEX, "routing-protocol-context"); @@ -76,12 +81,14 @@ public class SpecialNextHopRequestFactoryIpv6Test @Test public void testIpv6Blackhole( @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) - StaticRoutes routes) { + StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Blackhole); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, IPV_6_PREFIX), + mappingContext, Blackhole); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), - request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 1, 0, 0, 0, + PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), + request); } @Test @@ -89,9 +96,12 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteReceive.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Receive); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, IPV_6_PREFIX), + mappingContext, Receive); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 1, 0, 0, + PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), + request); } @Test @@ -99,9 +109,12 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteUnreachable.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Unreachable); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, IPV_6_PREFIX), + mappingContext, Unreachable); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 0, 1, 0, + PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), + request); } @Test @@ -109,14 +122,17 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteProhibited.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Prohibit); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, IPV_6_PREFIX), + mappingContext, Prohibit); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, DST_PREFIX, 0, 0, 0, 1, + PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), + request); } - private Route extractSingleRoute(final StaticRoutes staticRoutes, final long id) { + private Route extractSingleRoute(final StaticRoutes staticRoutes, final Ipv6Prefix id) { return staticRoutes.getAugmentation(StaticRoutes1.class).getIpv6().getRoute().stream() - .filter(route -> route.getId() == id).collect( + .filter(route -> route.getDestinationPrefix().getValue().equals(id.getValue())).collect( RWUtils.singleItemCollector()); } |