alshabib | ab98466 | 2014-12-04 18:56:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.sdnip; |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 552e31f | 2015-02-06 11:11:59 -0800 | [diff] [blame] | 18 | import com.google.common.collect.Sets; |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
| 21 | import org.onlab.junit.TestUtils; |
| 22 | import org.onlab.junit.TestUtils.TestUtilsException; |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 23 | import org.onlab.packet.Ethernet; |
| 24 | import org.onlab.packet.Ip4Address; |
| 25 | import org.onlab.packet.Ip4Prefix; |
| 26 | import org.onlab.packet.IpAddress; |
| 27 | import org.onlab.packet.IpPrefix; |
| 28 | import org.onlab.packet.MacAddress; |
| 29 | import org.onlab.packet.VlanId; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 30 | import org.onosproject.core.ApplicationId; |
| 31 | import org.onosproject.net.ConnectPoint; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 32 | import org.onosproject.net.DeviceId; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 33 | import org.onosproject.net.PortNumber; |
| 34 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 35 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 36 | import org.onosproject.net.flow.TrafficSelector; |
| 37 | import org.onosproject.net.flow.TrafficTreatment; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 38 | import org.onosproject.net.host.InterfaceIpAddress; |
| 39 | import org.onosproject.net.intent.AbstractIntentTest; |
| 40 | import org.onosproject.net.intent.Intent; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 41 | import org.onosproject.net.intent.IntentService; |
| 42 | import org.onosproject.net.intent.IntentState; |
| 43 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
Jonathan Hart | 2da1e60 | 2015-02-18 19:09:24 -0800 | [diff] [blame] | 44 | import org.onosproject.routing.FibEntry; |
| 45 | import org.onosproject.routing.FibUpdate; |
| 46 | import org.onosproject.routing.RouteEntry; |
| 47 | import org.onosproject.routing.config.BgpPeer; |
| 48 | import org.onosproject.routing.config.Interface; |
| 49 | import org.onosproject.routing.config.RoutingConfigurationService; |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 50 | import org.onosproject.sdnip.IntentSynchronizer.IntentKey; |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 51 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 52 | import java.util.Collections; |
| 53 | import java.util.HashMap; |
Jonathan Hart | 552e31f | 2015-02-06 11:11:59 -0800 | [diff] [blame] | 54 | import java.util.HashSet; |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 55 | import java.util.Map; |
Jonathan Hart | 552e31f | 2015-02-06 11:11:59 -0800 | [diff] [blame] | 56 | import java.util.Set; |
| 57 | import java.util.concurrent.ConcurrentHashMap; |
| 58 | |
| 59 | import static org.easymock.EasyMock.*; |
| 60 | import static org.hamcrest.Matchers.is; |
Jonathan Hart | cb726fc | 2015-02-13 16:26:22 -0800 | [diff] [blame] | 61 | import static org.junit.Assert.assertEquals; |
| 62 | import static org.junit.Assert.assertFalse; |
| 63 | import static org.junit.Assert.assertThat; |
| 64 | import static org.junit.Assert.assertTrue; |
| 65 | import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId; |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
Pavlin Radoslavov | a071b1e | 2014-11-17 13:37:57 -0800 | [diff] [blame] | 68 | * This class tests the intent synchronization function in the |
| 69 | * IntentSynchronizer class. |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 70 | */ |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 71 | public class IntentSyncTest extends AbstractIntentTest { |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 72 | |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 73 | private RoutingConfigurationService routingConfig; |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 74 | private IntentService intentService; |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 75 | |
| 76 | private static final ConnectPoint SW1_ETH1 = new ConnectPoint( |
| 77 | DeviceId.deviceId("of:0000000000000001"), |
| 78 | PortNumber.portNumber(1)); |
| 79 | |
| 80 | private static final ConnectPoint SW2_ETH1 = new ConnectPoint( |
| 81 | DeviceId.deviceId("of:0000000000000002"), |
| 82 | PortNumber.portNumber(1)); |
| 83 | |
| 84 | private static final ConnectPoint SW3_ETH1 = new ConnectPoint( |
| 85 | DeviceId.deviceId("of:0000000000000003"), |
| 86 | PortNumber.portNumber(1)); |
| 87 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 88 | private static final ConnectPoint SW4_ETH1 = new ConnectPoint( |
| 89 | DeviceId.deviceId("of:0000000000000004"), |
| 90 | PortNumber.portNumber(1)); |
| 91 | |
Pavlin Radoslavov | a071b1e | 2014-11-17 13:37:57 -0800 | [diff] [blame] | 92 | private IntentSynchronizer intentSynchronizer; |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 93 | |
| 94 | private static final ApplicationId APPID = new ApplicationId() { |
| 95 | @Override |
| 96 | public short id() { |
| 97 | return 1; |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public String name() { |
| 102 | return "SDNIP"; |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | @Before |
| 107 | public void setUp() throws Exception { |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 108 | super.setUp(); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 109 | |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 110 | routingConfig = createMock(RoutingConfigurationService.class); |
| 111 | |
| 112 | // These will set expectations on routingConfig |
| 113 | setUpInterfaceService(); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 114 | setUpBgpPeers(); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 115 | |
| 116 | replay(routingConfig); |
| 117 | |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 118 | intentService = createMock(IntentService.class); |
| 119 | |
Jonathan Hart | 552e31f | 2015-02-06 11:11:59 -0800 | [diff] [blame] | 120 | intentSynchronizer = new IntentSynchronizer(APPID, intentService, |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 121 | routingConfig); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Sets up BGP peers in external networks. |
| 126 | */ |
| 127 | private void setUpBgpPeers() { |
| 128 | |
| 129 | Map<IpAddress, BgpPeer> peers = new HashMap<>(); |
| 130 | |
| 131 | String peerSw1Eth1 = "192.168.10.1"; |
| 132 | peers.put(IpAddress.valueOf(peerSw1Eth1), |
| 133 | new BgpPeer("00:00:00:00:00:00:00:01", 1, peerSw1Eth1)); |
| 134 | |
| 135 | // Two BGP peers are connected to switch 2 port 1. |
| 136 | String peer1Sw2Eth1 = "192.168.20.1"; |
| 137 | peers.put(IpAddress.valueOf(peer1Sw2Eth1), |
| 138 | new BgpPeer("00:00:00:00:00:00:00:02", 1, peer1Sw2Eth1)); |
| 139 | |
| 140 | String peer2Sw2Eth1 = "192.168.20.2"; |
| 141 | peers.put(IpAddress.valueOf(peer2Sw2Eth1), |
| 142 | new BgpPeer("00:00:00:00:00:00:00:02", 1, peer2Sw2Eth1)); |
| 143 | |
| 144 | String peer1Sw4Eth1 = "192.168.40.1"; |
| 145 | peers.put(IpAddress.valueOf(peer1Sw4Eth1), |
| 146 | new BgpPeer("00:00:00:00:00:00:00:04", 1, peer1Sw4Eth1)); |
| 147 | |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 148 | expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes(); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Sets up InterfaceService. |
| 153 | */ |
| 154 | private void setUpInterfaceService() { |
| 155 | |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 156 | Set<Interface> interfaces = Sets.newHashSet(); |
| 157 | |
| 158 | Set<InterfaceIpAddress> interfaceIpAddresses1 = Sets.newHashSet(); |
| 159 | interfaceIpAddresses1.add(new InterfaceIpAddress( |
| 160 | IpAddress.valueOf("192.168.10.101"), |
| 161 | IpPrefix.valueOf("192.168.10.0/24"))); |
| 162 | Interface sw1Eth1 = new Interface(SW1_ETH1, |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 163 | interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"), |
| 164 | VlanId.NONE); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 165 | interfaces.add(sw1Eth1); |
| 166 | |
| 167 | Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet(); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 168 | interfaceIpAddresses2.add( |
| 169 | new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"), |
| 170 | IpPrefix.valueOf("192.168.20.0/24"))); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 171 | Interface sw2Eth1 = new Interface(SW2_ETH1, |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 172 | interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"), |
| 173 | VlanId.NONE); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 174 | interfaces.add(sw2Eth1); |
| 175 | |
| 176 | Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet(); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 177 | interfaceIpAddresses3.add( |
| 178 | new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"), |
| 179 | IpPrefix.valueOf("192.168.30.0/24"))); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 180 | Interface sw3Eth1 = new Interface(SW3_ETH1, |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 181 | interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"), |
| 182 | VlanId.NONE); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 183 | interfaces.add(sw3Eth1); |
| 184 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 185 | InterfaceIpAddress interfaceIpAddress4 = |
| 186 | new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), |
| 187 | IpPrefix.valueOf("192.168.40.0/24")); |
| 188 | Interface sw4Eth1 = new Interface(SW4_ETH1, |
| 189 | Sets.newHashSet(interfaceIpAddress4), |
| 190 | MacAddress.valueOf("00:00:00:00:00:04"), |
| 191 | VlanId.vlanId((short) 1)); |
| 192 | |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 193 | expect(routingConfig.getInterface(SW4_ETH1)).andReturn( |
| 194 | sw4Eth1).anyTimes(); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 195 | interfaces.add(sw4Eth1); |
| 196 | |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 197 | expect(routingConfig.getInterface(SW1_ETH1)).andReturn( |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 198 | sw1Eth1).anyTimes(); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 199 | expect(routingConfig.getInterface(SW2_ETH1)).andReturn( |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 200 | sw2Eth1).anyTimes(); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 201 | expect(routingConfig.getInterface(SW3_ETH1)).andReturn(sw3Eth1).anyTimes(); |
| 202 | expect(routingConfig.getInterfaces()).andReturn(interfaces).anyTimes(); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /** |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 206 | * Tests adding a FIB entry to the IntentSynchronizer. |
| 207 | * |
| 208 | * We verify that the synchronizer records the correct state and that the |
| 209 | * correct intent is submitted to the IntentService. |
| 210 | * |
| 211 | * @throws TestUtilsException |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 212 | */ |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 213 | @Test |
| 214 | public void testFibAdd() throws TestUtilsException { |
| 215 | FibEntry fibEntry = new FibEntry( |
| 216 | Ip4Prefix.valueOf("1.1.1.0/24"), |
| 217 | Ip4Address.valueOf("192.168.10.1"), |
| 218 | MacAddress.valueOf("00:00:00:00:00:01")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 219 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 220 | // Construct a MultiPointToSinglePointIntent intent |
| 221 | TrafficSelector.Builder selectorBuilder = |
| 222 | DefaultTrafficSelector.builder(); |
| 223 | selectorBuilder.matchEthType(Ethernet.TYPE_IPV4).matchIPDst( |
| 224 | fibEntry.prefix()); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 225 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 226 | TrafficTreatment.Builder treatmentBuilder = |
| 227 | DefaultTrafficTreatment.builder(); |
| 228 | treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 229 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 230 | Set<ConnectPoint> ingressPoints = new HashSet<>(); |
| 231 | ingressPoints.add(SW2_ETH1); |
| 232 | ingressPoints.add(SW3_ETH1); |
| 233 | ingressPoints.add(SW4_ETH1); |
| 234 | |
| 235 | MultiPointToSinglePointIntent intent = |
| 236 | new MultiPointToSinglePointIntent(APPID, |
| 237 | selectorBuilder.build(), treatmentBuilder.build(), |
| 238 | ingressPoints, SW1_ETH1); |
| 239 | |
| 240 | // Setup the expected intents |
Jonathan Hart | cb726fc | 2015-02-13 16:26:22 -0800 | [diff] [blame] | 241 | intentService.submit(eqExceptId(intent)); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 242 | replay(intentService); |
| 243 | |
| 244 | intentSynchronizer.leaderChanged(true); |
| 245 | TestUtils.setField(intentSynchronizer, "isActivatedLeader", true); |
| 246 | |
| 247 | FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, |
| 248 | fibEntry); |
| 249 | intentSynchronizer.update(Collections.singleton(fibUpdate), |
| 250 | Collections.emptyList()); |
| 251 | |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 252 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 253 | Intent firstIntent = |
| 254 | intentSynchronizer.getRouteIntents().iterator().next(); |
| 255 | IntentKey firstIntentKey = new IntentKey(firstIntent); |
| 256 | IntentKey intentKey = new IntentKey(intent); |
| 257 | assertTrue(firstIntentKey.equals(intentKey)); |
| 258 | verify(intentService); |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Tests adding a FIB entry with to a next hop in a VLAN. |
| 263 | * |
| 264 | * We verify that the synchronizer records the correct state and that the |
| 265 | * correct intent is submitted to the IntentService. |
| 266 | * |
| 267 | * @throws TestUtilsException |
| 268 | */ |
| 269 | @Test |
| 270 | public void testFibAddWithVlan() throws TestUtilsException { |
| 271 | FibEntry fibEntry = new FibEntry( |
| 272 | Ip4Prefix.valueOf("3.3.3.0/24"), |
| 273 | Ip4Address.valueOf("192.168.40.1"), |
| 274 | MacAddress.valueOf("00:00:00:00:00:04")); |
| 275 | |
| 276 | // Construct a MultiPointToSinglePointIntent intent |
| 277 | TrafficSelector.Builder selectorBuilder = |
| 278 | DefaultTrafficSelector.builder(); |
| 279 | selectorBuilder.matchEthType(Ethernet.TYPE_IPV4) |
| 280 | .matchIPDst(fibEntry.prefix()) |
| 281 | .matchVlanId(VlanId.ANY); |
| 282 | |
| 283 | TrafficTreatment.Builder treatmentBuilder = |
| 284 | DefaultTrafficTreatment.builder(); |
| 285 | treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:04")) |
| 286 | .setVlanId(VlanId.vlanId((short) 1)); |
| 287 | |
| 288 | Set<ConnectPoint> ingressPoints = new HashSet<>(); |
| 289 | ingressPoints.add(SW1_ETH1); |
| 290 | ingressPoints.add(SW2_ETH1); |
| 291 | ingressPoints.add(SW3_ETH1); |
| 292 | |
| 293 | MultiPointToSinglePointIntent intent = |
| 294 | new MultiPointToSinglePointIntent(APPID, |
| 295 | selectorBuilder.build(), treatmentBuilder.build(), |
| 296 | ingressPoints, SW4_ETH1); |
| 297 | |
| 298 | // Setup the expected intents |
Jonathan Hart | cb726fc | 2015-02-13 16:26:22 -0800 | [diff] [blame] | 299 | intentService.submit(eqExceptId(intent)); |
| 300 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 301 | replay(intentService); |
| 302 | |
| 303 | // Run the test |
| 304 | intentSynchronizer.leaderChanged(true); |
| 305 | TestUtils.setField(intentSynchronizer, "isActivatedLeader", true); |
| 306 | FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, fibEntry); |
| 307 | |
| 308 | intentSynchronizer.update(Collections.singleton(fibUpdate), |
| 309 | Collections.emptyList()); |
| 310 | |
| 311 | // Verify |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 312 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 313 | Intent firstIntent = |
| 314 | intentSynchronizer.getRouteIntents().iterator().next(); |
| 315 | IntentKey firstIntentKey = new IntentKey(firstIntent); |
| 316 | IntentKey intentKey = new IntentKey(intent); |
| 317 | assertTrue(firstIntentKey.equals(intentKey)); |
| 318 | verify(intentService); |
| 319 | } |
| 320 | |
| 321 | /** |
| 322 | * Tests updating a FIB entry. |
| 323 | * |
| 324 | * We verify that the synchronizer records the correct state and that the |
| 325 | * correct intent is submitted to the IntentService. |
| 326 | * |
| 327 | * @throws TestUtilsException |
| 328 | */ |
| 329 | @Test |
| 330 | public void testFibUpdate() throws TestUtilsException { |
| 331 | // Firstly add a route |
| 332 | testFibAdd(); |
| 333 | |
| 334 | Intent addedIntent = |
| 335 | intentSynchronizer.getRouteIntents().iterator().next(); |
| 336 | |
| 337 | // Start to construct a new route entry and new intent |
| 338 | FibEntry fibEntryUpdate = new FibEntry( |
| 339 | Ip4Prefix.valueOf("1.1.1.0/24"), |
| 340 | Ip4Address.valueOf("192.168.20.1"), |
| 341 | MacAddress.valueOf("00:00:00:00:00:02")); |
| 342 | |
| 343 | // Construct a new MultiPointToSinglePointIntent intent |
| 344 | TrafficSelector.Builder selectorBuilderNew = |
| 345 | DefaultTrafficSelector.builder(); |
| 346 | selectorBuilderNew.matchEthType(Ethernet.TYPE_IPV4).matchIPDst( |
| 347 | fibEntryUpdate.prefix()); |
| 348 | |
| 349 | TrafficTreatment.Builder treatmentBuilderNew = |
| 350 | DefaultTrafficTreatment.builder(); |
| 351 | treatmentBuilderNew.setEthDst(MacAddress.valueOf("00:00:00:00:00:02")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 352 | |
| 353 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 354 | Set<ConnectPoint> ingressPointsNew = new HashSet<>(); |
| 355 | ingressPointsNew.add(SW1_ETH1); |
| 356 | ingressPointsNew.add(SW3_ETH1); |
| 357 | ingressPointsNew.add(SW4_ETH1); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 358 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 359 | MultiPointToSinglePointIntent intentNew = |
| 360 | new MultiPointToSinglePointIntent(APPID, |
| 361 | selectorBuilderNew.build(), |
| 362 | treatmentBuilderNew.build(), |
| 363 | ingressPointsNew, SW2_ETH1); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 364 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 365 | // Set up test expectation |
| 366 | reset(intentService); |
| 367 | // Setup the expected intents |
Jonathan Hart | cb726fc | 2015-02-13 16:26:22 -0800 | [diff] [blame] | 368 | intentService.withdraw(eqExceptId(addedIntent)); |
| 369 | intentService.submit(eqExceptId(intentNew)); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 370 | replay(intentService); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 371 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 372 | // Call the update() method in IntentSynchronizer class |
| 373 | intentSynchronizer.leaderChanged(true); |
| 374 | TestUtils.setField(intentSynchronizer, "isActivatedLeader", true); |
| 375 | FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, |
| 376 | fibEntryUpdate); |
| 377 | intentSynchronizer.update(Collections.singletonList(fibUpdate), |
| 378 | Collections.emptyList()); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 379 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 380 | // Verify |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 381 | assertEquals(intentSynchronizer.getRouteIntents().size(), 1); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 382 | Intent firstIntent = |
| 383 | intentSynchronizer.getRouteIntents().iterator().next(); |
| 384 | IntentKey firstIntentKey = new IntentKey(firstIntent); |
| 385 | IntentKey intentNewKey = new IntentKey(intentNew); |
| 386 | assertTrue(firstIntentKey.equals(intentNewKey)); |
| 387 | verify(intentService); |
| 388 | } |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 389 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 390 | /** |
| 391 | * Tests deleting a FIB entry. |
| 392 | * |
| 393 | * We verify that the synchronizer records the correct state and that the |
| 394 | * correct intent is withdrawn from the IntentService. |
| 395 | * |
| 396 | * @throws TestUtilsException |
| 397 | */ |
| 398 | @Test |
| 399 | public void testFibDelete() throws TestUtilsException { |
| 400 | // Firstly add a route |
| 401 | testFibAdd(); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 402 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 403 | Intent addedIntent = |
| 404 | intentSynchronizer.getRouteIntents().iterator().next(); |
| 405 | |
| 406 | // Construct the existing route entry |
| 407 | FibEntry fibEntry = new FibEntry( |
| 408 | Ip4Prefix.valueOf("1.1.1.0/24"), null, null); |
| 409 | |
| 410 | // Set up expectation |
| 411 | reset(intentService); |
| 412 | // Setup the expected intents |
Jonathan Hart | cb726fc | 2015-02-13 16:26:22 -0800 | [diff] [blame] | 413 | intentService.withdraw(eqExceptId(addedIntent)); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 414 | replay(intentService); |
| 415 | |
| 416 | // Call the update() method in IntentSynchronizer class |
| 417 | intentSynchronizer.leaderChanged(true); |
| 418 | TestUtils.setField(intentSynchronizer, "isActivatedLeader", true); |
| 419 | FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.DELETE, fibEntry); |
| 420 | intentSynchronizer.update(Collections.emptyList(), |
| 421 | Collections.singletonList(fibUpdate)); |
| 422 | |
| 423 | // Verify |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 424 | assertEquals(intentSynchronizer.getRouteIntents().size(), 0); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 425 | verify(intentService); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | /** |
| 429 | * This method tests the behavior of intent Synchronizer. |
| 430 | * |
| 431 | * @throws TestUtilsException |
| 432 | */ |
| 433 | @Test |
| 434 | public void testIntentSync() throws TestUtilsException { |
| 435 | |
| 436 | // |
| 437 | // Construct routes and intents. |
| 438 | // This test simulates the following cases during the master change |
| 439 | // time interval: |
| 440 | // 1. RouteEntry1 did not change and the intent also did not change. |
| 441 | // 2. RouteEntry2 was deleted, but the intent was not deleted. |
| 442 | // 3. RouteEntry3 was newly added, and the intent was also submitted. |
| 443 | // 4. RouteEntry4 was updated to RouteEntry4Update, and the intent was |
| 444 | // also updated to a new one. |
| 445 | // 5. RouteEntry5 did not change, but its intent id changed. |
| 446 | // 6. RouteEntry6 was newly added, but the intent was not submitted. |
| 447 | // |
| 448 | RouteEntry routeEntry1 = new RouteEntry( |
Pavlin Radoslavov | 6b57073 | 2014-11-06 13:16:45 -0800 | [diff] [blame] | 449 | Ip4Prefix.valueOf("1.1.1.0/24"), |
| 450 | Ip4Address.valueOf("192.168.10.1")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 451 | |
| 452 | RouteEntry routeEntry2 = new RouteEntry( |
Pavlin Radoslavov | 6b57073 | 2014-11-06 13:16:45 -0800 | [diff] [blame] | 453 | Ip4Prefix.valueOf("2.2.2.0/24"), |
| 454 | Ip4Address.valueOf("192.168.20.1")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 455 | |
| 456 | RouteEntry routeEntry3 = new RouteEntry( |
Pavlin Radoslavov | 6b57073 | 2014-11-06 13:16:45 -0800 | [diff] [blame] | 457 | Ip4Prefix.valueOf("3.3.3.0/24"), |
| 458 | Ip4Address.valueOf("192.168.30.1")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 459 | |
| 460 | RouteEntry routeEntry4 = new RouteEntry( |
Pavlin Radoslavov | 6b57073 | 2014-11-06 13:16:45 -0800 | [diff] [blame] | 461 | Ip4Prefix.valueOf("4.4.4.0/24"), |
| 462 | Ip4Address.valueOf("192.168.30.1")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 463 | |
| 464 | RouteEntry routeEntry4Update = new RouteEntry( |
Pavlin Radoslavov | 6b57073 | 2014-11-06 13:16:45 -0800 | [diff] [blame] | 465 | Ip4Prefix.valueOf("4.4.4.0/24"), |
| 466 | Ip4Address.valueOf("192.168.20.1")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 467 | |
| 468 | RouteEntry routeEntry5 = new RouteEntry( |
Pavlin Radoslavov | 6b57073 | 2014-11-06 13:16:45 -0800 | [diff] [blame] | 469 | Ip4Prefix.valueOf("5.5.5.0/24"), |
| 470 | Ip4Address.valueOf("192.168.10.1")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 471 | |
| 472 | RouteEntry routeEntry6 = new RouteEntry( |
Pavlin Radoslavov | 6b57073 | 2014-11-06 13:16:45 -0800 | [diff] [blame] | 473 | Ip4Prefix.valueOf("6.6.6.0/24"), |
| 474 | Ip4Address.valueOf("192.168.10.1")); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 475 | |
Jonathan Hart | ec2df01 | 2014-10-23 16:40:24 -0700 | [diff] [blame] | 476 | RouteEntry routeEntry7 = new RouteEntry( |
Pavlin Radoslavov | 6b57073 | 2014-11-06 13:16:45 -0800 | [diff] [blame] | 477 | Ip4Prefix.valueOf("7.7.7.0/24"), |
| 478 | Ip4Address.valueOf("192.168.10.1")); |
Jonathan Hart | ec2df01 | 2014-10-23 16:40:24 -0700 | [diff] [blame] | 479 | |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 480 | MultiPointToSinglePointIntent intent1 = intentBuilder( |
| 481 | routeEntry1.prefix(), "00:00:00:00:00:01", SW1_ETH1); |
| 482 | MultiPointToSinglePointIntent intent2 = intentBuilder( |
| 483 | routeEntry2.prefix(), "00:00:00:00:00:02", SW2_ETH1); |
| 484 | MultiPointToSinglePointIntent intent3 = intentBuilder( |
| 485 | routeEntry3.prefix(), "00:00:00:00:00:03", SW3_ETH1); |
| 486 | MultiPointToSinglePointIntent intent4 = intentBuilder( |
| 487 | routeEntry4.prefix(), "00:00:00:00:00:03", SW3_ETH1); |
| 488 | MultiPointToSinglePointIntent intent4Update = intentBuilder( |
| 489 | routeEntry4Update.prefix(), "00:00:00:00:00:02", SW2_ETH1); |
| 490 | MultiPointToSinglePointIntent intent5 = intentBuilder( |
| 491 | routeEntry5.prefix(), "00:00:00:00:00:01", SW1_ETH1); |
Jonathan Hart | ec2df01 | 2014-10-23 16:40:24 -0700 | [diff] [blame] | 492 | MultiPointToSinglePointIntent intent7 = intentBuilder( |
| 493 | routeEntry7.prefix(), "00:00:00:00:00:01", SW1_ETH1); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 494 | |
| 495 | // Compose a intent, which is equal to intent5 but the id is different. |
| 496 | MultiPointToSinglePointIntent intent5New = |
| 497 | staticIntentBuilder(intent5, routeEntry5, "00:00:00:00:00:01"); |
Pavlin Radoslavov | a7243cc | 2014-11-22 21:38:02 -0800 | [diff] [blame] | 498 | assertThat(IntentSynchronizer.IntentKey.equalIntents( |
| 499 | intent5, intent5New), |
| 500 | is(true)); |
Jonathan Hart | ec2df01 | 2014-10-23 16:40:24 -0700 | [diff] [blame] | 501 | assertFalse(intent5.equals(intent5New)); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 502 | |
| 503 | MultiPointToSinglePointIntent intent6 = intentBuilder( |
| 504 | routeEntry6.prefix(), "00:00:00:00:00:01", SW1_ETH1); |
| 505 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 506 | // Set up the routeIntents field in IntentSynchronizer class |
Pavlin Radoslavov | 3a0a52e | 2015-01-06 17:41:37 -0800 | [diff] [blame] | 507 | ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent> |
| 508 | routeIntents = new ConcurrentHashMap<>(); |
Pavlin Radoslavov | a7243cc | 2014-11-22 21:38:02 -0800 | [diff] [blame] | 509 | routeIntents.put(routeEntry1.prefix(), intent1); |
| 510 | routeIntents.put(routeEntry3.prefix(), intent3); |
| 511 | routeIntents.put(routeEntry4Update.prefix(), intent4Update); |
| 512 | routeIntents.put(routeEntry5.prefix(), intent5New); |
| 513 | routeIntents.put(routeEntry6.prefix(), intent6); |
| 514 | routeIntents.put(routeEntry7.prefix(), intent7); |
| 515 | TestUtils.setField(intentSynchronizer, "routeIntents", routeIntents); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 516 | |
| 517 | // Set up expectation |
| 518 | reset(intentService); |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 519 | Set<Intent> intents = new HashSet<>(); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 520 | intents.add(intent1); |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 521 | expect(intentService.getIntentState(intent1.key())) |
Jonathan Hart | ec2df01 | 2014-10-23 16:40:24 -0700 | [diff] [blame] | 522 | .andReturn(IntentState.INSTALLED).anyTimes(); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 523 | intents.add(intent2); |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 524 | expect(intentService.getIntentState(intent2.key())) |
Jonathan Hart | ec2df01 | 2014-10-23 16:40:24 -0700 | [diff] [blame] | 525 | .andReturn(IntentState.INSTALLED).anyTimes(); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 526 | intents.add(intent4); |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 527 | expect(intentService.getIntentState(intent4.key())) |
Jonathan Hart | ec2df01 | 2014-10-23 16:40:24 -0700 | [diff] [blame] | 528 | .andReturn(IntentState.INSTALLED).anyTimes(); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 529 | intents.add(intent5); |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 530 | expect(intentService.getIntentState(intent5.key())) |
Jonathan Hart | ec2df01 | 2014-10-23 16:40:24 -0700 | [diff] [blame] | 531 | .andReturn(IntentState.INSTALLED).anyTimes(); |
| 532 | intents.add(intent7); |
Ray Milkey | f9af43c | 2015-02-09 16:45:48 -0800 | [diff] [blame] | 533 | expect(intentService.getIntentState(intent7.key())) |
Jonathan Hart | ec2df01 | 2014-10-23 16:40:24 -0700 | [diff] [blame] | 534 | .andReturn(IntentState.WITHDRAWING).anyTimes(); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 535 | expect(intentService.getIntents()).andReturn(intents).anyTimes(); |
| 536 | |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 537 | intentService.withdraw(intent2); |
| 538 | intentService.withdraw(intent4); |
Pavlin Radoslavov | a7243cc | 2014-11-22 21:38:02 -0800 | [diff] [blame] | 539 | |
Brian O'Connor | 03406a4 | 2015-02-03 17:28:57 -0800 | [diff] [blame] | 540 | intentService.submit(intent3); |
| 541 | intentService.submit(intent4Update); |
| 542 | intentService.submit(intent6); |
| 543 | intentService.submit(intent7); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 544 | replay(intentService); |
| 545 | |
| 546 | // Start the test |
Pavlin Radoslavov | a071b1e | 2014-11-17 13:37:57 -0800 | [diff] [blame] | 547 | intentSynchronizer.leaderChanged(true); |
Pavlin Radoslavov | a7243cc | 2014-11-22 21:38:02 -0800 | [diff] [blame] | 548 | intentSynchronizer.synchronizeIntents(); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 549 | |
| 550 | // Verify |
Pavlin Radoslavov | a7243cc | 2014-11-22 21:38:02 -0800 | [diff] [blame] | 551 | assertEquals(intentSynchronizer.getRouteIntents().size(), 6); |
| 552 | assertTrue(intentSynchronizer.getRouteIntents().contains(intent1)); |
| 553 | assertTrue(intentSynchronizer.getRouteIntents().contains(intent3)); |
| 554 | assertTrue(intentSynchronizer.getRouteIntents().contains(intent4Update)); |
| 555 | assertTrue(intentSynchronizer.getRouteIntents().contains(intent5)); |
| 556 | assertTrue(intentSynchronizer.getRouteIntents().contains(intent6)); |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 557 | |
| 558 | verify(intentService); |
| 559 | } |
| 560 | |
| 561 | /** |
| 562 | * MultiPointToSinglePointIntent builder. |
| 563 | * |
| 564 | * @param ipPrefix the ipPrefix to match |
| 565 | * @param nextHopMacAddress to which the destination MAC address in packet |
| 566 | * should be rewritten |
| 567 | * @param egressPoint to which packets should be sent |
| 568 | * @return the constructed MultiPointToSinglePointIntent |
| 569 | */ |
Pavlin Radoslavov | 3a0a52e | 2015-01-06 17:41:37 -0800 | [diff] [blame] | 570 | private MultiPointToSinglePointIntent intentBuilder(IpPrefix ipPrefix, |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 571 | String nextHopMacAddress, ConnectPoint egressPoint) { |
| 572 | |
| 573 | TrafficSelector.Builder selectorBuilder = |
| 574 | DefaultTrafficSelector.builder(); |
Pavlin Radoslavov | 87dd930 | 2015-03-10 13:53:24 -0700 | [diff] [blame^] | 575 | if (ipPrefix.isIp4()) { |
Pavlin Radoslavov | 3a0a52e | 2015-01-06 17:41:37 -0800 | [diff] [blame] | 576 | selectorBuilder.matchEthType(Ethernet.TYPE_IPV4); // IPv4 |
Pavlin Radoslavov | a853709 | 2015-02-23 10:15:20 -0800 | [diff] [blame] | 577 | selectorBuilder.matchIPDst(ipPrefix); |
Pavlin Radoslavov | 3a0a52e | 2015-01-06 17:41:37 -0800 | [diff] [blame] | 578 | } else { |
| 579 | selectorBuilder.matchEthType(Ethernet.TYPE_IPV6); // IPv6 |
Pavlin Radoslavov | a853709 | 2015-02-23 10:15:20 -0800 | [diff] [blame] | 580 | selectorBuilder.matchIPv6Dst(ipPrefix); |
Pavlin Radoslavov | 3a0a52e | 2015-01-06 17:41:37 -0800 | [diff] [blame] | 581 | } |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 582 | |
| 583 | TrafficTreatment.Builder treatmentBuilder = |
| 584 | DefaultTrafficTreatment.builder(); |
| 585 | treatmentBuilder.setEthDst(MacAddress.valueOf(nextHopMacAddress)); |
| 586 | |
Jonathan Hart | 90a02c2 | 2015-02-13 11:52:07 -0800 | [diff] [blame] | 587 | Set<ConnectPoint> ingressPoints = new HashSet<>(); |
| 588 | for (Interface intf : routingConfig.getInterfaces()) { |
| 589 | if (!intf.equals(routingConfig.getInterface(egressPoint))) { |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 590 | ConnectPoint srcPort = intf.connectPoint(); |
| 591 | ingressPoints.add(srcPort); |
| 592 | } |
| 593 | } |
| 594 | MultiPointToSinglePointIntent intent = |
| 595 | new MultiPointToSinglePointIntent(APPID, |
| 596 | selectorBuilder.build(), treatmentBuilder.build(), |
| 597 | ingressPoints, egressPoint); |
| 598 | return intent; |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * A static MultiPointToSinglePointIntent builder, the returned intent is |
| 603 | * equal to the input intent except that the id is different. |
| 604 | * |
| 605 | * |
| 606 | * @param intent the intent to be used for building a new intent |
| 607 | * @param routeEntry the relative routeEntry of the intent |
| 608 | * @return the newly constructed MultiPointToSinglePointIntent |
| 609 | * @throws TestUtilsException |
| 610 | */ |
| 611 | private MultiPointToSinglePointIntent staticIntentBuilder( |
| 612 | MultiPointToSinglePointIntent intent, RouteEntry routeEntry, |
| 613 | String nextHopMacAddress) throws TestUtilsException { |
| 614 | |
| 615 | // Use a different egress ConnectPoint with that in intent |
| 616 | // to generate a different id |
| 617 | MultiPointToSinglePointIntent intentNew = intentBuilder( |
| 618 | routeEntry.prefix(), nextHopMacAddress, SW2_ETH1); |
| 619 | TestUtils.setField(intentNew, "egressPoint", intent.egressPoint()); |
| 620 | TestUtils.setField(intentNew, |
| 621 | "ingressPoints", intent.ingressPoints()); |
| 622 | return intentNew; |
| 623 | } |
Pingping | f5d9093 | 2014-10-27 10:50:04 -0700 | [diff] [blame] | 624 | } |