Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2017-present Open Networking Foundation |
Hyunsun Moon | 090d77d | 2017-07-05 17:48:37 +0900 | [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.openstacknode.impl; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableSet; |
| 19 | import com.google.common.collect.Lists; |
| 20 | import com.google.common.collect.Maps; |
| 21 | import com.google.common.util.concurrent.MoreExecutors; |
| 22 | import org.junit.After; |
| 23 | import org.junit.Before; |
| 24 | import org.junit.Test; |
| 25 | import org.onlab.junit.TestUtils; |
| 26 | import org.onlab.packet.ChassisId; |
| 27 | import org.onlab.packet.Ip4Address; |
| 28 | import org.onlab.packet.IpAddress; |
| 29 | import org.onlab.packet.MacAddress; |
| 30 | import org.onlab.packet.VlanId; |
| 31 | import org.onosproject.cfg.ComponentConfigAdapter; |
| 32 | import org.onosproject.cluster.ClusterServiceAdapter; |
| 33 | import org.onosproject.cluster.ControllerNode; |
| 34 | import org.onosproject.cluster.DefaultControllerNode; |
| 35 | import org.onosproject.cluster.LeadershipServiceAdapter; |
| 36 | import org.onosproject.cluster.NodeId; |
| 37 | import org.onosproject.core.ApplicationId; |
| 38 | import org.onosproject.core.CoreServiceAdapter; |
| 39 | import org.onosproject.core.DefaultApplicationId; |
| 40 | import org.onosproject.core.GroupId; |
| 41 | import org.onosproject.net.Annotations; |
| 42 | import org.onosproject.net.DefaultAnnotations; |
| 43 | import org.onosproject.net.DefaultDevice; |
| 44 | import org.onosproject.net.DefaultPort; |
| 45 | import org.onosproject.net.Device; |
| 46 | import org.onosproject.net.DeviceId; |
| 47 | import org.onosproject.net.Port; |
| 48 | import org.onosproject.net.PortNumber; |
| 49 | import org.onosproject.net.behaviour.BridgeConfig; |
| 50 | import org.onosproject.net.behaviour.BridgeDescription; |
| 51 | import org.onosproject.net.behaviour.BridgeName; |
| 52 | import org.onosproject.net.behaviour.ControllerInfo; |
| 53 | import org.onosproject.net.behaviour.DefaultBridgeDescription; |
| 54 | import org.onosproject.net.behaviour.ExtensionTreatmentResolver; |
| 55 | import org.onosproject.net.behaviour.InterfaceConfig; |
| 56 | import org.onosproject.net.behaviour.PatchDescription; |
| 57 | import org.onosproject.net.behaviour.TunnelDescription; |
| 58 | import org.onosproject.net.device.DefaultPortDescription; |
| 59 | import org.onosproject.net.device.DeviceAdminService; |
| 60 | import org.onosproject.net.device.DeviceEvent; |
| 61 | import org.onosproject.net.device.DeviceInterfaceDescription; |
| 62 | import org.onosproject.net.device.DeviceListener; |
| 63 | import org.onosproject.net.device.DeviceServiceAdapter; |
| 64 | import org.onosproject.net.device.PortDescription; |
| 65 | import org.onosproject.net.driver.Behaviour; |
| 66 | import org.onosproject.net.driver.DriverData; |
| 67 | import org.onosproject.net.driver.DriverHandler; |
| 68 | import org.onosproject.net.flow.instructions.ExtensionPropertyException; |
| 69 | import org.onosproject.net.flow.instructions.ExtensionTreatment; |
| 70 | import org.onosproject.net.flow.instructions.ExtensionTreatmentType; |
| 71 | import org.onosproject.net.group.DefaultGroup; |
| 72 | import org.onosproject.net.group.Group; |
| 73 | import org.onosproject.net.group.GroupBuckets; |
| 74 | import org.onosproject.net.group.GroupDescription; |
| 75 | import org.onosproject.net.group.GroupEvent; |
| 76 | import org.onosproject.net.group.GroupKey; |
| 77 | import org.onosproject.net.group.GroupListener; |
| 78 | import org.onosproject.net.group.GroupService; |
| 79 | import org.onosproject.net.provider.ProviderId; |
| 80 | import org.onosproject.openstacknode.api.NodeState; |
| 81 | import org.onosproject.openstacknode.api.OpenstackNode; |
| 82 | import org.onosproject.openstacknode.api.OpenstackNodeAdminService; |
| 83 | import org.onosproject.openstacknode.api.OpenstackNodeListener; |
| 84 | import org.onosproject.openstacknode.api.OpenstackNodeService; |
| 85 | import org.onosproject.ovsdb.controller.OvsdbClientService; |
| 86 | import org.onosproject.ovsdb.controller.OvsdbController; |
| 87 | |
| 88 | import java.util.Collection; |
| 89 | import java.util.List; |
| 90 | import java.util.Map; |
| 91 | import java.util.Objects; |
| 92 | import java.util.Set; |
| 93 | import java.util.stream.Collectors; |
| 94 | |
| 95 | import static org.easymock.EasyMock.*; |
| 96 | import static org.easymock.EasyMock.expect; |
| 97 | import static org.junit.Assert.assertEquals; |
| 98 | import static org.onosproject.net.AnnotationKeys.PORT_NAME; |
| 99 | import static org.onosproject.net.Device.Type.CONTROLLER; |
| 100 | import static org.onosproject.net.Device.Type.SWITCH; |
| 101 | import static org.onosproject.net.device.DeviceEvent.Type.*; |
| 102 | import static org.onosproject.openstacknode.api.Constants.*; |
| 103 | import static org.onosproject.openstacknode.api.NodeState.*; |
| 104 | import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE; |
| 105 | import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY; |
| 106 | |
| 107 | /** |
| 108 | * Unit test for DefaultOpenstackNodeHandler. |
| 109 | */ |
| 110 | public class DefaultOpenstackNodeHandlerTest { |
| 111 | |
| 112 | private static final ApplicationId TEST_APP_ID = new DefaultApplicationId(1, "test"); |
| 113 | private static final String ERR_STATE_NOT_MATCH = "Node state did not match"; |
| 114 | private static final NodeId LOCAL_NODE_ID = new NodeId("local"); |
| 115 | private static final ControllerNode LOCAL_CTRL = |
| 116 | new DefaultControllerNode(LOCAL_NODE_ID, IpAddress.valueOf("127.0.0.1")); |
| 117 | |
| 118 | private static final BridgeDescription ROUT_BRIDGE = DefaultBridgeDescription.builder() |
| 119 | .name(ROUTER_BRIDGE) |
| 120 | .failMode(BridgeDescription.FailMode.SECURE) |
| 121 | .disableInBand() |
| 122 | .build(); |
| 123 | |
| 124 | private static final PortDescription PATCH_ROUT = new DefaultPortDescription( |
| 125 | PortNumber.portNumber(1), |
| 126 | true, |
| 127 | DefaultAnnotations.builder() |
| 128 | .set(PORT_NAME, PATCH_ROUT_BRIDGE) |
| 129 | .build() |
| 130 | ); |
| 131 | |
| 132 | private static final String COMPUTE_1_HOSTNAME = "compute_1"; |
| 133 | private static final String COMPUTE_2_HOSTNAME = "compute_2"; |
| 134 | private static final String COMPUTE_3_HOSTNAME = "compute_3"; |
| 135 | private static final String COMPUTE_4_HOSTNAME = "compute_4"; |
| 136 | private static final String GATEWAY_1_HOSTNAME = "gateway_1"; |
| 137 | private static final String GATEWAY_2_HOSTNAME = "gateway_2"; |
| 138 | private static final String GATEWAY_3_HOSTNAME = "gateway_3"; |
| 139 | private static final String GATEWAY_4_HOSTNAME = "gateway_4"; |
| 140 | |
| 141 | private static final IpAddress COMPUTE_1_IP = IpAddress.valueOf("10.100.0.1"); |
| 142 | private static final IpAddress COMPUTE_2_IP = IpAddress.valueOf("10.100.0.2"); |
| 143 | private static final IpAddress COMPUTE_3_IP = IpAddress.valueOf("10.100.0.3"); |
| 144 | private static final IpAddress COMPUTE_4_IP = IpAddress.valueOf("10.100.0.4"); |
| 145 | private static final IpAddress GATEWAY_1_IP = IpAddress.valueOf("10.100.0.5"); |
| 146 | private static final IpAddress GATEWAY_2_IP = IpAddress.valueOf("10.100.0.6"); |
| 147 | private static final IpAddress GATEWAY_3_IP = IpAddress.valueOf("10.100.0.7"); |
| 148 | private static final IpAddress GATEWAY_4_IP = IpAddress.valueOf("10.100.0.8"); |
| 149 | |
| 150 | private static final Device COMPUTE_1_INTG_DEVICE = createOpenFlowDevice(1, INTEGRATION_BRIDGE); |
| 151 | private static final Device COMPUTE_2_INTG_DEVICE = createOpenFlowDevice(2, INTEGRATION_BRIDGE); |
| 152 | private static final Device COMPUTE_3_INTG_DEVICE = createOpenFlowDevice(3, INTEGRATION_BRIDGE); |
| 153 | private static final Device COMPUTE_4_INTG_DEVICE = createOpenFlowDevice(4, INTEGRATION_BRIDGE); |
| 154 | private static final Device GATEWAY_1_INTG_DEVICE = createOpenFlowDevice(5, INTEGRATION_BRIDGE); |
| 155 | private static final Device GATEWAY_1_ROUT_DEVICE = createOpenFlowDevice(6, ROUTER_BRIDGE); |
| 156 | private static final Device GATEWAY_2_INTG_DEVICE = createOpenFlowDevice(7, INTEGRATION_BRIDGE); |
| 157 | private static final Device GATEWAY_2_ROUT_DEVICE = createOpenFlowDevice(8, ROUTER_BRIDGE); |
| 158 | private static final Device GATEWAY_3_INTG_DEVICE = createOpenFlowDevice(9, INTEGRATION_BRIDGE); |
| 159 | private static final Device GATEWAY_3_ROUT_DEVICE = createOpenFlowDevice(10, ROUTER_BRIDGE); |
| 160 | private static final Device GATEWAY_4_INTG_DEVICE = createOpenFlowDevice(11, INTEGRATION_BRIDGE); |
| 161 | private static final Device GATEWAY_4_ROUT_DEVICE = createOpenFlowDevice(12, ROUTER_BRIDGE); |
| 162 | |
| 163 | private static final Device COMPUTE_1_OVSDB_DEVICE = createOvsdbDevice(COMPUTE_1_IP); |
| 164 | private static final Device COMPUTE_2_OVSDB_DEVICE = createOvsdbDevice(COMPUTE_2_IP); |
| 165 | private static final Device COMPUTE_3_OVSDB_DEVICE = createOvsdbDevice(COMPUTE_3_IP); |
| 166 | private static final Device COMPUTE_4_OVSDB_DEVICE = createOvsdbDevice(COMPUTE_4_IP); |
| 167 | private static final Device GATEWAY_1_OVSDB_DEVICE = createOvsdbDevice(GATEWAY_1_IP); |
| 168 | private static final Device GATEWAY_2_OVSDB_DEVICE = createOvsdbDevice(GATEWAY_2_IP); |
| 169 | |
| 170 | private static final OpenstackNode COMPUTE_1 = createNode( |
| 171 | COMPUTE_1_HOSTNAME, |
| 172 | COMPUTE, |
| 173 | COMPUTE_1_INTG_DEVICE, |
| 174 | COMPUTE_1_IP, |
| 175 | INIT |
| 176 | ); |
| 177 | |
| 178 | private static final OpenstackNode COMPUTE_2 = createNode( |
| 179 | COMPUTE_2_HOSTNAME, |
| 180 | COMPUTE, |
| 181 | COMPUTE_2_INTG_DEVICE, |
| 182 | COMPUTE_2_IP, |
| 183 | DEVICE_CREATED |
| 184 | ); |
| 185 | |
| 186 | private static final OpenstackNode COMPUTE_3 = createNode( |
| 187 | COMPUTE_3_HOSTNAME, |
| 188 | COMPUTE, |
| 189 | COMPUTE_3_INTG_DEVICE, |
| 190 | COMPUTE_3_IP, |
| 191 | PORT_CREATED |
| 192 | ); |
| 193 | |
| 194 | private static final OpenstackNode COMPUTE_4 = createNode( |
| 195 | COMPUTE_4_HOSTNAME, |
| 196 | COMPUTE, |
| 197 | COMPUTE_4_INTG_DEVICE, |
| 198 | COMPUTE_4_IP, |
| 199 | COMPLETE |
| 200 | ); |
| 201 | |
| 202 | private static final OpenstackNode GATEWAY_1 = createNode( |
| 203 | GATEWAY_1_HOSTNAME, |
| 204 | GATEWAY, |
| 205 | GATEWAY_1_INTG_DEVICE, |
| 206 | GATEWAY_1_ROUT_DEVICE, |
| 207 | GATEWAY_1_IP, |
| 208 | INIT |
| 209 | ); |
| 210 | |
| 211 | private static final OpenstackNode GATEWAY_2 = createNode( |
| 212 | GATEWAY_2_HOSTNAME, |
| 213 | GATEWAY, |
| 214 | GATEWAY_2_INTG_DEVICE, |
| 215 | GATEWAY_2_ROUT_DEVICE, |
| 216 | GATEWAY_2_IP, |
| 217 | DEVICE_CREATED |
| 218 | ); |
| 219 | |
| 220 | private static final OpenstackNode GATEWAY_3 = createNode( |
| 221 | GATEWAY_3_HOSTNAME, |
| 222 | GATEWAY, |
| 223 | GATEWAY_3_INTG_DEVICE, |
| 224 | GATEWAY_3_ROUT_DEVICE, |
| 225 | GATEWAY_3_IP, |
| 226 | PORT_CREATED |
| 227 | ); |
| 228 | |
| 229 | private static final OpenstackNode GATEWAY_4 = createNode( |
| 230 | GATEWAY_4_HOSTNAME, |
| 231 | GATEWAY, |
| 232 | GATEWAY_4_INTG_DEVICE, |
| 233 | GATEWAY_4_ROUT_DEVICE, |
| 234 | GATEWAY_4_IP, |
| 235 | COMPLETE |
| 236 | ); |
| 237 | |
| 238 | private static final TestDeviceService TEST_DEVICE_SERVICE = new TestDeviceService(); |
| 239 | |
| 240 | private TestOpenstackNodeManager testNodeManager; |
| 241 | private DefaultOpenstackNodeHandler target; |
| 242 | |
| 243 | @Before |
| 244 | public void setUp() throws Exception { |
| 245 | DeviceAdminService mockDeviceAdminService = createMock(DeviceAdminService.class); |
| 246 | mockDeviceAdminService.removeDevice(anyObject()); |
| 247 | replay(mockDeviceAdminService); |
| 248 | |
| 249 | OvsdbClientService mockOvsdbClient = createMock(OvsdbClientService.class); |
| 250 | expect(mockOvsdbClient.isConnected()) |
| 251 | .andReturn(true) |
| 252 | .anyTimes(); |
| 253 | replay(mockOvsdbClient); |
| 254 | |
| 255 | OvsdbController mockOvsdbController = createMock(OvsdbController.class); |
| 256 | expect(mockOvsdbController.getOvsdbClient(anyObject())) |
| 257 | .andReturn(mockOvsdbClient) |
| 258 | .anyTimes(); |
| 259 | replay(mockOvsdbController); |
| 260 | |
| 261 | testNodeManager = new TestOpenstackNodeManager(); |
| 262 | target = new DefaultOpenstackNodeHandler(); |
| 263 | |
| 264 | target.coreService = new TestCoreService(); |
| 265 | target.leadershipService = new TestLeadershipService(); |
| 266 | target.clusterService = new TestClusterService(); |
| 267 | target.deviceService = TEST_DEVICE_SERVICE; |
| 268 | target.deviceAdminService = mockDeviceAdminService; |
| 269 | target.ovsdbController = mockOvsdbController; |
| 270 | target.groupService = new TestGroupService(); |
| 271 | target.osNodeService = testNodeManager; |
| 272 | target.osNodeAdminService = testNodeManager; |
| 273 | target.componentConfigService = new TestComponentConfigService(); |
| 274 | TestUtils.setField(target, "eventExecutor", MoreExecutors.newDirectExecutorService()); |
| 275 | target.activate(); |
| 276 | } |
| 277 | |
| 278 | @After |
| 279 | public void tearDown() { |
| 280 | TEST_DEVICE_SERVICE.clear(); |
| 281 | target.deactivate(); |
| 282 | target = null; |
| 283 | testNodeManager = null; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Checks if the compute node state changes from INIT to DEVICE_CREATED |
| 288 | * after processing INIT state. |
| 289 | */ |
| 290 | @Test |
| 291 | public void testComputeNodeProcessNodeInitState() { |
| 292 | testNodeManager.createNode(COMPUTE_1); |
| 293 | TEST_DEVICE_SERVICE.devMap.put(COMPUTE_1_OVSDB_DEVICE.id(), COMPUTE_1_OVSDB_DEVICE); |
| 294 | |
| 295 | assertEquals(ERR_STATE_NOT_MATCH, INIT, |
| 296 | testNodeManager.node(COMPUTE_1_HOSTNAME).state()); |
| 297 | target.processInitState(COMPUTE_1); |
| 298 | assertEquals(ERR_STATE_NOT_MATCH, DEVICE_CREATED, |
| 299 | testNodeManager.node(COMPUTE_1_HOSTNAME).state()); |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Checks if the gateway node state changes from INIT to DEVICE_CREATED |
| 304 | * after processing INIT state. |
| 305 | */ |
| 306 | @Test |
| 307 | public void testGatewayNodeProcessNodeInitState() { |
| 308 | testNodeManager.createNode(GATEWAY_1); |
| 309 | TEST_DEVICE_SERVICE.devMap.put(GATEWAY_1_OVSDB_DEVICE.id(), GATEWAY_1_OVSDB_DEVICE); |
| 310 | |
| 311 | assertEquals(ERR_STATE_NOT_MATCH, INIT, |
| 312 | testNodeManager.node(GATEWAY_1_HOSTNAME).state()); |
| 313 | target.processInitState(GATEWAY_1); |
| 314 | assertEquals(ERR_STATE_NOT_MATCH, DEVICE_CREATED, |
| 315 | testNodeManager.node(GATEWAY_1_HOSTNAME).state()); |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * Checks if the compute node state changes from DEVICE_CREATED to |
| 320 | * PORT_CREATED after processing DEVICE_CREATED state. |
| 321 | */ |
| 322 | @Test |
| 323 | public void testComputeNodeProcessDeviceCreatedState() { |
| 324 | testNodeManager.createNode(COMPUTE_2); |
| 325 | TEST_DEVICE_SERVICE.devMap.put(COMPUTE_2_OVSDB_DEVICE.id(), COMPUTE_2_OVSDB_DEVICE); |
| 326 | TEST_DEVICE_SERVICE.devMap.put(COMPUTE_2_INTG_DEVICE.id(), COMPUTE_2_INTG_DEVICE); |
| 327 | |
| 328 | assertEquals(ERR_STATE_NOT_MATCH, DEVICE_CREATED, |
| 329 | testNodeManager.node(COMPUTE_2_HOSTNAME).state()); |
| 330 | target.processDeviceCreatedState(COMPUTE_2); |
| 331 | assertEquals(ERR_STATE_NOT_MATCH, PORT_CREATED, |
| 332 | testNodeManager.node(COMPUTE_2_HOSTNAME).state()); |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Checks if the gateway node state changes from DEVICE_CREATED to |
| 337 | * PORT_CREATED after processing DEVICE_CREATED state. |
| 338 | */ |
| 339 | @Test |
| 340 | public void testGatewayNodeProcessDeviceCreatedState() { |
| 341 | testNodeManager.createNode(GATEWAY_2); |
| 342 | TEST_DEVICE_SERVICE.devMap.put(GATEWAY_2_OVSDB_DEVICE.id(), GATEWAY_2_OVSDB_DEVICE); |
| 343 | TEST_DEVICE_SERVICE.devMap.put(GATEWAY_2_INTG_DEVICE.id(), GATEWAY_2_INTG_DEVICE); |
| 344 | |
| 345 | assertEquals(ERR_STATE_NOT_MATCH, DEVICE_CREATED, |
| 346 | testNodeManager.node(GATEWAY_2_HOSTNAME).state()); |
| 347 | target.processDeviceCreatedState(GATEWAY_2); |
| 348 | assertEquals(ERR_STATE_NOT_MATCH, PORT_CREATED, |
| 349 | testNodeManager.node(GATEWAY_2_HOSTNAME).state()); |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * Checks if the compute node state changes from PORT_CREATED to |
| 354 | * COMPLETE after processing PORT_CREATED state. |
| 355 | */ |
| 356 | @Test |
| 357 | public void testComputeNodeProcessPortCreatedState() { |
| 358 | testNodeManager.createNode(COMPUTE_3); |
| 359 | TEST_DEVICE_SERVICE.devMap.put(COMPUTE_3_OVSDB_DEVICE.id(), COMPUTE_3_OVSDB_DEVICE); |
| 360 | TEST_DEVICE_SERVICE.devMap.put(COMPUTE_3_INTG_DEVICE.id(), COMPUTE_3_INTG_DEVICE); |
| 361 | TEST_DEVICE_SERVICE.portList.add(createPort(COMPUTE_3_INTG_DEVICE, DEFAULT_TUNNEL)); |
| 362 | |
| 363 | testNodeManager.createNode(GATEWAY_4); |
| 364 | TEST_DEVICE_SERVICE.devMap.put(GATEWAY_4_INTG_DEVICE.id(), GATEWAY_4_INTG_DEVICE); |
| 365 | |
| 366 | assertEquals(ERR_STATE_NOT_MATCH, PORT_CREATED, |
| 367 | testNodeManager.node(COMPUTE_3_HOSTNAME).state()); |
| 368 | target.processPortCreatedState(COMPUTE_3); |
| 369 | assertEquals(ERR_STATE_NOT_MATCH, COMPLETE, |
| 370 | testNodeManager.node(COMPUTE_3_HOSTNAME).state()); |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Checks if the gateway node state changes from PORT_CREATED to |
| 375 | * COMPLETE after processing PORT_CREATED state. |
| 376 | */ |
| 377 | @Test |
| 378 | public void testGatewayNodeProcessPortCreatedState() { |
| 379 | testNodeManager.createNode(COMPUTE_4); |
| 380 | TEST_DEVICE_SERVICE.devMap.put(COMPUTE_4_OVSDB_DEVICE.id(), COMPUTE_4_OVSDB_DEVICE); |
| 381 | TEST_DEVICE_SERVICE.devMap.put(COMPUTE_4_INTG_DEVICE.id(), COMPUTE_4_INTG_DEVICE); |
| 382 | TEST_DEVICE_SERVICE.portList.add(createPort(COMPUTE_4_INTG_DEVICE, DEFAULT_TUNNEL)); |
| 383 | |
| 384 | testNodeManager.createNode(GATEWAY_3); |
| 385 | TEST_DEVICE_SERVICE.devMap.put(GATEWAY_3_INTG_DEVICE.id(), GATEWAY_4_INTG_DEVICE); |
| 386 | |
| 387 | assertEquals(ERR_STATE_NOT_MATCH, PORT_CREATED, |
| 388 | testNodeManager.node(GATEWAY_3_HOSTNAME).state()); |
| 389 | target.processPortCreatedState(GATEWAY_3); |
| 390 | assertEquals(ERR_STATE_NOT_MATCH, COMPLETE, |
| 391 | testNodeManager.node(GATEWAY_3_HOSTNAME).state()); |
| 392 | } |
| 393 | |
| 394 | /** |
| 395 | * Checks if the compute node state changes from COMPLETE to INCOMPLETE |
| 396 | * when integration bridge is disconnected. |
| 397 | */ |
| 398 | @Test |
| 399 | public void testBackToIncompleteWhenBrIntDisconnected() { |
| 400 | testNodeManager.createNode(COMPUTE_4); |
| 401 | |
| 402 | assertEquals(ERR_STATE_NOT_MATCH, COMPLETE, |
| 403 | testNodeManager.node(COMPUTE_4_HOSTNAME).state()); |
| 404 | TEST_DEVICE_SERVICE.removeDevice(COMPUTE_4_INTG_DEVICE); |
| 405 | assertEquals(ERR_STATE_NOT_MATCH, INCOMPLETE, |
| 406 | testNodeManager.node(COMPUTE_4_HOSTNAME).state()); |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * Checks if the compute node state changes from COMPLETE to INCOMPLETE |
| 411 | * when vxlan port is removed from integration bridge. |
| 412 | */ |
| 413 | @Test |
| 414 | public void testBackToIncompleteWhenVxlanRemoved() { |
| 415 | testNodeManager.createNode(COMPUTE_4); |
| 416 | |
| 417 | assertEquals(ERR_STATE_NOT_MATCH, COMPLETE, |
| 418 | testNodeManager.node(COMPUTE_4_HOSTNAME).state()); |
| 419 | TEST_DEVICE_SERVICE.removePort(COMPUTE_4_INTG_DEVICE, createPort( |
| 420 | COMPUTE_4_INTG_DEVICE, DEFAULT_TUNNEL)); |
| 421 | assertEquals(ERR_STATE_NOT_MATCH, INCOMPLETE, |
| 422 | testNodeManager.node(COMPUTE_4_HOSTNAME).state()); |
| 423 | |
| 424 | } |
| 425 | |
| 426 | private static Device createOvsdbDevice(IpAddress ovsdbIp) { |
| 427 | return new TestDevice(new ProviderId("of", "foo"), |
| 428 | DeviceId.deviceId("ovsdb:" + ovsdbIp.toString()), |
| 429 | CONTROLLER, |
| 430 | "manufacturer", |
| 431 | "hwVersion", |
| 432 | "swVersion", |
| 433 | "serialNumber", |
| 434 | new ChassisId(1)); |
| 435 | } |
| 436 | |
| 437 | private static Device createOpenFlowDevice(long devIdNum, String type) { |
| 438 | return new TestDevice(new ProviderId("of", "foo"), |
| 439 | DeviceId.deviceId(String.format("of:%016d", devIdNum)), |
| 440 | SWITCH, |
| 441 | type, |
| 442 | "hwVersion", |
| 443 | "swVersion", |
| 444 | "serialNumber", |
| 445 | new ChassisId(1)); |
| 446 | } |
| 447 | |
| 448 | private static Port createPort(Device device, String portName) { |
| 449 | return new DefaultPort(device, |
| 450 | PortNumber.portNumber(1), |
| 451 | true, |
| 452 | DefaultAnnotations.builder().set(PORT_NAME, portName).build()); |
| 453 | } |
| 454 | |
| 455 | private static OpenstackNode createNode(String hostname, |
| 456 | OpenstackNode.NodeType type, |
| 457 | Device intgBridge, |
| 458 | IpAddress ipAddr, |
| 459 | NodeState state) { |
| 460 | return new TestOpenstackNode( |
| 461 | hostname, |
| 462 | type, |
| 463 | intgBridge.id(), |
| 464 | null, |
| 465 | ipAddr, |
| 466 | ipAddr, |
| 467 | null, state); |
| 468 | } |
| 469 | |
| 470 | private static OpenstackNode createNode(String hostname, |
| 471 | OpenstackNode.NodeType type, |
| 472 | Device intgBridge, |
| 473 | Device routerBridge, |
| 474 | IpAddress ipAddr, |
| 475 | NodeState state) { |
| 476 | return new TestOpenstackNode( |
| 477 | hostname, |
| 478 | type, |
| 479 | intgBridge.id(), |
| 480 | routerBridge.id(), |
| 481 | ipAddr, |
| 482 | ipAddr, |
| 483 | null, state); |
| 484 | } |
| 485 | |
| 486 | private static final class TestDevice extends DefaultDevice { |
| 487 | private TestDevice(ProviderId providerId, |
| 488 | DeviceId id, |
| 489 | Type type, |
| 490 | String manufacturer, |
| 491 | String hwVersion, |
| 492 | String swVersion, |
| 493 | String serialNumber, |
| 494 | ChassisId chassisId, |
| 495 | Annotations... annotations) { |
| 496 | super(providerId, |
| 497 | id, |
| 498 | type, |
| 499 | manufacturer, |
| 500 | hwVersion, |
| 501 | swVersion, |
| 502 | serialNumber, |
| 503 | chassisId, |
| 504 | annotations); |
| 505 | } |
| 506 | |
| 507 | @Override |
| 508 | @SuppressWarnings("unchecked") |
| 509 | public <B extends Behaviour> B as(Class<B> projectionClass) { |
| 510 | if (projectionClass.equals(BridgeConfig.class)) { |
| 511 | return (B) new TestBridgeConfig(); |
| 512 | } else if (projectionClass.equals(InterfaceConfig.class)) { |
| 513 | return (B) new TestInterfaceConfig(); |
| 514 | } else if (projectionClass.equals(ExtensionTreatmentResolver.class)) { |
| 515 | ExtensionTreatmentResolver treatmentResolver = createMock(ExtensionTreatmentResolver.class); |
| 516 | expect(treatmentResolver.getExtensionInstruction(anyObject())) |
| 517 | .andReturn(new TestExtensionTreatment()) |
| 518 | .anyTimes(); |
| 519 | replay(treatmentResolver); |
| 520 | return (B) treatmentResolver; |
| 521 | } else { |
| 522 | return null; |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | @Override |
| 527 | public <B extends Behaviour> boolean is(Class<B> projectionClass) { |
| 528 | return true; |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | private static final class TestOpenstackNode extends DefaultOpenstackNode { |
| 533 | private TestOpenstackNode(String hostname, |
| 534 | NodeType type, |
| 535 | DeviceId intgBridge, |
| 536 | DeviceId routerBridge, |
| 537 | IpAddress managementIp, |
| 538 | IpAddress dataIp, |
| 539 | String vlanIntf, |
| 540 | NodeState state) { |
| 541 | super(hostname, |
| 542 | type, |
| 543 | intgBridge, |
| 544 | routerBridge, |
| 545 | managementIp, |
| 546 | dataIp, |
| 547 | vlanIntf, |
| 548 | state); |
| 549 | } |
| 550 | |
| 551 | @Override |
| 552 | public PortNumber tunnelPortNum() { |
| 553 | return PortNumber.portNumber(1); |
| 554 | } |
| 555 | |
| 556 | @Override |
| 557 | public PortNumber vlanPortNum() { |
| 558 | return PortNumber.portNumber(1); |
| 559 | } |
| 560 | |
| 561 | @Override |
| 562 | public PortNumber patchPortNum() { |
| 563 | return PortNumber.portNumber(1); |
| 564 | } |
| 565 | |
| 566 | @Override |
| 567 | public MacAddress vlanPortMac() { |
| 568 | return MacAddress.NONE; |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | private static class TestOpenstackNodeManager implements OpenstackNodeService, OpenstackNodeAdminService { |
| 573 | Map<String, OpenstackNode> osNodeMap = Maps.newHashMap(); |
| 574 | List<OpenstackNodeListener> listeners = Lists.newArrayList(); |
| 575 | |
| 576 | @Override |
| 577 | public Set<OpenstackNode> nodes() { |
| 578 | return ImmutableSet.copyOf(osNodeMap.values()); |
| 579 | } |
| 580 | |
| 581 | @Override |
| 582 | public Set<OpenstackNode> nodes(OpenstackNode.NodeType type) { |
| 583 | return osNodeMap.values().stream() |
| 584 | .filter(osNode -> osNode.type() == type) |
| 585 | .collect(Collectors.toSet()); |
| 586 | } |
| 587 | |
| 588 | @Override |
| 589 | public Set<OpenstackNode> completeNodes() { |
| 590 | return osNodeMap.values().stream() |
| 591 | .filter(osNode -> osNode.state() == COMPLETE) |
| 592 | .collect(Collectors.toSet()); |
| 593 | } |
| 594 | |
| 595 | @Override |
| 596 | public Set<OpenstackNode> completeNodes(OpenstackNode.NodeType type) { |
| 597 | return osNodeMap.values().stream() |
| 598 | .filter(osNode -> osNode.type() == type && osNode.state() == COMPLETE) |
| 599 | .collect(Collectors.toSet()); |
| 600 | } |
| 601 | |
| 602 | @Override |
| 603 | public OpenstackNode node(String hostname) { |
| 604 | return osNodeMap.get(hostname); |
| 605 | } |
| 606 | |
| 607 | @Override |
| 608 | public OpenstackNode node(DeviceId deviceId) { |
| 609 | return osNodeMap.values().stream() |
| 610 | .filter(osNode -> Objects.equals(osNode.intgBridge(), deviceId) || |
| 611 | Objects.equals(osNode.ovsdb(), deviceId) || |
| 612 | Objects.equals(osNode.routerBridge(), deviceId)) |
| 613 | .findFirst().orElse(null); |
| 614 | } |
| 615 | |
| 616 | @Override |
| 617 | public void addListener(OpenstackNodeListener listener) { |
| 618 | listeners.add(listener); |
| 619 | } |
| 620 | |
| 621 | @Override |
| 622 | public void removeListener(OpenstackNodeListener listener) { |
| 623 | listeners.remove(listener); |
| 624 | } |
| 625 | |
| 626 | @Override |
| 627 | public void createNode(OpenstackNode osNode) { |
| 628 | osNodeMap.put(osNode.hostname(), osNode); |
| 629 | } |
| 630 | |
| 631 | @Override |
| 632 | public void updateNode(OpenstackNode osNode) { |
| 633 | osNodeMap.put(osNode.hostname(), osNode); |
| 634 | } |
| 635 | |
| 636 | @Override |
| 637 | public OpenstackNode removeNode(String hostname) { |
| 638 | return null; |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | private static class TestDeviceService extends DeviceServiceAdapter { |
| 643 | Map<DeviceId, Device> devMap = Maps.newHashMap(); |
| 644 | List<Port> portList = Lists.newArrayList(); |
| 645 | List<DeviceListener> listeners = Lists.newArrayList(); |
| 646 | |
| 647 | @Override |
| 648 | public void addListener(DeviceListener listener) { |
| 649 | listeners.add(listener); |
| 650 | } |
| 651 | |
| 652 | @Override |
| 653 | public void removeListener(DeviceListener listener) { |
| 654 | listeners.remove(listener); |
| 655 | } |
| 656 | |
| 657 | @Override |
| 658 | public Device getDevice(DeviceId deviceId) { |
| 659 | return devMap.get(deviceId); |
| 660 | } |
| 661 | |
| 662 | @Override |
| 663 | public List<Port> getPorts(DeviceId deviceId) { |
| 664 | return this.portList.stream() |
| 665 | .filter(p -> p.element().id().equals(deviceId)) |
| 666 | .collect(Collectors.toList()); |
| 667 | } |
| 668 | |
| 669 | @Override |
| 670 | public boolean isAvailable(DeviceId deviceId) { |
| 671 | return devMap.containsKey(deviceId); |
| 672 | } |
| 673 | |
| 674 | void addDevice(Device device) { |
| 675 | devMap.put(device.id(), device); |
| 676 | DeviceEvent event = new DeviceEvent(DEVICE_ADDED, device); |
| 677 | listeners.stream().filter(l -> l.isRelevant(event)).forEach(l -> l.event(event)); |
| 678 | } |
| 679 | |
| 680 | void removeDevice(Device device) { |
| 681 | devMap.remove(device.id()); |
| 682 | DeviceEvent event = new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device); |
| 683 | listeners.stream().filter(l -> l.isRelevant(event)).forEach(l -> l.event(event)); |
| 684 | } |
| 685 | |
| 686 | void addPort(Device device, Port port) { |
| 687 | portList.add(port); |
| 688 | DeviceEvent event = new DeviceEvent(PORT_ADDED, device, port); |
| 689 | listeners.stream().filter(l -> l.isRelevant(event)).forEach(l -> l.event(event)); |
| 690 | } |
| 691 | |
| 692 | void removePort(Device device, Port port) { |
| 693 | portList.remove(port); |
| 694 | DeviceEvent event = new DeviceEvent(PORT_REMOVED, device, port); |
| 695 | listeners.stream().filter(l -> l.isRelevant(event)).forEach(l -> l.event(event)); |
| 696 | } |
| 697 | |
| 698 | void clear() { |
| 699 | this.listeners.clear(); |
| 700 | this.devMap.clear(); |
| 701 | this.portList.clear(); |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | private static class TestBridgeConfig implements BridgeConfig { |
| 706 | |
| 707 | @Override |
| 708 | public DriverData data() { |
| 709 | return null; |
| 710 | } |
| 711 | |
| 712 | @Override |
| 713 | public void setData(DriverData data) { |
| 714 | |
| 715 | } |
| 716 | |
| 717 | @Override |
| 718 | public DriverHandler handler() { |
| 719 | return null; |
| 720 | } |
| 721 | |
| 722 | @Override |
| 723 | public void setHandler(DriverHandler handler) { |
| 724 | |
| 725 | } |
| 726 | |
| 727 | @Override |
| 728 | public void addBridge(BridgeName bridgeName) { |
| 729 | |
| 730 | } |
| 731 | |
| 732 | @Override |
| 733 | public void addBridge(BridgeName bridgeName, String dpid, String exPortName) { |
| 734 | |
| 735 | } |
| 736 | |
| 737 | @Override |
| 738 | public boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers) { |
| 739 | return false; |
| 740 | } |
| 741 | |
| 742 | @Override |
| 743 | public boolean addBridge(BridgeDescription bridge) { |
| 744 | TEST_DEVICE_SERVICE.addDevice(new DefaultDevice(new ProviderId("of", "foo"), |
| 745 | DeviceId.deviceId("of:" + bridge.datapathId().get()), |
| 746 | SWITCH, |
| 747 | bridge.name(), |
| 748 | "hwVersion", |
| 749 | "swVersion", |
| 750 | "serialNumber", |
| 751 | new ChassisId(1))); |
| 752 | return true; |
| 753 | } |
| 754 | |
| 755 | @Override |
| 756 | public void deleteBridge(BridgeName bridgeName) { |
| 757 | |
| 758 | } |
| 759 | |
| 760 | @Override |
| 761 | public Collection<BridgeDescription> getBridges() { |
| 762 | return ImmutableSet.of(ROUT_BRIDGE); |
| 763 | } |
| 764 | |
| 765 | @Override |
| 766 | public void addPort(BridgeName bridgeName, String portName) { |
| 767 | |
| 768 | } |
| 769 | |
| 770 | @Override |
| 771 | public void deletePort(BridgeName bridgeName, String portName) { |
| 772 | |
| 773 | } |
| 774 | |
| 775 | @Override |
| 776 | public Collection<PortDescription> getPorts() { |
| 777 | return ImmutableSet.of(PATCH_ROUT); |
| 778 | } |
| 779 | |
| 780 | @Override |
| 781 | public Set<PortNumber> getPortNumbers() { |
| 782 | return null; |
| 783 | } |
| 784 | |
| 785 | @Override |
| 786 | public List<PortNumber> getLocalPorts(Iterable<String> ifaceIds) { |
| 787 | return null; |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | private static class TestInterfaceConfig implements InterfaceConfig { |
| 792 | |
| 793 | @Override |
| 794 | public DriverData data() { |
| 795 | return null; |
| 796 | } |
| 797 | |
| 798 | @Override |
| 799 | public void setData(DriverData data) { |
| 800 | |
| 801 | } |
| 802 | |
| 803 | @Override |
| 804 | public DriverHandler handler() { |
| 805 | return null; |
| 806 | } |
| 807 | |
| 808 | @Override |
| 809 | public void setHandler(DriverHandler handler) { |
| 810 | |
| 811 | } |
| 812 | |
| 813 | @Override |
| 814 | public boolean addAccessInterface(DeviceId deviceId, String intf, VlanId vlanId) { |
| 815 | return false; |
| 816 | } |
| 817 | |
| 818 | @Override |
| 819 | public boolean addAccessMode(String intf, VlanId vlanId) { |
| 820 | return false; |
| 821 | } |
| 822 | |
| 823 | @Override |
| 824 | public boolean removeAccessInterface(DeviceId deviceId, String intf) { |
| 825 | return false; |
| 826 | } |
| 827 | |
| 828 | @Override |
| 829 | public boolean removeAccessMode(String intf) { |
| 830 | return false; |
| 831 | } |
| 832 | |
| 833 | @Override |
| 834 | public boolean addTrunkInterface(DeviceId deviceId, String intf, List<VlanId> vlanIds) { |
| 835 | return false; |
| 836 | } |
| 837 | |
| 838 | @Override |
| 839 | public boolean addTrunkMode(String intf, List<VlanId> vlanIds) { |
| 840 | return false; |
| 841 | } |
| 842 | |
| 843 | @Override |
| 844 | public boolean removeTrunkInterface(DeviceId deviceId, String intf) { |
| 845 | return false; |
| 846 | } |
| 847 | |
| 848 | @Override |
| 849 | public boolean removeTrunkMode(String intf) { |
| 850 | return false; |
| 851 | } |
| 852 | |
| 853 | @Override |
| 854 | public boolean addRateLimit(String intf, short limit) { |
| 855 | return false; |
| 856 | } |
| 857 | |
| 858 | @Override |
| 859 | public boolean removeRateLimit(String intf) { |
| 860 | return false; |
| 861 | } |
| 862 | |
| 863 | @Override |
| 864 | public boolean addTunnelMode(String intf, TunnelDescription tunnelDesc) { |
| 865 | TEST_DEVICE_SERVICE.devMap.values().stream() |
| 866 | .filter(device -> device.type() == SWITCH && |
| 867 | device.manufacturer().equals(INTEGRATION_BRIDGE)) |
| 868 | .forEach(device -> { |
| 869 | TEST_DEVICE_SERVICE.addPort(device, createPort(device, intf)); |
| 870 | }); |
| 871 | return true; |
| 872 | } |
| 873 | |
| 874 | @Override |
| 875 | public boolean removeTunnelMode(String intf) { |
| 876 | return false; |
| 877 | } |
| 878 | |
| 879 | @Override |
| 880 | public boolean addPatchMode(String ifaceName, PatchDescription patchInterface) { |
| 881 | if (ifaceName.equals(PATCH_INTG_BRIDGE)) { |
| 882 | TEST_DEVICE_SERVICE.devMap.values().stream() |
| 883 | .filter(device -> device.type() == SWITCH && |
| 884 | device.manufacturer().equals(INTEGRATION_BRIDGE)) |
| 885 | .forEach(device -> { |
| 886 | TEST_DEVICE_SERVICE.addPort(device, createPort(device, ifaceName)); |
| 887 | }); |
| 888 | } else if (ifaceName.equals(PATCH_ROUT_BRIDGE)) { |
| 889 | TEST_DEVICE_SERVICE.devMap.values().stream() |
| 890 | .filter(device -> device.type() == SWITCH && |
| 891 | device.manufacturer().equals(ROUTER_BRIDGE)) |
| 892 | .forEach(device -> { |
| 893 | TEST_DEVICE_SERVICE.addPort(device, createPort(device, ifaceName)); |
| 894 | }); |
| 895 | } |
| 896 | return true; |
| 897 | } |
| 898 | |
| 899 | @Override |
| 900 | public boolean removePatchMode(String ifaceName) { |
| 901 | return false; |
| 902 | } |
| 903 | |
| 904 | @Override |
| 905 | public List<DeviceInterfaceDescription> getInterfaces(DeviceId deviceId) { |
| 906 | return null; |
| 907 | } |
| 908 | |
| 909 | @Override |
| 910 | public List<DeviceInterfaceDescription> getInterfaces() { |
| 911 | return null; |
| 912 | } |
| 913 | } |
| 914 | |
| 915 | private static class TestGroupService implements GroupService { |
| 916 | Map<GroupKey, Group> groupMap = Maps.newHashMap(); |
| 917 | Map<GroupKey, GroupBuckets> groupBucketsMap = Maps.newHashMap(); |
| 918 | List<GroupListener> listeners = Lists.newArrayList(); |
| 919 | |
| 920 | @Override |
| 921 | public void addListener(GroupListener listener) { |
| 922 | listeners.add(listener); |
| 923 | } |
| 924 | |
| 925 | @Override |
| 926 | public void removeListener(GroupListener listener) { |
| 927 | listeners.remove(listener); |
| 928 | } |
| 929 | |
| 930 | @Override |
| 931 | public void addGroup(GroupDescription groupDesc) { |
| 932 | DefaultGroup group = new DefaultGroup(GroupId.valueOf(groupDesc.givenGroupId()), groupDesc); |
| 933 | group.setState(Group.GroupState.ADDED); |
| 934 | groupMap.put(groupDesc.appCookie(), group); |
| 935 | groupBucketsMap.put(groupDesc.appCookie(), groupDesc.buckets()); |
| 936 | |
| 937 | GroupEvent event = new GroupEvent(GroupEvent.Type.GROUP_ADDED, group); |
| 938 | listeners.stream().filter(listener -> listener.isRelevant(event)) |
| 939 | .forEach(listener -> listener.event(event)); |
| 940 | } |
| 941 | |
| 942 | @Override |
| 943 | public Group getGroup(DeviceId deviceId, GroupKey appCookie) { |
| 944 | return groupMap.get(appCookie); |
| 945 | } |
| 946 | |
| 947 | @Override |
| 948 | public void addBucketsToGroup(DeviceId deviceId, GroupKey oldCookie, GroupBuckets buckets, |
| 949 | GroupKey newCookie, ApplicationId appId) { |
| 950 | |
| 951 | } |
| 952 | |
| 953 | @Override |
| 954 | public void removeBucketsFromGroup(DeviceId deviceId, GroupKey oldCookie, GroupBuckets buckets, |
| 955 | GroupKey newCookie, ApplicationId appId) { |
| 956 | |
| 957 | } |
| 958 | |
| 959 | @Override |
| 960 | public void purgeGroupEntries(DeviceId deviceId) { |
| 961 | |
| 962 | } |
| 963 | |
| 964 | @Override |
| 965 | public void removeGroup(DeviceId deviceId, GroupKey appCookie, ApplicationId appId) { |
| 966 | |
| 967 | } |
| 968 | |
| 969 | @Override |
| 970 | public Iterable<Group> getGroups(DeviceId deviceId, ApplicationId appId) { |
| 971 | return null; |
| 972 | } |
| 973 | |
| 974 | @Override |
| 975 | public Iterable<Group> getGroups(DeviceId deviceId) { |
| 976 | return null; |
| 977 | } |
| 978 | |
| 979 | @Override |
| 980 | public void setBucketsForGroup(DeviceId deviceId, GroupKey oldCookie, GroupBuckets buckets, |
| 981 | GroupKey newCookie, ApplicationId appId) { |
| 982 | groupBucketsMap.put(newCookie, buckets); |
| 983 | GroupEvent event = new GroupEvent(GroupEvent.Type.GROUP_UPDATED, groupMap.get(newCookie)); |
| 984 | listeners.stream().filter(listener -> listener.isRelevant(event)) |
| 985 | .forEach(listener -> listener.event(event)); |
| 986 | } |
| 987 | |
| 988 | } |
| 989 | |
| 990 | private static class TestExtensionTreatment implements ExtensionTreatment { |
| 991 | Ip4Address tunnelDst; |
| 992 | |
| 993 | @Override |
| 994 | public ExtensionTreatmentType type() { |
| 995 | return null; |
| 996 | } |
| 997 | |
| 998 | @Override |
| 999 | public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException { |
| 1000 | tunnelDst = (Ip4Address) value; |
| 1001 | } |
| 1002 | |
| 1003 | @Override |
| 1004 | public <T> T getPropertyValue(String key) throws ExtensionPropertyException { |
| 1005 | return null; |
| 1006 | } |
| 1007 | |
| 1008 | @Override |
| 1009 | public List<String> getProperties() { |
| 1010 | return null; |
| 1011 | } |
| 1012 | |
| 1013 | @Override |
| 1014 | public byte[] serialize() { |
| 1015 | return new byte[0]; |
| 1016 | } |
| 1017 | |
| 1018 | @Override |
| 1019 | public void deserialize(byte[] data) { |
| 1020 | |
| 1021 | } |
| 1022 | |
| 1023 | @Override |
| 1024 | public boolean equals(Object obj) { |
| 1025 | TestExtensionTreatment that = (TestExtensionTreatment) obj; |
| 1026 | return Objects.equals(tunnelDst, that.tunnelDst); |
| 1027 | } |
| 1028 | |
| 1029 | @Override |
| 1030 | public int hashCode() { |
| 1031 | return Objects.hash(tunnelDst); |
| 1032 | } |
| 1033 | } |
| 1034 | |
| 1035 | private static class TestCoreService extends CoreServiceAdapter { |
| 1036 | |
| 1037 | @Override |
| 1038 | public ApplicationId getAppId(String name) { |
| 1039 | return TEST_APP_ID; |
| 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | private static class TestLeadershipService extends LeadershipServiceAdapter { |
| 1044 | |
| 1045 | @Override |
| 1046 | public NodeId getLeader(String path) { |
| 1047 | return LOCAL_NODE_ID; |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | private static class TestClusterService extends ClusterServiceAdapter { |
| 1052 | |
| 1053 | @Override |
| 1054 | public ControllerNode getLocalNode() { |
| 1055 | return LOCAL_CTRL; |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | private class TestComponentConfigService extends ComponentConfigAdapter { |
| 1060 | |
| 1061 | } |
| 1062 | } |