blob: e4808f7d2e0cfd78b3e787df76b64f0aec082f40 [file] [log] [blame]
alshabibab984662014-12-04 18:56:18 -08001/*
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'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;
19import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory;
20import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree;
21import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree;
Pingpingf5d90932014-10-27 10:50:04 -070022import org.junit.Before;
23import org.junit.Test;
24import org.onlab.junit.TestUtils;
25import org.onlab.junit.TestUtils.TestUtilsException;
Jonathan Hart6cd2f352015-01-13 17:44:45 -080026import org.onlab.packet.Ethernet;
27import org.onlab.packet.Ip4Address;
28import org.onlab.packet.Ip4Prefix;
29import org.onlab.packet.IpAddress;
30import org.onlab.packet.IpPrefix;
31import org.onlab.packet.MacAddress;
32import org.onlab.packet.VlanId;
Brian O'Connorabafb502014-12-02 22:26:20 -080033import org.onosproject.core.ApplicationId;
34import org.onosproject.net.ConnectPoint;
35import org.onosproject.net.DefaultHost;
36import org.onosproject.net.DeviceId;
37import org.onosproject.net.Host;
38import org.onosproject.net.HostId;
39import org.onosproject.net.HostLocation;
40import org.onosproject.net.PortNumber;
41import org.onosproject.net.flow.DefaultTrafficSelector;
42import org.onosproject.net.flow.DefaultTrafficTreatment;
43import org.onosproject.net.flow.TrafficSelector;
44import org.onosproject.net.flow.TrafficTreatment;
45import org.onosproject.net.host.HostListener;
46import org.onosproject.net.host.HostService;
47import org.onosproject.net.host.InterfaceIpAddress;
48import org.onosproject.net.intent.AbstractIntentTest;
49import org.onosproject.net.intent.Intent;
50import org.onosproject.net.intent.IntentOperations;
51import org.onosproject.net.intent.IntentService;
52import org.onosproject.net.intent.IntentState;
53import org.onosproject.net.intent.MultiPointToSinglePointIntent;
54import org.onosproject.net.provider.ProviderId;
55import org.onosproject.sdnip.config.Interface;
Pingpingf5d90932014-10-27 10:50:04 -070056
Jonathan Hart552e31f2015-02-06 11:11:59 -080057import java.util.HashSet;
58import java.util.Set;
59import java.util.concurrent.ConcurrentHashMap;
60
61import static org.easymock.EasyMock.*;
62import static org.hamcrest.Matchers.is;
63import static org.junit.Assert.assertEquals;
64import static org.junit.Assert.assertFalse;
65import static org.junit.Assert.assertThat;
66import static org.junit.Assert.assertTrue;
Pingpingf5d90932014-10-27 10:50:04 -070067
68/**
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -080069 * This class tests the intent synchronization function in the
70 * IntentSynchronizer class.
Pingpingf5d90932014-10-27 10:50:04 -070071 */
Brian O'Connor520c0522014-11-23 23:50:47 -080072public class IntentSyncTest extends AbstractIntentTest {
Pingpingf5d90932014-10-27 10:50:04 -070073
74 private InterfaceService interfaceService;
75 private IntentService intentService;
76 private HostService hostService;
77
78 private static final ConnectPoint SW1_ETH1 = new ConnectPoint(
79 DeviceId.deviceId("of:0000000000000001"),
80 PortNumber.portNumber(1));
81
82 private static final ConnectPoint SW2_ETH1 = new ConnectPoint(
83 DeviceId.deviceId("of:0000000000000002"),
84 PortNumber.portNumber(1));
85
86 private static final ConnectPoint SW3_ETH1 = new ConnectPoint(
87 DeviceId.deviceId("of:0000000000000003"),
88 PortNumber.portNumber(1));
89
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -080090 private IntentSynchronizer intentSynchronizer;
Pingpingf5d90932014-10-27 10:50:04 -070091 private Router router;
92
93 private static final ApplicationId APPID = new ApplicationId() {
94 @Override
95 public short id() {
96 return 1;
97 }
98
99 @Override
100 public String name() {
101 return "SDNIP";
102 }
103 };
104
105 @Before
106 public void setUp() throws Exception {
Brian O'Connor520c0522014-11-23 23:50:47 -0800107 super.setUp();
Pingpingf5d90932014-10-27 10:50:04 -0700108 setUpInterfaceService();
109 setUpHostService();
110 intentService = createMock(IntentService.class);
111
Jonathan Hart552e31f2015-02-06 11:11:59 -0800112 intentSynchronizer = new IntentSynchronizer(APPID, intentService,
113 null, interfaceService);
114 router = new Router(intentSynchronizer, hostService);
Pingpingf5d90932014-10-27 10:50:04 -0700115 }
116
117 /**
118 * Sets up InterfaceService.
119 */
120 private void setUpInterfaceService() {
121
122 interfaceService = createMock(InterfaceService.class);
123
124 Set<Interface> interfaces = Sets.newHashSet();
125
126 Set<InterfaceIpAddress> interfaceIpAddresses1 = Sets.newHashSet();
127 interfaceIpAddresses1.add(new InterfaceIpAddress(
128 IpAddress.valueOf("192.168.10.101"),
129 IpPrefix.valueOf("192.168.10.0/24")));
130 Interface sw1Eth1 = new Interface(SW1_ETH1,
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800131 interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
132 VlanId.NONE);
Pingpingf5d90932014-10-27 10:50:04 -0700133 interfaces.add(sw1Eth1);
134
135 Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet();
136 interfaceIpAddresses2.add(new InterfaceIpAddress(
137 IpAddress.valueOf("192.168.20.101"),
138 IpPrefix.valueOf("192.168.20.0/24")));
139 Interface sw2Eth1 = new Interface(SW2_ETH1,
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800140 interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
141 VlanId.NONE);
Pingpingf5d90932014-10-27 10:50:04 -0700142 interfaces.add(sw2Eth1);
143
144 Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet();
145 interfaceIpAddresses3.add(new InterfaceIpAddress(
146 IpAddress.valueOf("192.168.30.101"),
147 IpPrefix.valueOf("192.168.30.0/24")));
148 Interface sw3Eth1 = new Interface(SW3_ETH1,
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800149 interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"),
150 VlanId.NONE);
Pingpingf5d90932014-10-27 10:50:04 -0700151 interfaces.add(sw3Eth1);
152
153 expect(interfaceService.getInterface(SW1_ETH1)).andReturn(
154 sw1Eth1).anyTimes();
155 expect(interfaceService.getInterface(SW2_ETH1)).andReturn(
156 sw2Eth1).anyTimes();
157 expect(interfaceService.getInterface(SW3_ETH1)).andReturn(
158 sw3Eth1).anyTimes();
159 expect(interfaceService.getInterfaces()).andReturn(
160 interfaces).anyTimes();
161 replay(interfaceService);
162 }
163
164 /**
165 * Sets up the host service with details of hosts.
166 */
167 private void setUpHostService() {
168 hostService = createMock(HostService.class);
169
170 hostService.addListener(anyObject(HostListener.class));
171 expectLastCall().anyTimes();
172
173 IpAddress host1Address = IpAddress.valueOf("192.168.10.1");
174 Host host1 = new DefaultHost(ProviderId.NONE, HostId.NONE,
175 MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE,
176 new HostLocation(SW1_ETH1, 1),
177 Sets.newHashSet(host1Address));
178
179 expect(hostService.getHostsByIp(host1Address))
180 .andReturn(Sets.newHashSet(host1)).anyTimes();
181 hostService.startMonitoringIp(host1Address);
182 expectLastCall().anyTimes();
183
184
185 IpAddress host2Address = IpAddress.valueOf("192.168.20.1");
186 Host host2 = new DefaultHost(ProviderId.NONE, HostId.NONE,
187 MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE,
188 new HostLocation(SW2_ETH1, 1),
189 Sets.newHashSet(host2Address));
190
191 expect(hostService.getHostsByIp(host2Address))
192 .andReturn(Sets.newHashSet(host2)).anyTimes();
193 hostService.startMonitoringIp(host2Address);
194 expectLastCall().anyTimes();
195
196
197 IpAddress host3Address = IpAddress.valueOf("192.168.30.1");
198 Host host3 = new DefaultHost(ProviderId.NONE, HostId.NONE,
199 MacAddress.valueOf("00:00:00:00:00:03"), VlanId.NONE,
200 new HostLocation(SW3_ETH1, 1),
201 Sets.newHashSet(host3Address));
202
203 expect(hostService.getHostsByIp(host3Address))
204 .andReturn(Sets.newHashSet(host3)).anyTimes();
205 hostService.startMonitoringIp(host3Address);
206 expectLastCall().anyTimes();
207
208
209 replay(hostService);
210 }
211
212 /**
213 * This method tests the behavior of intent Synchronizer.
214 *
215 * @throws TestUtilsException
216 */
217 @Test
218 public void testIntentSync() throws TestUtilsException {
219
220 //
221 // Construct routes and intents.
222 // This test simulates the following cases during the master change
223 // time interval:
224 // 1. RouteEntry1 did not change and the intent also did not change.
225 // 2. RouteEntry2 was deleted, but the intent was not deleted.
226 // 3. RouteEntry3 was newly added, and the intent was also submitted.
227 // 4. RouteEntry4 was updated to RouteEntry4Update, and the intent was
228 // also updated to a new one.
229 // 5. RouteEntry5 did not change, but its intent id changed.
230 // 6. RouteEntry6 was newly added, but the intent was not submitted.
231 //
232 RouteEntry routeEntry1 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800233 Ip4Prefix.valueOf("1.1.1.0/24"),
234 Ip4Address.valueOf("192.168.10.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700235
236 RouteEntry routeEntry2 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800237 Ip4Prefix.valueOf("2.2.2.0/24"),
238 Ip4Address.valueOf("192.168.20.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700239
240 RouteEntry routeEntry3 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800241 Ip4Prefix.valueOf("3.3.3.0/24"),
242 Ip4Address.valueOf("192.168.30.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700243
244 RouteEntry routeEntry4 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800245 Ip4Prefix.valueOf("4.4.4.0/24"),
246 Ip4Address.valueOf("192.168.30.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700247
248 RouteEntry routeEntry4Update = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800249 Ip4Prefix.valueOf("4.4.4.0/24"),
250 Ip4Address.valueOf("192.168.20.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700251
252 RouteEntry routeEntry5 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800253 Ip4Prefix.valueOf("5.5.5.0/24"),
254 Ip4Address.valueOf("192.168.10.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700255
256 RouteEntry routeEntry6 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800257 Ip4Prefix.valueOf("6.6.6.0/24"),
258 Ip4Address.valueOf("192.168.10.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700259
Jonathan Hartec2df012014-10-23 16:40:24 -0700260 RouteEntry routeEntry7 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800261 Ip4Prefix.valueOf("7.7.7.0/24"),
262 Ip4Address.valueOf("192.168.10.1"));
Jonathan Hartec2df012014-10-23 16:40:24 -0700263
Pingpingf5d90932014-10-27 10:50:04 -0700264 MultiPointToSinglePointIntent intent1 = intentBuilder(
265 routeEntry1.prefix(), "00:00:00:00:00:01", SW1_ETH1);
266 MultiPointToSinglePointIntent intent2 = intentBuilder(
267 routeEntry2.prefix(), "00:00:00:00:00:02", SW2_ETH1);
268 MultiPointToSinglePointIntent intent3 = intentBuilder(
269 routeEntry3.prefix(), "00:00:00:00:00:03", SW3_ETH1);
270 MultiPointToSinglePointIntent intent4 = intentBuilder(
271 routeEntry4.prefix(), "00:00:00:00:00:03", SW3_ETH1);
272 MultiPointToSinglePointIntent intent4Update = intentBuilder(
273 routeEntry4Update.prefix(), "00:00:00:00:00:02", SW2_ETH1);
274 MultiPointToSinglePointIntent intent5 = intentBuilder(
275 routeEntry5.prefix(), "00:00:00:00:00:01", SW1_ETH1);
Jonathan Hartec2df012014-10-23 16:40:24 -0700276 MultiPointToSinglePointIntent intent7 = intentBuilder(
277 routeEntry7.prefix(), "00:00:00:00:00:01", SW1_ETH1);
Pingpingf5d90932014-10-27 10:50:04 -0700278
279 // Compose a intent, which is equal to intent5 but the id is different.
280 MultiPointToSinglePointIntent intent5New =
281 staticIntentBuilder(intent5, routeEntry5, "00:00:00:00:00:01");
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800282 assertThat(IntentSynchronizer.IntentKey.equalIntents(
283 intent5, intent5New),
284 is(true));
Jonathan Hartec2df012014-10-23 16:40:24 -0700285 assertFalse(intent5.equals(intent5New));
Pingpingf5d90932014-10-27 10:50:04 -0700286
287 MultiPointToSinglePointIntent intent6 = intentBuilder(
288 routeEntry6.prefix(), "00:00:00:00:00:01", SW1_ETH1);
289
Pavlin Radoslavov64c1ed12014-12-10 18:10:55 -0800290 // Set up the ribTable field in Router class and routeIntents fields
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800291 // in IntentSynchronizer class
Pavlin Radoslavov64c1ed12014-12-10 18:10:55 -0800292 InvertedRadixTree<RouteEntry> ribTable =
Pingpingf5d90932014-10-27 10:50:04 -0700293 new ConcurrentInvertedRadixTree<>(
294 new DefaultByteArrayNodeFactory());
Pavlin Radoslavov64c1ed12014-12-10 18:10:55 -0800295 ribTable.put(RouteEntry.createBinaryString(routeEntry1.prefix()),
296 routeEntry1);
297 ribTable.put(RouteEntry.createBinaryString(routeEntry3.prefix()),
298 routeEntry3);
299 ribTable.put(RouteEntry.createBinaryString(routeEntry4Update.prefix()),
300 routeEntry4Update);
301 ribTable.put(RouteEntry.createBinaryString(routeEntry5.prefix()),
302 routeEntry5);
303 ribTable.put(RouteEntry.createBinaryString(routeEntry6.prefix()),
304 routeEntry6);
305 ribTable.put(RouteEntry.createBinaryString(routeEntry7.prefix()),
306 routeEntry7);
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800307 TestUtils.setField(router, "ribTable4", ribTable);
Pingpingf5d90932014-10-27 10:50:04 -0700308
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800309 ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent>
310 routeIntents = new ConcurrentHashMap<>();
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800311 routeIntents.put(routeEntry1.prefix(), intent1);
312 routeIntents.put(routeEntry3.prefix(), intent3);
313 routeIntents.put(routeEntry4Update.prefix(), intent4Update);
314 routeIntents.put(routeEntry5.prefix(), intent5New);
315 routeIntents.put(routeEntry6.prefix(), intent6);
316 routeIntents.put(routeEntry7.prefix(), intent7);
317 TestUtils.setField(intentSynchronizer, "routeIntents", routeIntents);
Pingpingf5d90932014-10-27 10:50:04 -0700318
319 // Set up expectation
320 reset(intentService);
321 Set<Intent> intents = new HashSet<Intent>();
322 intents.add(intent1);
Jonathan Hartec2df012014-10-23 16:40:24 -0700323 expect(intentService.getIntentState(intent1.id()))
324 .andReturn(IntentState.INSTALLED).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700325 intents.add(intent2);
Jonathan Hartec2df012014-10-23 16:40:24 -0700326 expect(intentService.getIntentState(intent2.id()))
327 .andReturn(IntentState.INSTALLED).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700328 intents.add(intent4);
Jonathan Hartec2df012014-10-23 16:40:24 -0700329 expect(intentService.getIntentState(intent4.id()))
330 .andReturn(IntentState.INSTALLED).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700331 intents.add(intent5);
Jonathan Hartec2df012014-10-23 16:40:24 -0700332 expect(intentService.getIntentState(intent5.id()))
333 .andReturn(IntentState.INSTALLED).anyTimes();
334 intents.add(intent7);
335 expect(intentService.getIntentState(intent7.id()))
336 .andReturn(IntentState.WITHDRAWING).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700337 expect(intentService.getIntents()).andReturn(intents).anyTimes();
338
Pavlin Radoslavov248c2ae2014-12-02 09:51:25 -0800339 IntentOperations.Builder builder = IntentOperations.builder(APPID);
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800340 builder.addWithdrawOperation(intent2.id());
341 builder.addWithdrawOperation(intent4.id());
Pavlin Radoslavovdde22ae2014-11-24 11:47:17 -0800342 intentService.execute(TestIntentServiceHelper.eqExceptId(
343 builder.build()));
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800344
Pavlin Radoslavov248c2ae2014-12-02 09:51:25 -0800345 builder = IntentOperations.builder(APPID);
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800346 builder.addSubmitOperation(intent3);
347 builder.addSubmitOperation(intent4Update);
348 builder.addSubmitOperation(intent6);
349 builder.addSubmitOperation(intent7);
Pavlin Radoslavovdde22ae2014-11-24 11:47:17 -0800350 intentService.execute(TestIntentServiceHelper.eqExceptId(
351 builder.build()));
Pingpingf5d90932014-10-27 10:50:04 -0700352 replay(intentService);
353
354 // Start the test
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -0800355 intentSynchronizer.leaderChanged(true);
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800356 /*
357 TestUtils.callMethod(intentSynchronizer, "synchronizeIntents",
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -0800358 new Class<?>[] {});
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800359 */
360 intentSynchronizer.synchronizeIntents();
Pingpingf5d90932014-10-27 10:50:04 -0700361
362 // Verify
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800363 assertEquals(router.getRoutes4().size(), 6);
364 assertTrue(router.getRoutes4().contains(routeEntry1));
365 assertTrue(router.getRoutes4().contains(routeEntry3));
366 assertTrue(router.getRoutes4().contains(routeEntry4Update));
367 assertTrue(router.getRoutes4().contains(routeEntry5));
368 assertTrue(router.getRoutes4().contains(routeEntry6));
Pingpingf5d90932014-10-27 10:50:04 -0700369
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800370 assertEquals(intentSynchronizer.getRouteIntents().size(), 6);
371 assertTrue(intentSynchronizer.getRouteIntents().contains(intent1));
372 assertTrue(intentSynchronizer.getRouteIntents().contains(intent3));
373 assertTrue(intentSynchronizer.getRouteIntents().contains(intent4Update));
374 assertTrue(intentSynchronizer.getRouteIntents().contains(intent5));
375 assertTrue(intentSynchronizer.getRouteIntents().contains(intent6));
Pingpingf5d90932014-10-27 10:50:04 -0700376
377 verify(intentService);
378 }
379
380 /**
381 * MultiPointToSinglePointIntent builder.
382 *
383 * @param ipPrefix the ipPrefix to match
384 * @param nextHopMacAddress to which the destination MAC address in packet
385 * should be rewritten
386 * @param egressPoint to which packets should be sent
387 * @return the constructed MultiPointToSinglePointIntent
388 */
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800389 private MultiPointToSinglePointIntent intentBuilder(IpPrefix ipPrefix,
Pingpingf5d90932014-10-27 10:50:04 -0700390 String nextHopMacAddress, ConnectPoint egressPoint) {
391
392 TrafficSelector.Builder selectorBuilder =
393 DefaultTrafficSelector.builder();
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800394 if (ipPrefix.version() == Ip4Address.VERSION) {
395 selectorBuilder.matchEthType(Ethernet.TYPE_IPV4); // IPv4
396 } else {
397 selectorBuilder.matchEthType(Ethernet.TYPE_IPV6); // IPv6
398 }
399 selectorBuilder.matchIPDst(ipPrefix);
Pingpingf5d90932014-10-27 10:50:04 -0700400
401 TrafficTreatment.Builder treatmentBuilder =
402 DefaultTrafficTreatment.builder();
403 treatmentBuilder.setEthDst(MacAddress.valueOf(nextHopMacAddress));
404
405 Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
406 for (Interface intf : interfaceService.getInterfaces()) {
407 if (!intf.equals(interfaceService.getInterface(egressPoint))) {
408 ConnectPoint srcPort = intf.connectPoint();
409 ingressPoints.add(srcPort);
410 }
411 }
412 MultiPointToSinglePointIntent intent =
413 new MultiPointToSinglePointIntent(APPID,
414 selectorBuilder.build(), treatmentBuilder.build(),
415 ingressPoints, egressPoint);
416 return intent;
417 }
418
419 /**
420 * A static MultiPointToSinglePointIntent builder, the returned intent is
421 * equal to the input intent except that the id is different.
422 *
423 *
424 * @param intent the intent to be used for building a new intent
425 * @param routeEntry the relative routeEntry of the intent
426 * @return the newly constructed MultiPointToSinglePointIntent
427 * @throws TestUtilsException
428 */
429 private MultiPointToSinglePointIntent staticIntentBuilder(
430 MultiPointToSinglePointIntent intent, RouteEntry routeEntry,
431 String nextHopMacAddress) throws TestUtilsException {
432
433 // Use a different egress ConnectPoint with that in intent
434 // to generate a different id
435 MultiPointToSinglePointIntent intentNew = intentBuilder(
436 routeEntry.prefix(), nextHopMacAddress, SW2_ETH1);
437 TestUtils.setField(intentNew, "egressPoint", intent.egressPoint());
438 TestUtils.setField(intentNew,
439 "ingressPoints", intent.ingressPoints());
440 return intentNew;
441 }
Pingpingf5d90932014-10-27 10:50:04 -0700442}