blob: 0868582bb4f84a8f2cfc13774cb8439f3d79c234 [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
18import static org.easymock.EasyMock.anyObject;
19import static org.easymock.EasyMock.createMock;
20import static org.easymock.EasyMock.expect;
21import static org.easymock.EasyMock.expectLastCall;
22import static org.easymock.EasyMock.replay;
23import static org.easymock.EasyMock.reset;
24import static org.easymock.EasyMock.verify;
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -080025import static org.hamcrest.Matchers.is;
Pingpingf5d90932014-10-27 10:50:04 -070026import static org.junit.Assert.assertEquals;
Jonathan Hartec2df012014-10-23 16:40:24 -070027import static org.junit.Assert.assertFalse;
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -080028import static org.junit.Assert.assertThat;
Pingpingf5d90932014-10-27 10:50:04 -070029import static org.junit.Assert.assertTrue;
30
31import java.util.HashSet;
32import java.util.Set;
33import java.util.concurrent.ConcurrentHashMap;
34
35import org.junit.Before;
36import org.junit.Test;
37import org.onlab.junit.TestUtils;
38import org.onlab.junit.TestUtils.TestUtilsException;
Brian O'Connorabafb502014-12-02 22:26:20 -080039import org.onosproject.core.ApplicationId;
40import org.onosproject.net.ConnectPoint;
41import org.onosproject.net.DefaultHost;
42import org.onosproject.net.DeviceId;
43import org.onosproject.net.Host;
44import org.onosproject.net.HostId;
45import org.onosproject.net.HostLocation;
46import org.onosproject.net.PortNumber;
47import org.onosproject.net.flow.DefaultTrafficSelector;
48import org.onosproject.net.flow.DefaultTrafficTreatment;
49import org.onosproject.net.flow.TrafficSelector;
50import org.onosproject.net.flow.TrafficTreatment;
51import org.onosproject.net.host.HostListener;
52import org.onosproject.net.host.HostService;
53import org.onosproject.net.host.InterfaceIpAddress;
54import org.onosproject.net.intent.AbstractIntentTest;
55import org.onosproject.net.intent.Intent;
56import org.onosproject.net.intent.IntentOperations;
57import org.onosproject.net.intent.IntentService;
58import org.onosproject.net.intent.IntentState;
59import org.onosproject.net.intent.MultiPointToSinglePointIntent;
60import org.onosproject.net.provider.ProviderId;
61import org.onosproject.sdnip.config.Interface;
Pingpingf5d90932014-10-27 10:50:04 -070062import org.onlab.packet.Ethernet;
63import org.onlab.packet.IpAddress;
64import org.onlab.packet.IpPrefix;
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -080065import org.onlab.packet.Ip4Address;
Pavlin Radoslavov6b570732014-11-06 13:16:45 -080066import org.onlab.packet.Ip4Prefix;
Pingpingf5d90932014-10-27 10:50:04 -070067import org.onlab.packet.MacAddress;
68import org.onlab.packet.VlanId;
69
70import com.google.common.collect.Sets;
71import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory;
72import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree;
73import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree;
74
75/**
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -080076 * This class tests the intent synchronization function in the
77 * IntentSynchronizer class.
Pingpingf5d90932014-10-27 10:50:04 -070078 */
Brian O'Connor520c0522014-11-23 23:50:47 -080079public class IntentSyncTest extends AbstractIntentTest {
Pingpingf5d90932014-10-27 10:50:04 -070080
81 private InterfaceService interfaceService;
82 private IntentService intentService;
83 private HostService hostService;
84
85 private static final ConnectPoint SW1_ETH1 = new ConnectPoint(
86 DeviceId.deviceId("of:0000000000000001"),
87 PortNumber.portNumber(1));
88
89 private static final ConnectPoint SW2_ETH1 = new ConnectPoint(
90 DeviceId.deviceId("of:0000000000000002"),
91 PortNumber.portNumber(1));
92
93 private static final ConnectPoint SW3_ETH1 = new ConnectPoint(
94 DeviceId.deviceId("of:0000000000000003"),
95 PortNumber.portNumber(1));
96
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -080097 private IntentSynchronizer intentSynchronizer;
Pingpingf5d90932014-10-27 10:50:04 -070098 private Router router;
99
100 private static final ApplicationId APPID = new ApplicationId() {
101 @Override
102 public short id() {
103 return 1;
104 }
105
106 @Override
107 public String name() {
108 return "SDNIP";
109 }
110 };
111
112 @Before
113 public void setUp() throws Exception {
Brian O'Connor520c0522014-11-23 23:50:47 -0800114 super.setUp();
Pingpingf5d90932014-10-27 10:50:04 -0700115 setUpInterfaceService();
116 setUpHostService();
117 intentService = createMock(IntentService.class);
118
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -0800119 intentSynchronizer = new IntentSynchronizer(APPID, intentService);
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800120 router = new Router(APPID, intentSynchronizer, null, interfaceService,
121 hostService);
Pingpingf5d90932014-10-27 10:50:04 -0700122 }
123
124 /**
125 * Sets up InterfaceService.
126 */
127 private void setUpInterfaceService() {
128
129 interfaceService = createMock(InterfaceService.class);
130
131 Set<Interface> interfaces = Sets.newHashSet();
132
133 Set<InterfaceIpAddress> interfaceIpAddresses1 = Sets.newHashSet();
134 interfaceIpAddresses1.add(new InterfaceIpAddress(
135 IpAddress.valueOf("192.168.10.101"),
136 IpPrefix.valueOf("192.168.10.0/24")));
137 Interface sw1Eth1 = new Interface(SW1_ETH1,
138 interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"));
139 interfaces.add(sw1Eth1);
140
141 Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet();
142 interfaceIpAddresses2.add(new InterfaceIpAddress(
143 IpAddress.valueOf("192.168.20.101"),
144 IpPrefix.valueOf("192.168.20.0/24")));
145 Interface sw2Eth1 = new Interface(SW2_ETH1,
146 interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"));
147 interfaces.add(sw2Eth1);
148
149 Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet();
150 interfaceIpAddresses3.add(new InterfaceIpAddress(
151 IpAddress.valueOf("192.168.30.101"),
152 IpPrefix.valueOf("192.168.30.0/24")));
153 Interface sw3Eth1 = new Interface(SW3_ETH1,
154 interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"));
155 interfaces.add(sw3Eth1);
156
157 expect(interfaceService.getInterface(SW1_ETH1)).andReturn(
158 sw1Eth1).anyTimes();
159 expect(interfaceService.getInterface(SW2_ETH1)).andReturn(
160 sw2Eth1).anyTimes();
161 expect(interfaceService.getInterface(SW3_ETH1)).andReturn(
162 sw3Eth1).anyTimes();
163 expect(interfaceService.getInterfaces()).andReturn(
164 interfaces).anyTimes();
165 replay(interfaceService);
166 }
167
168 /**
169 * Sets up the host service with details of hosts.
170 */
171 private void setUpHostService() {
172 hostService = createMock(HostService.class);
173
174 hostService.addListener(anyObject(HostListener.class));
175 expectLastCall().anyTimes();
176
177 IpAddress host1Address = IpAddress.valueOf("192.168.10.1");
178 Host host1 = new DefaultHost(ProviderId.NONE, HostId.NONE,
179 MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE,
180 new HostLocation(SW1_ETH1, 1),
181 Sets.newHashSet(host1Address));
182
183 expect(hostService.getHostsByIp(host1Address))
184 .andReturn(Sets.newHashSet(host1)).anyTimes();
185 hostService.startMonitoringIp(host1Address);
186 expectLastCall().anyTimes();
187
188
189 IpAddress host2Address = IpAddress.valueOf("192.168.20.1");
190 Host host2 = new DefaultHost(ProviderId.NONE, HostId.NONE,
191 MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE,
192 new HostLocation(SW2_ETH1, 1),
193 Sets.newHashSet(host2Address));
194
195 expect(hostService.getHostsByIp(host2Address))
196 .andReturn(Sets.newHashSet(host2)).anyTimes();
197 hostService.startMonitoringIp(host2Address);
198 expectLastCall().anyTimes();
199
200
201 IpAddress host3Address = IpAddress.valueOf("192.168.30.1");
202 Host host3 = new DefaultHost(ProviderId.NONE, HostId.NONE,
203 MacAddress.valueOf("00:00:00:00:00:03"), VlanId.NONE,
204 new HostLocation(SW3_ETH1, 1),
205 Sets.newHashSet(host3Address));
206
207 expect(hostService.getHostsByIp(host3Address))
208 .andReturn(Sets.newHashSet(host3)).anyTimes();
209 hostService.startMonitoringIp(host3Address);
210 expectLastCall().anyTimes();
211
212
213 replay(hostService);
214 }
215
216 /**
217 * This method tests the behavior of intent Synchronizer.
218 *
219 * @throws TestUtilsException
220 */
221 @Test
222 public void testIntentSync() throws TestUtilsException {
223
224 //
225 // Construct routes and intents.
226 // This test simulates the following cases during the master change
227 // time interval:
228 // 1. RouteEntry1 did not change and the intent also did not change.
229 // 2. RouteEntry2 was deleted, but the intent was not deleted.
230 // 3. RouteEntry3 was newly added, and the intent was also submitted.
231 // 4. RouteEntry4 was updated to RouteEntry4Update, and the intent was
232 // also updated to a new one.
233 // 5. RouteEntry5 did not change, but its intent id changed.
234 // 6. RouteEntry6 was newly added, but the intent was not submitted.
235 //
236 RouteEntry routeEntry1 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800237 Ip4Prefix.valueOf("1.1.1.0/24"),
238 Ip4Address.valueOf("192.168.10.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700239
240 RouteEntry routeEntry2 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800241 Ip4Prefix.valueOf("2.2.2.0/24"),
242 Ip4Address.valueOf("192.168.20.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700243
244 RouteEntry routeEntry3 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800245 Ip4Prefix.valueOf("3.3.3.0/24"),
246 Ip4Address.valueOf("192.168.30.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700247
248 RouteEntry routeEntry4 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800249 Ip4Prefix.valueOf("4.4.4.0/24"),
250 Ip4Address.valueOf("192.168.30.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700251
252 RouteEntry routeEntry4Update = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800253 Ip4Prefix.valueOf("4.4.4.0/24"),
254 Ip4Address.valueOf("192.168.20.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700255
256 RouteEntry routeEntry5 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800257 Ip4Prefix.valueOf("5.5.5.0/24"),
258 Ip4Address.valueOf("192.168.10.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700259
260 RouteEntry routeEntry6 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800261 Ip4Prefix.valueOf("6.6.6.0/24"),
262 Ip4Address.valueOf("192.168.10.1"));
Pingpingf5d90932014-10-27 10:50:04 -0700263
Jonathan Hartec2df012014-10-23 16:40:24 -0700264 RouteEntry routeEntry7 = new RouteEntry(
Pavlin Radoslavov6b570732014-11-06 13:16:45 -0800265 Ip4Prefix.valueOf("7.7.7.0/24"),
266 Ip4Address.valueOf("192.168.10.1"));
Jonathan Hartec2df012014-10-23 16:40:24 -0700267
Pingpingf5d90932014-10-27 10:50:04 -0700268 MultiPointToSinglePointIntent intent1 = intentBuilder(
269 routeEntry1.prefix(), "00:00:00:00:00:01", SW1_ETH1);
270 MultiPointToSinglePointIntent intent2 = intentBuilder(
271 routeEntry2.prefix(), "00:00:00:00:00:02", SW2_ETH1);
272 MultiPointToSinglePointIntent intent3 = intentBuilder(
273 routeEntry3.prefix(), "00:00:00:00:00:03", SW3_ETH1);
274 MultiPointToSinglePointIntent intent4 = intentBuilder(
275 routeEntry4.prefix(), "00:00:00:00:00:03", SW3_ETH1);
276 MultiPointToSinglePointIntent intent4Update = intentBuilder(
277 routeEntry4Update.prefix(), "00:00:00:00:00:02", SW2_ETH1);
278 MultiPointToSinglePointIntent intent5 = intentBuilder(
279 routeEntry5.prefix(), "00:00:00:00:00:01", SW1_ETH1);
Jonathan Hartec2df012014-10-23 16:40:24 -0700280 MultiPointToSinglePointIntent intent7 = intentBuilder(
281 routeEntry7.prefix(), "00:00:00:00:00:01", SW1_ETH1);
Pingpingf5d90932014-10-27 10:50:04 -0700282
283 // Compose a intent, which is equal to intent5 but the id is different.
284 MultiPointToSinglePointIntent intent5New =
285 staticIntentBuilder(intent5, routeEntry5, "00:00:00:00:00:01");
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800286 assertThat(IntentSynchronizer.IntentKey.equalIntents(
287 intent5, intent5New),
288 is(true));
Jonathan Hartec2df012014-10-23 16:40:24 -0700289 assertFalse(intent5.equals(intent5New));
Pingpingf5d90932014-10-27 10:50:04 -0700290
291 MultiPointToSinglePointIntent intent6 = intentBuilder(
292 routeEntry6.prefix(), "00:00:00:00:00:01", SW1_ETH1);
293
Pavlin Radoslavov64c1ed12014-12-10 18:10:55 -0800294 // Set up the ribTable field in Router class and routeIntents fields
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800295 // in IntentSynchronizer class
Pavlin Radoslavov64c1ed12014-12-10 18:10:55 -0800296 InvertedRadixTree<RouteEntry> ribTable =
Pingpingf5d90932014-10-27 10:50:04 -0700297 new ConcurrentInvertedRadixTree<>(
298 new DefaultByteArrayNodeFactory());
Pavlin Radoslavov64c1ed12014-12-10 18:10:55 -0800299 ribTable.put(RouteEntry.createBinaryString(routeEntry1.prefix()),
300 routeEntry1);
301 ribTable.put(RouteEntry.createBinaryString(routeEntry3.prefix()),
302 routeEntry3);
303 ribTable.put(RouteEntry.createBinaryString(routeEntry4Update.prefix()),
304 routeEntry4Update);
305 ribTable.put(RouteEntry.createBinaryString(routeEntry5.prefix()),
306 routeEntry5);
307 ribTable.put(RouteEntry.createBinaryString(routeEntry6.prefix()),
308 routeEntry6);
309 ribTable.put(RouteEntry.createBinaryString(routeEntry7.prefix()),
310 routeEntry7);
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800311 TestUtils.setField(router, "ribTable4", ribTable);
Pingpingf5d90932014-10-27 10:50:04 -0700312
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800313 ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent>
314 routeIntents = new ConcurrentHashMap<>();
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800315 routeIntents.put(routeEntry1.prefix(), intent1);
316 routeIntents.put(routeEntry3.prefix(), intent3);
317 routeIntents.put(routeEntry4Update.prefix(), intent4Update);
318 routeIntents.put(routeEntry5.prefix(), intent5New);
319 routeIntents.put(routeEntry6.prefix(), intent6);
320 routeIntents.put(routeEntry7.prefix(), intent7);
321 TestUtils.setField(intentSynchronizer, "routeIntents", routeIntents);
Pingpingf5d90932014-10-27 10:50:04 -0700322
323 // Set up expectation
324 reset(intentService);
325 Set<Intent> intents = new HashSet<Intent>();
326 intents.add(intent1);
Jonathan Hartec2df012014-10-23 16:40:24 -0700327 expect(intentService.getIntentState(intent1.id()))
328 .andReturn(IntentState.INSTALLED).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700329 intents.add(intent2);
Jonathan Hartec2df012014-10-23 16:40:24 -0700330 expect(intentService.getIntentState(intent2.id()))
331 .andReturn(IntentState.INSTALLED).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700332 intents.add(intent4);
Jonathan Hartec2df012014-10-23 16:40:24 -0700333 expect(intentService.getIntentState(intent4.id()))
334 .andReturn(IntentState.INSTALLED).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700335 intents.add(intent5);
Jonathan Hartec2df012014-10-23 16:40:24 -0700336 expect(intentService.getIntentState(intent5.id()))
337 .andReturn(IntentState.INSTALLED).anyTimes();
338 intents.add(intent7);
339 expect(intentService.getIntentState(intent7.id()))
340 .andReturn(IntentState.WITHDRAWING).anyTimes();
Pingpingf5d90932014-10-27 10:50:04 -0700341 expect(intentService.getIntents()).andReturn(intents).anyTimes();
342
Pavlin Radoslavov248c2ae2014-12-02 09:51:25 -0800343 IntentOperations.Builder builder = IntentOperations.builder(APPID);
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800344 builder.addWithdrawOperation(intent2.id());
345 builder.addWithdrawOperation(intent4.id());
Pavlin Radoslavovdde22ae2014-11-24 11:47:17 -0800346 intentService.execute(TestIntentServiceHelper.eqExceptId(
347 builder.build()));
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800348
Pavlin Radoslavov248c2ae2014-12-02 09:51:25 -0800349 builder = IntentOperations.builder(APPID);
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800350 builder.addSubmitOperation(intent3);
351 builder.addSubmitOperation(intent4Update);
352 builder.addSubmitOperation(intent6);
353 builder.addSubmitOperation(intent7);
Pavlin Radoslavovdde22ae2014-11-24 11:47:17 -0800354 intentService.execute(TestIntentServiceHelper.eqExceptId(
355 builder.build()));
Pingpingf5d90932014-10-27 10:50:04 -0700356 replay(intentService);
357
358 // Start the test
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -0800359 intentSynchronizer.leaderChanged(true);
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800360 /*
361 TestUtils.callMethod(intentSynchronizer, "synchronizeIntents",
Pavlin Radoslavova071b1e2014-11-17 13:37:57 -0800362 new Class<?>[] {});
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800363 */
364 intentSynchronizer.synchronizeIntents();
Pingpingf5d90932014-10-27 10:50:04 -0700365
366 // Verify
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800367 assertEquals(router.getRoutes4().size(), 6);
368 assertTrue(router.getRoutes4().contains(routeEntry1));
369 assertTrue(router.getRoutes4().contains(routeEntry3));
370 assertTrue(router.getRoutes4().contains(routeEntry4Update));
371 assertTrue(router.getRoutes4().contains(routeEntry5));
372 assertTrue(router.getRoutes4().contains(routeEntry6));
Pingpingf5d90932014-10-27 10:50:04 -0700373
Pavlin Radoslavova7243cc2014-11-22 21:38:02 -0800374 assertEquals(intentSynchronizer.getRouteIntents().size(), 6);
375 assertTrue(intentSynchronizer.getRouteIntents().contains(intent1));
376 assertTrue(intentSynchronizer.getRouteIntents().contains(intent3));
377 assertTrue(intentSynchronizer.getRouteIntents().contains(intent4Update));
378 assertTrue(intentSynchronizer.getRouteIntents().contains(intent5));
379 assertTrue(intentSynchronizer.getRouteIntents().contains(intent6));
Pingpingf5d90932014-10-27 10:50:04 -0700380
381 verify(intentService);
382 }
383
384 /**
385 * MultiPointToSinglePointIntent builder.
386 *
387 * @param ipPrefix the ipPrefix to match
388 * @param nextHopMacAddress to which the destination MAC address in packet
389 * should be rewritten
390 * @param egressPoint to which packets should be sent
391 * @return the constructed MultiPointToSinglePointIntent
392 */
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800393 private MultiPointToSinglePointIntent intentBuilder(IpPrefix ipPrefix,
Pingpingf5d90932014-10-27 10:50:04 -0700394 String nextHopMacAddress, ConnectPoint egressPoint) {
395
396 TrafficSelector.Builder selectorBuilder =
397 DefaultTrafficSelector.builder();
Pavlin Radoslavov3a0a52e2015-01-06 17:41:37 -0800398 if (ipPrefix.version() == Ip4Address.VERSION) {
399 selectorBuilder.matchEthType(Ethernet.TYPE_IPV4); // IPv4
400 } else {
401 selectorBuilder.matchEthType(Ethernet.TYPE_IPV6); // IPv6
402 }
403 selectorBuilder.matchIPDst(ipPrefix);
Pingpingf5d90932014-10-27 10:50:04 -0700404
405 TrafficTreatment.Builder treatmentBuilder =
406 DefaultTrafficTreatment.builder();
407 treatmentBuilder.setEthDst(MacAddress.valueOf(nextHopMacAddress));
408
409 Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
410 for (Interface intf : interfaceService.getInterfaces()) {
411 if (!intf.equals(interfaceService.getInterface(egressPoint))) {
412 ConnectPoint srcPort = intf.connectPoint();
413 ingressPoints.add(srcPort);
414 }
415 }
416 MultiPointToSinglePointIntent intent =
417 new MultiPointToSinglePointIntent(APPID,
418 selectorBuilder.build(), treatmentBuilder.build(),
419 ingressPoints, egressPoint);
420 return intent;
421 }
422
423 /**
424 * A static MultiPointToSinglePointIntent builder, the returned intent is
425 * equal to the input intent except that the id is different.
426 *
427 *
428 * @param intent the intent to be used for building a new intent
429 * @param routeEntry the relative routeEntry of the intent
430 * @return the newly constructed MultiPointToSinglePointIntent
431 * @throws TestUtilsException
432 */
433 private MultiPointToSinglePointIntent staticIntentBuilder(
434 MultiPointToSinglePointIntent intent, RouteEntry routeEntry,
435 String nextHopMacAddress) throws TestUtilsException {
436
437 // Use a different egress ConnectPoint with that in intent
438 // to generate a different id
439 MultiPointToSinglePointIntent intentNew = intentBuilder(
440 routeEntry.prefix(), nextHopMacAddress, SW2_ETH1);
441 TestUtils.setField(intentNew, "egressPoint", intent.egressPoint());
442 TestUtils.setField(intentNew,
443 "ingressPoints", intent.ingressPoints());
444 return intentNew;
445 }
Pingpingf5d90932014-10-27 10:50:04 -0700446}