blob: 762ce5266a2b3bd5ad8e14badada487af8771830 [file] [log] [blame]
Luca Pretee4a5e1a2016-09-07 17:01:22 -07001/*
2 * Copyright 2015-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.sdnip;
18
19import com.google.common.collect.Lists;
20import com.google.common.collect.Sets;
21import org.junit.Before;
22import org.junit.Test;
23import org.onlab.packet.Ethernet;
24import org.onlab.packet.Ip4Address;
25import org.onlab.packet.Ip4Prefix;
26import org.onlab.packet.IpAddress;
27import org.onlab.packet.IpPrefix;
28import org.onlab.packet.MacAddress;
29import org.onlab.packet.VlanId;
30import org.onosproject.TestApplicationId;
31import org.onosproject.core.ApplicationId;
32import org.onosproject.core.CoreServiceAdapter;
33import org.onosproject.incubator.net.intf.Interface;
34import org.onosproject.incubator.net.intf.InterfaceEvent;
35import org.onosproject.incubator.net.intf.InterfaceListener;
36import org.onosproject.incubator.net.intf.InterfaceService;
37import org.onosproject.incubator.net.intf.InterfaceServiceAdapter;
38import org.onosproject.incubator.net.routing.ResolvedRoute;
39import org.onosproject.incubator.net.routing.RouteEvent;
40import org.onosproject.incubator.net.routing.RouteListener;
41import org.onosproject.incubator.net.routing.RouteServiceAdapter;
42import org.onosproject.net.ConnectPoint;
43import org.onosproject.net.DeviceId;
44import org.onosproject.net.FilteredConnectPoint;
45import org.onosproject.net.PortNumber;
46import org.onosproject.net.flow.DefaultTrafficSelector;
47import org.onosproject.net.flow.DefaultTrafficTreatment;
48import org.onosproject.net.flow.TrafficSelector;
49import org.onosproject.net.flow.TrafficTreatment;
50import org.onosproject.net.host.InterfaceIpAddress;
51import org.onosproject.net.intent.AbstractIntentTest;
52import org.onosproject.net.intent.Key;
53import org.onosproject.net.intent.MultiPointToSinglePointIntent;
54import org.onosproject.routing.IntentSynchronizationService;
55
56import java.util.Collections;
57import java.util.List;
58import java.util.Set;
59
60import static org.easymock.EasyMock.anyObject;
61import static org.easymock.EasyMock.createMock;
62import static org.easymock.EasyMock.expect;
63import static org.easymock.EasyMock.expectLastCall;
64import static org.easymock.EasyMock.replay;
65import static org.easymock.EasyMock.reset;
66import static org.easymock.EasyMock.verify;
67import static org.onosproject.routing.TestIntentServiceHelper.eqExceptId;
68
69/**
70 * Unit tests for SdnIpFib.
71 */
72public class SdnIpFibTest extends AbstractIntentTest {
73
74 private InterfaceService interfaceService;
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
88 private static final ConnectPoint SW4_ETH1 = new ConnectPoint(
89 DeviceId.deviceId("of:0000000000000004"),
90 PortNumber.portNumber(1));
91
92 private static final MacAddress MAC1 = MacAddress.valueOf("00:00:00:00:00:01");
93 private static final MacAddress MAC2 = MacAddress.valueOf("00:00:00:00:00:02");
94 private static final MacAddress MAC3 = MacAddress.valueOf("00:00:00:00:00:03");
95 private static final MacAddress MAC4 = MacAddress.valueOf("00:00:00:00:00:04");
96
97 private static final VlanId NO_VLAN = VlanId.NONE;
98 private static final VlanId VLAN10 = VlanId.vlanId(Short.valueOf("10"));
99 private static final VlanId VLAN20 = VlanId.vlanId(Short.valueOf("20"));
100
101 private static final InterfaceIpAddress IIP1 =
102 InterfaceIpAddress.valueOf("192.168.10.101/24");
103 private static final InterfaceIpAddress IIP2 =
104 InterfaceIpAddress.valueOf("192.168.20.101/24");
105 private static final InterfaceIpAddress IIP3 =
106 InterfaceIpAddress.valueOf("192.168.30.101/24");
107 private static final InterfaceIpAddress IIP4 =
108 InterfaceIpAddress.valueOf("192.168.40.101/24");
109
110 private static final IpAddress IP1 = Ip4Address.valueOf("192.168.10.1");
111 private static final IpAddress IP2 = Ip4Address.valueOf("192.168.20.1");
112 private static final IpAddress IP3 = Ip4Address.valueOf("192.168.30.1");
113
114 private static final IpPrefix PREFIX1 = Ip4Prefix.valueOf("1.1.1.0/24");
115 private static final IpPrefix PREFIX2 = Ip4Prefix.valueOf("1.1.2.0/24");
116
117 private SdnIpFib sdnipFib;
118 private IntentSynchronizationService intentSynchronizer;
119 private final Set<Interface> interfaces = Sets.newHashSet();
120
121 private static final ApplicationId APPID = TestApplicationId.create("SDNIP");
122
123 private RouteListener routeListener;
124 private InterfaceListener interfaceListener;
125
126 @Before
127 public void setUp() throws Exception {
128 super.setUp();
129
130 interfaceService = createMock(InterfaceService.class);
131
132 interfaceService.addListener(anyObject(InterfaceListener.class));
133 expectLastCall().andDelegateTo(new InterfaceServiceDelegate());
134
135 // These will set expectations on routingConfig and interfaceService
136 setUpInterfaceService();
137
138 replay(interfaceService);
139
140 intentSynchronizer = createMock(IntentSynchronizationService.class);
141
142 sdnipFib = new SdnIpFib();
143 sdnipFib.routeService = new TestRouteService();
144 sdnipFib.coreService = new TestCoreService();
145 sdnipFib.interfaceService = interfaceService;
146 sdnipFib.intentSynchronizer = intentSynchronizer;
147
148 sdnipFib.activate();
149 }
150
151 /**
152 * Sets up the interface service.
153 */
154 private void setUpInterfaceService() {
155 List<InterfaceIpAddress> iIps1 = Lists.newArrayList();
156 iIps1.add(IIP1);
157 Interface sw1Eth1 = new Interface("sw1-eth1", SW1_ETH1, iIps1, MAC1, VLAN10);
158 interfaces.add(sw1Eth1);
159
160 List<InterfaceIpAddress> iIps2 = Lists.newArrayList();
161 iIps2.add(IIP2);
162 Interface sw2Eth1 = new Interface("sw2-eth1", SW2_ETH1, iIps2, MAC2, VLAN20);
163 interfaces.add(sw2Eth1);
164
165 List<InterfaceIpAddress> iIps3 = Lists.newArrayList();
166 iIps3.add(IIP3);
167 Interface sw3Eth1 = new Interface("sw3-eth1", SW3_ETH1, iIps3, MAC3, NO_VLAN);
168 interfaces.add(sw3Eth1);
169
170 expect(interfaceService.getInterfacesByPort(SW1_ETH1)).andReturn(
171 Collections.singleton(sw1Eth1)).anyTimes();
172 expect(interfaceService.getMatchingInterface(IP1))
173 .andReturn(sw1Eth1).anyTimes();
174 expect(interfaceService.getInterfacesByPort(SW2_ETH1)).andReturn(
175 Collections.singleton(sw2Eth1)).anyTimes();
176 expect(interfaceService.getMatchingInterface(IP2))
177 .andReturn(sw2Eth1).anyTimes();
178 expect(interfaceService.getInterfacesByPort(SW3_ETH1)).andReturn(
179 Collections.singleton(sw3Eth1)).anyTimes();
180 expect(interfaceService.getMatchingInterface(IP3))
181 .andReturn(sw3Eth1).anyTimes();
182 expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
183 }
184
185 /**
186 * Tests adding a route. The egress interface has no VLAN configured.
187 *
188 * We verify that the synchronizer records the correct state and that the
189 * correct intent is submitted to the IntentService.
190 */
191 @Test
192 public void testRouteAddToNoVlan() {
193 // Build the expected route
194 ResolvedRoute route = new ResolvedRoute(PREFIX1, IP3, MAC3);
195
196 MultiPointToSinglePointIntent intent =
197 createIntentToThreeSrcOneTwo(PREFIX1);
198
199 // Setup the expected intents
200 intentSynchronizer.submit(eqExceptId(intent));
201 replay(intentSynchronizer);
202
203 // Send in the added event
204 routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_ADDED, route));
205
206 verify(intentSynchronizer);
207 }
208
209 /**
210 * Tests adding a route. The egress interface has a VLAN configured.
211 *
212 * We verify that the synchronizer records the correct state and that the
213 * correct intent is submitted to the IntentService.
214 */
215 @Test
216 public void testRouteAddToVlan() {
217 // Build the expected route
218 ResolvedRoute route = new ResolvedRoute(PREFIX2, IP1, MAC1);
219
220 MultiPointToSinglePointIntent intent = createIntentToOne(PREFIX2);
221
222 // Setup the expected intents
223 intentSynchronizer.submit(eqExceptId(intent));
224 replay(intentSynchronizer);
225
226 // Send in the added event
227 routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_ADDED, route));
228
229 verify(intentSynchronizer);
230 }
231
232 /**
233 * Tests updating a route.
234 *
235 * We first add a route from a next-hop with no vlan. We then announce the
236 * same route from another next-hop with a vlan.
237 *
238 * We verify that the synchronizer records the correct state and that the
239 * correct intent is submitted to the IntentService.
240 */
241 @Test
242 public void testRouteUpdatesToVlan() {
243 // Add a route first to a destination with no VLAN
244 testRouteAddToNoVlan();
245
246 // Build the new route entries for prefix1 and prefix2
247 ResolvedRoute routePrefixOne = new ResolvedRoute(PREFIX1, IP1, MAC1);
248
249 // Create the new expected intents
250 MultiPointToSinglePointIntent newPrefixOneIntent = createIntentToOne(PREFIX1);
251
252 // Set up test expectation
253 reset(intentSynchronizer);
254
255 // Setup the expected intents
256 intentSynchronizer.submit(eqExceptId(newPrefixOneIntent));
257 replay(intentSynchronizer);
258
259 // Send in the update events
260 routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_UPDATED,
261 routePrefixOne));
262
263 verify(intentSynchronizer);
264 }
265
266 /**
267 * Tests updating a route.
268 *
269 * We first add a route from a next-hop with a vlan. We then announce the
270 * same route from another next-hop with no vlan.
271 *
272 * We verify that the synchronizer records the correct state and that the
273 * correct intent is submitted to the IntentService.
274 */
275 @Test
276 public void testRouteUpdatesToNoVlan() {
277 // Add a route first to a destination with no VLAN
278 testRouteAddToVlan();
279
280 // Build the new route entries for prefix1 and prefix2
281 ResolvedRoute routePrefix = new ResolvedRoute(PREFIX2, IP3, MAC3);
282
283 // Create the new expected intents
284 MultiPointToSinglePointIntent newPrefixIntent =
285 createIntentToThreeSrcOneTwo(PREFIX2);
286
287 // Set up test expectation
288 reset(intentSynchronizer);
289
290 // Setup the expected intents
291 intentSynchronizer.submit(eqExceptId(newPrefixIntent));
292 replay(intentSynchronizer);
293
294 // Send in the update events
295 routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_UPDATED,
296 routePrefix));
297
298 verify(intentSynchronizer);
299 }
300
301 /**
302 * Tests deleting a route.
303 *
304 * We verify that the synchronizer records the correct state and that the
305 * correct intent is withdrawn from the IntentService.
306 */
307 @Test
308 public void testRouteDelete() {
309 // Add a route first
310 testRouteAddToNoVlan();
311
312 // Construct the existing route entry
313 ResolvedRoute route = new ResolvedRoute(PREFIX1, null, null);
314
315 // Create existing intent
316 MultiPointToSinglePointIntent removedIntent =
317 createIntentToThreeSrcOneTwo(PREFIX1);
318
319 // Set up expectation
320 reset(intentSynchronizer);
321 // Setup the expected intents
322 intentSynchronizer.withdraw(eqExceptId(removedIntent));
323 replay(intentSynchronizer);
324
325 // Send in the removed event
326 routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_REMOVED, route));
327
328 verify(intentSynchronizer);
329 }
330
331 /**
332 * Tests adding a new interface.
333 *
334 * We verify that the synchronizer records the correct state and that the
335 * correct intent is withdrawn from the IntentService.
336 */
337 @Test
338 public void testAddInterface() {
339 // Add a route first
340 testRouteAddToNoVlan();
341
342 // Create the new expected intent
343 MultiPointToSinglePointIntent addedIntent =
344 createIntentToThreeSrcOneTwoFour(PREFIX1);
345
346 reset(intentSynchronizer);
347
348 intentSynchronizer.submit(eqExceptId(addedIntent));
349 expectLastCall().once();
350
351 replay(intentSynchronizer);
352
353 // Create the new interface and add notify it
354 Interface intf = new Interface("sw4-eth1", SW4_ETH1,
355 Collections.singletonList(IIP4),
356 MAC4, NO_VLAN);
357 InterfaceEvent intfEvent =
358 new InterfaceEvent(InterfaceEvent.Type.INTERFACE_ADDED, intf);
359
360 interfaceListener.event(intfEvent);
361
362 verify(intentSynchronizer);
363 }
364
365 /**
366 * Tests removing an existing interface.
367 *
368 * We first push an intent with destination sw3 and source sw1 and sw2. We
369 * then remove the ingress interface on sw1.
370 *
371 * We verify that the synchronizer records the correct state and that the
372 * correct intent is withdrawn from the IntentService.
373 */
374 @Test
375 public void testRemoveIngressInterface() {
376 // Add a route first
377 testRouteAddToNoVlan();
378
379 // Create the new expected intent
380 MultiPointToSinglePointIntent remainingIntent =
381 createIntentToThreeSrcTwo(PREFIX1);
382
383 reset(intentSynchronizer);
384
385 intentSynchronizer.submit(eqExceptId(remainingIntent));
386 expectLastCall().once();
387
388 replay(intentSynchronizer);
389
390 // Define the existing ingress interface and remove it
391 Interface intf = new Interface("sw1-eth1", SW1_ETH1,
392 Collections.singletonList(IIP1),
393 MAC1, VLAN10);
394 InterfaceEvent intfEvent =
395 new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, intf);
396 interfaceListener.event(intfEvent);
397
398 verify(intentSynchronizer);
399 }
400
401 /**
402 * Tests removing an existing egress interface.
403 *
404 * We first push an intent with destination sw3 and source sw1 and sw2. We
405 * then remove the egress interface on sw3.
406 *
407 * We verify that the synchronizer records the correct state and that the
408 * correct intent is withdrawn from the IntentService.
409 */
410 @Test
411 public void testRemoveEgressInterface() {
412 // Add a route first
413 testRouteAddToNoVlan();
414
415 // Create existing intent
416 MultiPointToSinglePointIntent removedIntent =
417 createIntentToThreeSrcOneTwo(PREFIX1);
418
419 // Set up expectation
420 reset(intentSynchronizer);
421 // Setup the expected intents
422 intentSynchronizer.withdraw(eqExceptId(removedIntent));
423 replay(intentSynchronizer);
424
425 // Define the existing egress interface and remove it
426 Interface intf = new Interface("sw3-eth1", SW3_ETH1,
427 Collections.singletonList(IIP3),
428 MAC3, VlanId.NONE);
429 InterfaceEvent intfEvent =
430 new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, intf);
431 interfaceListener.event(intfEvent);
432
433 verify(intentSynchronizer);
434 }
435
436 /*
437 * Builds a MultiPointToSinglePointIntent with dest sw1 (VLAN Id) and src
438 * sw2, sw3.
439 */
440 private MultiPointToSinglePointIntent createIntentToOne(IpPrefix ipPrefix) {
441 // Build the expected treatment
442 TrafficTreatment.Builder treatmentBuilder =
443 DefaultTrafficTreatment.builder();
444 treatmentBuilder.setEthDst(MAC1);
445
446 // Build the expected egress FilteredConnectPoint
447 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
448 selector.matchVlanId(VLAN10);
449 FilteredConnectPoint egressFilteredCP =
450 new FilteredConnectPoint(SW1_ETH1, selector.build());
451
452 // Build the expected selectors
453 Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
454
455 // Build the expected ingress FilteredConnectPoint for sw2
456 selector = DefaultTrafficSelector.builder();
457 selector.matchVlanId(VLAN20);
458 selector.matchEthType(Ethernet.TYPE_IPV4);
459 selector.matchIPDst(ipPrefix);
460 FilteredConnectPoint ingressFilteredCP =
461 new FilteredConnectPoint(SW2_ETH1, selector.build());
462 ingressFilteredCPs.add(ingressFilteredCP);
463
464 // Build the expected ingress FilteredConnectPoint for sw3
465 selector = DefaultTrafficSelector.builder();
466 selector.matchEthType(Ethernet.TYPE_IPV4);
467 selector.matchIPDst(ipPrefix);
468 ingressFilteredCP = new FilteredConnectPoint(SW3_ETH1, selector.build());
469 ingressFilteredCPs.add(ingressFilteredCP);
470
471 // Build the expected intent
472 MultiPointToSinglePointIntent intent =
473 MultiPointToSinglePointIntent.builder()
474 .appId(APPID)
475 .key(Key.of(ipPrefix.toString(), APPID))
476 .filteredIngressPoints(ingressFilteredCPs)
477 .filteredEgressPoint(egressFilteredCP)
478 .treatment(treatmentBuilder.build())
479 .constraints(SdnIpFib.CONSTRAINTS)
480 .build();
481
482 return intent;
483 }
484
485 /*
486 * Builds a MultiPointToSinglePointIntent with dest sw3 (no VLAN Id) and src
487 * sw1, sw2.
488 */
489 private MultiPointToSinglePointIntent createIntentToThreeSrcOneTwo(IpPrefix ipPrefix) {
490 // Build the expected treatment
491 TrafficTreatment.Builder treatmentBuilder =
492 DefaultTrafficTreatment.builder();
493 treatmentBuilder.setEthDst(MAC3);
494
495 // Build the expected egress FilteredConnectPoint
496 FilteredConnectPoint egressFilteredCP = new FilteredConnectPoint(SW3_ETH1);
497
498 // Build the expected selectors
499 Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
500
501 // Build the expected ingress FilteredConnectPoint for sw1
502 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
503 selector.matchVlanId(VLAN10);
504 selector.matchEthType(Ethernet.TYPE_IPV4);
505 selector.matchIPDst(ipPrefix);
506 FilteredConnectPoint ingressFilteredCP =
507 new FilteredConnectPoint(SW1_ETH1, selector.build());
508 ingressFilteredCPs.add(ingressFilteredCP);
509
510 // Build the expected ingress FilteredConnectPoint for sw2
511 selector = DefaultTrafficSelector.builder();
512 selector.matchVlanId(VLAN20);
513 selector.matchEthType(Ethernet.TYPE_IPV4);
514 selector.matchIPDst(ipPrefix);
515 ingressFilteredCP = new FilteredConnectPoint(SW2_ETH1, selector.build());
516 ingressFilteredCPs.add(ingressFilteredCP);
517
518 // Build the expected intent
519 MultiPointToSinglePointIntent intent =
520 MultiPointToSinglePointIntent.builder()
521 .appId(APPID)
522 .key(Key.of(ipPrefix.toString(), APPID))
523 .filteredIngressPoints(ingressFilteredCPs)
524 .filteredEgressPoint(egressFilteredCP)
525 .treatment(treatmentBuilder.build())
526 .constraints(SdnIpFib.CONSTRAINTS)
527 .build();
528
529 return intent;
530 }
531
532 /*
533 * Builds a MultiPointToSinglePointIntent with dest sw3 (no VLAN Id) and src
534 * sw2.
535 */
536 private MultiPointToSinglePointIntent createIntentToThreeSrcTwo(IpPrefix ipPrefix) {
537 // Build the expected treatment
538 TrafficTreatment.Builder treatmentBuilder =
539 DefaultTrafficTreatment.builder();
540 treatmentBuilder.setEthDst(MAC3);
541
542 // Build the expected egress FilteredConnectPoint
543 FilteredConnectPoint egressFilteredCP = new FilteredConnectPoint(SW3_ETH1);
544
545 // Build the expected ingress FilteredConnectPoint for sw2
546 Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
547 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
548 selector.matchVlanId(VLAN20);
549 selector.matchEthType(Ethernet.TYPE_IPV4);
550 selector.matchIPDst(ipPrefix);
551 FilteredConnectPoint ingressFilteredCP =
552 new FilteredConnectPoint(SW2_ETH1, selector.build());
553 ingressFilteredCPs.add(ingressFilteredCP);
554
555 // Build the expected intent
556 MultiPointToSinglePointIntent intent =
557 MultiPointToSinglePointIntent.builder()
558 .appId(APPID)
559 .key(Key.of(ipPrefix.toString(), APPID))
560 .filteredIngressPoints(ingressFilteredCPs)
561 .filteredEgressPoint(egressFilteredCP)
562 .treatment(treatmentBuilder.build())
563 .constraints(SdnIpFib.CONSTRAINTS)
564 .build();
565
566 return intent;
567 }
568
569 /*
570 * Builds a MultiPointToSinglePointIntent with dest sw3 (no VLAN Id) and src
571 * sw1, sw2, sw4.
572 */
573 private MultiPointToSinglePointIntent createIntentToThreeSrcOneTwoFour(IpPrefix ipPrefix) {
574 // Build the expected treatment
575 TrafficTreatment.Builder treatmentBuilder =
576 DefaultTrafficTreatment.builder();
577 treatmentBuilder.setEthDst(MAC3);
578
579 // Build the expected egress FilteredConnectPoint
580 FilteredConnectPoint egressFilteredCP = new FilteredConnectPoint(SW3_ETH1);
581
582 // Build the expected selectors
583 Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
584
585 // Build the expected ingress FilteredConnectPoint for sw1
586 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
587 selector.matchVlanId(VLAN10);
588 selector.matchEthType(Ethernet.TYPE_IPV4);
589 selector.matchIPDst(ipPrefix);
590 FilteredConnectPoint ingressFilteredCP =
591 new FilteredConnectPoint(SW1_ETH1, selector.build());
592 ingressFilteredCPs.add(ingressFilteredCP);
593
594 // Build the expected ingress FilteredConnectPoint for sw2
595 selector = DefaultTrafficSelector.builder();
596 selector.matchVlanId(VLAN20);
597 selector.matchEthType(Ethernet.TYPE_IPV4);
598 selector.matchIPDst(ipPrefix);
599 ingressFilteredCP = new FilteredConnectPoint(SW2_ETH1, selector.build());
600 ingressFilteredCPs.add(ingressFilteredCP);
601
602 // Build the expected ingress FilteredConnectPoint for sw4
603 selector = DefaultTrafficSelector.builder();
604 selector.matchEthType(Ethernet.TYPE_IPV4);
605 selector.matchIPDst(ipPrefix);
606 ingressFilteredCP = new FilteredConnectPoint(SW4_ETH1, selector.build());
607 ingressFilteredCPs.add(ingressFilteredCP);
608
609 // Build the expected intent
610 MultiPointToSinglePointIntent intent =
611 MultiPointToSinglePointIntent.builder()
612 .appId(APPID)
613 .key(Key.of(ipPrefix.toString(), APPID))
614 .filteredIngressPoints(ingressFilteredCPs)
615 .filteredEgressPoint(egressFilteredCP)
616 .treatment(treatmentBuilder.build())
617 .constraints(SdnIpFib.CONSTRAINTS)
618 .build();
619
620 return intent;
621 }
622
623 private class TestCoreService extends CoreServiceAdapter {
624 @Override
625 public ApplicationId getAppId(String name) {
626 return APPID;
627 }
628 }
629
630 private class TestRouteService extends RouteServiceAdapter {
631 @Override
632 public void addListener(RouteListener routeListener) {
633 SdnIpFibTest.this.routeListener = routeListener;
634 }
635 }
636
637 private class InterfaceServiceDelegate extends InterfaceServiceAdapter {
638 @Override
639 public void addListener(InterfaceListener listener) {
640 SdnIpFibTest.this.interfaceListener = listener;
641 }
642 }
643}