diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-05-20 09:51:30 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-05-24 08:36:45 +0000 |
commit | 73b9a20da65a98f23a14f9d14536baf7c85f0ac0 (patch) | |
tree | 2cb2471064751485f976844a2f479f701c3f28a8 /v3po/v3po2vpp/src/test/java/io | |
parent | 5d8564699f2d304349ade4982f83147cb08b76a7 (diff) |
HONEYCOMB-61: Extend VPP initializers to initialize everything readers provide
Change-Id: Ic7c82f4abfb3bd1bb5065fdfc9c080ed3ba6c94c
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io')
3 files changed, 44 insertions, 11 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VlanTagRewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VlanTagRewriteCustomizerTest.java index 39a9823b5..639257914 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VlanTagRewriteCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VlanTagRewriteCustomizerTest.java @@ -26,6 +26,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; +import com.google.common.base.Optional; import io.fd.honeycomb.v3po.translate.MappingContext; import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext; import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException; @@ -39,7 +40,9 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; 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.InterfaceBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.SubInterface; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.TagRewriteOperation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VlanTag; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VlanType; @@ -140,6 +143,9 @@ public class VlanTagRewriteCustomizerTest { final InstanceIdentifier<VlanTagRewrite> id = getVlanTagRewriteId(VLAN_IF_NAME); whenL2InterfaceVlanTagRewriteThenSuccess(); + // Vlan Tag rewrite is checking ifc type by reading its configuration from write context + doReturn(Optional.of(new InterfaceBuilder().setType(SubInterface.class).build())) + .when(writeContext).readAfter(any(InstanceIdentifier.class)); customizer.writeCurrentAttributes(id, vlanTagRewrite, writeContext); @@ -153,6 +159,9 @@ public class VlanTagRewriteCustomizerTest { final InstanceIdentifier<VlanTagRewrite> id = getVlanTagRewriteId(VLAN_IF_NAME); whenL2InterfaceVlanTagRewriteThenFailure(); + // Vlan Tag rewrite is checking ifc type by reading its configuration from write context + doReturn(Optional.of(new InterfaceBuilder().setType(SubInterface.class).build())) + .when(writeContext).readAfter(any(InstanceIdentifier.class)); try { customizer.writeCurrentAttributes(id, vlanTagRewrite, writeContext); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2CustomizerTest.java index b09381584..b4bf1e115 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2CustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2CustomizerTest.java @@ -34,7 +34,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.Mappings; @@ -52,6 +51,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.l2.interconnection.BridgeBasedBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; +import org.openvpp.jvpp.dto.BridgeDomainDetails; import org.openvpp.jvpp.dto.BridgeDomainDetailsReplyDump; import org.openvpp.jvpp.dto.BridgeDomainDump; import org.openvpp.jvpp.dto.BridgeDomainSwIfDetails; @@ -91,15 +91,16 @@ public class L2CustomizerTest extends ChildReaderCustomizerTest<L2, L2Builder> { VppInterfaceStateAugmentation.class).child(L2.class); } - private void whenBridgeDomainSwIfDumpThenReturn(final List<BridgeDomainSwIfDetails> bdSwIfList) + private void whenBridgeDomainSwIfDumpThenReturn(final List<BridgeDomainSwIfDetails> bdSwIfList, + final List<BridgeDomainDetails> bridgeDomainDetailses) throws ExecutionException, InterruptedException { - final CompletionStage<BridgeDomainDetailsReplyDump> replyCS = mock(CompletionStage.class); - final CompletableFuture<BridgeDomainDetailsReplyDump> replyFuture = mock(CompletableFuture.class); - when(replyCS.toCompletableFuture()).thenReturn(replyFuture); final BridgeDomainDetailsReplyDump reply = new BridgeDomainDetailsReplyDump(); reply.bridgeDomainSwIfDetails = bdSwIfList; - when(replyFuture.get()).thenReturn(reply); - when(api.bridgeDomainSwIfDump(any(BridgeDomainDump.class))).thenReturn(replyCS); + reply.bridgeDomainDetails = bridgeDomainDetailses; + + final CompletableFuture<BridgeDomainDetailsReplyDump> replyFuture = new CompletableFuture<>(); + replyFuture.complete(reply); + when(api.bridgeDomainSwIfDump(any(BridgeDomainDump.class))).thenReturn(replyFuture); } @@ -111,10 +112,14 @@ public class L2CustomizerTest extends ChildReaderCustomizerTest<L2, L2Builder> { return bdSwIfDetails; } - private Interconnection generateInterconnection(final int ifId, final String bdName) { + private Interconnection generateInterconnection(final int ifId, final String bdName, final Boolean bvi) { final BridgeBasedBuilder bbBuilder = new BridgeBasedBuilder(); bbBuilder.setBridgeDomain(bdName); bbBuilder.setSplitHorizonGroup((short) 1); + // Empty type + if(bvi != null) { + bbBuilder.setBridgedVirtualInterface(bvi); + } return bbBuilder.build(); } @@ -143,11 +148,29 @@ public class L2CustomizerTest extends ChildReaderCustomizerTest<L2, L2Builder> { cachedInterfaceDump.put(ifId, ifaceDetails); cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, cachedInterfaceDump); - whenBridgeDomainSwIfDumpThenReturn(Collections.singletonList(generateBdSwIfDetails(ifId, bdId))); + // BVI + whenBridgeDomainSwIfDumpThenReturn(Collections.singletonList(generateBdSwIfDetails(ifId, bdId)), + Collections.singletonList(generateBdDetails(ifId, bdId))); - final L2Builder builder = mock(L2Builder.class); + L2Builder builder = mock(L2Builder.class); getCustomizer().readCurrentAttributes(getL2Id(ifName), builder, ctx); - verify(builder).setInterconnection(generateInterconnection(ifId, bdName)); + verify(builder).setInterconnection(generateInterconnection(ifId, bdName, true)); + + // Not BVI + whenBridgeDomainSwIfDumpThenReturn(Collections.singletonList(generateBdSwIfDetails(ifId, bdId)), + Collections.singletonList(generateBdDetails(99 /* Different ifc is marked as BVI in bd details */, bdId))); + + builder = mock(L2Builder.class); + getCustomizer().readCurrentAttributes(getL2Id(ifName), builder, ctx); + + verify(builder).setInterconnection(generateInterconnection(ifId, bdName, null)); + } + + private BridgeDomainDetails generateBdDetails(final int ifId, final int bdId) { + final BridgeDomainDetails bridgeDomainDetails = new BridgeDomainDetails(); + bridgeDomainDetails.bviSwIfIndex = ifId; + bridgeDomainDetails.bdId = bdId; + return bridgeDomainDetails; } }
\ No newline at end of file diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VlanTagRewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VlanTagRewriteCustomizerTest.java index d00745ec1..bd1e09c11 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VlanTagRewriteCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VlanTagRewriteCustomizerTest.java @@ -85,6 +85,7 @@ public class VlanTagRewriteCustomizerTest extends ChildReaderCustomizerTest<Vlan final SwInterfaceDetails ifaceDetails = new SwInterfaceDetails(); ifaceDetails.subId = ifId; + ifaceDetails.interfaceName = ifName.getBytes(); cachedInterfaceDump.put(ifId, ifaceDetails); cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, cachedInterfaceDump); |