diff options
Diffstat (limited to 'fib-management/fib-management-impl/src/test')
6 files changed, 520 insertions, 0 deletions
diff --git a/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/FibManagementModuleTest.java b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/FibManagementModuleTest.java new file mode 100644 index 000000000..f1f537114 --- /dev/null +++ b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/FibManagementModuleTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018 Bell Canada, 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.fib.management; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.empty; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.mockito.MockitoAnnotations.initMocks; + +import com.google.inject.Guice; +import com.google.inject.Inject; +import com.google.inject.name.Named; +import com.google.inject.testing.fieldbinder.Bind; +import com.google.inject.testing.fieldbinder.BoundFieldModule; +import io.fd.hc2vpp.fib.management.read.FibManagementReaderFactory; +import io.fd.hc2vpp.fib.management.write.FibManagementWriterFactory; +import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder; +import io.fd.honeycomb.translate.impl.write.registry.FlatWriterRegistryBuilder; +import io.fd.honeycomb.translate.read.ReaderFactory; +import io.fd.honeycomb.translate.util.YangDAG; +import io.fd.honeycomb.translate.write.WriterFactory; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import java.util.HashSet; +import java.util.Set; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; + +public class FibManagementModuleTest { + + @Named("honeycomb-context") + @Bind + @Mock + private DataBroker honeycombContext; + + @Named("honeycomb-initializer") + @Bind + @Mock + private DataBroker honeycombInitializer; + + @Bind + @Mock + private FutureJVppCore futureJVppCore; + + @Inject + private Set<ReaderFactory> readerFactories = new HashSet<>(); + + @Inject + private Set<WriterFactory> writerFactories = new HashSet<>(); + + @Before + public void setUp() { + initMocks(this); + Guice.createInjector(new FibManagementModule(), BoundFieldModule.of(this)).injectMembers(this); + } + + @Test + public void testReaderFactories() { + assertThat(readerFactories, is(not(empty()))); + + // Test registration process (all dependencies present, topological order of readers does exist, etc.) + final CompositeReaderRegistryBuilder registryBuilder = new CompositeReaderRegistryBuilder(new YangDAG()); + readerFactories.forEach(factory -> factory.init(registryBuilder)); + assertNotNull(registryBuilder.build()); + assertEquals(1, readerFactories.size()); + assertTrue(readerFactories.iterator().next() instanceof FibManagementReaderFactory); + } + + @Test + public void testWriterFactories() { + assertThat(writerFactories, is(not(empty()))); + + // Test registration process (all dependencies present, topological order of writers does exist, etc.) + final FlatWriterRegistryBuilder registryBuilder = new FlatWriterRegistryBuilder(new YangDAG()); + writerFactories.forEach(factory -> factory.init(registryBuilder)); + assertNotNull(registryBuilder.build()); + assertEquals(1, writerFactories.size()); + assertTrue(writerFactories.iterator().next() instanceof FibManagementWriterFactory); + } +} diff --git a/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/helpers/SchemaContextTestHelper.java b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/helpers/SchemaContextTestHelper.java new file mode 100644 index 000000000..1341e7e86 --- /dev/null +++ b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/helpers/SchemaContextTestHelper.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018 Bell Canada, 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.fib.management.helpers; + +import com.google.common.collect.ImmutableSet; +import io.fd.honeycomb.test.tools.annotations.InjectablesProcessor; +import io.fd.honeycomb.test.tools.annotations.SchemaContextProvider; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.$YangModuleInfoImpl; + +public interface SchemaContextTestHelper extends InjectablesProcessor { + + @SchemaContextProvider + default ModuleInfoBackedContext getSchemaContext() { + return provideSchemaContextFor(ImmutableSet.of($YangModuleInfoImpl.getInstance())); + } +} diff --git a/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizerTest.java b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizerTest.java new file mode 100644 index 000000000..6b2d8c4d7 --- /dev/null +++ b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizerTest.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2018 Bell Canada, 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.fib.management.read; + +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.junit.Assert.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.AddressTranslator; +import io.fd.hc2vpp.fib.management.FibManagementIIds; +import io.fd.honeycomb.translate.ModificationCache; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; +import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; +import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; +import io.fd.vpp.jvpp.core.dto.Ip6FibDetails; +import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; +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.Collections; +import java.util.List; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv4; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv6; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.FibTablesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.Table; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.TableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.TableKey; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class FibTableCustomizerTest extends ListReaderCustomizerTest<Table, TableKey, TableBuilder> implements + AddressTranslator { + + private static final String IPV4_VRF_1 = "IPV4_VRF_1"; + private static final IpAddress NEXT_HOP_1 = new IpAddress(new Ipv6Address("a::1")); + private static final IpAddress NEXT_HOP_2 = new IpAddress(new Ipv4Address("10.0.0.254")); + private static final InstanceIdentifier<Table> TABLE_V4_ID = + FibManagementIIds.FM_FIB_TABLES.child(Table.class, new TableKey(Ipv4.class, new VniReference(1L))); + private static final InstanceIdentifier<Table> TABLE_V6_ID = + FibManagementIIds.FM_FIB_TABLES.child(Table.class, new TableKey(Ipv6.class, new VniReference(1L))); + private static final IpAddress IP_ADDR_1 = new IpAddress(new Ipv6Address("a::")); + private static final IpAddress IP_ADDR_2 = new IpAddress(new Ipv4Address("10.0.0.1")); + private DumpCacheManager<Ip6FibDetailsReplyDump, Void> manager_v6; + private DumpCacheManager<IpFibDetailsReplyDump, Void> manager_v4; + + @Mock + private EntityDumpExecutor<Ip6FibDetailsReplyDump, Void> executor_v6; + + @Mock + private EntityDumpExecutor<IpFibDetailsReplyDump, Void> executor_v4; + + @Mock + private ModificationCache cache; + + public FibTableCustomizerTest() { + super(Table.class, FibTablesBuilder.class); + } + + @Override + public void setUp() throws ReadFailedException { + manager_v6 = new DumpCacheManager.DumpCacheManagerBuilder<Ip6FibDetailsReplyDump, Void>() + .withExecutor(executor_v6) + .acceptOnly(Ip6FibDetailsReplyDump.class) + .build(); + manager_v4 = new DumpCacheManager.DumpCacheManagerBuilder<IpFibDetailsReplyDump, Void>() + .withExecutor(executor_v4) + .acceptOnly(IpFibDetailsReplyDump.class) + .build(); + + when(executor_v6.executeDump(any(), any())).thenReturn(replyDumpV6()); + when(executor_v4.executeDump(any(), any())).thenReturn(replyDumpV4()); + when(ctx.getModificationCache()).thenReturn(cache); + } + + private Ip6FibDetailsReplyDump replyDumpV6() { + Ip6FibDetailsReplyDump replyDump = new Ip6FibDetailsReplyDump(); + + //simple + Ip6FibDetails ip6FibDetails = new Ip6FibDetails(); + ip6FibDetails.tableId = 1; + ip6FibDetails.address = ipAddressToArray(IP_ADDR_1); + ip6FibDetails.addressLength = 22; + ip6FibDetails.path = new FibPath[]{}; + + FibPath path = new FibPath(); + path.weight = 3; + path.nextHop = ipAddressToArray(NEXT_HOP_1); + path.afi = 0; + path.swIfIndex = 1; + ip6FibDetails.path = new FibPath[]{path}; + + replyDump.ip6FibDetails = Collections.singletonList(ip6FibDetails); + return replyDump; + } + + private IpFibDetailsReplyDump replyDumpV4() { + IpFibDetailsReplyDump replyDump = new IpFibDetailsReplyDump(); + + //simple + IpFibDetails detail = new IpFibDetails(); + detail.tableId = 1; + detail.address = ipAddressToArray(IP_ADDR_2); + detail.addressLength = 24; + detail.tableName = IPV4_VRF_1.getBytes(); + detail.path = new FibPath[]{}; + + FibPath path = new FibPath(); + path.weight = 3; + path.nextHop = ipAddressToArray(NEXT_HOP_2); + path.afi = 0; + path.swIfIndex = 1; + detail.path = new FibPath[]{path}; + + replyDump.ipFibDetails = Collections.singletonList(detail); + return replyDump; + } + + @Test + public void getAllIds() throws Exception { + final List<TableKey> keys = getCustomizer().getAllIds(TABLE_V6_ID, ctx); + + assertThat(keys, hasSize(2)); + assertThat(keys, hasItems(new TableKey(Ipv6.class, new VniReference(1L)), + new TableKey(Ipv4.class, new VniReference(1L)))); + } + + @Test + public void readCurrentAttributesSimpleHop() throws Exception { + TableBuilder builder = new TableBuilder(); + getCustomizer().readCurrentAttributes(TABLE_V6_ID, builder, ctx); + + Assert.assertEquals(Ipv6.class, builder.getAddressFamily()); + Assert.assertEquals(1L, builder.getTableId().getValue().longValue()); + Assert.assertNull(builder.getName()); + + builder = new TableBuilder(); + getCustomizer().readCurrentAttributes(TABLE_V4_ID, builder, ctx); + + Assert.assertEquals(Ipv4.class, builder.getAddressFamily()); + Assert.assertEquals(1L, builder.getTableId().getValue().longValue()); + Assert.assertEquals(IPV4_VRF_1, builder.getName()); + } + + @Override + protected ReaderCustomizer<Table, TableBuilder> initCustomizer() { + return new FibTableCustomizer(manager_v4, manager_v6); + } +} diff --git a/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImplTest.java b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImplTest.java new file mode 100644 index 000000000..2351ead2c --- /dev/null +++ b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/services/FibTableServiceImplTest.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2018 Bell Canada, 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.fib.management.services; + +import static io.fd.vpp.jvpp.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.google.inject.Inject; +import io.fd.hc2vpp.common.test.util.FutureProducer; +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; +import io.fd.hc2vpp.fib.management.FibManagementIIds; +import io.fd.hc2vpp.fib.management.helpers.SchemaContextTestHelper; +import io.fd.honeycomb.translate.ModificationCache; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.IpTableAddDel; +import io.fd.vpp.jvpp.core.dto.IpTableAddDelReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +public class FibTableServiceImplTest implements SchemaContextTestHelper, ByteDataTranslator, FutureProducer { + + private static final int FIB_TABLE_ID = 123456; + private static final String FIB_TABLE_NAME = "VRF123456"; + + @Inject + @Mock + private static FutureJVppCore api; + + @Mock + private ModificationCache modificationCache; + + @Captor + private ArgumentCaptor<IpTableAddDel> argumentCaptor; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + when(api.ipTableAddDel(any())).thenReturn(future(new IpTableAddDelReply())); + when(api.ipFibDump(any())).thenReturn(future(new IpFibDetailsReplyDump())); + when(api.ip6FibDump(any())).thenReturn(future(new Ip6FibDetailsReplyDump())); + when(modificationCache.get(any())).thenReturn(null); + + } + + @Test(expected = FibTableService.FibTableDoesNotExistException.class) + public void checkTableExistTest() throws ReadFailedException, FibTableService.FibTableDoesNotExistException { + FibTableServiceImpl fibService = new FibTableServiceImpl(api); + fibService.checkTableExist(FIB_TABLE_ID, modificationCache); + } + + @Test + public void writeIpv4Test() throws WriteFailedException { + FibTableServiceImpl fibTableService = new FibTableServiceImpl(api); + fibTableService.write(FibManagementIIds.FIB_MNGMNT, FIB_TABLE_ID, FIB_TABLE_NAME, false); + + verify(api, times(1)).ipTableAddDel(argumentCaptor.capture()); + + assertTableAddDelRequest(argumentCaptor.getValue(), false); + } + + @Test + public void writeIpv6Test() throws WriteFailedException { + FibTableServiceImpl fibTableService = new FibTableServiceImpl(api); + fibTableService.write(FibManagementIIds.FIB_MNGMNT, FIB_TABLE_ID, FIB_TABLE_NAME, true); + + verify(api, times(1)).ipTableAddDel(argumentCaptor.capture()); + + assertTableAddDelRequest(argumentCaptor.getValue(), true); + } + + private void assertTableAddDelRequest(IpTableAddDel jvppRequest, boolean isIpv6) { + assertEquals(ByteDataTranslator.BYTE_TRUE, jvppRequest.isAdd); + assertEquals(ByteDataTranslator.INSTANCE.booleanToByte(isIpv6), jvppRequest.isIpv6); + assertEquals(FIB_TABLE_ID, jvppRequest.tableId); + Assert.assertArrayEquals(FIB_TABLE_NAME.getBytes(), jvppRequest.name); + } +} diff --git a/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/write/FibTableCustomizerTest.java b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/write/FibTableCustomizerTest.java new file mode 100644 index 000000000..c9d05dc45 --- /dev/null +++ b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/write/FibTableCustomizerTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2018 Bell Canada, 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.fib.management.write; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; +import io.fd.hc2vpp.fib.management.FibManagementIIds; +import io.fd.hc2vpp.fib.management.helpers.SchemaContextTestHelper; +import io.fd.honeycomb.test.tools.HoneycombTestRunner; +import io.fd.honeycomb.test.tools.annotations.InjectTestData; +import io.fd.honeycomb.translate.ModificationCache; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.IpTableAddDel; +import io.fd.vpp.jvpp.core.dto.IpTableAddDelReply; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv6; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.FibTables; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.Table; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.TableKey; + +@RunWith(HoneycombTestRunner.class) +public class FibTableCustomizerTest extends WriterCustomizerTest implements SchemaContextTestHelper, + ByteDataTranslator { + private static final String FIB_PATH = + "/vpp-fib-table-management:fib-table-management/vpp-fib-table-management:fib-tables"; + private static final String IPV4_VRF_0 = "ipv4-VRF:0"; + private static final String IPV6_VRF_0 = "ipv6-VRF:0"; + @Mock + private ModificationCache modificationCache; + private FibTableCustomizer customizer; + + @Override + protected void setUpTest() { + customizer = new FibTableCustomizer(api); + when(writeContext.getModificationCache()).thenReturn(modificationCache); + when(api.ipTableAddDel(any())).thenReturn(future(new IpTableAddDelReply())); + } + + @Test + public void testWriteSimple(@InjectTestData(resourcePath = "/fib.json", id = FIB_PATH) FibTables tables) + throws WriteFailedException { + final Table data = tables.getTable().get(0); + customizer.writeCurrentAttributes(FibManagementIIds.FM_FIB_TABLES + .child(Table.class, new TableKey(Ipv6.class, new VniReference(0L))), data, writeContext); + final IpTableAddDel request = new IpTableAddDel(); + request.isAdd = 1; + request.isIpv6 = 0; + request.tableId = 0; + request.name = IPV4_VRF_0.getBytes(); + + verify(api).ipTableAddDel(request); + } + + @Test + public void testDelete(@InjectTestData(resourcePath = "/fib.json", id = FIB_PATH) FibTables tables) + throws WriteFailedException { + final Table data = tables.getTable().get(3); + customizer.deleteCurrentAttributes(FibManagementIIds.FM_FIB_TABLES + .child(Table.class, new TableKey(Ipv6.class, new VniReference(0L))), data, writeContext); + final IpTableAddDel request = new IpTableAddDel(); + request.isAdd = 0; + request.isIpv6 = 1; + request.tableId = 0; + request.name = IPV6_VRF_0.getBytes(); + + verify(api).ipTableAddDel(request); + } +} diff --git a/fib-management/fib-management-impl/src/test/resources/fib.json b/fib-management/fib-management-impl/src/test/resources/fib.json new file mode 100644 index 000000000..a96ca2866 --- /dev/null +++ b/fib-management/fib-management-impl/src/test/resources/fib.json @@ -0,0 +1,26 @@ +{ + "fib-tables": { + "vpp-fib-table-management:table": [ + { + "table-id": 0, + "address-family": "vpp-fib-table-management:ipv4", + "name": "ipv4-VRF:0" + }, + { + "table-id": 12, + "address-family": "vpp-fib-table-management:ipv4", + "name": "ipv4-VRF:12" + }, + { + "table-id": 0, + "address-family": "vpp-fib-table-management:ipv6", + "name": "ipv6-VRF:0" + }, + { + "table-id": 25, + "address-family": "vpp-fib-table-management:ipv6", + "name": "ipv6-VRF:25" + } + ] + } +} |