summaryrefslogtreecommitdiffstats
path: root/routing/routing-impl
diff options
context:
space:
mode:
Diffstat (limited to 'routing/routing-impl')
-rw-r--r--routing/routing-impl/pom.xml6
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingModule.java17
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableService.java57
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableServiceImpl.java114
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableServiceProvider.java38
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizer.java2
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingWriterFactory.java2
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/FibTableRequest.java101
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java5
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/services/FibTableServiceImplTest.java110
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java2
11 files changed, 14 insertions, 440 deletions
diff --git a/routing/routing-impl/pom.xml b/routing/routing-impl/pom.xml
index 8a37b5998..722679761 100644
--- a/routing/routing-impl/pom.xml
+++ b/routing/routing-impl/pom.xml
@@ -74,6 +74,12 @@
<artifactId>guice-multibindings</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.fd.hc2vpp.fib.management</groupId>
+ <artifactId>fib-management-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- Testing dependencies-->
<dependency>
<groupId>junit</groupId>
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingModule.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingModule.java
index 6badcab29..8a109aece 100644
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingModule.java
+++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/RoutingModule.java
@@ -16,21 +16,15 @@
package io.fd.hc2vpp.routing;
-import com.google.common.annotations.VisibleForTesting;
import com.google.inject.AbstractModule;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;
import io.fd.hc2vpp.common.translate.util.MultiNamingContext;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.routing.read.RoutingReaderFactory;
-import io.fd.hc2vpp.routing.services.FibTableService;
-import io.fd.hc2vpp.routing.services.FibTableServiceProvider;
import io.fd.hc2vpp.routing.write.RoutingWriterFactory;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.write.WriterFactory;
-import javax.annotation.Nonnull;
import net.jmob.guice.conf.core.ConfigurationModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,23 +35,12 @@ import org.slf4j.LoggerFactory;
public class RoutingModule extends AbstractModule {
private static final Logger LOG = LoggerFactory.getLogger(RoutingModule.class);
- private final Class<? extends Provider<FibTableService>> fibTableServiceProvider;
-
- public RoutingModule() {
- this(FibTableServiceProvider.class);
- }
-
- @VisibleForTesting
- protected RoutingModule(@Nonnull final Class<? extends Provider<FibTableService>> fibTableServiceProvider) {
- this.fibTableServiceProvider = fibTableServiceProvider;
- }
@Override
protected void configure() {
LOG.info("Starting initialization");
// requests injection of properties
install(ConfigurationModule.create());
- bind(FibTableService.class).toProvider(fibTableServiceProvider).in(Singleton.class);
requestInjection(RoutingConfiguration.class);
bind(NamingContext.class)
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableService.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableService.java
deleted file mode 100644
index 4b01139a4..000000000
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableService.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.routing.services;
-
-import static java.lang.String.format;
-
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.write.WriteFailedException;
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public interface FibTableService {
-
- /**
- * Checks whether FIB table with provided index exist in VPP
- *
- * @throws ReadFailedException if there was an error while reading fib tables
- * @throws FibTableService.FibTableDoesNotExistException if requested index does not exist
- */
- void checkTableExist(@Nonnegative final int index, @Nonnull final ModificationCache cache)
- throws ReadFailedException, FibTableService.FibTableDoesNotExistException;
-
- /**
- * Writes FIB table in VPP
- *
- * @param identifier id of currently processed data
- * @param tableId table Id to be written in VPP
- * @param tableName name of the FIB table that will be added
- * @param isIpv6 true if adding IPv6 FIB table, false if adding IPv4 table
- * @throws WriteFailedException if there was an error while writing FIB tables
- */
- void write(InstanceIdentifier<?> identifier, @Nonnegative int tableId, @Nonnull String tableName, boolean isIpv6)
- throws WriteFailedException;
-
- class FibTableDoesNotExistException extends Exception {
-
- public FibTableDoesNotExistException(final int index) {
- super(format("Fib table with index %s does not exist", index));
- }
- }
-}
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableServiceImpl.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableServiceImpl.java
deleted file mode 100644
index db40e4ee8..000000000
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableServiceImpl.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.routing.services;
-
-import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
-
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
-import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
-import io.fd.hc2vpp.routing.RoutingIIds;
-import io.fd.hc2vpp.routing.write.factory.FibTableRequest;
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
-import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump;
-import io.fd.vpp.jvpp.core.dto.Ip6FibDump;
-import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump;
-import io.fd.vpp.jvpp.core.dto.IpFibDump;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-import java.util.Collections;
-import java.util.stream.Stream;
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// Todo HC2VPP-317: FibTableService was created as a temporary workaround to write Fib tables in VPP.
-// We need to implement proper support for Fib table management.
-public class FibTableServiceImpl extends FutureJVppCustomizer implements FibTableService, JvppReplyConsumer {
-
- private static final Logger LOG = LoggerFactory.getLogger(FibTableServiceImpl.class);
- private final DumpCacheManager<IpFibDetailsReplyDump, Void> v4DumpManager;
- private final DumpCacheManager<Ip6FibDetailsReplyDump, Void> v6DumpManager;
- private ModificationCache modificationCache;
-
- public FibTableServiceImpl(@Nonnull FutureJVppCore futureJVppCore, ModificationCache modificationCache) {
- super(futureJVppCore);
- this.modificationCache = modificationCache;
-
- v4DumpManager = new DumpCacheManager.DumpCacheManagerBuilder<IpFibDetailsReplyDump, Void>()
- .acceptOnly(IpFibDetailsReplyDump.class)
- .withExecutor((identifier, params) -> getReplyForRead(
- futureJVppCore.ipFibDump(new IpFibDump()).toCompletableFuture(), identifier))
- .build();
- v6DumpManager = new DumpCacheManager.DumpCacheManagerBuilder<Ip6FibDetailsReplyDump, Void>()
- .acceptOnly(Ip6FibDetailsReplyDump.class)
- .withExecutor((identifier, params) -> getReplyForRead(
- futureJVppCore.ip6FibDump(new Ip6FibDump()).toCompletableFuture(), identifier))
- .build();
- }
-
- @Override
- public void write(InstanceIdentifier<?> identifier, @Nonnegative int tableId, @Nonnull String tableName,
- boolean isIpv6) throws WriteFailedException {
- // Register fib table in VPP
- FibTableRequest fibTableRequest = new FibTableRequest(getFutureJVpp(), modificationCache);
- fibTableRequest.setFibName(tableName);
- fibTableRequest.setIpv6(isIpv6);
- fibTableRequest.setFibTable(tableId);
- fibTableRequest.checkValid();
- try {
- fibTableRequest.write(identifier);
- LOG.debug("Fib table written successfully. table-name: {}, table-id: {}, request: {}", tableName, tableId,
- fibTableRequest);
- } catch (WriteFailedException e) {
- LOG.warn("Fib table write failed. request: {}", fibTableRequest);
- throw new WriteFailedException(identifier, "Failed to write fib table to VPP.", e);
- }
- }
-
- @Override
- public void checkTableExist(@Nonnegative final int index,
- @Nonnull final ModificationCache cache)
- throws ReadFailedException, FibTableService.FibTableDoesNotExistException {
-
- if (Stream.concat(dumpV4FibTableIdsStream(cache), dumpV6FibTableIdsStream(cache))
- .noneMatch(id -> id == index)) {
- throw new FibTableService.FibTableDoesNotExistException(index);
- }
- }
-
- private Stream<Integer> dumpV6FibTableIdsStream(final ModificationCache cache) throws ReadFailedException {
- return v6DumpManager.getDump(RoutingIIds.ROUTING, cache, NO_PARAMS)
- .toJavaUtil()
- .map(ip6FibDetailsReplyDump -> ip6FibDetailsReplyDump.ip6FibDetails)
- .orElse(Collections.emptyList())
- .stream()
- .map(ip6FibDetails -> ip6FibDetails.tableId);
- }
-
- private Stream<Integer> dumpV4FibTableIdsStream(final ModificationCache cache) throws ReadFailedException {
- return v4DumpManager.getDump(RoutingIIds.ROUTING, cache, NO_PARAMS)
- .toJavaUtil()
- .map(ipFibDetailsReplyDump -> ipFibDetailsReplyDump.ipFibDetails)
- .orElse(Collections.emptyList())
- .stream()
- .map(ipFibDetails -> ipFibDetails.tableId);
- }
-}
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableServiceProvider.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableServiceProvider.java
deleted file mode 100644
index e9d394610..000000000
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/services/FibTableServiceProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.routing.services;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-
-public class FibTableServiceProvider implements Provider<FibTableService> {
-
- @Inject
- private
- FutureJVppCore api;
-
- @Inject
- private ModificationCache modificationCache;
-
- @Override
- public FibTableService get() {
- return new FibTableServiceImpl(api, modificationCache);
- }
-}
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizer.java
index 326b6f873..b68a503be 100644
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizer.java
+++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizer.java
@@ -20,7 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.hc2vpp.routing.services.FibTableService;
+import io.fd.hc2vpp.fib.management.services.FibTableService;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingWriterFactory.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingWriterFactory.java
index cd3c4d275..4af6f5579 100644
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingWriterFactory.java
+++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/RoutingWriterFactory.java
@@ -25,11 +25,11 @@ import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.fd.hc2vpp.common.translate.util.MultiNamingContext;
import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.fib.management.services.FibTableService;
import io.fd.hc2vpp.routing.Ipv4RoutingNodes;
import io.fd.hc2vpp.routing.Ipv6RoutingNodes;
import io.fd.hc2vpp.routing.RoutingConfiguration;
import io.fd.hc2vpp.routing.RoutingIIds;
-import io.fd.hc2vpp.routing.services.FibTableService;
import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager;
import io.fd.honeycomb.translate.impl.write.GenericWriter;
import io.fd.honeycomb.translate.write.WriterFactory;
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/FibTableRequest.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/FibTableRequest.java
deleted file mode 100644
index 5a471de35..000000000
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/factory/FibTableRequest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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.routing.write.factory;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import io.fd.hc2vpp.common.translate.util.AddressTranslator;
-import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
-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.future.FutureJVppCore;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FibTableRequest implements AddressTranslator, JvppReplyConsumer {
-
- private final ModificationCache modificationCache;
- private static final Logger LOG = LoggerFactory.getLogger(FibTableRequest.class);
-
- private final FutureJVppCore api;
- /**
- * FIB table Name
- */
- private String fibName;
-
- /**
- * FIB table id to be installed
- */
- private int fibTable;
-
- /**
- * Whether to write IPv6 fib table or IPv4
- */
- private boolean isIpv6;
-
- public FibTableRequest(FutureJVppCore api, ModificationCache modificationCache) {
- this.api = api;
- this.modificationCache = modificationCache;
- }
-
- public void checkValid() {
- checkNotNull(getFibName(), "Fib table name not set");
- checkArgument(!getFibName().isEmpty(), "Fib table name must not be empty");
- }
-
- public void write(InstanceIdentifier<?> identifier) throws WriteFailedException {
- IpTableAddDel tableAddDel = new IpTableAddDel();
- try {
- tableAddDel.tableId = getFibTable();
- tableAddDel.isIpv6 = (booleanToByte(isIpv6()));
- tableAddDel.isAdd = (booleanToByte(true));
- tableAddDel.name = getFibName().getBytes();
- getReplyForWrite(api.ipTableAddDel(tableAddDel).toCompletableFuture(), identifier);
- } catch (Exception ex) {
- LOG.error("Error writing fib table. fibTable: {}, api: {}, cache: {}, id: {}", tableAddDel, api,
- modificationCache, identifier);
- throw new WriteFailedException(identifier, ex);
- }
- }
-
- public int getFibTable() {
- return fibTable;
- }
-
- public void setFibTable(int fibTable) {
- this.fibTable = fibTable;
- }
-
- public boolean isIpv6() {
- return isIpv6;
- }
-
- public void setIpv6(boolean ipv6) {
- isIpv6 = ipv6;
- }
-
- public String getFibName() {
- return fibName;
- }
-
- public void setFibName(String fibName) {
- this.fibName = fibName;
- }
-}
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 679b90316..a12d0e0cc 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,6 +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.fib.management.services.FibTableService;
import io.fd.hc2vpp.routing.read.RoutingReaderFactory;
import io.fd.hc2vpp.routing.write.RoutingWriterFactory;
import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager;
@@ -72,6 +73,10 @@ public class RoutingModuleTest {
@Mock
private FutureJVppCore futureJVppCore;
+ @Bind
+ @Mock
+ private FibTableService fibTableService;
+
@Inject
private Set<ReaderFactory> readerFactories = new HashSet<>();
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/services/FibTableServiceImplTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/services/FibTableServiceImplTest.java
deleted file mode 100644
index 988738aa6..000000000
--- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/services/FibTableServiceImplTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.routing.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.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.routing.RoutingIIds;
-import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
-import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.write.WriteContext;
-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 RoutingRequestTestHelper, SchemaContextTestHelper {
-
- private static final int FIB_TABLE_ID = 123456;
- private static final String FIB_TABLE_NAME = "VRF123456";
-
- @Inject
- @Mock
- private static FutureJVppCore api;
-
- @Mock
- private static WriteContext ctx;
-
- @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, ctx.getModificationCache());
-
- fibService.checkTableExist(FIB_TABLE_ID, modificationCache);
- }
-
- @Test
- public void writeIpv4Test() throws WriteFailedException {
- FibTableServiceImpl fibTableService = new FibTableServiceImpl(api, ctx.getModificationCache());
- fibTableService.write(RoutingIIds.ROUTING, FIB_TABLE_ID, FIB_TABLE_NAME, false);
-
- verify(api, times(1)).ipTableAddDel(argumentCaptor.capture());
-
- final IpTableAddDel jvppRequest = argumentCaptor.getValue();
- assertTableAddDelRequest(jvppRequest, true, false);
- }
-
- @Test
- public void writeIpv6Test() throws WriteFailedException {
- FibTableServiceImpl fibTableService = new FibTableServiceImpl(api, ctx.getModificationCache());
- fibTableService.write(RoutingIIds.ROUTING, FIB_TABLE_ID, FIB_TABLE_NAME, true);
-
- verify(api, times(1)).ipTableAddDel(argumentCaptor.capture());
-
- final IpTableAddDel jvppRequest = argumentCaptor.getValue();
- assertTableAddDelRequest(jvppRequest, true, true);
- }
-
- private void assertTableAddDelRequest(IpTableAddDel jvppRequest, boolean isAdd, boolean isIpv6) {
- assertEquals(ByteDataTranslator.INSTANCE.booleanToByte(isAdd), 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/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java
index b4cf64ead..c96e31373 100644
--- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/ControlPlaneProtocolCustomizerTest.java
@@ -23,7 +23,7 @@ import static org.junit.Assert.fail;
import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.hc2vpp.routing.services.FibTableService;
+import io.fd.hc2vpp.fib.management.services.FibTableService;
import io.fd.honeycomb.translate.write.WriteFailedException;
import org.junit.Before;
import org.junit.Test;