Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 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 | package org.onosproject.net.intent.impl.compiler; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableSet; |
| 19 | import org.junit.After; |
| 20 | import org.junit.Before; |
| 21 | import org.junit.Test; |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 22 | import org.onlab.packet.IpPrefix; |
| 23 | import org.onlab.packet.MacAddress; |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 24 | import org.onlab.packet.VlanId; |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 25 | import org.onosproject.TestApplicationId; |
Thomas Vachuska | bdbdd24 | 2016-03-01 01:55:55 -0800 | [diff] [blame] | 26 | import org.onosproject.cfg.ComponentConfigAdapter; |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 27 | import org.onosproject.core.ApplicationId; |
| 28 | import org.onosproject.core.CoreService; |
| 29 | import org.onosproject.core.IdGenerator; |
| 30 | import org.onosproject.net.ConnectPoint; |
| 31 | import org.onosproject.net.DefaultLink; |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 32 | import org.onosproject.net.DeviceId; |
| 33 | import org.onosproject.net.FilteredConnectPoint; |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 34 | import org.onosproject.net.Link; |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 35 | import org.onosproject.net.PortNumber; |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 36 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 37 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 38 | import org.onosproject.net.flow.FlowRule; |
| 39 | import org.onosproject.net.flow.TrafficSelector; |
| 40 | import org.onosproject.net.flow.TrafficTreatment; |
| 41 | import org.onosproject.net.intent.FlowRuleIntent; |
| 42 | import org.onosproject.net.intent.Intent; |
| 43 | import org.onosproject.net.intent.IntentExtensionService; |
| 44 | import org.onosproject.net.intent.LinkCollectionIntent; |
| 45 | import org.onosproject.net.intent.MockIdGenerator; |
| 46 | |
| 47 | import java.util.Collection; |
| 48 | import java.util.Collections; |
| 49 | import java.util.List; |
| 50 | import java.util.Set; |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 51 | import java.util.stream.Collectors; |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 52 | |
| 53 | import static org.easymock.EasyMock.createMock; |
| 54 | import static org.easymock.EasyMock.expect; |
| 55 | import static org.easymock.EasyMock.replay; |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 56 | import static org.hamcrest.CoreMatchers.instanceOf; |
| 57 | import static org.hamcrest.CoreMatchers.notNullValue; |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 58 | import static org.hamcrest.MatcherAssert.assertThat; |
| 59 | import static org.hamcrest.Matchers.hasSize; |
| 60 | import static org.hamcrest.Matchers.is; |
| 61 | import static org.onosproject.net.Link.Type.DIRECT; |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 62 | import static org.onosproject.net.NetTestTools.*; |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 63 | |
| 64 | public class LinkCollectionIntentCompilerTest { |
| 65 | |
| 66 | private final ApplicationId appId = new TestApplicationId("test"); |
| 67 | |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 68 | private final ConnectPoint d1p1 = connectPoint("s1", 1); |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 69 | private final ConnectPoint d2p0 = connectPoint("s2", 0); |
| 70 | private final ConnectPoint d2p1 = connectPoint("s2", 1); |
| 71 | private final ConnectPoint d3p1 = connectPoint("s3", 1); |
| 72 | private final ConnectPoint d3p0 = connectPoint("s3", 10); |
| 73 | private final ConnectPoint d1p0 = connectPoint("s1", 10); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 74 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 75 | private final DeviceId of1Id = DeviceId.deviceId("of:of1"); |
| 76 | private final DeviceId of2Id = DeviceId.deviceId("of:of2"); |
| 77 | private final DeviceId of3Id = DeviceId.deviceId("of:of3"); |
| 78 | private final DeviceId of4Id = DeviceId.deviceId("of:of4"); |
| 79 | |
| 80 | private final ConnectPoint of1p1 = connectPoint("of1", 1); |
| 81 | private final ConnectPoint of1p2 = connectPoint("of1", 2); |
| 82 | private final ConnectPoint of2p1 = connectPoint("of2", 1); |
| 83 | private final ConnectPoint of2p2 = connectPoint("of2", 2); |
| 84 | private final ConnectPoint of2p3 = connectPoint("of2", 3); |
| 85 | private final ConnectPoint of3p1 = connectPoint("of3", 1); |
| 86 | private final ConnectPoint of3p2 = connectPoint("of3", 2); |
| 87 | private final ConnectPoint of4p1 = connectPoint("of4", 1); |
| 88 | private final ConnectPoint of4p2 = connectPoint("of4", 2); |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 89 | |
| 90 | private final Set<Link> links = ImmutableSet.of( |
Ray Milkey | 2693bda | 2016-01-22 16:08:14 -0800 | [diff] [blame] | 91 | DefaultLink.builder().providerId(PID).src(d1p1).dst(d2p0).type(DIRECT).build(), |
| 92 | DefaultLink.builder().providerId(PID).src(d2p1).dst(d3p1).type(DIRECT).build(), |
| 93 | DefaultLink.builder().providerId(PID).src(d1p1).dst(d3p1).type(DIRECT).build()); |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 94 | |
| 95 | private final TrafficSelector selector = DefaultTrafficSelector.builder().build(); |
| 96 | private final TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); |
| 97 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 98 | private final TrafficSelector vlan100Selector = DefaultTrafficSelector.builder() |
| 99 | .matchVlanId(VlanId.vlanId("100")) |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 100 | .build(); |
| 101 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 102 | private final TrafficSelector vlan200Selector = DefaultTrafficSelector.builder() |
| 103 | .matchVlanId(VlanId.vlanId("200")) |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 104 | .build(); |
| 105 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 106 | private final TrafficSelector ipPrefixSelector = DefaultTrafficSelector.builder() |
| 107 | .matchIPDst(IpPrefix.valueOf("192.168.100.0/24")) |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 108 | .build(); |
| 109 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 110 | private final TrafficTreatment ethDstTreatment = DefaultTrafficTreatment.builder() |
| 111 | .setEthDst(MacAddress.valueOf("C0:FF:EE:C0:FF:EE")) |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 112 | .build(); |
| 113 | |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 114 | private CoreService coreService; |
| 115 | private IntentExtensionService intentExtensionService; |
Thomas Vachuska | bdbdd24 | 2016-03-01 01:55:55 -0800 | [diff] [blame] | 116 | private IntentConfigurableRegistrator registrator; |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 117 | private IdGenerator idGenerator = new MockIdGenerator(); |
| 118 | |
| 119 | private LinkCollectionIntent intent; |
| 120 | |
| 121 | private LinkCollectionIntentCompiler sut; |
| 122 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 123 | |
| 124 | |
| 125 | private List<FlowRule> getFlowRulesByDevice(DeviceId deviceId, Collection<FlowRule> flowRules) { |
| 126 | return flowRules.stream() |
| 127 | .filter(fr -> fr.deviceId().equals(deviceId)) |
| 128 | .collect(Collectors.toList()); |
| 129 | } |
| 130 | |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 131 | @Before |
Brian O'Connor | 8113466 | 2015-06-25 17:23:33 -0400 | [diff] [blame] | 132 | public void setUp() { |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 133 | sut = new LinkCollectionIntentCompiler(); |
| 134 | coreService = createMock(CoreService.class); |
| 135 | expect(coreService.registerApplication("org.onosproject.net.intent")) |
| 136 | .andReturn(appId); |
| 137 | sut.coreService = coreService; |
| 138 | |
| 139 | Intent.bindIdGenerator(idGenerator); |
| 140 | |
| 141 | intent = LinkCollectionIntent.builder() |
| 142 | .appId(APP_ID) |
| 143 | .selector(selector) |
| 144 | .treatment(treatment) |
| 145 | .links(links) |
| 146 | .ingressPoints(ImmutableSet.of(d1p1)) |
| 147 | .egressPoints(ImmutableSet.of(d3p1)) |
| 148 | .build(); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 149 | |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 150 | intentExtensionService = createMock(IntentExtensionService.class); |
| 151 | intentExtensionService.registerCompiler(LinkCollectionIntent.class, sut); |
| 152 | intentExtensionService.unregisterCompiler(LinkCollectionIntent.class); |
Thomas Vachuska | bdbdd24 | 2016-03-01 01:55:55 -0800 | [diff] [blame] | 153 | |
| 154 | registrator = new IntentConfigurableRegistrator(); |
| 155 | registrator.extensionService = intentExtensionService; |
| 156 | registrator.cfgService = new ComponentConfigAdapter(); |
| 157 | registrator.activate(); |
| 158 | |
| 159 | sut.registrator = registrator; |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 160 | |
| 161 | replay(coreService, intentExtensionService); |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 162 | |
| 163 | |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | @After |
| 167 | public void tearDown() { |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 168 | |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 169 | Intent.unbindIdGenerator(idGenerator); |
| 170 | } |
| 171 | |
| 172 | @Test |
| 173 | public void testCompile() { |
| 174 | sut.activate(); |
| 175 | |
Sho SHIMIZU | ec07ffd | 2016-02-22 20:45:21 -0800 | [diff] [blame] | 176 | List<Intent> compiled = sut.compile(intent, Collections.emptyList()); |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 177 | assertThat(compiled, hasSize(1)); |
| 178 | |
| 179 | Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules(); |
| 180 | assertThat(rules, hasSize(links.size())); |
| 181 | |
| 182 | // if not found, get() raises an exception |
| 183 | FlowRule rule1 = rules.stream() |
| 184 | .filter(rule -> rule.deviceId().equals(d1p0.deviceId())) |
| 185 | .findFirst() |
| 186 | .get(); |
| 187 | assertThat(rule1.selector(), is( |
| 188 | DefaultTrafficSelector.builder(intent.selector()).matchInPort(d1p1.port()).build() |
| 189 | )); |
| 190 | assertThat(rule1.treatment(), is( |
| 191 | DefaultTrafficTreatment.builder(intent.treatment()).setOutput(d1p1.port()).build() |
| 192 | )); |
Brian O'Connor | 8113466 | 2015-06-25 17:23:33 -0400 | [diff] [blame] | 193 | assertThat(rule1.priority(), is(intent.priority())); |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 194 | |
| 195 | FlowRule rule2 = rules.stream() |
| 196 | .filter(rule -> rule.deviceId().equals(d2p0.deviceId())) |
| 197 | .findFirst() |
| 198 | .get(); |
| 199 | assertThat(rule2.selector(), is( |
| 200 | DefaultTrafficSelector.builder(intent.selector()).matchInPort(d2p0.port()).build() |
| 201 | )); |
| 202 | assertThat(rule2.treatment(), is( |
| 203 | DefaultTrafficTreatment.builder().setOutput(d2p1.port()).build() |
| 204 | )); |
Brian O'Connor | 8113466 | 2015-06-25 17:23:33 -0400 | [diff] [blame] | 205 | assertThat(rule2.priority(), is(intent.priority())); |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 206 | |
| 207 | FlowRule rule3 = rules.stream() |
| 208 | .filter(rule -> rule.deviceId().equals(d3p0.deviceId())) |
| 209 | .findFirst() |
| 210 | .get(); |
| 211 | assertThat(rule3.selector(), is( |
| 212 | DefaultTrafficSelector.builder(intent.selector()).matchInPort(d3p1.port()).build() |
| 213 | )); |
| 214 | assertThat(rule3.treatment(), is( |
| 215 | DefaultTrafficTreatment.builder().setOutput(d3p1.port()).build() |
| 216 | )); |
Brian O'Connor | 8113466 | 2015-06-25 17:23:33 -0400 | [diff] [blame] | 217 | assertThat(rule3.priority(), is(intent.priority())); |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 218 | |
| 219 | sut.deactivate(); |
| 220 | } |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 221 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 222 | /** |
| 223 | * Single point to multi point case. |
| 224 | * -1 of1 2-1 of2 2--1 of3 2- |
| 225 | * 3 |
| 226 | * `-1 of4 2- |
| 227 | */ |
| 228 | @Test |
| 229 | public void testFilteredConnectPoint1() { |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 230 | sut.activate(); |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 231 | Set<Link> testLinks = ImmutableSet.of( |
| 232 | DefaultLink.builder().providerId(PID).src(of1p2).dst(of2p1).type(DIRECT).build(), |
| 233 | DefaultLink.builder().providerId(PID).src(of2p2).dst(of3p1).type(DIRECT).build(), |
| 234 | DefaultLink.builder().providerId(PID).src(of2p3).dst(of4p1).type(DIRECT).build() |
| 235 | ); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 236 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 237 | TrafficSelector expectOf1Selector = DefaultTrafficSelector.builder(vlan100Selector) |
| 238 | .matchInPort(PortNumber.portNumber(1)) |
| 239 | .build(); |
| 240 | |
| 241 | TrafficTreatment expectOf1Treatment = DefaultTrafficTreatment.builder() |
| 242 | .setOutput(PortNumber.portNumber(2)) |
| 243 | .build(); |
| 244 | |
| 245 | TrafficSelector expectOf2Selector = DefaultTrafficSelector.builder(vlan100Selector) |
| 246 | .matchInPort(PortNumber.portNumber(1)) |
| 247 | .build(); |
| 248 | |
| 249 | TrafficTreatment expectOf2Treatment = DefaultTrafficTreatment.builder() |
| 250 | .setOutput(PortNumber.portNumber(2)) |
| 251 | .setOutput(PortNumber.portNumber(3)) |
| 252 | .build(); |
| 253 | |
| 254 | TrafficSelector expectOf3Selector = DefaultTrafficSelector.builder(vlan100Selector) |
| 255 | .matchInPort(PortNumber.portNumber(1)) |
| 256 | .build(); |
| 257 | |
| 258 | TrafficTreatment expectOf3Treatment = DefaultTrafficTreatment.builder() |
| 259 | .setOutput(PortNumber.portNumber(2)) |
| 260 | .build(); |
| 261 | |
| 262 | TrafficSelector expectOf4Selector = DefaultTrafficSelector.builder(vlan100Selector) |
| 263 | .matchInPort(PortNumber.portNumber(1)) |
| 264 | .build(); |
| 265 | |
| 266 | TrafficTreatment expectOf4Treatment = DefaultTrafficTreatment.builder() |
| 267 | .setVlanId(VlanId.vlanId("200")) |
| 268 | .setOutput(PortNumber.portNumber(2)) |
| 269 | .build(); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 270 | |
| 271 | |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 272 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 273 | Set<FilteredConnectPoint> ingress = ImmutableSet.of( |
| 274 | new FilteredConnectPoint(of1p1, vlan100Selector) |
| 275 | ); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 276 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 277 | Set<FilteredConnectPoint> egress = ImmutableSet.of( |
| 278 | new FilteredConnectPoint(of3p2, vlan100Selector), |
| 279 | new FilteredConnectPoint(of4p2, vlan200Selector) |
| 280 | ); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 281 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 282 | intent = LinkCollectionIntent.builder() |
| 283 | .appId(APP_ID) |
| 284 | .filteredIngressPoints(ingress) |
| 285 | .filteredEgressPoints(egress) |
| 286 | .treatment(treatment) |
| 287 | .applyTreatmentOnEgress(true) |
| 288 | .links(testLinks) |
| 289 | .build(); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 290 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 291 | assertThat(sut, is(notNullValue())); |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 292 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 293 | List<Intent> result = sut.compile(intent, Collections.emptyList()); |
| 294 | |
| 295 | assertThat(result, is(notNullValue())); |
| 296 | assertThat(result, hasSize(1)); |
| 297 | |
| 298 | Intent resultIntent = result.get(0); |
| 299 | assertThat(resultIntent, instanceOf(FlowRuleIntent.class)); |
| 300 | |
| 301 | if (resultIntent instanceof FlowRuleIntent) { |
| 302 | FlowRuleIntent frIntent = (FlowRuleIntent) resultIntent; |
| 303 | |
| 304 | assertThat(frIntent.flowRules(), hasSize(4)); |
| 305 | |
| 306 | List<FlowRule> deviceFlowRules; |
| 307 | FlowRule flowRule; |
| 308 | |
| 309 | // Of1 |
| 310 | deviceFlowRules = getFlowRulesByDevice(of1Id, frIntent.flowRules()); |
| 311 | assertThat(deviceFlowRules, hasSize(1)); |
| 312 | flowRule = deviceFlowRules.get(0); |
| 313 | assertThat(flowRule.selector(), is(expectOf1Selector)); |
| 314 | assertThat(flowRule.treatment(), is(expectOf1Treatment)); |
| 315 | |
| 316 | // Of2 |
| 317 | deviceFlowRules = getFlowRulesByDevice(of2Id, frIntent.flowRules()); |
| 318 | assertThat(deviceFlowRules, hasSize(1)); |
| 319 | flowRule = deviceFlowRules.get(0); |
| 320 | assertThat(flowRule.selector(), is(expectOf2Selector)); |
| 321 | assertThat(flowRule.treatment(), is(expectOf2Treatment)); |
| 322 | |
| 323 | // Of3 |
| 324 | deviceFlowRules = getFlowRulesByDevice(of3Id, frIntent.flowRules()); |
| 325 | assertThat(deviceFlowRules, hasSize(1)); |
| 326 | flowRule = deviceFlowRules.get(0); |
| 327 | assertThat(flowRule.selector(), is(expectOf3Selector)); |
| 328 | assertThat(flowRule.treatment(), is(expectOf3Treatment)); |
| 329 | |
| 330 | // Of4 |
| 331 | deviceFlowRules = getFlowRulesByDevice(of4Id, frIntent.flowRules()); |
| 332 | assertThat(deviceFlowRules, hasSize(1)); |
| 333 | flowRule = deviceFlowRules.get(0); |
| 334 | assertThat(flowRule.selector(), is(expectOf4Selector)); |
| 335 | assertThat(flowRule.treatment(), is(expectOf4Treatment)); |
| 336 | |
| 337 | } |
| 338 | sut.deactivate(); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Multi point to single point intent with filtered connect point. |
| 343 | * |
| 344 | * -1 of1 2-1 of2 2-1 of4 2- |
| 345 | * 3 |
| 346 | * -1 of3 2---/ |
| 347 | */ |
| 348 | @Test |
| 349 | public void testFilteredConnectPoint2() { |
| 350 | sut.activate(); |
| 351 | Set<Link> testlinks = ImmutableSet.of( |
| 352 | DefaultLink.builder().providerId(PID).src(of1p2).dst(of2p1).type(DIRECT).build(), |
| 353 | DefaultLink.builder().providerId(PID).src(of3p2).dst(of2p3).type(DIRECT).build(), |
| 354 | DefaultLink.builder().providerId(PID).src(of2p2).dst(of4p1).type(DIRECT).build() |
| 355 | ); |
| 356 | |
| 357 | Set<FilteredConnectPoint> ingress = ImmutableSet.of( |
| 358 | new FilteredConnectPoint(of1p1, vlan100Selector), |
| 359 | new FilteredConnectPoint(of3p1, vlan100Selector) |
| 360 | ); |
| 361 | |
| 362 | Set<FilteredConnectPoint> egress = ImmutableSet.of( |
| 363 | new FilteredConnectPoint(of4p2, vlan200Selector) |
| 364 | ); |
| 365 | |
| 366 | TrafficSelector expectOf1Selector = DefaultTrafficSelector.builder(vlan100Selector) |
| 367 | .matchInPort(PortNumber.portNumber(1)) |
| 368 | .build(); |
| 369 | |
| 370 | TrafficTreatment expectOf1Treatment = DefaultTrafficTreatment.builder() |
| 371 | .setVlanId(VlanId.vlanId("200")) |
| 372 | .setOutput(PortNumber.portNumber(2)) |
| 373 | .build(); |
| 374 | |
| 375 | TrafficSelector expectOf2Selector1 = DefaultTrafficSelector.builder(vlan200Selector) |
| 376 | .matchInPort(PortNumber.portNumber(1)) |
| 377 | .build(); |
| 378 | |
| 379 | TrafficSelector expectOf2Selector2 = DefaultTrafficSelector.builder(vlan200Selector) |
| 380 | .matchInPort(PortNumber.portNumber(3)) |
| 381 | .build(); |
| 382 | |
| 383 | TrafficTreatment expectOf2Treatment = DefaultTrafficTreatment.builder() |
| 384 | .setOutput(PortNumber.portNumber(2)) |
| 385 | .build(); |
| 386 | |
| 387 | TrafficSelector expectOf3Selector = DefaultTrafficSelector.builder(vlan100Selector) |
| 388 | .matchInPort(PortNumber.portNumber(1)) |
| 389 | .build(); |
| 390 | |
| 391 | TrafficTreatment expectOf3Treatment = DefaultTrafficTreatment.builder() |
| 392 | .setVlanId(VlanId.vlanId("200")) |
| 393 | .setOutput(PortNumber.portNumber(2)) |
| 394 | .build(); |
| 395 | |
| 396 | TrafficSelector expectOf4Selector = DefaultTrafficSelector.builder(vlan100Selector) |
| 397 | .matchInPort(PortNumber.portNumber(1)) |
| 398 | .matchVlanId(VlanId.vlanId("200")) |
| 399 | .build(); |
| 400 | |
| 401 | TrafficTreatment expectOf4Treatment = DefaultTrafficTreatment.builder() |
| 402 | .setOutput(PortNumber.portNumber(2)) |
| 403 | .build(); |
| 404 | |
| 405 | intent = LinkCollectionIntent.builder() |
| 406 | .appId(APP_ID) |
| 407 | .filteredIngressPoints(ingress) |
| 408 | .filteredEgressPoints(egress) |
| 409 | .treatment(treatment) |
| 410 | .links(testlinks) |
| 411 | .build(); |
| 412 | |
| 413 | List<Intent> result = sut.compile(intent, Collections.emptyList()); |
| 414 | |
| 415 | assertThat(result, is(notNullValue())); |
| 416 | assertThat(result, hasSize(1)); |
| 417 | |
| 418 | Intent resultIntent = result.get(0); |
| 419 | assertThat(resultIntent, instanceOf(FlowRuleIntent.class)); |
| 420 | |
| 421 | if (resultIntent instanceof FlowRuleIntent) { |
| 422 | FlowRuleIntent frIntent = (FlowRuleIntent) resultIntent; |
| 423 | assertThat(frIntent.flowRules(), hasSize(5)); |
| 424 | |
| 425 | List<FlowRule> deviceFlowRules; |
| 426 | FlowRule flowRule; |
| 427 | |
| 428 | // Of1 |
| 429 | deviceFlowRules = getFlowRulesByDevice(of1Id, frIntent.flowRules()); |
| 430 | assertThat(deviceFlowRules, hasSize(1)); |
| 431 | flowRule = deviceFlowRules.get(0); |
| 432 | assertThat(flowRule.selector(), is(expectOf1Selector)); |
| 433 | assertThat(flowRule.treatment(), is(expectOf1Treatment)); |
| 434 | |
| 435 | // Of2 (has 2 flows) |
| 436 | deviceFlowRules = getFlowRulesByDevice(of2Id, frIntent.flowRules()); |
| 437 | assertThat(deviceFlowRules, hasSize(2)); |
| 438 | flowRule = deviceFlowRules.get(0); |
| 439 | assertThat(flowRule.selector(), is(expectOf2Selector1)); |
| 440 | assertThat(flowRule.treatment(), is(expectOf2Treatment)); |
| 441 | flowRule = deviceFlowRules.get(1); |
| 442 | assertThat(flowRule.selector(), is(expectOf2Selector2)); |
| 443 | assertThat(flowRule.treatment(), is(expectOf2Treatment)); |
| 444 | |
| 445 | // Of3 |
| 446 | deviceFlowRules = getFlowRulesByDevice(of3Id, frIntent.flowRules()); |
| 447 | assertThat(deviceFlowRules, hasSize(1)); |
| 448 | flowRule = deviceFlowRules.get(0); |
| 449 | assertThat(flowRule.selector(), is(expectOf3Selector)); |
| 450 | assertThat(flowRule.treatment(), is(expectOf3Treatment)); |
| 451 | |
| 452 | // Of4 |
| 453 | deviceFlowRules = getFlowRulesByDevice(of4Id, frIntent.flowRules()); |
| 454 | assertThat(deviceFlowRules, hasSize(1)); |
| 455 | flowRule = deviceFlowRules.get(0); |
| 456 | assertThat(flowRule.selector(), is(expectOf4Selector)); |
| 457 | assertThat(flowRule.treatment(), is(expectOf4Treatment)); |
| 458 | } |
Pier Ventre | 647138f | 2016-08-26 17:32:44 -0700 | [diff] [blame] | 459 | |
| 460 | sut.deactivate(); |
| 461 | } |
| 462 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 463 | /** |
| 464 | * Single point to multi point without filtered connect point case. |
| 465 | * -1 of1 2-1 of2 2--1 of3 2- |
| 466 | * 3 |
| 467 | * `-1 of4 2- |
| 468 | */ |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 469 | @Test |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 470 | public void nonTrivialTranslation1() { |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 471 | sut.activate(); |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 472 | Set<Link> testLinks = ImmutableSet.of( |
| 473 | DefaultLink.builder().providerId(PID).src(of1p2).dst(of2p1).type(DIRECT).build(), |
| 474 | DefaultLink.builder().providerId(PID).src(of2p2).dst(of3p1).type(DIRECT).build(), |
| 475 | DefaultLink.builder().providerId(PID).src(of2p3).dst(of4p1).type(DIRECT).build() |
| 476 | ); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 477 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 478 | TrafficSelector expectOf1Selector = DefaultTrafficSelector.builder(ipPrefixSelector) |
| 479 | .matchInPort(PortNumber.portNumber(1)) |
| 480 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 481 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 482 | TrafficTreatment expectOf1Treatment = DefaultTrafficTreatment.builder() |
| 483 | .setOutput(PortNumber.portNumber(2)) |
| 484 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 485 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 486 | TrafficSelector expectOf2Selector = DefaultTrafficSelector.builder(ipPrefixSelector) |
| 487 | .matchInPort(PortNumber.portNumber(1)) |
| 488 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 489 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 490 | TrafficTreatment expectOf2Treatment = DefaultTrafficTreatment.builder() |
| 491 | .setOutput(PortNumber.portNumber(2)) |
| 492 | .setOutput(PortNumber.portNumber(3)) |
| 493 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 494 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 495 | TrafficSelector expectOf3Selector = DefaultTrafficSelector.builder(ipPrefixSelector) |
| 496 | .matchInPort(PortNumber.portNumber(1)) |
| 497 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 498 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 499 | TrafficTreatment expectOf3Treatment = DefaultTrafficTreatment.builder(ethDstTreatment) |
| 500 | .setOutput(PortNumber.portNumber(2)) |
| 501 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 502 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 503 | TrafficSelector expectOf4Selector = DefaultTrafficSelector.builder(ipPrefixSelector) |
| 504 | .matchInPort(PortNumber.portNumber(1)) |
| 505 | .build(); |
| 506 | |
| 507 | TrafficTreatment expectOf4Treatment = DefaultTrafficTreatment.builder(ethDstTreatment) |
| 508 | .setOutput(PortNumber.portNumber(2)) |
| 509 | .build(); |
| 510 | |
| 511 | |
| 512 | |
| 513 | Set<ConnectPoint> ingress = ImmutableSet.of( |
| 514 | of1p1 |
| 515 | ); |
| 516 | |
| 517 | Set<ConnectPoint> egress = ImmutableSet.of( |
| 518 | of3p2, |
| 519 | of4p2 |
| 520 | ); |
| 521 | |
| 522 | intent = LinkCollectionIntent.builder() |
| 523 | .appId(APP_ID) |
| 524 | .selector(ipPrefixSelector) |
| 525 | .treatment(ethDstTreatment) |
| 526 | .ingressPoints(ingress) |
| 527 | .egressPoints(egress) |
| 528 | .applyTreatmentOnEgress(true) |
| 529 | .links(testLinks) |
| 530 | .build(); |
| 531 | |
| 532 | assertThat(sut, is(notNullValue())); |
| 533 | |
| 534 | List<Intent> result = sut.compile(intent, Collections.emptyList()); |
| 535 | |
| 536 | assertThat(result, is(notNullValue())); |
| 537 | assertThat(result, hasSize(1)); |
| 538 | |
| 539 | Intent resultIntent = result.get(0); |
| 540 | assertThat(resultIntent, instanceOf(FlowRuleIntent.class)); |
| 541 | |
| 542 | if (resultIntent instanceof FlowRuleIntent) { |
| 543 | FlowRuleIntent frIntent = (FlowRuleIntent) resultIntent; |
| 544 | |
| 545 | assertThat(frIntent.flowRules(), hasSize(4)); |
| 546 | |
| 547 | List<FlowRule> deviceFlowRules; |
| 548 | FlowRule flowRule; |
| 549 | |
| 550 | // Of1 |
| 551 | deviceFlowRules = getFlowRulesByDevice(of1Id, frIntent.flowRules()); |
| 552 | assertThat(deviceFlowRules, hasSize(1)); |
| 553 | flowRule = deviceFlowRules.get(0); |
| 554 | assertThat(flowRule.selector(), is(expectOf1Selector)); |
| 555 | assertThat(flowRule.treatment(), is(expectOf1Treatment)); |
| 556 | |
| 557 | // Of2 |
| 558 | deviceFlowRules = getFlowRulesByDevice(of2Id, frIntent.flowRules()); |
| 559 | assertThat(deviceFlowRules, hasSize(1)); |
| 560 | flowRule = deviceFlowRules.get(0); |
| 561 | assertThat(flowRule.selector(), is(expectOf2Selector)); |
| 562 | assertThat(flowRule.treatment(), is(expectOf2Treatment)); |
| 563 | |
| 564 | // Of3 |
| 565 | deviceFlowRules = getFlowRulesByDevice(of3Id, frIntent.flowRules()); |
| 566 | assertThat(deviceFlowRules, hasSize(1)); |
| 567 | flowRule = deviceFlowRules.get(0); |
| 568 | assertThat(flowRule.selector(), is(expectOf3Selector)); |
| 569 | assertThat(flowRule.treatment(), is(expectOf3Treatment)); |
| 570 | |
| 571 | // Of4 |
| 572 | deviceFlowRules = getFlowRulesByDevice(of4Id, frIntent.flowRules()); |
| 573 | assertThat(deviceFlowRules, hasSize(1)); |
| 574 | flowRule = deviceFlowRules.get(0); |
| 575 | assertThat(flowRule.selector(), is(expectOf4Selector)); |
| 576 | assertThat(flowRule.treatment(), is(expectOf4Treatment)); |
| 577 | |
| 578 | } |
| 579 | sut.deactivate(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 580 | } |
| 581 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 582 | /** |
| 583 | * Multi point to single point intent without filtered connect point. |
| 584 | * |
| 585 | * -1 of1 2-1 of2 2-1 of4 2- |
| 586 | * 3 |
| 587 | * -1 of3 2---/ |
| 588 | */ |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 589 | @Test |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 590 | public void nonTrivialTranslation2() { |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 591 | sut.activate(); |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 592 | Set<Link> testlinks = ImmutableSet.of( |
| 593 | DefaultLink.builder().providerId(PID).src(of1p2).dst(of2p1).type(DIRECT).build(), |
| 594 | DefaultLink.builder().providerId(PID).src(of3p2).dst(of2p3).type(DIRECT).build(), |
| 595 | DefaultLink.builder().providerId(PID).src(of2p2).dst(of4p1).type(DIRECT).build() |
| 596 | ); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 597 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 598 | Set<ConnectPoint> ingress = ImmutableSet.of( |
| 599 | of1p1, |
| 600 | of3p1 |
| 601 | ); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 602 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 603 | Set<ConnectPoint> egress = ImmutableSet.of( |
| 604 | of4p2 |
| 605 | ); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 606 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 607 | TrafficSelector expectOf1Selector = DefaultTrafficSelector.builder(ipPrefixSelector) |
| 608 | .matchInPort(PortNumber.portNumber(1)) |
| 609 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 610 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 611 | TrafficTreatment expectOf1Treatment = DefaultTrafficTreatment.builder(ethDstTreatment) |
| 612 | .setOutput(PortNumber.portNumber(2)) |
| 613 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 614 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 615 | TrafficSelector expectOf2Selector1 = DefaultTrafficSelector.builder(ipPrefixSelector) |
| 616 | .matchInPort(PortNumber.portNumber(1)) |
| 617 | .matchEthDst(MacAddress.valueOf("C0:FF:EE:C0:FF:EE")) |
| 618 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 619 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 620 | TrafficSelector expectOf2Selector2 = DefaultTrafficSelector.builder(ipPrefixSelector) |
| 621 | .matchEthDst(MacAddress.valueOf("C0:FF:EE:C0:FF:EE")) |
| 622 | .matchInPort(PortNumber.portNumber(3)) |
| 623 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 624 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 625 | TrafficTreatment expectOf2Treatment = DefaultTrafficTreatment.builder() |
| 626 | .setOutput(PortNumber.portNumber(2)) |
| 627 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 628 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 629 | TrafficSelector expectOf3Selector = DefaultTrafficSelector.builder(ipPrefixSelector) |
| 630 | .matchInPort(PortNumber.portNumber(1)) |
| 631 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 632 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 633 | TrafficTreatment expectOf3Treatment = DefaultTrafficTreatment.builder(ethDstTreatment) |
| 634 | .setOutput(PortNumber.portNumber(2)) |
| 635 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 636 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 637 | TrafficSelector expectOf4Selector = DefaultTrafficSelector.builder(ipPrefixSelector) |
| 638 | .matchEthDst(MacAddress.valueOf("C0:FF:EE:C0:FF:EE")) |
| 639 | .matchInPort(PortNumber.portNumber(1)) |
| 640 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 641 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 642 | TrafficTreatment expectOf4Treatment = DefaultTrafficTreatment.builder() |
| 643 | .setOutput(PortNumber.portNumber(2)) |
| 644 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 645 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 646 | intent = LinkCollectionIntent.builder() |
| 647 | .appId(APP_ID) |
| 648 | .selector(ipPrefixSelector) |
| 649 | .ingressPoints(ingress) |
| 650 | .egressPoints(egress) |
| 651 | .treatment(ethDstTreatment) |
| 652 | .links(testlinks) |
| 653 | .build(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 654 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 655 | List<Intent> result = sut.compile(intent, Collections.emptyList()); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 656 | |
Yi Tseng | 2a81c9d | 2016-09-14 10:14:24 -0700 | [diff] [blame^] | 657 | assertThat(result, is(notNullValue())); |
| 658 | assertThat(result, hasSize(1)); |
| 659 | |
| 660 | Intent resultIntent = result.get(0); |
| 661 | assertThat(resultIntent, instanceOf(FlowRuleIntent.class)); |
| 662 | |
| 663 | if (resultIntent instanceof FlowRuleIntent) { |
| 664 | FlowRuleIntent frIntent = (FlowRuleIntent) resultIntent; |
| 665 | assertThat(frIntent.flowRules(), hasSize(5)); |
| 666 | |
| 667 | List<FlowRule> deviceFlowRules; |
| 668 | FlowRule flowRule; |
| 669 | |
| 670 | // Of1 |
| 671 | deviceFlowRules = getFlowRulesByDevice(of1Id, frIntent.flowRules()); |
| 672 | assertThat(deviceFlowRules, hasSize(1)); |
| 673 | flowRule = deviceFlowRules.get(0); |
| 674 | assertThat(flowRule.selector(), is(expectOf1Selector)); |
| 675 | assertThat(flowRule.treatment(), is(expectOf1Treatment)); |
| 676 | |
| 677 | // Of2 (has 2 flows) |
| 678 | deviceFlowRules = getFlowRulesByDevice(of2Id, frIntent.flowRules()); |
| 679 | assertThat(deviceFlowRules, hasSize(2)); |
| 680 | flowRule = deviceFlowRules.get(0); |
| 681 | assertThat(flowRule.selector(), is(expectOf2Selector1)); |
| 682 | assertThat(flowRule.treatment(), is(expectOf2Treatment)); |
| 683 | flowRule = deviceFlowRules.get(1); |
| 684 | assertThat(flowRule.selector(), is(expectOf2Selector2)); |
| 685 | assertThat(flowRule.treatment(), is(expectOf2Treatment)); |
| 686 | |
| 687 | // Of3 |
| 688 | deviceFlowRules = getFlowRulesByDevice(of3Id, frIntent.flowRules()); |
| 689 | assertThat(deviceFlowRules, hasSize(1)); |
| 690 | flowRule = deviceFlowRules.get(0); |
| 691 | assertThat(flowRule.selector(), is(expectOf3Selector)); |
| 692 | assertThat(flowRule.treatment(), is(expectOf3Treatment)); |
| 693 | |
| 694 | // Of4 |
| 695 | deviceFlowRules = getFlowRulesByDevice(of4Id, frIntent.flowRules()); |
| 696 | assertThat(deviceFlowRules, hasSize(1)); |
| 697 | flowRule = deviceFlowRules.get(0); |
| 698 | assertThat(flowRule.selector(), is(expectOf4Selector)); |
| 699 | assertThat(flowRule.treatment(), is(expectOf4Treatment)); |
| 700 | } |
| 701 | |
| 702 | sut.deactivate(); |
Pier Ventre | 27d4257 | 2016-08-29 17:37:08 -0700 | [diff] [blame] | 703 | } |
Sho SHIMIZU | ee2aa65 | 2015-02-25 18:56:43 -0800 | [diff] [blame] | 704 | } |