summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd
diff options
context:
space:
mode:
authorTibor Král <tibor.kral@pantheon.tech>2018-10-03 17:23:08 +0200
committerMichal Cmarada <mcmarada@cisco.com>2018-10-17 18:11:19 +0200
commite4c6d641269efdff2eb1212a54f06683cb99d3d3 (patch)
treeda49ebf995ee538d04f7bbe5c85d73354fb52c00 /v3po/v3po2vpp/src/test/java/io/fd
parentb3c731b754efc83230ea49cc579f8101b8750190 (diff)
HC2VPP-390: Tap v2 interface implementation
Change-Id: I92fe8adabbb770a45ad47c56f5cd21262c4bd6e1 Signed-off-by: Tibor Král <tibor.kral@pantheon.tech> Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/TapV2CustomizerTest.java162
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java7
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java2
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapV2CustomizerTest.java142
4 files changed, 310 insertions, 3 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/TapV2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/TapV2CustomizerTest.java
new file mode 100644
index 000000000..12dd43452
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/TapV2CustomizerTest.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies 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.v3po.interfaces;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
+import io.fd.hc2vpp.common.translate.util.MacTranslator;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.vpp.jvpp.core.dto.TapCreateV2;
+import io.fd.vpp.jvpp.core.dto.TapCreateV2Reply;
+import io.fd.vpp.jvpp.core.dto.TapDeleteV2;
+import io.fd.vpp.jvpp.core.dto.TapDeleteV2Reply;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.Assert;
+import org.junit.Test;
+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.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.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.yang.types.rev130715.PhysAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.interfaces._interface.TapV2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.interfaces._interface.TapV2Builder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class TapV2CustomizerTest extends WriterCustomizerTest
+ implements Ipv4Translator, Ipv6Translator, MacTranslator {
+
+ private static final String IFC_TEST_INSTANCE = "ifc-test-instance";
+ private TapV2Customizer tapCustomizer;
+ private static final String HOST_IF_NAME = "tapV21";
+ private static final String HOST_BRIDGE = "TestBridge";
+ private static final String HOST_IPV4_PREFIX = "192.168.255.100";
+ private static final byte HOST_IPV4_PREFIX_LEN = 24;
+ private static final String HOST_IPV4_GW = "192.168.255.1";
+ private static final String HOST_IPV6_PREFIX = "a::100";
+ private static final String HOST_IPV6_GW = "a::1";
+ private static final byte HOST_IPV6_PREFIX_LEN = -128;
+ private static final int HOST_IPV6_PREFIX_LEN_EXP = 128;
+ private static final int RX_TX_RING_SIZE = 512;
+ private static final String HOST_MAC = "00:ee:ee:ee:ee:ee";
+ private static final String HOST_NAMESPACE = "testHostNS";
+
+ @Override
+ public void setUpTest() throws Exception {
+ InterfaceTypeTestUtils.setupWriteContext(writeContext,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.TapV2.class);
+ tapCustomizer = new TapV2Customizer(api, new NamingContext("ifcintest", IFC_TEST_INSTANCE));
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ final AtomicInteger idx = new AtomicInteger(0);
+ doAnswer((i) -> {
+ final TapCreateV2 tapData = i.getArgument(0);
+ if (tapData == null) {
+ return failedFuture();
+ }
+
+ Assert.assertArrayEquals(tapData.hostBridge, HOST_BRIDGE.getBytes());
+ Assert.assertEquals(tapData.hostBridgeSet, 1);
+ Assert.assertArrayEquals(tapData.hostIfName, HOST_IF_NAME.getBytes());
+ Assert.assertEquals(tapData.hostIfNameSet, 1);
+ Assert.assertArrayEquals(tapData.hostNamespace, HOST_NAMESPACE.getBytes());
+ Assert.assertEquals(tapData.hostNamespaceSet, 1);
+ Assert.assertArrayEquals(tapData.hostIp4Addr, ipv4AddressPrefixToArray(
+ new Ipv4Prefix(String.format("%s/%d", HOST_IPV4_PREFIX, HOST_IPV4_PREFIX_LEN))));
+ Assert.assertEquals(tapData.hostIp4AddrSet, 1);
+ Assert.assertEquals(tapData.hostIp4PrefixLen, HOST_IPV4_PREFIX_LEN);
+ Assert.assertArrayEquals(tapData.hostIp6Addr, ipv6AddressPrefixToArray(
+ new Ipv6Prefix(String.format("%s/%d", HOST_IPV6_PREFIX, HOST_IPV6_PREFIX_LEN_EXP))));
+ Assert.assertEquals(tapData.hostIp6AddrSet, 1);
+ Assert.assertEquals(tapData.hostIp6PrefixLen, HOST_IPV6_PREFIX_LEN);
+ Assert.assertArrayEquals(tapData.hostIp4Gw, ipv4AddressPrefixToArray(
+ new Ipv4Prefix(String.format("%s/%d", HOST_IPV4_GW, 24))));
+ Assert.assertEquals(tapData.hostIp4GwSet, 1);
+ Assert.assertArrayEquals(tapData.hostIp6Gw, ipv6AddressPrefixToArray(
+ new Ipv6Prefix(String.format("%s/%d", HOST_IPV6_GW, 96))));
+ Assert.assertEquals(tapData.hostIp6GwSet, 1);
+ Assert.assertArrayEquals(tapData.hostMacAddr, parseMac(HOST_MAC));
+ Assert.assertEquals(tapData.hostMacAddrSet, 1);
+ Assert.assertEquals(tapData.rxRingSz, RX_TX_RING_SIZE);
+ Assert.assertEquals(tapData.txRingSz, RX_TX_RING_SIZE);
+ final TapCreateV2Reply t = new TapCreateV2Reply();
+ t.swIfIndex = idx.getAndIncrement();
+ return future(t);
+
+ }).when(api).tapCreateV2(any(TapCreateV2.class));
+
+ tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap"), writeContext);
+ tapCustomizer.writeCurrentAttributes(getTapId("tap2"), getTapData("tap2"), writeContext);
+
+ verify(api, times(2)).tapCreateV2(any(TapCreateV2.class));
+ verify(mappingContext).put(eq(mappingIid("tap", IFC_TEST_INSTANCE)), eq(
+ mapping("tap", 0).get()));
+ verify(mappingContext).put(eq(mappingIid("tap2", IFC_TEST_INSTANCE)), eq(
+ mapping("tap2", 1).get()));
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ final TapCreateV2Reply t = new TapCreateV2Reply();
+ t.swIfIndex = 0;
+ doReturn(future(t)).when(api).tapCreateV2(any(TapCreateV2.class));
+
+ doReturn(future(new TapDeleteV2Reply())).when(api).tapDeleteV2(any(TapDeleteV2.class));
+ tapCustomizer.writeCurrentAttributes(getTapId("tap-v2"), getTapData("tap-v2"), writeContext);
+ defineMapping(mappingContext, "tap-v2", 1, IFC_TEST_INSTANCE);
+ tapCustomizer.deleteCurrentAttributes(getTapId("tap-v2"), getTapData("tap-v2"), writeContext);
+
+ verify(api).tapCreateV2(any(TapCreateV2.class));
+ verify(api).tapDeleteV2(any(TapDeleteV2.class));
+ verify(mappingContext).delete(eq(mappingIid("tap-v2", IFC_TEST_INSTANCE)));
+ }
+
+ private InstanceIdentifier<TapV2> getTapId(final String tap) {
+ return InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(tap)).augmentation(
+ VppInterfaceAugmentation.class).child(TapV2.class);
+ }
+
+ private TapV2 getTapData(final String tap) {
+ return new TapV2Builder()
+ .setHostInterfaceName(HOST_IF_NAME)
+ .setMac(new PhysAddress(HOST_MAC))
+ .setTag(tap + "_tag")
+ .setHostBridge(HOST_BRIDGE)
+ .setHostIpv4Address(new Ipv4Prefix(String.format("%s/%s", HOST_IPV4_PREFIX, HOST_IPV4_PREFIX_LEN)))
+ .setHostIpv4Gateway(new Ipv4Address(HOST_IPV4_GW))
+ .setHostIpv6Address(new Ipv6Prefix(String.format("%s/%s", HOST_IPV6_PREFIX, HOST_IPV6_PREFIX_LEN_EXP)))
+ .setHostIpv6Gateway(new Ipv6Address(HOST_IPV6_GW))
+ .setRxRingSize(RX_TX_RING_SIZE)
+ .setTxRingSize(RX_TX_RING_SIZE)
+ .setHostMac(new PhysAddress(HOST_MAC))
+ .setHostNamespace(HOST_NAMESPACE)
+ .build();
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java
index 17665ee30..a3864e583 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java
@@ -34,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.AfPacket;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.Tap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.TapV2;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.VhostUser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.VxlanGpeTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.VxlanTunnel;
@@ -61,7 +62,8 @@ public class InterfaceDataTranslatorTest implements InterfaceDataTranslator {
@Test
public void testGetInterfaceType() {
- assertEquals(Tap.class, getInterfaceType("tap0"));
+ assertEquals(Tap.class, getInterfaceType("tapcli-0"));
+ assertEquals(TapV2.class, getInterfaceType("tap0"));
assertEquals(VxlanTunnel.class, getInterfaceType("vxlan0"));
assertEquals(VxlanGpeTunnel.class, getInterfaceType("vxlan_gpe0"));
assertEquals(VhostUser.class, getInterfaceType("VirtualEthernet0/0/0"));
@@ -72,7 +74,8 @@ public class InterfaceDataTranslatorTest implements InterfaceDataTranslator {
@Test
public void testIsInterfaceOfType() {
- assertTrue(isInterfaceOfType(Tap.class, interfaceDetails("tap0")));
+ assertTrue(isInterfaceOfType(Tap.class, interfaceDetails("tapcli-0")));
+ assertTrue(isInterfaceOfType(TapV2.class, interfaceDetails("tap0")));
assertTrue(isInterfaceOfType(VxlanTunnel.class, interfaceDetails("vxlan0")));
assertTrue(isInterfaceOfType(VxlanGpeTunnel.class, interfaceDetails("vxlan_gpe0")));
assertTrue(isInterfaceOfType(VhostUser.class, interfaceDetails("VirtualEthernet0/0/0")));
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java
index aa07eaff5..11d8ab8da 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java
@@ -44,7 +44,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class TapCustomizerTest extends ReaderCustomizerTest<Tap, TapBuilder> implements InterfaceDumpHelper {
private static final String IFC_CTX_NAME = "ifc-test-instance";
- private static final String IF_NAME = "tap1";
+ private static final String IF_NAME = "tapcli-1";
private static final String TAP_NAME = "testTapName";
private static final int IF_INDEX = 1;
private static final InstanceIdentifier<Tap> IID =
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapV2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapV2CustomizerTest.java
new file mode 100644
index 000000000..ee77afc82
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapV2CustomizerTest.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies 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.v3po.interfacesstate;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
+import io.fd.hc2vpp.common.test.util.InterfaceDumpHelper;
+import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
+import io.fd.hc2vpp.common.translate.util.MacTranslator;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceTapV2Details;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceTapV2DetailsReplyDump;
+import org.junit.Test;
+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.inet.types.rev130715.Ipv6AddressNoZone;
+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.interfaces.rev140508.InterfacesState;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.VppInterfaceStateAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.VppInterfaceStateAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.interfaces.state._interface.TapV2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev181008.interfaces.state._interface.TapV2Builder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class TapV2CustomizerTest extends ReaderCustomizerTest<TapV2, TapV2Builder> implements InterfaceDumpHelper,
+ Ipv4Translator, Ipv6Translator, MacTranslator {
+
+ private static final String IFC_CTX_NAME = "ifc-test-instance";
+ private static final String IF_NAME = "tapV21";
+ private static final String DEVICE_NAME = "testTapV2Device";
+ private static final int IF_INDEX = 1;
+ private static final String HOST_BRIDGE = "TestBridge";
+ private static final String HOST_IPV4_PREFIX = "192.168.255.100";
+ private static final byte HOST_IPV4_PREFIX_LEN = 24;
+ private static final String HOST_IPV6_PREFIX = "a::100";
+ private static final byte HOST_IPV6_PREFIX_LEN = -128;
+ private static final int HOST_IPV6_PREFIX_LEN_EXP = 128;
+ private static final int RX_TX_RING_SIZE = 512;
+ private static final String HOST_MAC = "00:ee:ee:ee:ee:ee";
+ private static final String HOST_NAMESPACE = "testHostNS";
+
+ private static final InstanceIdentifier<TapV2> IID =
+ InstanceIdentifier.create(InterfacesState.class).child(Interface.class, new InterfaceKey(IF_NAME))
+ .augmentation(VppInterfaceStateAugmentation.class).child(TapV2.class);
+ private NamingContext interfaceContext;
+
+ @Mock
+ private InterfaceCacheDumpManager dumpCacheManager;
+
+ public TapV2CustomizerTest() {
+ super(TapV2.class, VppInterfaceStateAugmentationBuilder.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
+ defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
+ when(dumpCacheManager.getInterfaceDetail(IID, ctx, IF_NAME)).thenReturn(ifaceDetails());
+ }
+
+ private SwInterfaceDetails ifaceDetails() {
+ final SwInterfaceDetails details = new SwInterfaceDetails();
+ details.swIfIndex = IF_INDEX;
+ details.interfaceName = IF_NAME.getBytes();
+ details.tag = new byte[64];
+ return details;
+ }
+
+ @Override
+ protected ReaderCustomizer<TapV2, TapV2Builder> initCustomizer() {
+ return new TapV2Customizer(api, interfaceContext, dumpCacheManager);
+ }
+
+ @Test
+ public void testRead() throws ReadFailedException {
+ final TapV2Builder builder = mock(TapV2Builder.class);
+ when(api.swInterfaceTapV2Dump(any())).thenReturn(future(tapDump()));
+ getCustomizer().readCurrentAttributes(IID, builder, ctx);
+ verify(builder).setHostInterfaceName(IF_NAME);
+ verify(builder).setDeviceName(DEVICE_NAME);
+ verify(builder).setHostBridge(HOST_BRIDGE);
+ verify(builder)
+ .setHostIpv4Address(new Ipv4Prefix(String.format("%s/%d", HOST_IPV4_PREFIX, HOST_IPV4_PREFIX_LEN)));
+ verify(builder)
+ .setHostIpv6Address(new Ipv6Prefix(String.format("%s/%d", HOST_IPV6_PREFIX, HOST_IPV6_PREFIX_LEN_EXP)));
+ verify(builder).setTxRingSize(RX_TX_RING_SIZE);
+ verify(builder).setRxRingSize(RX_TX_RING_SIZE);
+ verify(builder).setHostNamespace(HOST_NAMESPACE);
+ verify(builder).setHostMac(new PhysAddress(HOST_MAC));
+ }
+
+ @Test(expected = ReadFailedException.class)
+ public void testReadFailed() throws ReadFailedException {
+ when(api.swInterfaceTapV2Dump(any())).thenReturn(failedFuture());
+ getCustomizer().readCurrentAttributes(IID, mock(TapV2Builder.class), ctx);
+ }
+
+ private SwInterfaceTapV2DetailsReplyDump tapDump() {
+ final SwInterfaceTapV2DetailsReplyDump reply = new SwInterfaceTapV2DetailsReplyDump();
+ final SwInterfaceTapV2Details details = new SwInterfaceTapV2Details();
+ details.devName = DEVICE_NAME.getBytes(UTF_8);
+ details.swIfIndex = IF_INDEX;
+ details.hostBridge = HOST_BRIDGE.getBytes(UTF_8);
+ details.hostNamespace = HOST_NAMESPACE.getBytes(UTF_8);
+ details.hostIfName = IF_NAME.getBytes(UTF_8);
+ details.hostIp4PrefixLen = HOST_IPV4_PREFIX_LEN;
+ details.hostIp4Addr = ipv4AddressNoZoneToArray(HOST_IPV4_PREFIX);
+ details.hostIp6Addr = ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(HOST_IPV6_PREFIX));
+ details.hostIp6PrefixLen = HOST_IPV6_PREFIX_LEN;
+ details.hostMacAddr = parseMac(HOST_MAC);
+ details.txRingSz = details.rxRingSz = RX_TX_RING_SIZE;
+ reply.swInterfaceTapV2Details.add(details);
+ return reply;
+ }
+}