Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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.t3.impl; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableList; |
| 19 | import com.google.common.collect.ImmutableSet; |
| 20 | import org.junit.Before; |
| 21 | import org.junit.Test; |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 22 | import org.onlab.packet.ChassisId; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 23 | import org.onlab.packet.EthType; |
| 24 | import org.onlab.packet.IpAddress; |
| 25 | import org.onlab.packet.MacAddress; |
| 26 | import org.onlab.packet.VlanId; |
Andrea Campanella | 54923d6 | 2018-01-23 12:46:04 +0100 | [diff] [blame] | 27 | import org.onosproject.cluster.NodeId; |
| 28 | import org.onosproject.mastership.MastershipServiceAdapter; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 29 | import org.onosproject.net.ConnectPoint; |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 30 | import org.onosproject.net.DefaultAnnotations; |
| 31 | import org.onosproject.net.DefaultDevice; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 32 | import org.onosproject.net.DefaultLink; |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 33 | import org.onosproject.net.DefaultPort; |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 34 | import org.onosproject.net.Device; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 35 | import org.onosproject.net.DeviceId; |
| 36 | import org.onosproject.net.Host; |
| 37 | import org.onosproject.net.Link; |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 38 | import org.onosproject.net.Port; |
Andrea Campanella | 94dfb9e | 2018-02-27 12:36:00 +0100 | [diff] [blame] | 39 | import org.onosproject.net.PortNumber; |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 40 | import org.onosproject.net.device.DeviceServiceAdapter; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 41 | import org.onosproject.net.driver.DefaultDriver; |
| 42 | import org.onosproject.net.driver.Driver; |
| 43 | import org.onosproject.net.driver.DriverServiceAdapter; |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 44 | import org.onosproject.net.edge.EdgePortServiceAdapter; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 45 | import org.onosproject.net.flow.FlowEntry; |
| 46 | import org.onosproject.net.flow.FlowRuleServiceAdapter; |
| 47 | import org.onosproject.net.flow.TrafficSelector; |
| 48 | import org.onosproject.net.flow.criteria.Criterion; |
| 49 | import org.onosproject.net.flow.criteria.EthTypeCriterion; |
| 50 | import org.onosproject.net.flow.criteria.VlanIdCriterion; |
| 51 | import org.onosproject.net.group.Group; |
| 52 | import org.onosproject.net.group.GroupServiceAdapter; |
| 53 | import org.onosproject.net.host.HostServiceAdapter; |
| 54 | import org.onosproject.net.link.LinkServiceAdapter; |
| 55 | import org.onosproject.net.provider.ProviderId; |
Andrea Campanella | 08d07e1 | 2018-03-07 14:27:54 -0800 | [diff] [blame] | 56 | import org.onosproject.routeservice.ResolvedRoute; |
| 57 | import org.onosproject.routeservice.RouteServiceAdapter; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 58 | import org.onosproject.t3.api.StaticPacketTrace; |
| 59 | import org.slf4j.Logger; |
| 60 | |
| 61 | import java.util.HashMap; |
Andrea Campanella | 08d07e1 | 2018-03-07 14:27:54 -0800 | [diff] [blame] | 62 | import java.util.Optional; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 63 | import java.util.Set; |
| 64 | |
| 65 | import static org.junit.Assert.assertEquals; |
| 66 | import static org.junit.Assert.assertNotNull; |
| 67 | import static org.junit.Assert.assertNull; |
| 68 | import static org.junit.Assert.assertTrue; |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 69 | import static org.onosproject.net.Device.Type.SWITCH; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 70 | import static org.onosproject.t3.impl.T3TestObjects.*; |
Andrea Campanella | 1445f7a | 2018-02-07 12:00:12 +0100 | [diff] [blame] | 71 | import static org.onosproject.t3.impl.TroubleshootManager.PACKET_TO_CONTROLLER; |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 72 | import static org.slf4j.LoggerFactory.getLogger; |
| 73 | |
| 74 | /** |
| 75 | * Test Class for Troubleshoot Manager. |
| 76 | */ |
| 77 | public class TroubleshootManagerTest { |
| 78 | |
| 79 | private static final Logger log = getLogger(TroubleshootManager.class); |
| 80 | |
| 81 | private TroubleshootManager mngr; |
| 82 | |
| 83 | @Before |
| 84 | public void setUp() throws Exception { |
| 85 | mngr = new TroubleshootManager(); |
| 86 | mngr.flowRuleService = new TestFlowRuleService(); |
| 87 | mngr.hostService = new TestHostService(); |
| 88 | mngr.linkService = new TestLinkService(); |
| 89 | mngr.driverService = new TestDriverService(); |
| 90 | mngr.groupService = new TestGroupService(); |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 91 | mngr.deviceService = new TestDeviceService(); |
Andrea Campanella | 54923d6 | 2018-01-23 12:46:04 +0100 | [diff] [blame] | 92 | mngr.mastershipService = new TestMastershipService(); |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 93 | mngr.edgePortService = new TestEdgePortService(); |
Andrea Campanella | 08d07e1 | 2018-03-07 14:27:54 -0800 | [diff] [blame] | 94 | mngr.routeService = new TestRouteService(); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 95 | |
| 96 | assertNotNull("Manager should not be null", mngr); |
| 97 | |
| 98 | assertNotNull("Flow rule Service should not be null", mngr.flowRuleService); |
| 99 | assertNotNull("Host Service should not be null", mngr.hostService); |
| 100 | assertNotNull("Group Service should not be null", mngr.groupService); |
| 101 | assertNotNull("Driver Service should not be null", mngr.driverService); |
| 102 | assertNotNull("Link Service should not be null", mngr.linkService); |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 103 | assertNotNull("Device Service should not be null", mngr.deviceService); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Tests failure on non existent device. |
| 108 | */ |
| 109 | @Test(expected = NullPointerException.class) |
| 110 | public void nonExistentDevice() { |
| 111 | StaticPacketTrace traceFail = mngr.trace(PACKET_OK, ConnectPoint.deviceConnectPoint("nonexistent" + "/1")); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Tests failure on offline device. |
| 116 | */ |
| 117 | @Test |
| 118 | public void offlineDevice() { |
| 119 | StaticPacketTrace traceFail = mngr.trace(PACKET_OK, ConnectPoint.deviceConnectPoint(OFFLINE_DEVICE + "/1")); |
| 120 | assertNotNull("Trace should not be null", traceFail); |
| 121 | assertNull("Trace should have 0 output", traceFail.getGroupOuputs(SINGLE_FLOW_DEVICE)); |
Andrea Campanella | 7d3cf65 | 2018-01-22 15:10:30 +0100 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Tests failure on same output. |
| 126 | */ |
| 127 | @Test |
| 128 | public void sameOutput() { |
| 129 | StaticPacketTrace traceFail = mngr.trace(PACKET_OK, SAME_OUTPUT_FLOW_CP); |
| 130 | assertNotNull("Trace should not be null", traceFail); |
| 131 | assertTrue("Trace should be unsuccessful", |
| 132 | traceFail.resultMessage().contains("is same as initial input")); |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 133 | log.info("trace {}", traceFail.resultMessage()); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 134 | } |
| 135 | |
Andrea Campanella | 54923d6 | 2018-01-23 12:46:04 +0100 | [diff] [blame] | 136 | /** |
| 137 | * Tests ARP to controller. |
| 138 | */ |
| 139 | @Test |
| 140 | public void arpToController() { |
| 141 | StaticPacketTrace traceSuccess = mngr.trace(PACKET_ARP, ARP_FLOW_CP); |
| 142 | assertNotNull("Trace should not be null", traceSuccess); |
| 143 | assertTrue("Trace should be successful", |
Andrea Campanella | 1445f7a | 2018-02-07 12:00:12 +0100 | [diff] [blame] | 144 | traceSuccess.resultMessage().contains(PACKET_TO_CONTROLLER)); |
Andrea Campanella | 54923d6 | 2018-01-23 12:46:04 +0100 | [diff] [blame] | 145 | assertTrue("Master should be Master1", |
| 146 | traceSuccess.resultMessage().contains(MASTER_1)); |
| 147 | ConnectPoint connectPoint = traceSuccess.getGroupOuputs(ARP_FLOW_DEVICE).get(0).getOutput(); |
| 148 | assertEquals("Packet Should go to CONTROLLER", PortNumber.CONTROLLER, connectPoint.port()); |
Andrea Campanella | e679801 | 2018-02-06 15:46:52 +0100 | [diff] [blame] | 149 | assertNull("VlanId should be null", traceSuccess.getGroupOuputs(ARP_FLOW_DEVICE).get(0) |
| 150 | .getFinalPacket().getCriterion(Criterion.Type.VLAN_VID)); |
Andrea Campanella | 54923d6 | 2018-01-23 12:46:04 +0100 | [diff] [blame] | 151 | log.info("trace {}", traceSuccess.resultMessage()); |
| 152 | } |
| 153 | |
Andrea Campanella | 7d3cf65 | 2018-01-22 15:10:30 +0100 | [diff] [blame] | 154 | |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 155 | /** |
Andrea Campanella | 4401bd7 | 2018-01-18 16:54:34 +0100 | [diff] [blame] | 156 | * Tests failure on device with no flows. |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 157 | */ |
| 158 | @Test |
| 159 | public void noFlows() { |
| 160 | StaticPacketTrace traceFail = mngr.trace(PACKET_OK, ConnectPoint.deviceConnectPoint("test/1")); |
| 161 | assertNotNull("Trace should not be null", traceFail); |
| 162 | assertNull("Trace should have 0 output", traceFail.getGroupOuputs(SINGLE_FLOW_DEVICE)); |
| 163 | log.info("trace {}", traceFail.resultMessage()); |
| 164 | } |
| 165 | |
| 166 | /** |
Andrea Campanella | 94dfb9e | 2018-02-27 12:36:00 +0100 | [diff] [blame] | 167 | * Test group with no buckets. |
| 168 | */ |
| 169 | @Test |
| 170 | public void noBucketsTest() throws Exception { |
| 171 | |
| 172 | StaticPacketTrace traceFail = mngr.trace(PACKET_OK, NO_BUCKET_CP); |
| 173 | assertNotNull("Trace should not be null", traceFail); |
| 174 | assertTrue("Trace should be unsuccessful", |
| 175 | traceFail.resultMessage().contains("no buckets")); |
| 176 | log.info("trace {}", traceFail.resultMessage()); |
| 177 | |
| 178 | } |
| 179 | |
| 180 | /** |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 181 | * Test a single flow rule that has output port in it. |
| 182 | */ |
| 183 | @Test |
| 184 | public void testSingleFlowRule() { |
| 185 | |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 186 | testSuccess(PACKET_OK, SINGLE_FLOW_IN_CP, SINGLE_FLOW_DEVICE, SINGLE_FLOW_OUT_CP, 1, 1); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 187 | |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 188 | testFailure(PACKET_FAIL, SINGLE_FLOW_IN_CP, SINGLE_FLOW_DEVICE); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Tests two flow rule the last one of which has output port in it. |
| 193 | */ |
| 194 | @Test |
| 195 | public void testDualFlowRule() { |
| 196 | |
| 197 | //Test Success |
| 198 | |
Andrea Campanella | 4401bd7 | 2018-01-18 16:54:34 +0100 | [diff] [blame] | 199 | StaticPacketTrace traceSuccess = testSuccess(PACKET_OK, DUAL_FLOW_IN_CP, DUAL_FLOW_DEVICE, |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 200 | DUAL_FLOW_OUT_CP, 1, 1); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 201 | |
| 202 | //Testing Vlan |
| 203 | Criterion criterion = traceSuccess.getGroupOuputs(DUAL_FLOW_DEVICE).get(0). |
| 204 | getFinalPacket().getCriterion(Criterion.Type.VLAN_VID); |
| 205 | assertNotNull("Packet Should have Vlan", criterion); |
| 206 | |
| 207 | VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) criterion; |
| 208 | |
| 209 | assertEquals("Vlan should be 100", VlanId.vlanId((short) 100), vlanIdCriterion.vlanId()); |
| 210 | |
| 211 | //Test Faliure |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 212 | testFailure(PACKET_FAIL, DUAL_FLOW_IN_CP, DUAL_FLOW_DEVICE); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 213 | |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Test a single flow rule that points to a group with output port in it. |
| 218 | */ |
| 219 | @Test |
| 220 | public void flowAndGroup() throws Exception { |
| 221 | |
Andrea Campanella | 4401bd7 | 2018-01-18 16:54:34 +0100 | [diff] [blame] | 222 | StaticPacketTrace traceSuccess = testSuccess(PACKET_OK, GROUP_FLOW_IN_CP, GROUP_FLOW_DEVICE, |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 223 | GROUP_FLOW_OUT_CP, 1, 1); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 224 | |
| 225 | assertTrue("Wrong Output Group", traceSuccess.getGroupOuputs(GROUP_FLOW_DEVICE) |
| 226 | .get(0).getGroups().contains(GROUP)); |
Andrea Campanella | 3970e47 | 2018-01-25 16:44:04 +0100 | [diff] [blame] | 227 | assertEquals("Packet should not have MPLS Label", EthType.EtherType.IPV4.ethType(), |
| 228 | ((EthTypeCriterion) traceSuccess.getGroupOuputs(GROUP_FLOW_DEVICE) |
| 229 | .get(0).getFinalPacket().getCriterion(Criterion.Type.ETH_TYPE)).ethType()); |
| 230 | assertNull("Packet should not have MPLS Label", traceSuccess.getGroupOuputs(GROUP_FLOW_DEVICE) |
| 231 | .get(0).getFinalPacket().getCriterion(Criterion.Type.MPLS_LABEL)); |
| 232 | assertNull("Packet should not have MPLS Label", traceSuccess.getGroupOuputs(GROUP_FLOW_DEVICE) |
| 233 | .get(0).getFinalPacket().getCriterion(Criterion.Type.MPLS_BOS)); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 234 | |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Test path through a 3 device topology. |
| 239 | */ |
| 240 | @Test |
| 241 | public void singlePathTopology() throws Exception { |
| 242 | |
| 243 | StaticPacketTrace traceSuccess = testSuccess(PACKET_OK_TOPO, TOPO_FLOW_1_IN_CP, |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 244 | TOPO_FLOW_3_DEVICE, TOPO_FLOW_3_OUT_CP, 1, 1); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 245 | |
| 246 | assertTrue("Incorrect path", |
| 247 | traceSuccess.getCompletePaths().get(0).contains(TOPO_FLOW_2_IN_CP)); |
| 248 | assertTrue("Incorrect path", |
| 249 | traceSuccess.getCompletePaths().get(0).contains(TOPO_FLOW_2_OUT_CP)); |
| 250 | assertTrue("Incorrect path", |
| 251 | traceSuccess.getCompletePaths().get(0).contains(TOPO_FLOW_3_IN_CP)); |
| 252 | |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Test path through a 4 device topology with first device that has groups with multiple output buckets. |
| 257 | */ |
| 258 | @Test |
| 259 | public void testGroupTopo() throws Exception { |
| 260 | |
| 261 | StaticPacketTrace traceSuccess = testSuccess(PACKET_OK_TOPO, TOPO_FLOW_IN_CP, |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 262 | TOPO_FLOW_3_DEVICE, TOPO_FLOW_3_OUT_CP, 2, 1); |
| 263 | |
| 264 | log.info("{}", traceSuccess); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 265 | |
| 266 | assertTrue("Incorrect groups", |
| 267 | traceSuccess.getGroupOuputs(TOPO_GROUP_FLOW_DEVICE).get(0).getGroups().contains(TOPO_GROUP)); |
| 268 | assertTrue("Incorrect bucket", |
| 269 | traceSuccess.getGroupOuputs(TOPO_GROUP_FLOW_DEVICE).get(1).getGroups().contains(TOPO_GROUP)); |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * Test HW support in a single device with 2 flow rules to check hit of static HW rules. |
| 274 | */ |
| 275 | @Test |
| 276 | public void hardwareTest() throws Exception { |
| 277 | |
| 278 | StaticPacketTrace traceSuccess = testSuccess(PACKET_OK, HARDWARE_DEVICE_IN_CP, |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 279 | HARDWARE_DEVICE, HARDWARE_DEVICE_OUT_CP, 1, 1); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 280 | |
| 281 | assertEquals("wrong ETH type", EthType.EtherType.IPV4.ethType(), |
| 282 | ((EthTypeCriterion) traceSuccess.getGroupOuputs(HARDWARE_DEVICE).get(0).getFinalPacket() |
| 283 | .getCriterion(Criterion.Type.ETH_TYPE)).ethType()); |
| 284 | |
| 285 | } |
| 286 | |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 287 | /** |
Andrea Campanella | 94c594a | 2018-02-06 18:58:40 +0100 | [diff] [blame] | 288 | * Test that HW has two rules on table 10 for untagged packets. |
| 289 | */ |
| 290 | @Test |
| 291 | public void hardwareTable10Test() throws Exception { |
| 292 | |
| 293 | StaticPacketTrace traceSuccess = testSuccess(PACKET_OK, HARDWARE_DEVICE_10_IN_CP, |
| 294 | HARDWARE_DEVICE_10, HARDWARE_DEVICE_10_OUT_CP, 1, 1); |
| 295 | |
| 296 | assertTrue("Second flow rule is absent", traceSuccess.getFlowsForDevice(HARDWARE_DEVICE_10) |
| 297 | .contains(HARDWARE_10_SECOND_FLOW_ENTRY)); |
| 298 | |
| 299 | } |
| 300 | |
| 301 | /** |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 302 | * Test dual links between 3 topology elements. |
| 303 | */ |
| 304 | @Test |
| 305 | public void dualLinks() throws Exception { |
| 306 | |
| 307 | StaticPacketTrace traceSuccess = testSuccess(PACKET_OK, DUAL_LINK_1_CP_1_IN, |
| 308 | DUAL_LINK_3, DUAL_LINK_3_CP_3_OUT, 4, 1); |
| 309 | |
| 310 | //TODO tests |
| 311 | |
| 312 | } |
| 313 | |
Andrea Campanella | 8292ba6 | 2018-01-31 16:43:23 +0100 | [diff] [blame] | 314 | /** |
| 315 | * Test proper clear deferred behaviour. |
| 316 | */ |
| 317 | @Test |
| 318 | public void clearDeferred() throws Exception { |
| 319 | |
| 320 | StaticPacketTrace traceSuccess = testSuccess(PACKET_OK, DEFERRED_CP_1_IN, |
| 321 | DEFERRED_1, DEFERRED_CP_2_OUT, 1, 1); |
| 322 | |
| 323 | assertNull("MPLS should have been not applied due to clear deferred", traceSuccess |
| 324 | .getGroupOuputs(DEFERRED_1).get(0).getFinalPacket().getCriterion(Criterion.Type.MPLS_LABEL)); |
| 325 | |
| 326 | } |
| 327 | |
| 328 | |
Andrea Campanella | 1445f7a | 2018-02-07 12:00:12 +0100 | [diff] [blame] | 329 | /** |
| 330 | * Test LLDP output to controller. |
| 331 | */ |
| 332 | @Test |
| 333 | public void lldpToController() { |
| 334 | StaticPacketTrace traceSuccess = mngr.trace(PACKET_LLDP, LLDP_FLOW_CP); |
| 335 | assertNotNull("Trace should not be null", traceSuccess); |
| 336 | assertTrue("Trace should be successful", |
| 337 | traceSuccess.resultMessage().contains("Packet goes to the controller")); |
| 338 | assertTrue("Master should be Master1", |
| 339 | traceSuccess.resultMessage().contains(MASTER_1)); |
| 340 | ConnectPoint connectPoint = traceSuccess.getGroupOuputs(LLDP_FLOW_DEVICE).get(0).getOutput(); |
| 341 | assertEquals("Packet Should go to CONTROLLER", PortNumber.CONTROLLER, connectPoint.port()); |
| 342 | log.info("trace {}", traceSuccess.resultMessage()); |
| 343 | } |
| 344 | |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 345 | /** |
| 346 | * Test multicast in single device. |
| 347 | */ |
| 348 | @Test |
| 349 | public void multicastTest() throws Exception { |
| 350 | |
| 351 | StaticPacketTrace traceSuccess = mngr.trace(PACKET_OK_MULTICAST, MULTICAST_IN_CP); |
| 352 | |
| 353 | log.info("trace {}", traceSuccess); |
| 354 | |
| 355 | log.info("trace {}", traceSuccess.resultMessage()); |
| 356 | |
| 357 | assertNotNull("trace should not be null", traceSuccess); |
| 358 | assertEquals("Trace should have " + 2 + " output", 2, |
| 359 | traceSuccess.getGroupOuputs(MULTICAST_GROUP_FLOW_DEVICE).size()); |
| 360 | assertEquals("Trace should only have " + 2 + "output", 2, |
| 361 | traceSuccess.getCompletePaths().size()); |
| 362 | assertTrue("Trace should be successful", |
| 363 | traceSuccess.resultMessage().contains("reached output")); |
| 364 | assertEquals("Incorrect Output CP", MULTICAST_OUT_CP_2, |
| 365 | traceSuccess.getGroupOuputs(MULTICAST_GROUP_FLOW_DEVICE).get(0).getOutput()); |
| 366 | assertEquals("Incorrect Output CP", MULTICAST_OUT_CP, |
| 367 | traceSuccess.getGroupOuputs(MULTICAST_GROUP_FLOW_DEVICE).get(1).getOutput()); |
| 368 | |
| 369 | } |
| 370 | |
Andrea Campanella | 4906ba7 | 2018-03-01 16:22:21 +0100 | [diff] [blame] | 371 | /** |
| 372 | * Tests dual homing of a host. |
| 373 | */ |
| 374 | @Test |
| 375 | public void dualhomedTest() throws Exception { |
| 376 | StaticPacketTrace traceSuccess = mngr.trace(PACKET_DUAL_HOME, DUAL_HOME_CP_1_1); |
| 377 | |
| 378 | assertNotNull("trace should not be null", traceSuccess); |
| 379 | assertTrue("Should have 2 output paths", traceSuccess.getCompletePaths().size() == 2); |
| 380 | assertTrue("Should contain proper path", traceSuccess.getCompletePaths() |
| 381 | .contains(ImmutableList.of(DUAL_HOME_CP_1_1, DUAL_HOME_CP_1_2, DUAL_HOME_CP_2_1, DUAL_HOME_CP_2_2))); |
| 382 | assertTrue("Should contain proper path", traceSuccess.getCompletePaths() |
| 383 | .contains(ImmutableList.of(DUAL_HOME_CP_1_1, DUAL_HOME_CP_1_3, DUAL_HOME_CP_3_1, DUAL_HOME_CP_3_2))); |
| 384 | |
| 385 | } |
| 386 | |
| 387 | |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 388 | private StaticPacketTrace testSuccess(TrafficSelector packet, ConnectPoint in, DeviceId deviceId, ConnectPoint out, |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 389 | int paths, int outputs) { |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 390 | StaticPacketTrace traceSuccess = mngr.trace(packet, in); |
| 391 | |
| 392 | log.info("trace {}", traceSuccess); |
| 393 | |
| 394 | log.info("trace {}", traceSuccess.resultMessage()); |
| 395 | |
| 396 | assertNotNull("trace should not be null", traceSuccess); |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 397 | assertEquals("Trace should have " + outputs + " output", outputs, |
| 398 | traceSuccess.getGroupOuputs(deviceId).size()); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 399 | assertEquals("Trace should only have " + paths + "output", paths, traceSuccess.getCompletePaths().size()); |
| 400 | assertTrue("Trace should be successful", |
| 401 | traceSuccess.resultMessage().contains("Reached required destination Host")); |
| 402 | assertEquals("Incorrect Output CP", out, |
| 403 | traceSuccess.getGroupOuputs(deviceId).get(0).getOutput()); |
| 404 | |
| 405 | return traceSuccess; |
| 406 | } |
| 407 | |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 408 | private void testFailure(TrafficSelector packet, ConnectPoint in, DeviceId deviceId) { |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 409 | StaticPacketTrace traceFail = mngr.trace(packet, in); |
| 410 | |
| 411 | log.info("trace {}", traceFail.resultMessage()); |
| 412 | |
| 413 | assertNotNull("Trace should not be null", traceFail); |
| 414 | assertNull("Trace should have 0 output", traceFail.getGroupOuputs(deviceId)); |
| 415 | } |
| 416 | |
| 417 | private class TestFlowRuleService extends FlowRuleServiceAdapter { |
| 418 | @Override |
| 419 | public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { |
| 420 | if (deviceId.equals(SINGLE_FLOW_DEVICE)) { |
| 421 | return ImmutableList.of(SINGLE_FLOW_ENTRY); |
| 422 | } else if (deviceId.equals(DUAL_FLOW_DEVICE)) { |
| 423 | return ImmutableList.of(FIRST_FLOW_ENTRY, SECOND_FLOW_ENTRY); |
| 424 | } else if (deviceId.equals(GROUP_FLOW_DEVICE)) { |
| 425 | return ImmutableList.of(GROUP_FLOW_ENTRY); |
| 426 | } else if (deviceId.equals(TOPO_FLOW_DEVICE) || |
| 427 | deviceId.equals(TOPO_FLOW_2_DEVICE) || |
| 428 | deviceId.equals(TOPO_FLOW_3_DEVICE) || |
| 429 | deviceId.equals(TOPO_FLOW_4_DEVICE)) { |
| 430 | return ImmutableList.of(TOPO_SINGLE_FLOW_ENTRY, TOPO_SECOND_INPUT_FLOW_ENTRY); |
| 431 | } else if (deviceId.equals(TOPO_GROUP_FLOW_DEVICE)) { |
| 432 | return ImmutableList.of(TOPO_GROUP_FLOW_ENTRY); |
Andrea Campanella | 4401bd7 | 2018-01-18 16:54:34 +0100 | [diff] [blame] | 433 | } else if (deviceId.equals(HARDWARE_DEVICE)) { |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 434 | return ImmutableList.of(HARDWARE_ETH_FLOW_ENTRY, HARDWARE_FLOW_ENTRY); |
Andrea Campanella | 7d3cf65 | 2018-01-22 15:10:30 +0100 | [diff] [blame] | 435 | } else if (deviceId.equals(SAME_OUTPUT_FLOW_DEVICE)) { |
| 436 | return ImmutableList.of(SAME_OUTPUT_FLOW_ENTRY); |
Andrea Campanella | 54923d6 | 2018-01-23 12:46:04 +0100 | [diff] [blame] | 437 | } else if (deviceId.equals(ARP_FLOW_DEVICE)) { |
| 438 | return ImmutableList.of(ARP_FLOW_ENTRY); |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 439 | } else if (deviceId.equals(DUAL_LINK_1)) { |
| 440 | return ImmutableList.of(DUAL_LINK_1_GROUP_FLOW_ENTRY); |
| 441 | } else if (deviceId.equals(DUAL_LINK_2)) { |
| 442 | return ImmutableList.of(DUAL_LINK_1_GROUP_FLOW_ENTRY, DUAL_LINK_2_GROUP_FLOW_ENTRY); |
| 443 | } else if (deviceId.equals(DUAL_LINK_3)) { |
| 444 | return ImmutableList.of(DUAL_LINK_3_FLOW_ENTRY, DUAL_LINK_3_FLOW_ENTRY_2); |
Andrea Campanella | 8292ba6 | 2018-01-31 16:43:23 +0100 | [diff] [blame] | 445 | } else if (deviceId.equals(DEFERRED_1)) { |
| 446 | return ImmutableList.of(DEFERRED_FLOW_ENTRY, DEFERRED_CLEAR_FLOW_ENTRY); |
Andrea Campanella | 94c594a | 2018-02-06 18:58:40 +0100 | [diff] [blame] | 447 | } else if (deviceId.equals(HARDWARE_DEVICE_10)) { |
| 448 | return ImmutableList.of(HARDWARE_10_FLOW_ENTRY, HARDWARE_10_SECOND_FLOW_ENTRY, |
| 449 | HARDWARE_10_OUTPUT_FLOW_ENTRY); |
Andrea Campanella | 1445f7a | 2018-02-07 12:00:12 +0100 | [diff] [blame] | 450 | } else if (deviceId.equals(LLDP_FLOW_DEVICE)) { |
| 451 | return ImmutableList.of(LLDP_FLOW_ENTRY); |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 452 | } else if (deviceId.equals(MULTICAST_GROUP_FLOW_DEVICE)) { |
| 453 | return ImmutableList.of(MULTICAST_GROUP_FLOW_ENTRY); |
Andrea Campanella | 94dfb9e | 2018-02-27 12:36:00 +0100 | [diff] [blame] | 454 | } else if (deviceId.equals(NO_BUCKET_DEVICE)) { |
| 455 | return ImmutableList.of(NO_BUCKET_ENTRY); |
Andrea Campanella | 4906ba7 | 2018-03-01 16:22:21 +0100 | [diff] [blame] | 456 | } else if (deviceId.equals(DUAL_HOME_DEVICE_1)) { |
| 457 | return ImmutableList.of(DUAL_HOME_FLOW_ENTRY); |
| 458 | } else if (deviceId.equals(DUAL_HOME_DEVICE_2) || deviceId.equals(DUAL_HOME_DEVICE_3)) { |
| 459 | return ImmutableList.of(DUAL_HOME_OUT_FLOW_ENTRY); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 460 | } |
| 461 | return ImmutableList.of(); |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | private class TestDriverService extends DriverServiceAdapter { |
| 466 | @Override |
| 467 | public Driver getDriver(DeviceId deviceId) { |
Andrea Campanella | 94c594a | 2018-02-06 18:58:40 +0100 | [diff] [blame] | 468 | if (deviceId.equals(HARDWARE_DEVICE) || deviceId.equals(HARDWARE_DEVICE_10)) { |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 469 | return new DefaultDriver("ofdpa", ImmutableList.of(), |
| 470 | "test", "test", "test", new HashMap<>(), new HashMap<>()); |
| 471 | } |
| 472 | return new DefaultDriver("NotHWDriver", ImmutableList.of(), |
| 473 | "test", "test", "test", new HashMap<>(), new HashMap<>()); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | private class TestGroupService extends GroupServiceAdapter { |
| 478 | @Override |
| 479 | public Iterable<Group> getGroups(DeviceId deviceId) { |
| 480 | if (deviceId.equals(GROUP_FLOW_DEVICE)) { |
| 481 | return ImmutableList.of(GROUP); |
| 482 | } else if (deviceId.equals(TOPO_GROUP_FLOW_DEVICE)) { |
| 483 | return ImmutableList.of(TOPO_GROUP); |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 484 | } else if (deviceId.equals(DUAL_LINK_1) || deviceId.equals(DUAL_LINK_2)) { |
| 485 | return ImmutableList.of(DUAL_LINK_GROUP); |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 486 | } else if (deviceId.equals(MULTICAST_GROUP_FLOW_DEVICE)) { |
| 487 | return ImmutableList.of(MULTICAST_GROUP); |
Andrea Campanella | 94dfb9e | 2018-02-27 12:36:00 +0100 | [diff] [blame] | 488 | } else if (deviceId.equals(NO_BUCKET_DEVICE)) { |
| 489 | return ImmutableList.of(NO_BUCKET_GROUP); |
Andrea Campanella | 4906ba7 | 2018-03-01 16:22:21 +0100 | [diff] [blame] | 490 | } else if (deviceId.equals(DUAL_HOME_DEVICE_1)) { |
| 491 | return ImmutableList.of(DUAL_HOME_GROUP); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 492 | } |
| 493 | return ImmutableList.of(); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | private class TestHostService extends HostServiceAdapter { |
| 498 | @Override |
| 499 | public Set<Host> getConnectedHosts(ConnectPoint connectPoint) { |
| 500 | if (connectPoint.equals(TOPO_FLOW_3_OUT_CP)) { |
| 501 | return ImmutableSet.of(H2); |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 502 | } else if (connectPoint.equals(DUAL_LINK_1_CP_2_OUT) || connectPoint.equals(DUAL_LINK_1_CP_3_OUT) || |
| 503 | connectPoint.equals(DUAL_LINK_2_CP_2_OUT) || connectPoint.equals(DUAL_LINK_2_CP_3_OUT)) { |
| 504 | return ImmutableSet.of(); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 505 | } |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 506 | if (connectPoint.equals(SINGLE_FLOW_OUT_CP) || |
| 507 | connectPoint.equals(DUAL_FLOW_OUT_CP) || |
| 508 | connectPoint.equals(GROUP_FLOW_OUT_CP) || |
| 509 | connectPoint.equals(HARDWARE_DEVICE_OUT_CP) || |
| 510 | connectPoint.equals(HARDWARE_DEVICE_10_OUT_CP) || |
| 511 | connectPoint.equals(DEFERRED_CP_2_OUT) || |
| 512 | connectPoint.equals(DUAL_LINK_3_CP_3_OUT)) { |
| 513 | return ImmutableSet.of(H1); |
| 514 | } |
Andrea Campanella | 4906ba7 | 2018-03-01 16:22:21 +0100 | [diff] [blame] | 515 | if (connectPoint.equals(DUAL_HOME_CP_2_2) || connectPoint.equals(DUAL_HOME_CP_3_2)) { |
| 516 | return ImmutableSet.of(DUAL_HOME_H); |
| 517 | } |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 518 | return ImmutableSet.of(); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | @Override |
| 522 | public Set<Host> getHostsByMac(MacAddress mac) { |
| 523 | if (mac.equals(H1.mac())) { |
| 524 | return ImmutableSet.of(H1); |
| 525 | } else if (mac.equals(H2.mac())) { |
| 526 | return ImmutableSet.of(H2); |
Andrea Campanella | 4906ba7 | 2018-03-01 16:22:21 +0100 | [diff] [blame] | 527 | } else if (mac.equals(DUAL_HOME_H.mac())) { |
| 528 | return ImmutableSet.of(DUAL_HOME_H); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 529 | } |
| 530 | return ImmutableSet.of(); |
| 531 | } |
| 532 | |
| 533 | @Override |
| 534 | public Set<Host> getHostsByIp(IpAddress ip) { |
| 535 | if ((H1.ipAddresses().contains(ip))) { |
| 536 | return ImmutableSet.of(H1); |
| 537 | } else if ((H2.ipAddresses().contains(ip))) { |
| 538 | return ImmutableSet.of(H2); |
Andrea Campanella | 4906ba7 | 2018-03-01 16:22:21 +0100 | [diff] [blame] | 539 | } else if ((DUAL_HOME_H.ipAddresses().contains(ip))) { |
| 540 | return ImmutableSet.of(DUAL_HOME_H); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 541 | } |
| 542 | return ImmutableSet.of(); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | private class TestLinkService extends LinkServiceAdapter { |
| 547 | @Override |
| 548 | public Set<Link> getEgressLinks(ConnectPoint connectPoint) { |
| 549 | if (connectPoint.equals(TOPO_FLOW_1_OUT_CP) |
| 550 | || connectPoint.equals(TOPO_FLOW_OUT_CP_1)) { |
| 551 | return ImmutableSet.of(DefaultLink.builder() |
| 552 | .providerId(ProviderId.NONE) |
| 553 | .type(Link.Type.DIRECT) |
| 554 | .src(connectPoint) |
| 555 | .dst(TOPO_FLOW_2_IN_CP) |
| 556 | .build()); |
| 557 | } else if (connectPoint.equals(TOPO_FLOW_2_OUT_CP)) { |
| 558 | return ImmutableSet.of(DefaultLink.builder() |
| 559 | .providerId(ProviderId.NONE) |
| 560 | .type(Link.Type.DIRECT) |
| 561 | .src(TOPO_FLOW_2_OUT_CP) |
| 562 | .dst(TOPO_FLOW_3_IN_CP) |
| 563 | .build()); |
| 564 | } else if (connectPoint.equals(TOPO_FLOW_OUT_CP_2)) { |
| 565 | return ImmutableSet.of(DefaultLink.builder() |
| 566 | .providerId(ProviderId.NONE) |
| 567 | .type(Link.Type.DIRECT) |
| 568 | .src(TOPO_FLOW_OUT_CP_2) |
| 569 | .dst(TOPO_FLOW_4_IN_CP) |
| 570 | .build()); |
| 571 | } else if (connectPoint.equals(TOPO_FLOW_4_OUT_CP)) { |
| 572 | return ImmutableSet.of(DefaultLink.builder() |
| 573 | .providerId(ProviderId.NONE) |
| 574 | .type(Link.Type.DIRECT) |
| 575 | .src(TOPO_FLOW_4_OUT_CP) |
| 576 | .dst(TOPO_FLOW_3_IN_2_CP) |
| 577 | .build()); |
Andrea Campanella | b022b5e | 2018-01-31 14:59:03 +0100 | [diff] [blame] | 578 | } else if (connectPoint.equals(DUAL_LINK_1_CP_2_OUT)) { |
| 579 | return ImmutableSet.of(DefaultLink.builder() |
| 580 | .providerId(ProviderId.NONE) |
| 581 | .type(Link.Type.DIRECT) |
| 582 | .src(DUAL_LINK_1_CP_2_OUT) |
| 583 | .dst(DUAL_LINK_2_CP_1_IN) |
| 584 | .build()); |
| 585 | } else if (connectPoint.equals(DUAL_LINK_1_CP_3_OUT)) { |
| 586 | return ImmutableSet.of(DefaultLink.builder() |
| 587 | .providerId(ProviderId.NONE) |
| 588 | .type(Link.Type.DIRECT) |
| 589 | .src(DUAL_LINK_1_CP_3_OUT) |
| 590 | .dst(DUAL_LINK_2_CP_4_IN) |
| 591 | .build()); |
| 592 | } else if (connectPoint.equals(DUAL_LINK_2_CP_2_OUT)) { |
| 593 | return ImmutableSet.of(DefaultLink.builder() |
| 594 | .providerId(ProviderId.NONE) |
| 595 | .type(Link.Type.DIRECT) |
| 596 | .src(DUAL_LINK_2_CP_2_OUT) |
| 597 | .dst(DUAL_LINK_3_CP_1_IN) |
| 598 | .build()); |
| 599 | } else if (connectPoint.equals(DUAL_LINK_2_CP_3_OUT)) { |
| 600 | return ImmutableSet.of(DefaultLink.builder() |
| 601 | .providerId(ProviderId.NONE) |
| 602 | .type(Link.Type.DIRECT) |
| 603 | .src(DUAL_LINK_2_CP_3_OUT) |
| 604 | .dst(DUAL_LINK_3_CP_2_IN) |
| 605 | .build()); |
Andrea Campanella | 4906ba7 | 2018-03-01 16:22:21 +0100 | [diff] [blame] | 606 | } else if (connectPoint.equals(DUAL_HOME_CP_1_2)) { |
| 607 | return ImmutableSet.of(DefaultLink.builder() |
| 608 | .providerId(ProviderId.NONE) |
| 609 | .type(Link.Type.DIRECT) |
| 610 | .src(DUAL_HOME_CP_1_2) |
| 611 | .dst(DUAL_HOME_CP_2_1) |
| 612 | .build()); |
| 613 | } else if (connectPoint.equals(DUAL_HOME_CP_1_3)) { |
| 614 | return ImmutableSet.of(DefaultLink.builder() |
| 615 | .providerId(ProviderId.NONE) |
| 616 | .type(Link.Type.DIRECT) |
| 617 | .src(DUAL_HOME_CP_1_3) |
| 618 | .dst(DUAL_HOME_CP_3_1) |
| 619 | .build()); |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 620 | } |
| 621 | return ImmutableSet.of(); |
| 622 | } |
| 623 | } |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 624 | |
| 625 | private class TestDeviceService extends DeviceServiceAdapter { |
| 626 | @Override |
| 627 | public Device getDevice(DeviceId deviceId) { |
| 628 | if (deviceId.equals(DeviceId.deviceId("nonexistent"))) { |
| 629 | return null; |
| 630 | } |
| 631 | return new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("test"), SWITCH, |
| 632 | "test", "test", "test", "test", new ChassisId(), |
| 633 | DefaultAnnotations.builder().set("foo", "bar").build()); |
| 634 | } |
| 635 | |
| 636 | @Override |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 637 | public Port getPort(ConnectPoint cp) { |
| 638 | return new DefaultPort(null, cp.port(), true, DefaultAnnotations.builder().build()); |
| 639 | } |
| 640 | |
| 641 | @Override |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 642 | public boolean isAvailable(DeviceId deviceId) { |
Andrea Campanella | 4c6170a | 2018-01-17 16:34:51 +0100 | [diff] [blame] | 643 | return !deviceId.equals(OFFLINE_DEVICE); |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | private class TestEdgePortService extends EdgePortServiceAdapter { |
| 648 | |
| 649 | @Override |
| 650 | public boolean isEdgePoint(ConnectPoint point) { |
| 651 | return point.equals(MULTICAST_OUT_CP) || |
| 652 | point.equals(MULTICAST_OUT_CP_2); |
Andrea Campanella | 17d4519 | 2018-01-18 17:11:42 +0100 | [diff] [blame] | 653 | } |
| 654 | } |
Andrea Campanella | 54923d6 | 2018-01-23 12:46:04 +0100 | [diff] [blame] | 655 | |
Andrea Campanella | 08d07e1 | 2018-03-07 14:27:54 -0800 | [diff] [blame] | 656 | private class TestRouteService extends RouteServiceAdapter { |
| 657 | @Override |
| 658 | public Optional<ResolvedRoute> longestPrefixLookup(IpAddress ip) { |
| 659 | return Optional.empty(); |
| 660 | } |
| 661 | } |
| 662 | |
Andrea Campanella | 54923d6 | 2018-01-23 12:46:04 +0100 | [diff] [blame] | 663 | private class TestMastershipService extends MastershipServiceAdapter { |
| 664 | @Override |
| 665 | public NodeId getMasterFor(DeviceId deviceId) { |
| 666 | return NodeId.nodeId(MASTER_1); |
| 667 | } |
| 668 | } |
Andrea Campanella | e408440 | 2017-12-15 15:27:31 +0100 | [diff] [blame] | 669 | } |