blob: 1265cc1e9b681cfbcf8ad981f2f2d043b03a1edf [file] [log] [blame]
alshabibab984662014-12-04 18:56:18 -08001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
alshabibab984662014-12-04 18:56:18 -08003 *
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.sdnip;
Pingpingf5d90932014-10-27 10:50:04 -070017
Jonathan Hart552e31f2015-02-06 11:11:59 -080018import com.google.common.collect.Sets;
Jonathan Hart9a426f82015-09-03 15:43:13 +020019import com.google.common.util.concurrent.MoreExecutors;
Pingpingf5d90932014-10-27 10:50:04 -070020import org.junit.Before;
21import org.junit.Test;
22import org.onlab.junit.TestUtils;
23import org.onlab.junit.TestUtils.TestUtilsException;
Jonathan Hart6cd2f352015-01-13 17:44:45 -080024import org.onlab.packet.Ethernet;
25import org.onlab.packet.Ip4Address;
26import org.onlab.packet.Ip4Prefix;
27import org.onlab.packet.IpAddress;
28import org.onlab.packet.IpPrefix;
29import org.onlab.packet.MacAddress;
30import org.onlab.packet.VlanId;
Jonathan Hart9a426f82015-09-03 15:43:13 +020031import org.onosproject.TestApplicationId;
Brian O'Connorabafb502014-12-02 22:26:20 -080032import org.onosproject.core.ApplicationId;
Jonathan Hart4cb39882015-08-12 23:50:55 -040033import org.onosproject.incubator.net.intf.Interface;
Brian O'Connorabafb502014-12-02 22:26:20 -080034import org.onosproject.net.ConnectPoint;
Brian O'Connorabafb502014-12-02 22:26:20 -080035import org.onosproject.net.DeviceId;
Brian O'Connorabafb502014-12-02 22:26:20 -080036import org.onosproject.net.PortNumber;
37import org.onosproject.net.flow.DefaultTrafficSelector;
38import org.onosproject.net.flow.DefaultTrafficTreatment;
39import org.onosproject.net.flow.TrafficSelector;
40import org.onosproject.net.flow.TrafficTreatment;
Brian O'Connorabafb502014-12-02 22:26:20 -080041import org.onosproject.net.host.InterfaceIpAddress;
42import org.onosproject.net.intent.AbstractIntentTest;
43import org.onosproject.net.intent.Intent;
Brian O'Connorabafb502014-12-02 22:26:20 -080044import org.onosproject.net.intent.IntentService;
45import org.onosproject.net.intent.IntentState;
Jonathan Hart9a426f82015-09-03 15:43:13 +020046import org.onosproject.net.intent.Key;
Brian O'Connorabafb502014-12-02 22:26:20 -080047import org.onosproject.net.intent.MultiPointToSinglePointIntent;
Luca Prete86ac7d12015-12-02 23:36:49 -080048import org.onosproject.net.intent.IntentUtils;
Jonathan Hart2da1e602015-02-18 19:09:24 -080049import org.onosproject.routing.RouteEntry;
Pingpingf5d90932014-10-27 10:50:04 -070050
Jonathan Hart41349e92015-02-09 14:14:02 -080051import java.util.Collections;
Jonathan Hart552e31f2015-02-06 11:11:59 -080052import java.util.HashSet;
53import java.util.Set;
Jonathan Hart552e31f2015-02-06 11:11:59 -080054
Jonathan Hart4cb39882015-08-12 23:50:55 -040055import static org.easymock.EasyMock.createMock;
56import static org.easymock.EasyMock.expect;
57import static org.easymock.EasyMock.replay;
58import static org.easymock.EasyMock.reset;
59import static org.easymock.EasyMock.verify;
Jonathan Hart552e31f2015-02-06 11:11:59 -080060import static org.hamcrest.Matchers.is;
Jonathan Hartcb726fc2015-02-13 16:26:22 -080061import static org.junit.Assert.assertFalse;
62import static org.junit.Assert.assertThat;
Pingpingf5d90932014-10-27 10:50:04 -070063
64/**
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -080065 * This class tests the intent synchronization function in the
66 * IntentSynchronizer class.
Pingpingf5d90932014-10-27 10:50:04 -070067 */
Brian O'Connor520c0522014-11-23 23:50:47 -080068public class IntentSyncTest extends AbstractIntentTest {
Pingpingf5d90932014-10-27 10:50:04 -070069
Pingpingf5d90932014-10-27 10:50:04 -070070 private IntentService intentService;
Pingpingf5d90932014-10-27 10:50:04 -070071
72 private static final ConnectPoint SW1_ETH1 = new ConnectPoint(
73 DeviceId.deviceId("of:0000000000000001"),
74 PortNumber.portNumber(1));
75
76 private static final ConnectPoint SW2_ETH1 = new ConnectPoint(
77 DeviceId.deviceId("of:0000000000000002"),
78 PortNumber.portNumber(1));
79
80 private static final ConnectPoint SW3_ETH1 = new ConnectPoint(
81 DeviceId.deviceId("of:0000000000000003"),
82 PortNumber.portNumber(1));
83
Jonathan Hart41349e92015-02-09 14:14:02 -080084 private static final ConnectPoint SW4_ETH1 = new ConnectPoint(
85 DeviceId.deviceId("of:0000000000000004"),
86 PortNumber.portNumber(1));
87
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -080088 private IntentSynchronizer intentSynchronizer;
Jonathan Hart4cb39882015-08-12 23:50:55 -040089 private final Set<Interface> interfaces = Sets.newHashSet();
Pingpingf5d90932014-10-27 10:50:04 -070090
Jonathan Hart9a426f82015-09-03 15:43:13 +020091 private static final ApplicationId APPID = TestApplicationId.create("SDNIP");
Pingpingf5d90932014-10-27 10:50:04 -070092
93 @Before
94 public void setUp() throws Exception {
Brian O'Connor520c0522014-11-23 23:50:47 -080095 super.setUp();
Jonathan Hart41349e92015-02-09 14:14:02 -080096
Jonathan Hart90a02c22015-02-13 11:52:07 -080097 setUpInterfaceService();
Jonathan Hart90a02c22015-02-13 11:52:07 -080098
Pingpingf5d90932014-10-27 10:50:04 -070099 intentService = createMock(IntentService.class);
100
Jonathan Hart552e31f2015-02-06 11:11:59 -0800101 intentSynchronizer = new IntentSynchronizer(APPID, intentService,
Jonathan Hart9a426f82015-09-03 15:43:13 +0200102 MoreExecutors.newDirectExecutorService());
Pingpingf5d90932014-10-27 10:50:04 -0700103 }
104
105 /**
106 * Sets up InterfaceService.
107 */
108 private void setUpInterfaceService() {
Pingpingf5d90932014-10-27 10:50:04 -0700109 Set<InterfaceIpAddress> interfaceIpAddresses1 = Sets.newHashSet();
110 interfaceIpAddresses1.add(new InterfaceIpAddress(
111 IpAddress.valueOf("192.168.10.101"),
112 IpPrefix.valueOf("192.168.10.0/24")));
113 Interface sw1Eth1 = new Interface(SW1_ETH1,
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800114 interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
115 VlanId.NONE);
Pingpingf5d90932014-10-27 10:50:04 -0700116 interfaces.add(sw1Eth1);
117
118 Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet();
Jonathan Hart41349e92015-02-09 14:14:02 -0800119 interfaceIpAddresses2.add(
120 new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"),
121 IpPrefix.valueOf("192.168.20.0/24")));
Pingpingf5d90932014-10-27 10:50:04 -0700122 Interface sw2Eth1 = new Interface(SW2_ETH1,
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800123 interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
124 VlanId.NONE);
Pingpingf5d90932014-10-27 10:50:04 -0700125 interfaces.add(sw2Eth1);
126
127 Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet();
Jonathan Hart41349e92015-02-09 14:14:02 -0800128 interfaceIpAddresses3.add(
129 new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"),
130 IpPrefix.valueOf("192.168.30.0/24")));
Pingpingf5d90932014-10-27 10:50:04 -0700131 Interface sw3Eth1 = new Interface(SW3_ETH1,
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800132 interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"),
133 VlanId.NONE);
Pingpingf5d90932014-10-27 10:50:04 -0700134 interfaces.add(sw3Eth1);
135
Jonathan Hart41349e92015-02-09 14:14:02 -0800136 InterfaceIpAddress interfaceIpAddress4 =
137 new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"),
138 IpPrefix.valueOf("192.168.40.0/24"));
139 Interface sw4Eth1 = new Interface(SW4_ETH1,
140 Sets.newHashSet(interfaceIpAddress4),
141 MacAddress.valueOf("00:00:00:00:00:04"),
142 VlanId.vlanId((short) 1));
143
Jonathan Hart41349e92015-02-09 14:14:02 -0800144 interfaces.add(sw4Eth1);
Pingpingf5d90932014-10-27 10:50:04 -0700145 }
146
147 /**
Jonathan Hart9a426f82015-09-03 15:43:13 +0200148 * Tests the synchronization behavior of intent synchronizer. We set up
149 * a discrepancy between the intent service state and the intent
150 * synchronizer's state and ensure that this is reconciled correctly.
Pingpingf5d90932014-10-27 10:50:04 -0700151 *
152 * @throws TestUtilsException
153 */
154 @Test
155 public void testIntentSync() throws TestUtilsException {
156
157 //
158 // Construct routes and intents.
159 // This test simulates the following cases during the master change
160 // time interval:
161 // 1. RouteEntry1 did not change and the intent also did not change.
162 // 2. RouteEntry2 was deleted, but the intent was not deleted.
163 // 3. RouteEntry3 was newly added, and the intent was also submitted.
164 // 4. RouteEntry4 was updated to RouteEntry4Update, and the intent was
165 // also updated to a new one.
166 // 5. RouteEntry5 did not change, but its intent id changed.
167 // 6. RouteEntry6 was newly added, but the intent was not submitted.
168 //
169 RouteEntry routeEntry1 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800170 Ip4Prefix.valueOf("1.1.1.0/24"),
171 Ip4Address.valueOf("192.168.10.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700172
173 RouteEntry routeEntry2 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800174 Ip4Prefix.valueOf("2.2.2.0/24"),
175 Ip4Address.valueOf("192.168.20.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700176
177 RouteEntry routeEntry3 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800178 Ip4Prefix.valueOf("3.3.3.0/24"),
179 Ip4Address.valueOf("192.168.30.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700180
181 RouteEntry routeEntry4 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800182 Ip4Prefix.valueOf("4.4.4.0/24"),
183 Ip4Address.valueOf("192.168.30.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700184
185 RouteEntry routeEntry4Update = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800186 Ip4Prefix.valueOf("4.4.4.0/24"),
187 Ip4Address.valueOf("192.168.20.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700188
189 RouteEntry routeEntry5 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800190 Ip4Prefix.valueOf("5.5.5.0/24"),
191 Ip4Address.valueOf("192.168.10.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700192
193 RouteEntry routeEntry6 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800194 Ip4Prefix.valueOf("6.6.6.0/24"),
195 Ip4Address.valueOf("192.168.10.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700196
Jonathan Hartec2df012014-10-23 16:40:24 -0700197 RouteEntry routeEntry7 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800198 Ip4Prefix.valueOf("7.7.7.0/24"),
199 Ip4Address.valueOf("192.168.10.1"));
Jonathan Hartec2df012014-10-23 16:40:24 -0700200
Pingpingf5d90932014-10-27 10:50:04 -0700201 MultiPointToSinglePointIntent intent1 = intentBuilder(
202 routeEntry1.prefix(), "00:00:00:00:00:01", SW1_ETH1);
203 MultiPointToSinglePointIntent intent2 = intentBuilder(
204 routeEntry2.prefix(), "00:00:00:00:00:02", SW2_ETH1);
205 MultiPointToSinglePointIntent intent3 = intentBuilder(
206 routeEntry3.prefix(), "00:00:00:00:00:03", SW3_ETH1);
207 MultiPointToSinglePointIntent intent4 = intentBuilder(
208 routeEntry4.prefix(), "00:00:00:00:00:03", SW3_ETH1);
209 MultiPointToSinglePointIntent intent4Update = intentBuilder(
210 routeEntry4Update.prefix(), "00:00:00:00:00:02", SW2_ETH1);
211 MultiPointToSinglePointIntent intent5 = intentBuilder(
212 routeEntry5.prefix(), "00:00:00:00:00:01", SW1_ETH1);
Jonathan Hartec2df012014-10-23 16:40:24 -0700213 MultiPointToSinglePointIntent intent7 = intentBuilder(
214 routeEntry7.prefix(), "00:00:00:00:00:01", SW1_ETH1);
Pingpingf5d90932014-10-27 10:50:04 -0700215
216 // Compose a intent, which is equal to intent5 but the id is different.
217 MultiPointToSinglePointIntent intent5New =
218 staticIntentBuilder(intent5, routeEntry5, "00:00:00:00:00:01");
Ray Milkey4fd3ceb2015-12-10 14:43:08 -0800219 assertThat(IntentUtils.intentsAreEqual(intent5, intent5New), is(true));
Jonathan Hartec2df012014-10-23 16:40:24 -0700220 assertFalse(intent5.equals(intent5New));
Pingpingf5d90932014-10-27 10:50:04 -0700221
222 MultiPointToSinglePointIntent intent6 = intentBuilder(
223 routeEntry6.prefix(), "00:00:00:00:00:01", SW1_ETH1);
224
Pingpingf5d90932014-10-27 10:50:04 -0700225 // Set up expectation
Jonathan Hart90a02c22015-02-13 11:52:07 -0800226 Set<Intent> intents = new HashSet<>();
Pingpingf5d90932014-10-27 10:50:04 -0700227 intents.add(intent1);
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800228 expect(intentService.getIntentState(intent1.key()))
Jonathan Hartec2df012014-10-23 16:40:24 -0700229 .andReturn(IntentState.INSTALLED).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700230 intents.add(intent2);
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800231 expect(intentService.getIntentState(intent2.key()))
Jonathan Hartec2df012014-10-23 16:40:24 -0700232 .andReturn(IntentState.INSTALLED).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700233 intents.add(intent4);
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800234 expect(intentService.getIntentState(intent4.key()))
Jonathan Hartec2df012014-10-23 16:40:24 -0700235 .andReturn(IntentState.INSTALLED).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700236 intents.add(intent5);
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800237 expect(intentService.getIntentState(intent5.key()))
Jonathan Hartec2df012014-10-23 16:40:24 -0700238 .andReturn(IntentState.INSTALLED).anyTimes();
239 intents.add(intent7);
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800240 expect(intentService.getIntentState(intent7.key()))
Jonathan Hartec2df012014-10-23 16:40:24 -0700241 .andReturn(IntentState.WITHDRAWING).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700242 expect(intentService.getIntents()).andReturn(intents).anyTimes();
243
Jonathan Hart9a426f82015-09-03 15:43:13 +0200244 // These are the operations that should be done to the intentService
245 // during synchronization
Brian O'Connor03406a42015-02-03 17:28:57 -0800246 intentService.withdraw(intent2);
Brian O'Connor03406a42015-02-03 17:28:57 -0800247 intentService.submit(intent3);
248 intentService.submit(intent4Update);
249 intentService.submit(intent6);
250 intentService.submit(intent7);
Pingpingf5d90932014-10-27 10:50:04 -0700251 replay(intentService);
252
253 // Start the test
Pingpingf5d90932014-10-27 10:50:04 -0700254
Jonathan Hart9a426f82015-09-03 15:43:13 +0200255 // Simulate some input from the clients. The intent synchronizer has not
256 // gained the global leadership yet, but it will remember this input for
257 // when it does.
258 intentSynchronizer.submit(intent1);
259 intentSynchronizer.submit(intent2);
260 intentSynchronizer.withdraw(intent2);
261 intentSynchronizer.submit(intent3);
262 intentSynchronizer.submit(intent4);
263 intentSynchronizer.submit(intent4Update);
264 intentSynchronizer.submit(intent5);
265 intentSynchronizer.submit(intent6);
266 intentSynchronizer.submit(intent7);
267
268 // Give the leadership to the intent synchronizer. It will now attempt
269 // to synchronize the intents in the store with the intents it has
270 // recorded based on the earlier user input.
271 intentSynchronizer.leaderChanged(true);
272
273 verify(intentService);
274 }
275
276 /**
277 * Tests the behavior of the submit API, both when the synchronizer has
278 * leadership and when it does not.
279 */
280 @Test
281 public void testSubmit() {
282 IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24");
283 Intent intent = intentBuilder(prefix, "00:00:00:00:00:01", SW1_ETH1);
284
285 // Set up expectations
286 intentService.submit(intent);
287 expect(intentService.getIntents()).andReturn(Collections.emptyList())
288 .anyTimes();
289 replay(intentService);
290
291 // Give the intent synchronizer leadership so it will submit intents
292 // to the intent service
293 intentSynchronizer.leaderChanged(true);
294
295 // Test the submit
296 intentSynchronizer.submit(intent);
297
298 verify(intentService);
299
300 // Now we'll remove leadership from the intent synchronizer and verify
301 // that it does not submit any intents to the intent service when we
302 // call the submit API
303 reset(intentService);
304 replay(intentService);
305
306 intentSynchronizer.leaderChanged(false);
307
308 intentSynchronizer.submit(intent);
309
310 verify(intentService);
311 }
312
313 /**
314 * Tests the behavior of the withdraw API, both when the synchronizer has
315 * leadership and when it does not.
316 */
317 @Test
318 public void testWithdraw() {
319 IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24");
320 Intent intent = intentBuilder(prefix, "00:00:00:00:00:01", SW1_ETH1);
321
322 // Submit an intent first so we can withdraw it later
323 intentService.submit(intent);
324 intentService.withdraw(intent);
325 expect(intentService.getIntents()).andReturn(Collections.emptyList())
326 .anyTimes();
327 replay(intentService);
328
329 // Give the intent synchronizer leadership so it will submit intents
330 // to the intent service
331 intentSynchronizer.leaderChanged(true);
332
333 // Test the submit then withdraw
334 intentSynchronizer.submit(intent);
335 intentSynchronizer.withdraw(intent);
336
337 verify(intentService);
338
339 // Now we'll remove leadership from the intent synchronizer and verify
340 // that it does not withdraw any intents to the intent service when we
341 // call the withdraw API
342 reset(intentService);
343 replay(intentService);
344
345 intentSynchronizer.leaderChanged(false);
346
347 intentSynchronizer.submit(intent);
348 intentSynchronizer.withdraw(intent);
Pingpingf5d90932014-10-27 10:50:04 -0700349
350 verify(intentService);
351 }
352
353 /**
354 * MultiPointToSinglePointIntent builder.
355 *
356 * @param ipPrefix the ipPrefix to match
357 * @param nextHopMacAddress to which the destination MAC address in packet
358 * should be rewritten
359 * @param egressPoint to which packets should be sent
360 * @return the constructed MultiPointToSinglePointIntent
361 */
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800362 private MultiPointToSinglePointIntent intentBuilder(IpPrefix ipPrefix,
Pingpingf5d90932014-10-27 10:50:04 -0700363 String nextHopMacAddress, ConnectPoint egressPoint) {
364
365 TrafficSelector.Builder selectorBuilder =
366 DefaultTrafficSelector.builder();
Pavlin Radoslavov87dd9302015-03-10 13:53:24 -0700367 if (ipPrefix.isIp4()) {
Jonathan Hart9a426f82015-09-03 15:43:13 +0200368 selectorBuilder.matchEthType(Ethernet.TYPE_IPV4);
Pavlin Radoslavova8537092015-02-23 10:15:20 -0800369 selectorBuilder.matchIPDst(ipPrefix);
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800370 } else {
Jonathan Hart9a426f82015-09-03 15:43:13 +0200371 selectorBuilder.matchEthType(Ethernet.TYPE_IPV6);
Pavlin Radoslavova8537092015-02-23 10:15:20 -0800372 selectorBuilder.matchIPv6Dst(ipPrefix);
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800373 }
Pingpingf5d90932014-10-27 10:50:04 -0700374
375 TrafficTreatment.Builder treatmentBuilder =
376 DefaultTrafficTreatment.builder();
377 treatmentBuilder.setEthDst(MacAddress.valueOf(nextHopMacAddress));
378
Jonathan Hart90a02c22015-02-13 11:52:07 -0800379 Set<ConnectPoint> ingressPoints = new HashSet<>();
Jonathan Hart4cb39882015-08-12 23:50:55 -0400380 for (Interface intf : interfaces) {
381 if (!intf.connectPoint().equals(egressPoint)) {
Pingpingf5d90932014-10-27 10:50:04 -0700382 ConnectPoint srcPort = intf.connectPoint();
383 ingressPoints.add(srcPort);
384 }
385 }
386 MultiPointToSinglePointIntent intent =
Ray Milkeyebc5d222015-03-18 15:45:36 -0700387 MultiPointToSinglePointIntent.builder()
388 .appId(APPID)
Jonathan Hart9a426f82015-09-03 15:43:13 +0200389 .key(Key.of(ipPrefix.toString(), APPID))
Ray Milkeyebc5d222015-03-18 15:45:36 -0700390 .selector(selectorBuilder.build())
391 .treatment(treatmentBuilder.build())
392 .ingressPoints(ingressPoints)
393 .egressPoint(egressPoint)
Jonathan Hart9a426f82015-09-03 15:43:13 +0200394 .constraints(SdnIpFib.CONSTRAINTS)
Ray Milkeyebc5d222015-03-18 15:45:36 -0700395 .build();
Pingpingf5d90932014-10-27 10:50:04 -0700396 return intent;
397 }
398
399 /**
400 * A static MultiPointToSinglePointIntent builder, the returned intent is
401 * equal to the input intent except that the id is different.
402 *
Pingpingf5d90932014-10-27 10:50:04 -0700403 * @param intent the intent to be used for building a new intent
404 * @param routeEntry the relative routeEntry of the intent
405 * @return the newly constructed MultiPointToSinglePointIntent
406 * @throws TestUtilsException
407 */
Jonathan Hart9a426f82015-09-03 15:43:13 +0200408 private MultiPointToSinglePointIntent staticIntentBuilder(
Pingpingf5d90932014-10-27 10:50:04 -0700409 MultiPointToSinglePointIntent intent, RouteEntry routeEntry,
410 String nextHopMacAddress) throws TestUtilsException {
411
412 // Use a different egress ConnectPoint with that in intent
413 // to generate a different id
414 MultiPointToSinglePointIntent intentNew = intentBuilder(
415 routeEntry.prefix(), nextHopMacAddress, SW2_ETH1);
416 TestUtils.setField(intentNew, "egressPoint", intent.egressPoint());
417 TestUtils.setField(intentNew,
418 "ingressPoints", intent.ingressPoints());
419 return intentNew;
420 }
Pingpingf5d90932014-10-27 10:50:04 -0700421}