Committed by
Gerrit Code Review
Remove old and unused Router code (incl. tests).
Added deprecated tags to a bunch of other objects that will be removed in a future release Change-Id: Iee80a260951070c1f280aa1a7755f06349aacb4f
Showing
8 changed files
with
15 additions
and
232 deletions
| ... | @@ -24,7 +24,10 @@ import java.util.Objects; | ... | @@ -24,7 +24,10 @@ import java.util.Objects; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
| 26 | * An entry in the Forwarding Information Base (FIB). | 26 | * An entry in the Forwarding Information Base (FIB). |
| 27 | + * | ||
| 28 | + * @deprecated use RouteService instead | ||
| 27 | */ | 29 | */ |
| 30 | +@Deprecated | ||
| 28 | public class FibEntry { | 31 | public class FibEntry { |
| 29 | 32 | ||
| 30 | private final IpPrefix prefix; | 33 | private final IpPrefix prefix; | ... | ... |
| ... | @@ -19,7 +19,10 @@ import java.util.Collection; | ... | @@ -19,7 +19,10 @@ import java.util.Collection; |
| 19 | 19 | ||
| 20 | /** | 20 | /** |
| 21 | * A component that is able to process Forwarding Information Base (FIB) updates. | 21 | * A component that is able to process Forwarding Information Base (FIB) updates. |
| 22 | + * | ||
| 23 | + * @deprecated use RouteService instead | ||
| 22 | */ | 24 | */ |
| 25 | +@Deprecated | ||
| 23 | public interface FibListener { | 26 | public interface FibListener { |
| 24 | 27 | ||
| 25 | /** | 28 | /** | ... | ... |
| ... | @@ -21,7 +21,10 @@ import java.util.Objects; | ... | @@ -21,7 +21,10 @@ import java.util.Objects; |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | * Represents a change to the Forwarding Information Base (FIB). | 23 | * Represents a change to the Forwarding Information Base (FIB). |
| 24 | + * | ||
| 25 | + * @deprecated use RouteService instead | ||
| 24 | */ | 26 | */ |
| 27 | +@Deprecated | ||
| 25 | public class FibUpdate { | 28 | public class FibUpdate { |
| 26 | 29 | ||
| 27 | /** | 30 | /** | ... | ... |
| ... | @@ -25,7 +25,10 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -25,7 +25,10 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| 27 | * Represents a route entry for an IP prefix. | 27 | * Represents a route entry for an IP prefix. |
| 28 | + * | ||
| 29 | + * @deprecated use RouteService instead | ||
| 28 | */ | 30 | */ |
| 31 | +@Deprecated | ||
| 29 | public class RouteEntry { | 32 | public class RouteEntry { |
| 30 | private final IpPrefix prefix; // The IP prefix | 33 | private final IpPrefix prefix; // The IP prefix |
| 31 | private final IpAddress nextHop; // Next-hop IP address | 34 | private final IpAddress nextHop; // Next-hop IP address | ... | ... |
| ... | @@ -23,7 +23,10 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -23,7 +23,10 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | * Represents a change in routing information. | 25 | * Represents a change in routing information. |
| 26 | + * | ||
| 27 | + * @deprecated use RouteService instead | ||
| 26 | */ | 28 | */ |
| 29 | +@Deprecated | ||
| 27 | public class RouteUpdate { | 30 | public class RouteUpdate { |
| 28 | private final Type type; // The route update type | 31 | private final Type type; // The route update type |
| 29 | private final RouteEntry routeEntry; // The updated route entry | 32 | private final RouteEntry routeEntry; // The updated route entry | ... | ... |
This diff is collapsed. Click to expand it.
| 1 | -/* | ||
| 2 | - * Copyright 2015-present Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.routing.impl; | ||
| 17 | - | ||
| 18 | -import com.google.common.collect.Sets; | ||
| 19 | - | ||
| 20 | -import org.junit.After; | ||
| 21 | -import org.junit.Before; | ||
| 22 | -import org.junit.Test; | ||
| 23 | -import org.onlab.packet.Ip4Address; | ||
| 24 | -import org.onlab.packet.Ip4Prefix; | ||
| 25 | -import org.onlab.packet.IpAddress; | ||
| 26 | -import org.onlab.packet.IpPrefix; | ||
| 27 | -import org.onlab.packet.MacAddress; | ||
| 28 | -import org.onlab.packet.VlanId; | ||
| 29 | -import org.onosproject.core.CoreService; | ||
| 30 | -import org.onosproject.net.ConnectPoint; | ||
| 31 | -import org.onosproject.net.DefaultHost; | ||
| 32 | -import org.onosproject.net.DeviceId; | ||
| 33 | -import org.onosproject.net.Host; | ||
| 34 | -import org.onosproject.net.HostId; | ||
| 35 | -import org.onosproject.net.HostLocation; | ||
| 36 | -import org.onosproject.net.PortNumber; | ||
| 37 | -import org.onosproject.net.host.HostEvent; | ||
| 38 | -import org.onosproject.net.host.HostListener; | ||
| 39 | -import org.onosproject.net.host.HostService; | ||
| 40 | -import org.onosproject.net.provider.ProviderId; | ||
| 41 | -import org.onosproject.routing.config.RoutingConfigurationService; | ||
| 42 | -import org.onosproject.routing.impl.DefaultRouter.InternalHostListener; | ||
| 43 | -import org.onosproject.routing.RouteSourceService; | ||
| 44 | -import org.onosproject.routing.FibEntry; | ||
| 45 | -import org.onosproject.routing.FibListener; | ||
| 46 | -import org.onosproject.routing.FibUpdate; | ||
| 47 | -import org.onosproject.routing.RouteEntry; | ||
| 48 | -import org.onosproject.routing.RouteListener; | ||
| 49 | -import org.onosproject.routing.RouteUpdate; | ||
| 50 | - | ||
| 51 | -import java.util.Collections; | ||
| 52 | - | ||
| 53 | -import static org.easymock.EasyMock.*; | ||
| 54 | - | ||
| 55 | -/** | ||
| 56 | -* This class tests adding a route and updating a route. | ||
| 57 | -* The HostService module answers the MAC address asynchronously. | ||
| 58 | -*/ | ||
| 59 | -public class RouterAsyncArpTest { | ||
| 60 | - | ||
| 61 | - private HostService hostService; | ||
| 62 | - private FibListener fibListener; | ||
| 63 | - private RoutingConfigurationService routingConfigurationService; | ||
| 64 | - | ||
| 65 | - private static final ConnectPoint SW1_ETH1 = new ConnectPoint( | ||
| 66 | - DeviceId.deviceId("of:0000000000000001"), | ||
| 67 | - PortNumber.portNumber(1)); | ||
| 68 | - | ||
| 69 | - private static final ConnectPoint SW2_ETH1 = new ConnectPoint( | ||
| 70 | - DeviceId.deviceId("of:0000000000000002"), | ||
| 71 | - PortNumber.portNumber(1)); | ||
| 72 | - | ||
| 73 | - private static final ConnectPoint SW3_ETH1 = new ConnectPoint( | ||
| 74 | - DeviceId.deviceId("of:0000000000000003"), | ||
| 75 | - PortNumber.portNumber(1)); | ||
| 76 | - | ||
| 77 | - private DefaultRouter router; | ||
| 78 | - private InternalHostListener internalHostListener; | ||
| 79 | - | ||
| 80 | - @Before | ||
| 81 | - public void setUp() throws Exception { | ||
| 82 | - hostService = createMock(HostService.class); | ||
| 83 | - routingConfigurationService = | ||
| 84 | - createMock(RoutingConfigurationService.class); | ||
| 85 | - | ||
| 86 | - RouteSourceService routeSourceService = createMock(RouteSourceService.class); | ||
| 87 | - routeSourceService.start(anyObject(RouteListener.class)); | ||
| 88 | - routeSourceService.stop(); | ||
| 89 | - replay(routeSourceService); | ||
| 90 | - | ||
| 91 | - fibListener = createMock(FibListener.class); | ||
| 92 | - | ||
| 93 | - router = new DefaultRouter(); | ||
| 94 | - router.coreService = createNiceMock(CoreService.class); | ||
| 95 | - router.hostService = hostService; | ||
| 96 | - router.routingConfigurationService = routingConfigurationService; | ||
| 97 | - router.routeSourceService = routeSourceService; | ||
| 98 | - router.activate(); | ||
| 99 | - | ||
| 100 | - router.addFibListener(fibListener); | ||
| 101 | - router.start(); | ||
| 102 | - | ||
| 103 | - internalHostListener = router.new InternalHostListener(); | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - @After | ||
| 107 | - public void tearDown() { | ||
| 108 | - // Called during shutdown | ||
| 109 | - reset(hostService); | ||
| 110 | - hostService.removeListener(anyObject(HostListener.class)); | ||
| 111 | - | ||
| 112 | - router.stop(); | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - /** | ||
| 116 | - * Tests adding a route entry with asynchronous HostService replies. | ||
| 117 | - */ | ||
| 118 | - @Test | ||
| 119 | - public void testRouteAdd() { | ||
| 120 | - // Construct a route entry | ||
| 121 | - IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24"); | ||
| 122 | - IpAddress nextHopIp = Ip4Address.valueOf("192.168.10.1"); | ||
| 123 | - | ||
| 124 | - RouteEntry routeEntry = new RouteEntry(prefix, nextHopIp); | ||
| 125 | - | ||
| 126 | - // Host service will reply with no hosts when asked | ||
| 127 | - reset(hostService); | ||
| 128 | - expect(hostService.getHostsByIp(anyObject(IpAddress.class))).andReturn( | ||
| 129 | - Collections.emptySet()).anyTimes(); | ||
| 130 | - hostService.startMonitoringIp(IpAddress.valueOf("192.168.10.1")); | ||
| 131 | - replay(hostService); | ||
| 132 | - | ||
| 133 | - reset(routingConfigurationService); | ||
| 134 | - expect(routingConfigurationService.isIpPrefixLocal( | ||
| 135 | - anyObject(IpPrefix.class))).andReturn(false); | ||
| 136 | - replay(routingConfigurationService); | ||
| 137 | - | ||
| 138 | - // Initially when we add the route, no FIB update will be sent | ||
| 139 | - replay(fibListener); | ||
| 140 | - | ||
| 141 | - router.processRouteUpdates(Collections.singletonList( | ||
| 142 | - new RouteUpdate(RouteUpdate.Type.UPDATE, routeEntry))); | ||
| 143 | - | ||
| 144 | - verify(fibListener); | ||
| 145 | - | ||
| 146 | - | ||
| 147 | - // Now when we send the event, we expect the FIB update to be sent | ||
| 148 | - reset(fibListener); | ||
| 149 | - FibEntry fibEntry = new FibEntry(prefix, nextHopIp, | ||
| 150 | - MacAddress.valueOf("00:00:00:00:00:01")); | ||
| 151 | - | ||
| 152 | - fibListener.update(Collections.singletonList(new FibUpdate( | ||
| 153 | - FibUpdate.Type.UPDATE, fibEntry)), Collections.emptyList()); | ||
| 154 | - replay(fibListener); | ||
| 155 | - | ||
| 156 | - Host host = new DefaultHost(ProviderId.NONE, HostId.NONE, | ||
| 157 | - MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE, | ||
| 158 | - new HostLocation( | ||
| 159 | - SW1_ETH1.deviceId(), | ||
| 160 | - SW1_ETH1.port(), 1), | ||
| 161 | - Sets.newHashSet(IpAddress.valueOf("192.168.10.1"))); | ||
| 162 | - | ||
| 163 | - // Send in the host event | ||
| 164 | - internalHostListener.event( | ||
| 165 | - new HostEvent(HostEvent.Type.HOST_ADDED, host)); | ||
| 166 | - | ||
| 167 | - verify(fibListener); | ||
| 168 | - } | ||
| 169 | - | ||
| 170 | - /** | ||
| 171 | - * Tests updating a route entry with asynchronous HostService replies. | ||
| 172 | - */ | ||
| 173 | - @Test | ||
| 174 | - public void testRouteUpdate() { | ||
| 175 | - // Add a route | ||
| 176 | - testRouteAdd(); | ||
| 177 | - | ||
| 178 | - // Construct a route entry | ||
| 179 | - IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24"); | ||
| 180 | - IpAddress nextHopIp = Ip4Address.valueOf("192.168.20.1"); | ||
| 181 | - | ||
| 182 | - RouteEntry routeEntry = new RouteEntry(prefix, nextHopIp); | ||
| 183 | - | ||
| 184 | - // Host service will reply with no hosts when asked | ||
| 185 | - reset(hostService); | ||
| 186 | - expect(hostService.getHostsByIp(anyObject(IpAddress.class))).andReturn( | ||
| 187 | - Collections.emptySet()).anyTimes(); | ||
| 188 | - hostService.startMonitoringIp(IpAddress.valueOf("192.168.20.1")); | ||
| 189 | - replay(hostService); | ||
| 190 | - | ||
| 191 | - reset(routingConfigurationService); | ||
| 192 | - expect(routingConfigurationService.isIpPrefixLocal( | ||
| 193 | - anyObject(IpPrefix.class))).andReturn(false); | ||
| 194 | - replay(routingConfigurationService); | ||
| 195 | - | ||
| 196 | - // Initially when we add the route, the DELETE FIB update will be sent | ||
| 197 | - // but the UPDATE FIB update will come later when the MAC is resolved | ||
| 198 | - reset(fibListener); | ||
| 199 | - | ||
| 200 | - fibListener.update(Collections.emptyList(), Collections.singletonList(new FibUpdate( | ||
| 201 | - FibUpdate.Type.DELETE, new FibEntry(prefix, null, null)))); | ||
| 202 | - replay(fibListener); | ||
| 203 | - | ||
| 204 | - router.processRouteUpdates(Collections.singletonList( | ||
| 205 | - new RouteUpdate(RouteUpdate.Type.UPDATE, routeEntry))); | ||
| 206 | - | ||
| 207 | - verify(fibListener); | ||
| 208 | - | ||
| 209 | - | ||
| 210 | - // Now when we send the event, we expect the FIB update to be sent | ||
| 211 | - reset(fibListener); | ||
| 212 | - FibEntry fibEntry = new FibEntry(prefix, nextHopIp, | ||
| 213 | - MacAddress.valueOf("00:00:00:00:00:02")); | ||
| 214 | - | ||
| 215 | - fibListener.update(Collections.singletonList(new FibUpdate( | ||
| 216 | - FibUpdate.Type.UPDATE, fibEntry)), Collections.emptyList()); | ||
| 217 | - replay(fibListener); | ||
| 218 | - | ||
| 219 | - Host host = new DefaultHost(ProviderId.NONE, HostId.NONE, | ||
| 220 | - MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE, | ||
| 221 | - new HostLocation( | ||
| 222 | - SW1_ETH1.deviceId(), | ||
| 223 | - SW1_ETH1.port(), 1), | ||
| 224 | - Sets.newHashSet(IpAddress.valueOf("192.168.20.1"))); | ||
| 225 | - | ||
| 226 | - // Send in the host event | ||
| 227 | - internalHostListener.event( | ||
| 228 | - new HostEvent(HostEvent.Type.HOST_ADDED, host)); | ||
| 229 | - | ||
| 230 | - verify(fibListener); | ||
| 231 | - } | ||
| 232 | -} |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment