blob: 9d72cd05f858c1009bdb5bafdbc0717a84558b1d [file] [log] [blame]
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +02001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +02003 *
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 */
16package org.onosproject.net.intent.impl.compiler;
17
18import org.easymock.EasyMock;
19import org.junit.After;
20import org.junit.Before;
21import org.junit.Test;
22import org.onlab.packet.ChassisId;
23import org.onosproject.TestApplicationId;
24import org.onosproject.cfg.ComponentConfigService;
25import org.onosproject.core.ApplicationId;
26import org.onosproject.core.CoreService;
27import org.onosproject.core.IdGenerator;
28import org.onosproject.net.Annotations;
29import org.onosproject.net.ChannelSpacing;
30import org.onosproject.net.DefaultAnnotations;
31import org.onosproject.net.CltSignalType;
32import org.onosproject.net.ConnectPoint;
33import org.onosproject.net.DefaultDevice;
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -080034import org.onosproject.net.DefaultPort;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +020035import org.onosproject.net.Device;
36import org.onosproject.net.DeviceId;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +020037import org.onosproject.net.OchSignal;
38import org.onosproject.net.OduCltPort;
39import org.onosproject.net.OduSignalId;
40import org.onosproject.net.OduSignalType;
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +020041import org.onosproject.net.OduSignalUtils;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +020042import org.onosproject.net.Port;
43import org.onosproject.net.PortNumber;
44import org.onosproject.net.TributarySlot;
45import org.onosproject.net.flow.DefaultTrafficSelector;
46import org.onosproject.net.flow.DefaultTrafficTreatment;
47import org.onosproject.net.flow.FlowRule;
48import org.onosproject.net.flow.TrafficSelector;
49import org.onosproject.net.flow.TrafficTreatment;
50import org.onosproject.net.flow.criteria.Criteria;
51import org.onosproject.net.flow.instructions.Instructions;
52import org.onosproject.net.intent.FlowRuleIntent;
53import org.onosproject.net.intent.Intent;
54import org.onosproject.net.intent.IntentExtensionService;
55import org.onosproject.net.intent.IntentId;
56import org.onosproject.net.intent.IntentServiceAdapter;
57import org.onosproject.net.intent.Key;
58import org.onosproject.net.intent.MockIdGenerator;
59import org.onosproject.net.intent.OpticalCircuitIntent;
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -080060import org.onosproject.net.optical.OchPort;
61import org.onosproject.net.optical.impl.DefaultOchPort;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +020062import org.onosproject.net.provider.ProviderId;
Sho SHIMIZU739873b2016-02-23 17:02:12 -080063import org.onosproject.net.intent.IntentSetMultimap;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +020064import org.onosproject.net.behaviour.TributarySlotQuery;
65import org.onosproject.net.device.DeviceServiceAdapter;
66import org.onosproject.net.driver.Behaviour;
67import org.onosproject.net.driver.DefaultDriver;
68import org.onosproject.net.driver.Driver;
69import org.onosproject.net.driver.DriverHandler;
70import org.onosproject.net.driver.DriverService;
71import org.onosproject.net.driver.TestBehaviourImpl;
72import org.onosproject.net.driver.TestBehaviourTwoImpl;
73
74import com.google.common.collect.ImmutableList;
75import com.google.common.collect.ImmutableMap;
76import com.google.common.collect.ImmutableSet;
77import com.google.common.collect.Sets;
78
79import java.util.ArrayList;
80import java.util.Collection;
81import java.util.Collections;
82import java.util.HashSet;
83import java.util.List;
84import java.util.Set;
85
86import static org.easymock.EasyMock.anyObject;
87import static org.easymock.EasyMock.createMock;
88import static org.easymock.EasyMock.expect;
89import static org.easymock.EasyMock.expectLastCall;
90import static org.easymock.EasyMock.replay;
91import static org.hamcrest.MatcherAssert.assertThat;
92import static org.hamcrest.Matchers.hasSize;
93import static org.hamcrest.Matchers.is;
94import static org.junit.Assert.assertEquals;
95import static org.onosproject.net.AnnotationKeys.STATIC_PORT;
96import static org.onosproject.net.AnnotationKeys.PORT_NAME;
97import static org.onosproject.net.Device.Type.ROADM;
98import static org.onosproject.net.DeviceId.deviceId;
99import static org.onosproject.net.NetTestTools.APP_ID;
100
101public class OpticalCircuitIntentCompilerTest {
102
103 private static final String DEV1 = "of:1";
104 private static final String DEV2 = "of:2";
105
106 static final Key KEY1 = Key.of(5L, APP_ID);
107
108 private static final String STATIC_TRUE = "true";
109 private static final String PNAME = "p2";
110
111 private CoreService coreService;
112 private IntentExtensionService intentExtensionService;
113 private final IdGenerator idGenerator = new MockIdGenerator();
114 private OpticalCircuitIntentCompiler sut;
115
116 private final ApplicationId appId = new TestApplicationId("test");
117 private static Device device1 = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), ROADM,
118 "m", "h", "s", "n", new ChassisId(0L));
119 private static Device device2 = new DefaultDevice(ProviderId.NONE, deviceId(DEV2), ROADM,
120 "m", "h", "s", "n", new ChassisId(1L));
121
122 private static Annotations annotations1 = DefaultAnnotations.builder().set(STATIC_PORT, STATIC_TRUE).build();
123 private static Annotations annotations2 = DefaultAnnotations.builder().set(PORT_NAME, PNAME).build();
124
125 // OduClt ports with signalType=1GBE
126 private static final OduCltPort D1P1 =
127 new OduCltPort(device1, PortNumber.portNumber(1), true, CltSignalType.CLT_1GBE, annotations1);
128 private static final OduCltPort D2P1 =
129 new OduCltPort(device2, PortNumber.portNumber(1), true, CltSignalType.CLT_1GBE, annotations1);
130
131 // Och ports with signalType=ODU2
132 private static final OchPort D1P2 =
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -0800133 new DefaultOchPort(new DefaultPort(device1, PortNumber.portNumber(2), true, annotations2),
134 OduSignalType.ODU2,
135 true, OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1));
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200136 private static final OchPort D2P2 =
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -0800137 new DefaultOchPort(new DefaultPort(device2, PortNumber.portNumber(2), true, annotations2),
138 OduSignalType.ODU2,
139 true, OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1));
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200140
141 // OduClt ports with signalType=10GBE
142 private static final OduCltPort D1P3 =
143 new OduCltPort(device1, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
144 private static final OduCltPort D2P3 =
145 new OduCltPort(device2, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
146
147
148 private OpticalCircuitIntent intent;
149
150 /**
151 * Mocks the device service so that devices and ports appear available in the test.
152 */
153 private static class MockDeviceService extends DeviceServiceAdapter {
154 @Override
155 public boolean isAvailable(DeviceId deviceId) {
156 return true;
157 }
158
159 @Override
160 public List<Port> getPorts(DeviceId deviceId) {
161 if (deviceId.equals(deviceId(DEV1))) {
162 return ImmutableList.of((Port) D1P1, (Port) D1P2, (Port) D1P3);
163 }
164
165 if (deviceId.equals(deviceId(DEV2))) {
166 return ImmutableList.of((Port) D2P1, (Port) D2P2, (Port) D2P3);
167 }
168 return Collections.emptyList();
169 }
170
171 @Override
172 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
173 if (deviceId.equals(deviceId(DEV1))) {
174 switch (portNumber.toString()) {
175 case "1":
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -0800176 return D1P1;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200177 case "2":
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -0800178 return D1P2;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200179 case "3":
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -0800180 return D1P3;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200181 default:
182 return null;
183 }
184 }
185 if (deviceId.equals(deviceId(DEV2))) {
186 switch (portNumber.toString()) {
187 case "1":
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -0800188 return D2P1;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200189 case "2":
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -0800190 return D2P2;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200191 case "3":
HIGUCHI Yuta34a3f692016-01-09 21:08:57 -0800192 return D2P3;
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200193 default:
194 return null;
195 }
196 }
197 return null;
198 }
199 }
200
201 /**
202 * Mocks the driver service so it will appear supporting TributarySlotQuery Behaviour in the test.
203 */
204 private static class MockDriverServiceWithTs implements DriverService {
205 @Override
206 public Driver getDriver(String driverName) {
207 // TODO Auto-generated method stub
208 return null;
209 }
210
211 @Override
212 public Set<Driver> getDrivers() {
213 // TODO Auto-generated method stub
214 return null;
215 }
216
217 @Override
218 public Set<Driver> getDrivers(Class<? extends Behaviour> withBehaviour) {
219 // TODO Auto-generated method stub
220 return null;
221 }
222
223 @Override
224 public Driver getDriver(String mfr, String hw, String sw) {
225 // TODO Auto-generated method stub
226 return null;
227 }
228
229 @Override
230 public Driver getDriver(DeviceId deviceId) {
231 DefaultDriver ddp = new DefaultDriver("foo.base", new ArrayList<>(), "Circus", "lux", "1.2a",
232 ImmutableMap.of(Behaviour.class,
233 TestBehaviourImpl.class,
234 TributarySlotQuery.class,
235 TestBehaviourTwoImpl.class),
236 ImmutableMap.of("foo", "bar"));
237 return ddp;
238 }
239
240 @Override
241 public DriverHandler createHandler(DeviceId deviceId,
242 String... credentials) {
243 // TODO Auto-generated method stub
244 return null;
245 }
246 }
247
248 /**
249 * Mocks the driver service so it will appear not-supporting TributarySlotQuery Behaviour in the test.
250 */
251 private static class MockDriverServiceNoTs implements DriverService {
252 @Override
253 public Driver getDriver(String driverName) {
254 // TODO Auto-generated method stub
255 return null;
256 }
257
258 @Override
259 public Set<Driver> getDrivers() {
260 // TODO Auto-generated method stub
261 return null;
262 }
263
264 @Override
265 public Set<Driver> getDrivers(Class<? extends Behaviour> withBehaviour) {
266 // TODO Auto-generated method stub
267 return null;
268 }
269
270 @Override
271 public Driver getDriver(String mfr, String hw, String sw) {
272 // TODO Auto-generated method stub
273 return null;
274 }
275
276 @Override
277 public Driver getDriver(DeviceId deviceId) {
278 DefaultDriver ddp = new DefaultDriver("foo.base", new ArrayList<>(), "Circus", "lux", "1.2a",
279 ImmutableMap.of(Behaviour.class,
280 TestBehaviourImpl.class),
281 ImmutableMap.of("foo", "bar"));
282 return ddp;
283 }
284
285 @Override
286 public DriverHandler createHandler(DeviceId deviceId,
287 String... credentials) {
288 // TODO Auto-generated method stub
289 return null;
290 }
291 }
292
293 private static class MockIntentSetMultimap implements IntentSetMultimap {
294 @Override
295 public boolean allocateMapping(IntentId keyIntentId,
296 IntentId valIntentId) {
297 // TODO Auto-generated method stub
298 return false;
299 }
300
301 @Override
302 public Set<IntentId> getMapping(IntentId intentId) {
303 // TODO Auto-generated method stub
304 return null;
305 }
306
307 @Override
308 public void releaseMapping(IntentId intentId) {
309 // TODO Auto-generated method stub
310 }
311
312 }
313
314 /**
315 * Represents a fake IntentService class that easily allows to store and
316 * retrieve intents without implementing the IntentService logic.
317 */
318 private class TestIntentService extends IntentServiceAdapter {
319
320 private Set<Intent> intents;
321
322 public TestIntentService() {
323 intents = Sets.newHashSet();
324 }
325
326 @Override
327 public void submit(Intent intent) {
328 intents.add(intent);
329 }
330
331 @Override
332 public long getIntentCount() {
333 return intents.size();
334 }
335
336 @Override
337 public Iterable<Intent> getIntents() {
338 return intents;
339 }
340
341 @Override
342 public Intent getIntent(Key intentKey) {
343 for (Intent intent : intents) {
344 if (intent.key().equals(intentKey)) {
345 return intent;
346 }
347 }
348 return null;
349 }
350 }
351
352 @Before
353 public void setUp() {
354 sut = new OpticalCircuitIntentCompiler();
355 coreService = createMock(CoreService.class);
356 expect(coreService.registerApplication("org.onosproject.net.intent"))
357 .andReturn(appId);
358 sut.coreService = coreService;
359 sut.deviceService = new MockDeviceService();
360 sut.resourceService = new MockResourceService();
361 sut.intentService = new TestIntentService();
362 sut.intentSetMultimap = new MockIntentSetMultimap();
363
364 Intent.bindIdGenerator(idGenerator);
365
366 intentExtensionService = createMock(IntentExtensionService.class);
367 intentExtensionService.registerCompiler(OpticalCircuitIntent.class, sut);
368 intentExtensionService.unregisterCompiler(OpticalCircuitIntent.class);
369 sut.intentManager = intentExtensionService;
370 replay(coreService, intentExtensionService);
371
372 // mocking ComponentConfigService
373 ComponentConfigService mockConfigService =
374 EasyMock.createMock(ComponentConfigService.class);
375 expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
376 mockConfigService.registerProperties(sut.getClass());
377 expectLastCall();
378 mockConfigService.unregisterProperties(sut.getClass(), false);
379 expectLastCall();
380 expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
381 sut.cfgService = mockConfigService;
382 replay(mockConfigService);
383
384 }
385
386 @After
387 public void tearDown() {
388 Intent.unbindIdGenerator(idGenerator);
389 }
390
391 /**
392 * Tests compile of OpticalCircuitIntent with allocation of TributarySlots.
393 * Compile two ODUCLT ports (with CLT_1GBE), over OCH ports (with ODU2):
394 * - only one TributarySlot is used
395 */
396 @Test
397 public void test1GbeMultiplexOverOdu2() {
398
399 // Use driver with TributarySlotQuery Behaviour
400 sut.driverService = new MockDriverServiceWithTs();
401
402 ConnectPoint oduCltSrcCP = new ConnectPoint(device1.id(), D1P1.number());
403 ConnectPoint oduCltDstCP = new ConnectPoint(device2.id(), D2P1.number());
404 ConnectPoint ochSrcCP = new ConnectPoint(device1.id(), D1P2.number());
405 ConnectPoint ochDstCP = new ConnectPoint(device2.id(), D2P2.number());
406
407 intent = OpticalCircuitIntent.builder()
408 .appId(APP_ID)
409 .key(KEY1)
410 .src(oduCltSrcCP)
411 .dst(oduCltDstCP)
412 .signalType(D1P1.signalType())
413 .bidirectional(false)
414 .build();
415
416 sut.activate(null);
417
Sho SHIMIZUec07ffd2016-02-22 20:45:21 -0800418 List<Intent> compiled = sut.compile(intent, Collections.emptyList());
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200419 assertThat(compiled, hasSize(1));
420
421 Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
422
423 FlowRule rule1 = rules.stream()
424 .filter(x -> x.deviceId().equals(device1.id()))
425 .findFirst()
426 .get();
427 // validate SRC selector
428 TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
429 selectorBuilder1.matchInPort(oduCltSrcCP.port());
430 selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
431 assertThat(rule1.selector(), is(selectorBuilder1.build()));
432
433 // validate SRC treatment (with OduSignalId, where 1 TributarySlot is used)
434 TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
435 Set<TributarySlot> slots = new HashSet<>();
436 slots.add(TributarySlot.of(1));
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +0200437 OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(D1P2.signalType(), slots);
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200438 treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
439 treatmentBuilder1.setOutput(ochSrcCP.port());
440 assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
441
442 FlowRule rule2 = rules.stream()
443 .filter(x -> x.deviceId().equals(device2.id()))
444 .findFirst()
445 .get();
446 // validate DST selector (with OduSignalId, where the same TributarySlot is used)
447 TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
448 selectorBuilder2.matchInPort(ochDstCP.port());
449 selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
450 selectorBuilder2.add(Criteria.matchOduSignalId(oduSignalId));
451 assertThat(rule2.selector(), is(selectorBuilder2.build()));
452
453 // validate DST treatment
454 assertThat(rule2.treatment(), is(
455 DefaultTrafficTreatment.builder().setOutput(oduCltDstCP.port()).build()
456 ));
457
458 rules.forEach(rule -> assertEquals("FlowRule priority is incorrect",
459 intent.priority(), rule.priority()));
460
461 sut.deactivate();
462 }
463
464 /**
465 * Tests compile of OpticalCircuitIntent with allocation of TributarySlots.
466 * Compile two ODUCLT ports (with CLT_10GBE), over OCH ports (with ODU2):
467 * - All TributarySlots are used
468 */
469 @Test
470 public void test10GbeMultiplexOverOdu2() {
471
472 // Use driver with TributarySlotQuery Behaviour
473 sut.driverService = new MockDriverServiceWithTs();
474
475 ConnectPoint oduCltSrcCP = new ConnectPoint(device1.id(), D1P3.number());
476 ConnectPoint oduCltDstCP = new ConnectPoint(device2.id(), D2P3.number());
477 ConnectPoint ochSrcCP = new ConnectPoint(device1.id(), D1P2.number());
478 ConnectPoint ochDstCP = new ConnectPoint(device2.id(), D2P2.number());
479
480 intent = OpticalCircuitIntent.builder()
481 .appId(APP_ID)
482 .key(KEY1)
483 .src(oduCltSrcCP)
484 .dst(oduCltDstCP)
485 .signalType(D1P3.signalType())
486 .bidirectional(false)
487 .build();
488
489 sut.activate(null);
490
Sho SHIMIZUec07ffd2016-02-22 20:45:21 -0800491 List<Intent> compiled = sut.compile(intent, Collections.emptyList());
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200492 assertThat(compiled, hasSize(1));
493
494 Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
495
496 FlowRule rule1 = rules.stream()
497 .filter(x -> x.deviceId().equals(device1.id()))
498 .findFirst()
499 .get();
500 // validate SRC selector
501 TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
502 selectorBuilder1.matchInPort(oduCltSrcCP.port());
503 selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
504 assertThat(rule1.selector(), is(selectorBuilder1.build()));
505
506 // validate SRC treatment (without OduSignalId, i.e. All TributarySlots are used)
507 TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
508 treatmentBuilder1.setOutput(ochSrcCP.port());
509 assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
510
511 FlowRule rule2 = rules.stream()
512 .filter(x -> x.deviceId().equals(device2.id()))
513 .findFirst()
514 .get();
515 // validate DST selector (without OduSignalId, i.e. All TributarySlots are used)
516 TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
517 selectorBuilder2.matchInPort(ochDstCP.port());
518 selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
519 assertThat(rule2.selector(), is(selectorBuilder2.build()));
520
521 // validate DST treatment
522 assertThat(rule2.treatment(), is(
523 DefaultTrafficTreatment.builder().setOutput(oduCltDstCP.port()).build()
524 ));
525
526 rules.forEach(rule -> assertEquals("FlowRule priority is incorrect",
527 intent.priority(), rule.priority()));
528
529 sut.deactivate();
530 }
531
532 /**
533 * Tests compile of OpticalCircuitIntent without allocation of TributarySlots.
534 * Compile two ODUCLT ports (with CLT_10GBE), over OCH ports (with ODU2):
535 * - No TributarySlots are used
536 */
537 @Test
538 public void test10GbeNoMuxOverOdu2() {
539
540 // Use driver without support for TributarySlotQuery Behaviour
541 sut.driverService = new MockDriverServiceNoTs();
542
543 ConnectPoint oduCltSrcCP = new ConnectPoint(device1.id(), D1P3.number());
544 ConnectPoint oduCltDstCP = new ConnectPoint(device2.id(), D2P3.number());
545 ConnectPoint ochSrcCP = new ConnectPoint(device1.id(), D1P2.number());
546 ConnectPoint ochDstCP = new ConnectPoint(device2.id(), D2P2.number());
547
548 intent = OpticalCircuitIntent.builder()
549 .appId(APP_ID)
550 .key(KEY1)
551 .src(oduCltSrcCP)
552 .dst(oduCltDstCP)
553 .signalType(D1P3.signalType())
554 .bidirectional(false)
555 .build();
556
557 sut.activate(null);
558
Sho SHIMIZUec07ffd2016-02-22 20:45:21 -0800559 List<Intent> compiled = sut.compile(intent, Collections.emptyList());
Rimon Ashkenazya4e3bd32016-02-22 16:12:20 +0200560 assertThat(compiled, hasSize(1));
561
562 Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
563
564 FlowRule rule1 = rules.stream()
565 .filter(x -> x.deviceId().equals(device1.id()))
566 .findFirst()
567 .get();
568 // validate SRC selector
569 TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
570 selectorBuilder1.matchInPort(oduCltSrcCP.port());
571 assertThat(rule1.selector(), is(selectorBuilder1.build()));
572
573 // validate SRC treatment (without OduSignalType and OduSignalId: i.e. No TributarySlots are used)
574 TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
575 treatmentBuilder1.setOutput(ochSrcCP.port());
576 assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
577
578 FlowRule rule2 = rules.stream()
579 .filter(x -> x.deviceId().equals(device2.id()))
580 .findFirst()
581 .get();
582 // validate DST selector (without OduSignalType and OduSignalId: i.e. No TributarySlots are used)
583 TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
584 selectorBuilder2.matchInPort(ochDstCP.port());
585 assertThat(rule2.selector(), is(selectorBuilder2.build()));
586 // validate DST treatment
587 assertThat(rule2.treatment(), is(
588 DefaultTrafficTreatment.builder().setOutput(oduCltDstCP.port()).build()
589 ));
590
591 rules.forEach(rule -> assertEquals("FlowRule priority is incorrect",
592 intent.priority(), rule.priority()));
593
594 sut.deactivate();
595 }
596
597}