Remove old config classes from routing bundle.
Change-Id: Ifc8ff03674c1cfb9e3cde86b9994b8362744840d
diff --git a/apps/routing/src/test/java/org/onosproject/routing/impl/IntentSynchronizerTest.java b/apps/routing/src/test/java/org/onosproject/routing/impl/IntentSynchronizerTest.java
index 0172dc7..4b7110a 100644
--- a/apps/routing/src/test/java/org/onosproject/routing/impl/IntentSynchronizerTest.java
+++ b/apps/routing/src/test/java/org/onosproject/routing/impl/IntentSynchronizerTest.java
@@ -15,20 +15,14 @@
*/
package org.onosproject.routing.impl;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import com.google.common.util.concurrent.MoreExecutors;
import org.junit.Before;
import org.junit.Test;
-import org.onlab.junit.TestUtils;
-import org.onlab.junit.TestUtils.TestUtilsException;
import org.onlab.packet.Ethernet;
-import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
import org.onosproject.TestApplicationId;
import org.onosproject.cluster.ClusterServiceAdapter;
import org.onosproject.cluster.ControllerNode;
@@ -37,7 +31,6 @@
import org.onosproject.cluster.NodeId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreServiceAdapter;
-import org.onosproject.incubator.net.intf.Interface;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
@@ -45,19 +38,15 @@
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.host.InterfaceIpAddress;
import org.onosproject.net.intent.AbstractIntentTest;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.intent.IntentUtils;
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.MultiPointToSinglePointIntent;
-import org.onosproject.routing.RouteEntry;
import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@@ -66,9 +55,6 @@
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.reset;
import static org.easymock.EasyMock.verify;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
/**
* This class tests the intent synchronization function in the
@@ -95,7 +81,7 @@
PortNumber.portNumber(1));
private IntentSynchronizer intentSynchronizer;
- private final Set<Interface> interfaces = Sets.newHashSet();
+ private final Set<ConnectPoint> connectPoints = new HashSet<>();
private static final ApplicationId APPID =
TestApplicationId.create("intent-sync-test");
@@ -107,7 +93,7 @@
public void setUp() throws Exception {
super.setUp();
- setUpInterfaceService();
+ setUpConnectPoints();
intentService = createMock(IntentService.class);
@@ -115,131 +101,58 @@
intentSynchronizer.coreService = new TestCoreService();
intentSynchronizer.clusterService = new TestClusterService();
- intentSynchronizer.leadershipService = new TestLeadershipService();
+ intentSynchronizer.leadershipService = new LeadershipServiceAdapter();
intentSynchronizer.intentService = intentService;
intentSynchronizer.activate();
}
/**
- * Sets up InterfaceService.
+ * Sets up connect points.
*/
- private void setUpInterfaceService() {
- List<InterfaceIpAddress> interfaceIpAddresses1 = Lists.newArrayList();
- interfaceIpAddresses1.add(new InterfaceIpAddress(
- IpAddress.valueOf("192.168.10.101"),
- IpPrefix.valueOf("192.168.10.0/24")));
- Interface sw1Eth1 = new Interface(SW1_ETH1,
- interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
- VlanId.NONE);
- interfaces.add(sw1Eth1);
-
- List<InterfaceIpAddress> interfaceIpAddresses2 = Lists.newArrayList();
- interfaceIpAddresses2.add(
- new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"),
- IpPrefix.valueOf("192.168.20.0/24")));
- Interface sw2Eth1 = new Interface(SW2_ETH1,
- interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
- VlanId.NONE);
- interfaces.add(sw2Eth1);
-
- List<InterfaceIpAddress> interfaceIpAddresses3 = Lists.newArrayList();
- interfaceIpAddresses3.add(
- new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"),
- IpPrefix.valueOf("192.168.30.0/24")));
- Interface sw3Eth1 = new Interface(SW3_ETH1,
- interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"),
- VlanId.NONE);
- interfaces.add(sw3Eth1);
-
- InterfaceIpAddress interfaceIpAddress4 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"),
- IpPrefix.valueOf("192.168.40.0/24"));
- Interface sw4Eth1 = new Interface(SW4_ETH1,
- Lists.newArrayList(interfaceIpAddress4),
- MacAddress.valueOf("00:00:00:00:00:04"),
- VlanId.vlanId((short) 1));
-
- interfaces.add(sw4Eth1);
+ private void setUpConnectPoints() {
+ connectPoints.add(SW1_ETH1);
+ connectPoints.add(SW2_ETH1);
+ connectPoints.add(SW3_ETH1);
+ connectPoints.add(SW4_ETH1);
}
/**
* Tests the synchronization behavior of intent synchronizer. We set up
* a discrepancy between the intent service state and the intent
* synchronizer's state and ensure that this is reconciled correctly.
- *
- * @throws TestUtilsException
*/
@Test
- public void testIntentSync() throws TestUtilsException {
+ public void testIntentSync() {
- //
// Construct routes and intents.
// This test simulates the following cases during the master change
// time interval:
- // 1. RouteEntry1 did not change and the intent also did not change.
- // 2. RouteEntry2 was deleted, but the intent was not deleted.
- // 3. RouteEntry3 was newly added, and the intent was also submitted.
- // 4. RouteEntry4 was updated to RouteEntry4Update, and the intent was
+ // 1. intent1 did not change and the intent also did not change.
+ // 2. intent2 was deleted, but the intent was not deleted.
+ // 3. intent3 was newly added, and the intent was also submitted.
+ // 4. intent4 was updated to RouteEntry4Update, and the intent was
// also updated to a new one.
- // 5. RouteEntry5 did not change, but its intent id changed.
- // 6. RouteEntry6 was newly added, but the intent was not submitted.
- //
- RouteEntry routeEntry1 = new RouteEntry(
- Ip4Prefix.valueOf("1.1.1.0/24"),
- Ip4Address.valueOf("192.168.10.1"));
-
- RouteEntry routeEntry2 = new RouteEntry(
- Ip4Prefix.valueOf("2.2.2.0/24"),
- Ip4Address.valueOf("192.168.20.1"));
-
- RouteEntry routeEntry3 = new RouteEntry(
- Ip4Prefix.valueOf("3.3.3.0/24"),
- Ip4Address.valueOf("192.168.30.1"));
-
- RouteEntry routeEntry4 = new RouteEntry(
- Ip4Prefix.valueOf("4.4.4.0/24"),
- Ip4Address.valueOf("192.168.30.1"));
-
- RouteEntry routeEntry4Update = new RouteEntry(
- Ip4Prefix.valueOf("4.4.4.0/24"),
- Ip4Address.valueOf("192.168.20.1"));
-
- RouteEntry routeEntry5 = new RouteEntry(
- Ip4Prefix.valueOf("5.5.5.0/24"),
- Ip4Address.valueOf("192.168.10.1"));
-
- RouteEntry routeEntry6 = new RouteEntry(
- Ip4Prefix.valueOf("6.6.6.0/24"),
- Ip4Address.valueOf("192.168.10.1"));
-
- RouteEntry routeEntry7 = new RouteEntry(
- Ip4Prefix.valueOf("7.7.7.0/24"),
- Ip4Address.valueOf("192.168.10.1"));
+ // 5. intent5 did not change, but its intent id changed.
+ // 6. intent6 was newly added, but the intent was not submitted.
MultiPointToSinglePointIntent intent1 = intentBuilder(
- routeEntry1.prefix(), "00:00:00:00:00:01", SW1_ETH1);
+ Ip4Prefix.valueOf("1.1.1.0/24"), "00:00:00:00:00:01", SW1_ETH1);
MultiPointToSinglePointIntent intent2 = intentBuilder(
- routeEntry2.prefix(), "00:00:00:00:00:02", SW2_ETH1);
+ Ip4Prefix.valueOf("2.2.2.0/24"), "00:00:00:00:00:02", SW2_ETH1);
MultiPointToSinglePointIntent intent3 = intentBuilder(
- routeEntry3.prefix(), "00:00:00:00:00:03", SW3_ETH1);
+ Ip4Prefix.valueOf("3.3.3.0/24"), "00:00:00:00:00:03", SW3_ETH1);
MultiPointToSinglePointIntent intent4 = intentBuilder(
- routeEntry4.prefix(), "00:00:00:00:00:03", SW3_ETH1);
+ Ip4Prefix.valueOf("4.4.4.0/24"), "00:00:00:00:00:03", SW3_ETH1);
MultiPointToSinglePointIntent intent4Update = intentBuilder(
- routeEntry4Update.prefix(), "00:00:00:00:00:02", SW2_ETH1);
+ Ip4Prefix.valueOf("4.4.4.0/24"), "00:00:00:00:00:02", SW2_ETH1);
MultiPointToSinglePointIntent intent5 = intentBuilder(
- routeEntry5.prefix(), "00:00:00:00:00:01", SW1_ETH1);
+ Ip4Prefix.valueOf("5.5.5.0/24"), "00:00:00:00:00:01", SW1_ETH1);
MultiPointToSinglePointIntent intent7 = intentBuilder(
- routeEntry7.prefix(), "00:00:00:00:00:01", SW1_ETH1);
-
- // Compose a intent, which is equal to intent5 but the id is different.
- MultiPointToSinglePointIntent intent5New =
- staticIntentBuilder(intent5, routeEntry5, "00:00:00:00:00:01");
- assertThat(IntentUtils.intentsAreEqual(intent5, intent5New), is(true));
- assertFalse(intent5.equals(intent5New));
+ Ip4Prefix.valueOf("7.7.7.0/24"), "00:00:00:00:00:01", SW1_ETH1);
MultiPointToSinglePointIntent intent6 = intentBuilder(
- routeEntry6.prefix(), "00:00:00:00:00:01", SW1_ETH1);
+ Ip4Prefix.valueOf("6.6.6.0/24"), "00:00:00:00:00:01", SW1_ETH1);
// Set up expectation
Set<Intent> intents = new HashSet<>();
@@ -395,13 +308,9 @@
DefaultTrafficTreatment.builder();
treatmentBuilder.setEthDst(MacAddress.valueOf(nextHopMacAddress));
- Set<ConnectPoint> ingressPoints = new HashSet<>();
- for (Interface intf : interfaces) {
- if (!intf.connectPoint().equals(egressPoint)) {
- ConnectPoint srcPort = intf.connectPoint();
- ingressPoints.add(srcPort);
- }
- }
+ Set<ConnectPoint> ingressPoints = new HashSet<>(connectPoints);
+ ingressPoints.remove(egressPoint);
+
MultiPointToSinglePointIntent intent =
MultiPointToSinglePointIntent.builder()
.appId(APPID)
@@ -414,29 +323,6 @@
return intent;
}
- /**
- * A static MultiPointToSinglePointIntent builder, the returned intent is
- * equal to the input intent except that the id is different.
- *
- * @param intent the intent to be used for building a new intent
- * @param routeEntry the relative routeEntry of the intent
- * @return the newly constructed MultiPointToSinglePointIntent
- * @throws TestUtilsException
- */
- private MultiPointToSinglePointIntent staticIntentBuilder(
- MultiPointToSinglePointIntent intent, RouteEntry routeEntry,
- String nextHopMacAddress) throws TestUtilsException {
-
- // Use a different egress ConnectPoint with that in intent
- // to generate a different id
- MultiPointToSinglePointIntent intentNew = intentBuilder(
- routeEntry.prefix(), nextHopMacAddress, SW2_ETH1);
- TestUtils.setField(intentNew, "egressPoint", intent.egressPoint());
- TestUtils.setField(intentNew,
- "ingressPoints", intent.ingressPoints());
- return intentNew;
- }
-
private class TestIntentSynchronizer extends IntentSynchronizer {
@Override
protected ExecutorService createExecutor() {
@@ -457,8 +343,4 @@
return LOCAL_NODE;
}
}
-
- private class TestLeadershipService extends LeadershipServiceAdapter {
-
- }
}