Pavlin Radoslavov

Updated SDN-IP to use the Intent framework batch-based intents.

Also, created a local cache of IPv4-to-MAC address mapping,
to avoid relatively costly hostService.getHostsByIp() calls
per added route.

Change-Id: I8abed378985708e883fd99e85c54b01f38756515
......@@ -26,6 +26,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import org.apache.commons.lang3.tuple.Pair;
import org.onlab.onos.core.ApplicationId;
import org.onlab.onos.net.flow.criteria.Criteria.IPCriterion;
import org.onlab.onos.net.flow.criteria.Criterion;
......@@ -116,7 +117,7 @@ public class IntentSynchronizer {
//
log.debug("SDN-IP Intent Synchronizer shutdown: " +
"withdrawing all intents...");
IntentOperations.Builder builder = IntentOperations.builder();
IntentOperations.Builder builder = IntentOperations.builder(appId);
for (Intent intent : intentService.getIntents()) {
// Skip the intents from other applications
if (!intent.appId().equals(appId)) {
......@@ -234,51 +235,84 @@ public class IntentSynchronizer {
}
/**
* Submits a multi-point-to-single-point intent.
* Updates multi-point-to-single-point route intents.
*
* @param prefix the IPv4 matching prefix for the intent to submit
* @param intent the intent to submit
* @param submitIntents the intents to submit
* @param withdrawPrefixes the IPv4 matching prefixes for the intents
* to withdraw
*/
void submitRouteIntent(Ip4Prefix prefix,
MultiPointToSinglePointIntent intent) {
void updateRouteIntents(
Collection<Pair<Ip4Prefix, MultiPointToSinglePointIntent>> submitIntents,
Collection<Ip4Prefix> withdrawPrefixes) {
//
// NOTE: Semantically, we MUST withdraw existing intents before
// submitting new intents.
//
synchronized (this) {
MultiPointToSinglePointIntent oldIntent =
routeIntents.put(prefix, intent);
MultiPointToSinglePointIntent intent;
if (isElectedLeader && isActivatedLeader) {
if (oldIntent != null) {
//
// TODO: Short-term solution to explicitly withdraw
// instead of using "replace" operation.
//
log.debug("SDN-IP Withdrawing old intent: {}", oldIntent);
intentService.withdraw(oldIntent);
log.debug("SDN-IP submitting intents = {} withdrawing = {}",
submitIntents.size(), withdrawPrefixes.size());
//
// Prepare the Intent batch operations for the intents to withdraw
//
IntentOperations.Builder withdrawBuilder =
IntentOperations.builder(appId);
for (Ip4Prefix prefix : withdrawPrefixes) {
intent = routeIntents.remove(prefix);
if (intent == null) {
log.debug("SDN-IP No intent in routeIntents to delete " +
"for prefix: {}", prefix);
continue;
}
if (isElectedLeader && isActivatedLeader) {
log.debug("SDN-IP Withdrawing intent: {}", intent);
withdrawBuilder.addWithdrawOperation(intent.id());
}
log.debug("SDN-IP Submitting intent: {}", intent);
intentService.submit(intent);
}
}
}
/**
* Withdraws a multi-point-to-single-point intent.
*
* @param prefix the IPv4 matching prefix for the intent to withdraw.
*/
void withdrawRouteIntent(Ip4Prefix prefix) {
synchronized (this) {
MultiPointToSinglePointIntent intent =
routeIntents.remove(prefix);
if (intent == null) {
log.debug("SDN-IP no intent in routeIntents to delete for " +
"prefix: {}", prefix);
return;
//
// Prepare the Intent batch operations for the intents to submit
//
IntentOperations.Builder submitBuilder =
IntentOperations.builder(appId);
for (Pair<Ip4Prefix, MultiPointToSinglePointIntent> pair :
submitIntents) {
Ip4Prefix prefix = pair.getLeft();
intent = pair.getRight();
MultiPointToSinglePointIntent oldIntent =
routeIntents.put(prefix, intent);
if (isElectedLeader && isActivatedLeader) {
if (oldIntent != null) {
//
// TODO: Short-term solution to explicitly withdraw
// instead of using "replace" operation.
//
log.debug("SDN-IP Withdrawing old intent: {}",
oldIntent);
withdrawBuilder.addWithdrawOperation(oldIntent.id());
}
log.debug("SDN-IP Submitting intent: {}", intent);
submitBuilder.addSubmitOperation(intent);
}
}
//
// Submit the Intent operations
//
if (isElectedLeader && isActivatedLeader) {
log.debug("SDN-IP Withdrawing intent: {}", intent);
intentService.withdraw(intent);
IntentOperations intentOperations = withdrawBuilder.build();
if (!intentOperations.operations().isEmpty()) {
log.debug("SDN-IP Withdrawing intents executed");
intentService.execute(intentOperations);
}
intentOperations = submitBuilder.build();
if (!intentOperations.operations().isEmpty()) {
log.debug("SDN-IP Submitting intents executed");
intentService.execute(intentOperations);
}
}
}
}
......
......@@ -15,6 +15,8 @@
*/
package org.onlab.onos.sdnip;
import java.util.Collection;
/**
* An interface to receive route updates from route providers.
*/
......@@ -22,7 +24,7 @@ public interface RouteListener {
/**
* Receives a route update from a route provider.
*
* @param routeUpdate the updated route information
* @param routeUpdates the collection with updated route information
*/
public void update(RouteUpdate routeUpdate);
public void update(Collection<RouteUpdate> routeUpdates);
}
......
......@@ -22,6 +22,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Collection;
import java.util.LinkedList;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executors;
......@@ -248,18 +249,28 @@ public class BgpSessionManager {
synchronized void routeUpdates(BgpSession bgpSession,
Collection<BgpRouteEntry> addedBgpRouteEntries,
Collection<BgpRouteEntry> deletedBgpRouteEntries) {
Collection<RouteUpdate> routeUpdates = new LinkedList<>();
RouteUpdate routeUpdate;
if (isShutdown) {
return; // Ignore any leftover updates if shutdown
}
// Process the deleted route entries
for (BgpRouteEntry bgpRouteEntry : deletedBgpRouteEntries) {
processDeletedRoute(bgpSession, bgpRouteEntry);
routeUpdate = processDeletedRoute(bgpSession, bgpRouteEntry);
if (routeUpdate != null) {
routeUpdates.add(routeUpdate);
}
}
// Process the added/updated route entries
for (BgpRouteEntry bgpRouteEntry : addedBgpRouteEntries) {
processAddedRoute(bgpSession, bgpRouteEntry);
routeUpdate = processAddedRoute(bgpSession, bgpRouteEntry);
if (routeUpdate != null) {
routeUpdates.add(routeUpdate);
}
}
routeListener.update(routeUpdates);
}
/**
......@@ -268,9 +279,11 @@ public class BgpSessionManager {
* @param bgpSession the BGP session the route entry update was
* received on
* @param bgpRouteEntry the added/updated route entry
* @return the result route update that should be forwarded to the
* Route Listener, or null if no route update should be forwarded
*/
private void processAddedRoute(BgpSession bgpSession,
BgpRouteEntry bgpRouteEntry) {
private RouteUpdate processAddedRoute(BgpSession bgpSession,
BgpRouteEntry bgpRouteEntry) {
RouteUpdate routeUpdate;
BgpRouteEntry bestBgpRouteEntry =
bgpRoutes.get(bgpRouteEntry.prefix());
......@@ -284,9 +297,7 @@ public class BgpSessionManager {
bgpRoutes.put(bgpRouteEntry.prefix(), bgpRouteEntry);
routeUpdate =
new RouteUpdate(RouteUpdate.Type.UPDATE, bgpRouteEntry);
// Forward the result route updates to the Route Listener
routeListener.update(routeUpdate);
return;
return routeUpdate;
}
//
......@@ -296,7 +307,7 @@ public class BgpSessionManager {
//
if (bestBgpRouteEntry.getBgpSession() !=
bgpRouteEntry.getBgpSession()) {
return;
return null; // Nothing to do
}
// Find the next best route
......@@ -315,8 +326,7 @@ public class BgpSessionManager {
bgpRoutes.put(bestBgpRouteEntry.prefix(), bestBgpRouteEntry);
routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
bestBgpRouteEntry);
// Forward the result route updates to the Route Listener
routeListener.update(routeUpdate);
return routeUpdate;
}
/**
......@@ -325,9 +335,11 @@ public class BgpSessionManager {
* @param bgpSession the BGP session the route entry update was
* received on
* @param bgpRouteEntry the deleted route entry
* @return the result route update that should be forwarded to the
* Route Listener, or null if no route update should be forwarded
*/
private void processDeletedRoute(BgpSession bgpSession,
BgpRouteEntry bgpRouteEntry) {
private RouteUpdate processDeletedRoute(BgpSession bgpSession,
BgpRouteEntry bgpRouteEntry) {
RouteUpdate routeUpdate;
BgpRouteEntry bestBgpRouteEntry =
bgpRoutes.get(bgpRouteEntry.prefix());
......@@ -340,7 +352,7 @@ public class BgpSessionManager {
// because we need to check whether this is same object.
//
if (bgpRouteEntry != bestBgpRouteEntry) {
return; // Nothing to do
return null; // Nothing to do
}
//
......@@ -353,9 +365,7 @@ public class BgpSessionManager {
bestBgpRouteEntry);
routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
bestBgpRouteEntry);
// Forward the result route updates to the Route Listener
routeListener.update(routeUpdate);
return;
return routeUpdate;
}
//
......@@ -364,8 +374,7 @@ public class BgpSessionManager {
bgpRoutes.remove(bgpRouteEntry.prefix());
routeUpdate = new RouteUpdate(RouteUpdate.Type.DELETE,
bgpRouteEntry);
// Forward the result route updates to the Route Listener
routeListener.update(routeUpdate);
return routeUpdate;
}
/**
......
......@@ -325,13 +325,13 @@ public class IntentSyncTest extends AbstractIntentTest {
.andReturn(IntentState.WITHDRAWING).anyTimes();
expect(intentService.getIntents()).andReturn(intents).anyTimes();
IntentOperations.Builder builder = IntentOperations.builder(null); //FIXME null
IntentOperations.Builder builder = IntentOperations.builder(APPID);
builder.addWithdrawOperation(intent2.id());
builder.addWithdrawOperation(intent4.id());
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
builder = IntentOperations.builder(null); //FIXME null
builder = IntentOperations.builder(APPID);
builder.addSubmitOperation(intent3);
builder.addSubmitOperation(intent4Update);
builder.addSubmitOperation(intent6);
......
......@@ -566,7 +566,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest {
reset(intentService);
// Setup the expected intents
IntentOperations.Builder builder = IntentOperations.builder(null); //FIXME null
IntentOperations.Builder builder = IntentOperations.builder(APPID);
for (Intent intent : intentList) {
builder.addSubmitOperation(intent);
}
......@@ -601,9 +601,8 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest {
replay(configInfoService);
reset(intentService);
IntentOperations.Builder builder = IntentOperations.builder(null); //FIXME null
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
IntentOperations.Builder builder = IntentOperations.builder(APPID);
intentService.execute(builder.build());
replay(intentService);
peerConnectivityManager.start();
verify(intentService);
......@@ -627,9 +626,8 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest {
replay(configInfoService);
reset(intentService);
IntentOperations.Builder builder = IntentOperations.builder(null); //FIXME null
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
IntentOperations.Builder builder = IntentOperations.builder(APPID);
intentService.execute(builder.build());
replay(intentService);
peerConnectivityManager.start();
verify(intentService);
......
......@@ -25,6 +25,7 @@ import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
......@@ -50,6 +51,7 @@ import org.onlab.onos.net.host.HostListener;
import org.onlab.onos.net.host.HostService;
import org.onlab.onos.net.host.InterfaceIpAddress;
import org.onlab.onos.net.intent.Intent;
import org.onlab.onos.net.intent.IntentOperations;
import org.onlab.onos.net.intent.IntentService;
import org.onlab.onos.net.intent.MultiPointToSinglePointIntent;
import org.onlab.onos.net.intent.AbstractIntentTest;
......@@ -234,7 +236,7 @@ public class RouterTest extends AbstractIntentTest {
* This method tests adding a route entry.
*/
@Test
public void testProcessRouteAdd() throws TestUtilsException {
public void testRouteAdd() throws TestUtilsException {
// Construct a route entry
RouteEntry routeEntry = new RouteEntry(
Ip4Prefix.valueOf("1.1.1.0/24"),
......@@ -261,13 +263,19 @@ public class RouterTest extends AbstractIntentTest {
// Set up test expectation
reset(intentService);
intentService.submit(TestIntentServiceHelper.eqExceptId(intent));
// Setup the expected intents
IntentOperations.Builder builder = IntentOperations.builder(APPID);
builder.addSubmitOperation(intent);
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
replay(intentService);
// Call the processRouteAdd() method in Router class
// Call the processRouteUpdates() method in Router class
intentSynchronizer.leaderChanged(true);
TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
router.processRouteAdd(routeEntry);
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
routeEntry);
router.processRouteUpdates(Collections.<RouteUpdate>singletonList(routeUpdate));
// Verify
assertEquals(router.getRoutes().size(), 1);
......@@ -289,32 +297,16 @@ public class RouterTest extends AbstractIntentTest {
@Test
public void testRouteUpdate() throws TestUtilsException {
// Firstly add a route
testProcessRouteAdd();
testRouteAdd();
Intent addedIntent =
intentSynchronizer.getRouteIntents().iterator().next();
// Construct the existing route entry
RouteEntry routeEntry = new RouteEntry(
Ip4Prefix.valueOf("1.1.1.0/24"),
Ip4Address.valueOf("192.168.10.1"));
// Construct the existing MultiPointToSinglePointIntent intent
TrafficSelector.Builder selectorBuilder =
DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(
routeEntry.prefix());
TrafficTreatment.Builder treatmentBuilder =
DefaultTrafficTreatment.builder();
treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01"));
Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
ingressPoints.add(SW2_ETH1);
ingressPoints.add(SW3_ETH1);
MultiPointToSinglePointIntent intent =
new MultiPointToSinglePointIntent(APPID,
selectorBuilder.build(), treatmentBuilder.build(),
ingressPoints, SW1_ETH1);
// Start to construct a new route entry and new intent
RouteEntry routeEntryUpdate = new RouteEntry(
Ip4Prefix.valueOf("1.1.1.0/24"),
......@@ -343,14 +335,23 @@ public class RouterTest extends AbstractIntentTest {
// Set up test expectation
reset(intentService);
intentService.withdraw(TestIntentServiceHelper.eqExceptId(intent));
intentService.submit(TestIntentServiceHelper.eqExceptId(intentNew));
// Setup the expected intents
IntentOperations.Builder builder = IntentOperations.builder(APPID);
builder.addWithdrawOperation(addedIntent.id());
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
builder = IntentOperations.builder(APPID);
builder.addSubmitOperation(intentNew);
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
replay(intentService);
// Call the processRouteAdd() method in Router class
// Call the processRouteUpdates() method in Router class
intentSynchronizer.leaderChanged(true);
TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
router.processRouteAdd(routeEntryUpdate);
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
routeEntryUpdate);
router.processRouteUpdates(Collections.<RouteUpdate>singletonList(routeUpdate));
// Verify
assertEquals(router.getRoutes().size(), 1);
......@@ -368,43 +369,33 @@ public class RouterTest extends AbstractIntentTest {
* This method tests deleting a route entry.
*/
@Test
public void testProcessRouteDelete() throws TestUtilsException {
public void testRouteDelete() throws TestUtilsException {
// Firstly add a route
testProcessRouteAdd();
testRouteAdd();
Intent addedIntent =
intentSynchronizer.getRouteIntents().iterator().next();
// Construct the existing route entry
RouteEntry routeEntry = new RouteEntry(
Ip4Prefix.valueOf("1.1.1.0/24"),
Ip4Address.valueOf("192.168.10.1"));
// Construct the existing MultiPointToSinglePointIntent intent
TrafficSelector.Builder selectorBuilder =
DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(
routeEntry.prefix());
TrafficTreatment.Builder treatmentBuilder =
DefaultTrafficTreatment.builder();
treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01"));
Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
ingressPoints.add(SW2_ETH1);
ingressPoints.add(SW3_ETH1);
MultiPointToSinglePointIntent intent =
new MultiPointToSinglePointIntent(APPID,
selectorBuilder.build(), treatmentBuilder.build(),
ingressPoints, SW1_ETH1);
// Set up expectation
reset(intentService);
intentService.withdraw(TestIntentServiceHelper.eqExceptId(intent));
// Setup the expected intents
IntentOperations.Builder builder = IntentOperations.builder(APPID);
builder.addWithdrawOperation(addedIntent.id());
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
replay(intentService);
// Call route deleting method in Router class
// Call the processRouteUpdates() method in Router class
intentSynchronizer.leaderChanged(true);
TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
router.processRouteDelete(routeEntry);
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.DELETE,
routeEntry);
router.processRouteUpdates(Collections.<RouteUpdate>singletonList(routeUpdate));
// Verify
assertEquals(router.getRoutes().size(), 0);
......@@ -428,10 +419,12 @@ public class RouterTest extends AbstractIntentTest {
reset(intentService);
replay(intentService);
// Call the processRouteAdd() method in Router class
// Call the processRouteUpdates() method in Router class
intentSynchronizer.leaderChanged(true);
TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
router.processRouteAdd(routeEntry);
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
routeEntry);
router.processRouteUpdates(Collections.<RouteUpdate>singletonList(routeUpdate));
// Verify
assertEquals(router.getRoutes().size(), 1);
......
......@@ -24,6 +24,7 @@ import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
......@@ -50,6 +51,7 @@ import org.onlab.onos.net.host.HostEvent;
import org.onlab.onos.net.host.HostService;
import org.onlab.onos.net.host.InterfaceIpAddress;
import org.onlab.onos.net.intent.Intent;
import org.onlab.onos.net.intent.IntentOperations;
import org.onlab.onos.net.intent.IntentService;
import org.onlab.onos.net.intent.MultiPointToSinglePointIntent;
import org.onlab.onos.net.intent.AbstractIntentTest;
......@@ -196,7 +198,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest {
* This method tests adding a route entry.
*/
@Test
public void testProcessRouteAdd() throws TestUtilsException {
public void testRouteAdd() throws TestUtilsException {
// Construct a route entry
RouteEntry routeEntry = new RouteEntry(
......@@ -214,13 +216,18 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest {
replay(hostService);
reset(intentService);
intentService.submit(TestIntentServiceHelper.eqExceptId(intent));
IntentOperations.Builder builder = IntentOperations.builder(APPID);
builder.addSubmitOperation(intent);
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
replay(intentService);
// Call the processRouteAdd() method in Router class
// Call the processRouteUpdates() method in Router class
intentSynchronizer.leaderChanged(true);
TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
router.processRouteAdd(routeEntry);
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
routeEntry);
router.processRouteUpdates(Collections.<RouteUpdate>singletonList(routeUpdate));
Host host = new DefaultHost(ProviderId.NONE, HostId.NONE,
MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE,
......@@ -299,14 +306,22 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest {
replay(hostService);
reset(intentService);
intentService.withdraw(TestIntentServiceHelper.eqExceptId(intent));
intentService.submit(TestIntentServiceHelper.eqExceptId(intentNew));
IntentOperations.Builder builder = IntentOperations.builder(APPID);
builder.addWithdrawOperation(intent.id());
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
builder = IntentOperations.builder(APPID);
builder.addSubmitOperation(intentNew);
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
replay(intentService);
// Call the processRouteAdd() method in Router class
// Call the processRouteUpdates() method in Router class
intentSynchronizer.leaderChanged(true);
TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
router.processRouteAdd(routeEntryUpdate);
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.UPDATE,
routeEntryUpdate);
router.processRouteUpdates(Collections.<RouteUpdate>singletonList(routeUpdate));
Host host = new DefaultHost(ProviderId.NONE, HostId.NONE,
MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE,
......@@ -334,7 +349,7 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest {
* This method tests deleting a route entry.
*/
@Test
public void testProcessRouteDelete() throws TestUtilsException {
public void testRouteDelete() throws TestUtilsException {
// Construct the existing route entry
RouteEntry routeEntry = new RouteEntry(
......@@ -351,13 +366,18 @@ public class RouterTestWithAsyncArp extends AbstractIntentTest {
// Set up expectation
reset(intentService);
intentService.withdraw(TestIntentServiceHelper.eqExceptId(intent));
IntentOperations.Builder builder = IntentOperations.builder(APPID);
builder.addWithdrawOperation(intent.id());
intentService.execute(TestIntentServiceHelper.eqExceptId(
builder.build()));
replay(intentService);
// Call route deleting method in Router class
// Call the processRouteUpdates() method in Router class
intentSynchronizer.leaderChanged(true);
TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
router.processRouteDelete(routeEntry);
RouteUpdate routeUpdate = new RouteUpdate(RouteUpdate.Type.DELETE,
routeEntry);
router.processRouteUpdates(Collections.<RouteUpdate>singletonList(routeUpdate));
// Verify
assertEquals(router.getRoutes().size(), 0);
......
......@@ -236,9 +236,7 @@ public class SdnIpTest extends AbstractIntentTest {
TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
// Add route updates
for (RouteUpdate update : routeUpdates) {
router.processRouteAdd(update.routeEntry());
}
router.processRouteUpdates(routeUpdates);
latch.await(5000, TimeUnit.MILLISECONDS);
......@@ -304,17 +302,19 @@ public class SdnIpTest extends AbstractIntentTest {
TestUtils.setField(intentSynchronizer, "isActivatedLeader", true);
// Send the add updates first
for (RouteUpdate update : routeUpdates) {
router.processRouteAdd(update.routeEntry());
}
router.processRouteUpdates(routeUpdates);
// Give some time to let the intents be submitted
installCount.await(5000, TimeUnit.MILLISECONDS);
// Send the DELETE updates
List<RouteUpdate> deleteRouteUpdates = new ArrayList<>();
for (RouteUpdate update : routeUpdates) {
router.processRouteDelete(update.routeEntry());
RouteUpdate deleteUpdate = new RouteUpdate(RouteUpdate.Type.DELETE,
update.routeEntry());
deleteRouteUpdates.add(deleteUpdate);
}
router.processRouteUpdates(deleteRouteUpdates);
deleteCount.await(5000, TimeUnit.MILLISECONDS);
......
......@@ -82,7 +82,7 @@ public class BgpSessionManagerTest {
*/
private class DummyRouteListener implements RouteListener {
@Override
public void update(RouteUpdate routeUpdate) {
public void update(Collection<RouteUpdate> routeUpdate) {
// Nothing to do
}
}
......