Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.store.device.impl; |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 7d656f4 | 2015-01-27 14:07:23 -0800 | [diff] [blame] | 18 | import com.google.common.collect.Iterables; |
| 19 | import com.google.common.collect.Sets; |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 20 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 21 | import org.easymock.Capture; |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 22 | import org.junit.After; |
| 23 | import org.junit.AfterClass; |
| 24 | import org.junit.Before; |
| 25 | import org.junit.BeforeClass; |
| 26 | import org.junit.Ignore; |
| 27 | import org.junit.Test; |
Jonathan Hart | 7d656f4 | 2015-01-27 14:07:23 -0800 | [diff] [blame] | 28 | import org.onlab.packet.ChassisId; |
| 29 | import org.onlab.packet.IpAddress; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 30 | import org.onosproject.cluster.ClusterService; |
| 31 | import org.onosproject.cluster.ControllerNode; |
| 32 | import org.onosproject.cluster.DefaultControllerNode; |
| 33 | import org.onosproject.cluster.NodeId; |
| 34 | import org.onosproject.mastership.MastershipServiceAdapter; |
| 35 | import org.onosproject.mastership.MastershipTerm; |
| 36 | import org.onosproject.net.Annotations; |
| 37 | import org.onosproject.net.DefaultAnnotations; |
| 38 | import org.onosproject.net.Device; |
| 39 | import org.onosproject.net.DeviceId; |
| 40 | import org.onosproject.net.Port; |
| 41 | import org.onosproject.net.PortNumber; |
| 42 | import org.onosproject.net.SparseAnnotations; |
| 43 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 44 | import org.onosproject.net.device.DefaultPortDescription; |
| 45 | import org.onosproject.net.device.DeviceClockService; |
| 46 | import org.onosproject.net.device.DeviceDescription; |
| 47 | import org.onosproject.net.device.DeviceEvent; |
| 48 | import org.onosproject.net.device.DeviceStore; |
| 49 | import org.onosproject.net.device.DeviceStoreDelegate; |
| 50 | import org.onosproject.net.device.PortDescription; |
| 51 | import org.onosproject.net.provider.ProviderId; |
| 52 | import org.onosproject.store.cluster.StaticClusterService; |
| 53 | import org.onosproject.store.cluster.messaging.ClusterCommunicationService; |
| 54 | import org.onosproject.store.cluster.messaging.ClusterMessage; |
| 55 | import org.onosproject.store.cluster.messaging.ClusterMessageHandler; |
| 56 | import org.onosproject.store.cluster.messaging.MessageSubject; |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 57 | |
Jonathan Hart | 7d656f4 | 2015-01-27 14:07:23 -0800 | [diff] [blame] | 58 | import java.io.IOException; |
| 59 | import java.util.Arrays; |
| 60 | import java.util.Collections; |
| 61 | import java.util.HashMap; |
| 62 | import java.util.List; |
| 63 | import java.util.Map; |
| 64 | import java.util.Set; |
| 65 | import java.util.concurrent.CountDownLatch; |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 66 | import java.util.concurrent.ExecutorService; |
Jonathan Hart | 7d656f4 | 2015-01-27 14:07:23 -0800 | [diff] [blame] | 67 | import java.util.concurrent.TimeUnit; |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 68 | import java.util.function.Function; |
Jonathan Hart | 7d656f4 | 2015-01-27 14:07:23 -0800 | [diff] [blame] | 69 | |
| 70 | import static java.util.Arrays.asList; |
| 71 | import static org.easymock.EasyMock.*; |
| 72 | import static org.junit.Assert.*; |
| 73 | import static org.onosproject.cluster.ControllerNode.State.ACTIVE; |
| 74 | import static org.onosproject.net.DefaultAnnotations.union; |
| 75 | import static org.onosproject.net.Device.Type.SWITCH; |
| 76 | import static org.onosproject.net.DeviceId.deviceId; |
| 77 | import static org.onosproject.net.device.DeviceEvent.Type.*; |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 78 | |
| 79 | |
| 80 | // TODO add tests for remote replication |
| 81 | /** |
| 82 | * Test of the gossip based distributed DeviceStore implementation. |
| 83 | */ |
| 84 | public class GossipDeviceStoreTest { |
| 85 | |
| 86 | private static final ProviderId PID = new ProviderId("of", "foo"); |
| 87 | private static final ProviderId PIDA = new ProviderId("of", "bar", true); |
| 88 | private static final DeviceId DID1 = deviceId("of:foo"); |
| 89 | private static final DeviceId DID2 = deviceId("of:bar"); |
| 90 | private static final String MFR = "whitebox"; |
| 91 | private static final String HW = "1.1.x"; |
| 92 | private static final String SW1 = "3.8.1"; |
| 93 | private static final String SW2 = "3.9.5"; |
| 94 | private static final String SN = "43311-12345"; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 95 | private static final ChassisId CID = new ChassisId(); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 96 | |
| 97 | private static final PortNumber P1 = PortNumber.portNumber(1); |
| 98 | private static final PortNumber P2 = PortNumber.portNumber(2); |
| 99 | private static final PortNumber P3 = PortNumber.portNumber(3); |
| 100 | |
| 101 | private static final SparseAnnotations A1 = DefaultAnnotations.builder() |
| 102 | .set("A1", "a1") |
| 103 | .set("B1", "b1") |
| 104 | .build(); |
| 105 | private static final SparseAnnotations A1_2 = DefaultAnnotations.builder() |
| 106 | .remove("A1") |
| 107 | .set("B3", "b3") |
| 108 | .build(); |
| 109 | private static final SparseAnnotations A2 = DefaultAnnotations.builder() |
| 110 | .set("A2", "a2") |
| 111 | .set("B2", "b2") |
| 112 | .build(); |
| 113 | private static final SparseAnnotations A2_2 = DefaultAnnotations.builder() |
| 114 | .remove("A2") |
| 115 | .set("B4", "b4") |
| 116 | .build(); |
| 117 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 118 | // local node |
| 119 | private static final NodeId NID1 = new NodeId("local"); |
| 120 | private static final ControllerNode ONOS1 = |
Pavlin Radoslavov | 444b519 | 2014-10-28 10:45:19 -0700 | [diff] [blame] | 121 | new DefaultControllerNode(NID1, IpAddress.valueOf("127.0.0.1")); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 122 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 123 | // remote node |
| 124 | private static final NodeId NID2 = new NodeId("remote"); |
| 125 | private static final ControllerNode ONOS2 = |
Pavlin Radoslavov | 444b519 | 2014-10-28 10:45:19 -0700 | [diff] [blame] | 126 | new DefaultControllerNode(NID2, IpAddress.valueOf("127.0.0.2")); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 127 | private static final List<SparseAnnotations> NO_ANNOTATION = Collections.<SparseAnnotations>emptyList(); |
| 128 | |
| 129 | |
| 130 | private TestGossipDeviceStore testGossipDeviceStore; |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 131 | private GossipDeviceStore gossipDeviceStore; |
| 132 | private DeviceStore deviceStore; |
| 133 | |
| 134 | private DeviceClockManager deviceClockManager; |
Yuta HIGUCHI | 093e83e | 2014-10-10 22:26:11 -0700 | [diff] [blame] | 135 | private DeviceClockService deviceClockService; |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 136 | private ClusterCommunicationService clusterCommunicator; |
Yuta HIGUCHI | 3e5d11a | 2014-11-04 14:16:44 -0800 | [diff] [blame] | 137 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 138 | @BeforeClass |
| 139 | public static void setUpBeforeClass() throws Exception { |
| 140 | } |
| 141 | |
| 142 | @AfterClass |
| 143 | public static void tearDownAfterClass() throws Exception { |
| 144 | } |
| 145 | |
| 146 | |
| 147 | @Before |
| 148 | public void setUp() throws Exception { |
| 149 | deviceClockManager = new DeviceClockManager(); |
| 150 | deviceClockManager.activate(); |
Yuta HIGUCHI | 093e83e | 2014-10-10 22:26:11 -0700 | [diff] [blame] | 151 | deviceClockService = deviceClockManager; |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 152 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 153 | deviceClockManager.setMastershipTerm(DID1, MastershipTerm.of(NID1, 1)); |
| 154 | deviceClockManager.setMastershipTerm(DID2, MastershipTerm.of(NID1, 2)); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 155 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 156 | clusterCommunicator = createNiceMock(ClusterCommunicationService.class); |
| 157 | clusterCommunicator.addSubscriber(anyObject(MessageSubject.class), |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 158 | anyObject(ClusterMessageHandler.class), anyObject(ExecutorService.class)); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 159 | expectLastCall().anyTimes(); |
| 160 | replay(clusterCommunicator); |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 161 | ClusterService clusterService = new TestClusterService(); |
Madan Jampani | 47c9373 | 2014-10-06 20:46:08 -0700 | [diff] [blame] | 162 | |
Yuta HIGUCHI | 093e83e | 2014-10-10 22:26:11 -0700 | [diff] [blame] | 163 | testGossipDeviceStore = new TestGossipDeviceStore(deviceClockService, clusterService, clusterCommunicator); |
Yuta HIGUCHI | e8252bb | 2014-10-22 09:41:01 -0700 | [diff] [blame] | 164 | testGossipDeviceStore.mastershipService = new TestMastershipService(); |
| 165 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 166 | gossipDeviceStore = testGossipDeviceStore; |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 167 | gossipDeviceStore.activate(); |
| 168 | deviceStore = gossipDeviceStore; |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 169 | verify(clusterCommunicator); |
| 170 | reset(clusterCommunicator); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | @After |
| 174 | public void tearDown() throws Exception { |
| 175 | gossipDeviceStore.deactivate(); |
| 176 | deviceClockManager.deactivate(); |
| 177 | } |
| 178 | |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 179 | private void putDevice(DeviceId deviceId, String swVersion, |
| 180 | SparseAnnotations... annotations) { |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 181 | DeviceDescription description = |
| 182 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 183 | HW, swVersion, SN, CID, annotations); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 184 | reset(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 185 | clusterCommunicator.<InternalDeviceEvent>broadcast( |
| 186 | anyObject(InternalDeviceEvent.class), anyObject(MessageSubject.class), anyObject(Function.class)); |
| 187 | expectLastCall().anyTimes(); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 188 | replay(clusterCommunicator); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 189 | deviceStore.createOrUpdateDevice(PID, deviceId, description); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 190 | verify(clusterCommunicator); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 193 | private void putDeviceAncillary(DeviceId deviceId, String swVersion, |
| 194 | SparseAnnotations... annotations) { |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 195 | DeviceDescription description = |
| 196 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 197 | HW, swVersion, SN, CID, annotations); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 198 | deviceStore.createOrUpdateDevice(PIDA, deviceId, description); |
| 199 | } |
| 200 | |
| 201 | private static void assertDevice(DeviceId id, String swVersion, Device device) { |
| 202 | assertNotNull(device); |
| 203 | assertEquals(id, device.id()); |
| 204 | assertEquals(MFR, device.manufacturer()); |
| 205 | assertEquals(HW, device.hwVersion()); |
| 206 | assertEquals(swVersion, device.swVersion()); |
| 207 | assertEquals(SN, device.serialNumber()); |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Verifies that Annotations created by merging {@code annotations} is |
| 212 | * equal to actual Annotations. |
| 213 | * |
| 214 | * @param actual Annotations to check |
| 215 | * @param annotations |
| 216 | */ |
| 217 | private static void assertAnnotationsEquals(Annotations actual, SparseAnnotations... annotations) { |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 218 | SparseAnnotations expected = DefaultAnnotations.builder().build(); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 219 | for (SparseAnnotations a : annotations) { |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 220 | expected = DefaultAnnotations.union(expected, a); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 221 | } |
| 222 | assertEquals(expected.keys(), actual.keys()); |
| 223 | for (String key : expected.keys()) { |
| 224 | assertEquals(expected.value(key), actual.value(key)); |
| 225 | } |
| 226 | } |
| 227 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 228 | private static void assertDeviceDescriptionEquals(DeviceDescription expected, |
| 229 | DeviceDescription actual) { |
| 230 | if (expected == actual) { |
| 231 | return; |
| 232 | } |
| 233 | assertEquals(expected.deviceURI(), actual.deviceURI()); |
| 234 | assertEquals(expected.hwVersion(), actual.hwVersion()); |
| 235 | assertEquals(expected.manufacturer(), actual.manufacturer()); |
| 236 | assertEquals(expected.serialNumber(), actual.serialNumber()); |
| 237 | assertEquals(expected.swVersion(), actual.swVersion()); |
| 238 | |
| 239 | assertAnnotationsEquals(actual.annotations(), expected.annotations()); |
| 240 | } |
| 241 | |
| 242 | private static void assertDeviceDescriptionEquals(DeviceDescription expected, |
| 243 | List<SparseAnnotations> expectedAnnotations, |
| 244 | DeviceDescription actual) { |
| 245 | if (expected == actual) { |
| 246 | return; |
| 247 | } |
| 248 | assertEquals(expected.deviceURI(), actual.deviceURI()); |
| 249 | assertEquals(expected.hwVersion(), actual.hwVersion()); |
| 250 | assertEquals(expected.manufacturer(), actual.manufacturer()); |
| 251 | assertEquals(expected.serialNumber(), actual.serialNumber()); |
| 252 | assertEquals(expected.swVersion(), actual.swVersion()); |
| 253 | |
| 254 | assertAnnotationsEquals(actual.annotations(), |
| 255 | expectedAnnotations.toArray(new SparseAnnotations[0])); |
| 256 | } |
| 257 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 258 | @Test |
| 259 | public final void testGetDeviceCount() { |
| 260 | assertEquals("initialy empty", 0, deviceStore.getDeviceCount()); |
| 261 | |
| 262 | putDevice(DID1, SW1); |
| 263 | putDevice(DID2, SW2); |
| 264 | putDevice(DID1, SW1); |
| 265 | |
| 266 | assertEquals("expect 2 uniq devices", 2, deviceStore.getDeviceCount()); |
| 267 | } |
| 268 | |
| 269 | @Test |
| 270 | public final void testGetDevices() { |
| 271 | assertEquals("initialy empty", 0, Iterables.size(deviceStore.getDevices())); |
| 272 | |
| 273 | putDevice(DID1, SW1); |
| 274 | putDevice(DID2, SW2); |
| 275 | putDevice(DID1, SW1); |
| 276 | |
| 277 | assertEquals("expect 2 uniq devices", |
| 278 | 2, Iterables.size(deviceStore.getDevices())); |
| 279 | |
| 280 | Map<DeviceId, Device> devices = new HashMap<>(); |
| 281 | for (Device device : deviceStore.getDevices()) { |
| 282 | devices.put(device.id(), device); |
| 283 | } |
| 284 | |
| 285 | assertDevice(DID1, SW1, devices.get(DID1)); |
| 286 | assertDevice(DID2, SW2, devices.get(DID2)); |
| 287 | |
| 288 | // add case for new node? |
| 289 | } |
| 290 | |
| 291 | @Test |
| 292 | public final void testGetDevice() { |
| 293 | |
| 294 | putDevice(DID1, SW1); |
| 295 | |
| 296 | assertDevice(DID1, SW1, deviceStore.getDevice(DID1)); |
| 297 | assertNull("DID2 shouldn't be there", deviceStore.getDevice(DID2)); |
| 298 | } |
| 299 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 300 | private void assertInternalDeviceEvent(NodeId sender, |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 301 | DeviceId deviceId, |
| 302 | ProviderId providerId, |
| 303 | DeviceDescription expectedDesc, |
| 304 | Capture<InternalDeviceEvent> actualEvent, |
| 305 | Capture<MessageSubject> actualSubject, |
| 306 | Capture<Function<InternalDeviceEvent, byte[]>> actualEncoder) { |
| 307 | assertTrue(actualEvent.hasCaptured()); |
| 308 | assertTrue(actualSubject.hasCaptured()); |
| 309 | assertTrue(actualEncoder.hasCaptured()); |
| 310 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 311 | assertEquals(GossipDeviceStoreMessageSubjects.DEVICE_UPDATE, |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 312 | actualSubject.getValue()); |
| 313 | assertEquals(deviceId, actualEvent.getValue().deviceId()); |
| 314 | assertEquals(providerId, actualEvent.getValue().providerId()); |
| 315 | assertDeviceDescriptionEquals(expectedDesc, actualEvent.getValue().deviceDescription().value()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | private void assertInternalDeviceEvent(NodeId sender, |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 319 | DeviceId deviceId, |
| 320 | ProviderId providerId, |
| 321 | DeviceDescription expectedDesc, |
| 322 | List<SparseAnnotations> expectedAnnotations, |
| 323 | Capture<InternalDeviceEvent> actualEvent, |
| 324 | Capture<MessageSubject> actualSubject, |
| 325 | Capture<Function<InternalDeviceEvent, byte[]>> actualEncoder) { |
| 326 | assertTrue(actualEvent.hasCaptured()); |
| 327 | assertTrue(actualSubject.hasCaptured()); |
| 328 | assertTrue(actualEncoder.hasCaptured()); |
| 329 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 330 | assertEquals(GossipDeviceStoreMessageSubjects.DEVICE_UPDATE, |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 331 | actualSubject.getValue()); |
| 332 | assertEquals(deviceId, actualEvent.getValue().deviceId()); |
| 333 | assertEquals(providerId, actualEvent.getValue().providerId()); |
| 334 | assertDeviceDescriptionEquals( |
| 335 | expectedDesc, |
| 336 | expectedAnnotations, |
| 337 | actualEvent.getValue().deviceDescription().value()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 340 | @Test |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 341 | public final void testCreateOrUpdateDevice() throws IOException { |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 342 | DeviceDescription description = |
| 343 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 344 | HW, SW1, SN, CID); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 345 | Capture<InternalDeviceEvent> message = new Capture<>(); |
| 346 | Capture<MessageSubject> subject = new Capture<>(); |
| 347 | Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>(); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 348 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 349 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 350 | DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description); |
| 351 | assertEquals(DEVICE_ADDED, event.type()); |
| 352 | assertDevice(DID1, SW1, event.subject()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 353 | verify(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 354 | assertInternalDeviceEvent(NID1, DID1, PID, description, message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 355 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 356 | |
| 357 | DeviceDescription description2 = |
| 358 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 359 | HW, SW2, SN, CID); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 360 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 361 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); |
| 362 | assertEquals(DEVICE_UPDATED, event2.type()); |
| 363 | assertDevice(DID1, SW2, event2.subject()); |
| 364 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 365 | verify(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 366 | assertInternalDeviceEvent(NID1, DID1, PID, description2, message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 367 | reset(clusterCommunicator); |
| 368 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 369 | assertNull("No change expected", deviceStore.createOrUpdateDevice(PID, DID1, description2)); |
| 370 | } |
| 371 | |
| 372 | @Test |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 373 | public final void testCreateOrUpdateDeviceAncillary() throws IOException { |
| 374 | // add |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 375 | DeviceDescription description = |
| 376 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 377 | HW, SW1, SN, CID, A2); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 378 | Capture<ClusterMessage> bcast = new Capture<>(); |
| 379 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 380 | Capture<InternalDeviceEvent> message = new Capture<>(); |
| 381 | Capture<MessageSubject> subject = new Capture<>(); |
| 382 | Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>(); |
| 383 | |
| 384 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 385 | DeviceEvent event = deviceStore.createOrUpdateDevice(PIDA, DID1, description); |
| 386 | assertEquals(DEVICE_ADDED, event.type()); |
| 387 | assertDevice(DID1, SW1, event.subject()); |
| 388 | assertEquals(PIDA, event.subject().providerId()); |
| 389 | assertAnnotationsEquals(event.subject().annotations(), A2); |
| 390 | assertFalse("Ancillary will not bring device up", deviceStore.isAvailable(DID1)); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 391 | verify(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 392 | assertInternalDeviceEvent(NID1, DID1, PIDA, description, message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 393 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 394 | // update from primary |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 395 | DeviceDescription description2 = |
| 396 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 397 | HW, SW2, SN, CID, A1); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 398 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 399 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 400 | DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); |
| 401 | assertEquals(DEVICE_UPDATED, event2.type()); |
| 402 | assertDevice(DID1, SW2, event2.subject()); |
| 403 | assertEquals(PID, event2.subject().providerId()); |
| 404 | assertAnnotationsEquals(event2.subject().annotations(), A1, A2); |
| 405 | assertTrue(deviceStore.isAvailable(DID1)); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 406 | verify(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 407 | assertInternalDeviceEvent(NID1, DID1, PID, description2, message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 408 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 409 | // no-op update from primary |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 410 | resetCommunicatorExpectingNoBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 411 | assertNull("No change expected", deviceStore.createOrUpdateDevice(PID, DID1, description2)); |
| 412 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 413 | verify(clusterCommunicator); |
| 414 | assertFalse("no broadcast expected", bcast.hasCaptured()); |
| 415 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 416 | // For now, Ancillary is ignored once primary appears |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 417 | resetCommunicatorExpectingNoBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 418 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 419 | assertNull("No change expected", deviceStore.createOrUpdateDevice(PIDA, DID1, description)); |
| 420 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 421 | verify(clusterCommunicator); |
| 422 | assertFalse("no broadcast expected", bcast.hasCaptured()); |
| 423 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 424 | // But, Ancillary annotations will be in effect |
| 425 | DeviceDescription description3 = |
| 426 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 427 | HW, SW1, SN, CID, A2_2); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 428 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 429 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 430 | DeviceEvent event3 = deviceStore.createOrUpdateDevice(PIDA, DID1, description3); |
| 431 | assertEquals(DEVICE_UPDATED, event3.type()); |
| 432 | // basic information will be the one from Primary |
| 433 | assertDevice(DID1, SW2, event3.subject()); |
| 434 | assertEquals(PID, event3.subject().providerId()); |
| 435 | // but annotation from Ancillary will be merged |
| 436 | assertAnnotationsEquals(event3.subject().annotations(), A1, A2, A2_2); |
| 437 | assertTrue(deviceStore.isAvailable(DID1)); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 438 | verify(clusterCommunicator); |
| 439 | // note: only annotation from PIDA is sent over the wire |
| 440 | assertInternalDeviceEvent(NID1, DID1, PIDA, description3, |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 441 | asList(union(A2, A2_2)), message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 442 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | |
| 446 | @Test |
| 447 | public final void testMarkOffline() { |
| 448 | |
| 449 | putDevice(DID1, SW1); |
| 450 | assertTrue(deviceStore.isAvailable(DID1)); |
| 451 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 452 | Capture<InternalDeviceEvent> message = new Capture<>(); |
| 453 | Capture<MessageSubject> subject = new Capture<>(); |
| 454 | Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>(); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 455 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 456 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 457 | DeviceEvent event = deviceStore.markOffline(DID1); |
| 458 | assertEquals(DEVICE_AVAILABILITY_CHANGED, event.type()); |
| 459 | assertDevice(DID1, SW1, event.subject()); |
| 460 | assertFalse(deviceStore.isAvailable(DID1)); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 461 | verify(clusterCommunicator); |
| 462 | // TODO: verify broadcast message |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 463 | assertTrue(message.hasCaptured()); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 464 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 465 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 466 | resetCommunicatorExpectingNoBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 467 | DeviceEvent event2 = deviceStore.markOffline(DID1); |
| 468 | assertNull("No change, no event", event2); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 469 | verify(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 470 | assertFalse(message.hasCaptured()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 471 | } |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 472 | |
| 473 | @Test |
| 474 | public final void testUpdatePorts() { |
| 475 | putDevice(DID1, SW1); |
| 476 | List<PortDescription> pds = Arrays.<PortDescription>asList( |
| 477 | new DefaultPortDescription(P1, true), |
| 478 | new DefaultPortDescription(P2, true) |
| 479 | ); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 480 | Capture<InternalDeviceEvent> message = new Capture<>(); |
| 481 | Capture<MessageSubject> subject = new Capture<>(); |
| 482 | Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>(); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 483 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 484 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 485 | List<DeviceEvent> events = deviceStore.updatePorts(PID, DID1, pds); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 486 | verify(clusterCommunicator); |
| 487 | // TODO: verify broadcast message |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 488 | assertTrue(message.hasCaptured()); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 489 | |
| 490 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); |
| 491 | for (DeviceEvent event : events) { |
| 492 | assertEquals(PORT_ADDED, event.type()); |
| 493 | assertDevice(DID1, SW1, event.subject()); |
| 494 | assertTrue("PortNumber is one of expected", |
| 495 | expectedPorts.remove(event.port().number())); |
| 496 | assertTrue("Port is enabled", event.port().isEnabled()); |
| 497 | } |
| 498 | assertTrue("Event for all expectedport appeared", expectedPorts.isEmpty()); |
| 499 | |
| 500 | |
| 501 | List<PortDescription> pds2 = Arrays.<PortDescription>asList( |
| 502 | new DefaultPortDescription(P1, false), |
| 503 | new DefaultPortDescription(P2, true), |
| 504 | new DefaultPortDescription(P3, true) |
| 505 | ); |
| 506 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 507 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 508 | events = deviceStore.updatePorts(PID, DID1, pds2); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 509 | verify(clusterCommunicator); |
| 510 | // TODO: verify broadcast message |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 511 | assertTrue(message.hasCaptured()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 512 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 513 | assertFalse("event should be triggered", events.isEmpty()); |
| 514 | for (DeviceEvent event : events) { |
| 515 | PortNumber num = event.port().number(); |
| 516 | if (P1.equals(num)) { |
| 517 | assertEquals(PORT_UPDATED, event.type()); |
| 518 | assertDevice(DID1, SW1, event.subject()); |
| 519 | assertFalse("Port is disabled", event.port().isEnabled()); |
| 520 | } else if (P2.equals(num)) { |
| 521 | fail("P2 event not expected."); |
| 522 | } else if (P3.equals(num)) { |
| 523 | assertEquals(PORT_ADDED, event.type()); |
| 524 | assertDevice(DID1, SW1, event.subject()); |
| 525 | assertTrue("Port is enabled", event.port().isEnabled()); |
| 526 | } else { |
| 527 | fail("Unknown port number encountered: " + num); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | List<PortDescription> pds3 = Arrays.<PortDescription>asList( |
| 532 | new DefaultPortDescription(P1, false), |
| 533 | new DefaultPortDescription(P2, true) |
| 534 | ); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 535 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 536 | events = deviceStore.updatePorts(PID, DID1, pds3); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 537 | verify(clusterCommunicator); |
| 538 | // TODO: verify broadcast message |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 539 | assertTrue(message.hasCaptured()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 540 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 541 | assertFalse("event should be triggered", events.isEmpty()); |
| 542 | for (DeviceEvent event : events) { |
| 543 | PortNumber num = event.port().number(); |
| 544 | if (P1.equals(num)) { |
| 545 | fail("P1 event not expected."); |
| 546 | } else if (P2.equals(num)) { |
| 547 | fail("P2 event not expected."); |
| 548 | } else if (P3.equals(num)) { |
| 549 | assertEquals(PORT_REMOVED, event.type()); |
| 550 | assertDevice(DID1, SW1, event.subject()); |
| 551 | assertTrue("Port was enabled", event.port().isEnabled()); |
| 552 | } else { |
| 553 | fail("Unknown port number encountered: " + num); |
| 554 | } |
| 555 | } |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | @Test |
| 559 | public final void testUpdatePortStatus() { |
| 560 | putDevice(DID1, SW1); |
| 561 | List<PortDescription> pds = Arrays.<PortDescription>asList( |
| 562 | new DefaultPortDescription(P1, true) |
| 563 | ); |
| 564 | deviceStore.updatePorts(PID, DID1, pds); |
| 565 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 566 | Capture<InternalPortStatusEvent> message = new Capture<>(); |
| 567 | Capture<MessageSubject> subject = new Capture<>(); |
| 568 | Capture<Function<InternalPortStatusEvent, byte[]>> encoder = new Capture<>(); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 569 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 570 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 571 | final DefaultPortDescription desc = new DefaultPortDescription(P1, false); |
| 572 | DeviceEvent event = deviceStore.updatePortStatus(PID, DID1, desc); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 573 | assertEquals(PORT_UPDATED, event.type()); |
| 574 | assertDevice(DID1, SW1, event.subject()); |
| 575 | assertEquals(P1, event.port().number()); |
| 576 | assertFalse("Port is disabled", event.port().isEnabled()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 577 | verify(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 578 | assertInternalPortStatusEvent(NID1, DID1, PID, desc, NO_ANNOTATION, message, subject, encoder); |
| 579 | assertTrue(message.hasCaptured()); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 580 | } |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 581 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 582 | @Test |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 583 | public final void testUpdatePortStatusAncillary() throws IOException { |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 584 | putDeviceAncillary(DID1, SW1); |
| 585 | putDevice(DID1, SW1); |
| 586 | List<PortDescription> pds = Arrays.<PortDescription>asList( |
| 587 | new DefaultPortDescription(P1, true, A1) |
| 588 | ); |
| 589 | deviceStore.updatePorts(PID, DID1, pds); |
| 590 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 591 | Capture<InternalPortStatusEvent> message = new Capture<>(); |
| 592 | Capture<MessageSubject> subject = new Capture<>(); |
| 593 | Capture<Function<InternalPortStatusEvent, byte[]>> encoder = new Capture<>(); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 594 | |
| 595 | // update port from primary |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 596 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
| 597 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 598 | final DefaultPortDescription desc1 = new DefaultPortDescription(P1, false, A1_2); |
| 599 | DeviceEvent event = deviceStore.updatePortStatus(PID, DID1, desc1); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 600 | assertEquals(PORT_UPDATED, event.type()); |
| 601 | assertDevice(DID1, SW1, event.subject()); |
| 602 | assertEquals(P1, event.port().number()); |
| 603 | assertAnnotationsEquals(event.port().annotations(), A1, A1_2); |
| 604 | assertFalse("Port is disabled", event.port().isEnabled()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 605 | verify(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 606 | assertInternalPortStatusEvent(NID1, DID1, PID, desc1, asList(A1, A1_2), message, subject, encoder); |
| 607 | assertTrue(message.hasCaptured()); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 608 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 609 | // update port from ancillary with no attributes |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 610 | resetCommunicatorExpectingNoBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 611 | final DefaultPortDescription desc2 = new DefaultPortDescription(P1, true); |
| 612 | DeviceEvent event2 = deviceStore.updatePortStatus(PIDA, DID1, desc2); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 613 | assertNull("Ancillary is ignored if primary exists", event2); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 614 | verify(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 615 | assertFalse(message.hasCaptured()); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 616 | |
| 617 | // but, Ancillary annotation update will be notified |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 618 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 619 | final DefaultPortDescription desc3 = new DefaultPortDescription(P1, true, A2); |
| 620 | DeviceEvent event3 = deviceStore.updatePortStatus(PIDA, DID1, desc3); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 621 | assertEquals(PORT_UPDATED, event3.type()); |
| 622 | assertDevice(DID1, SW1, event3.subject()); |
| 623 | assertEquals(P1, event3.port().number()); |
| 624 | assertAnnotationsEquals(event3.port().annotations(), A1, A1_2, A2); |
| 625 | assertFalse("Port is disabled", event3.port().isEnabled()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 626 | verify(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 627 | assertInternalPortStatusEvent(NID1, DID1, PIDA, desc3, asList(A2), message, subject, encoder); |
| 628 | assertTrue(message.hasCaptured()); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 629 | |
| 630 | // port only reported from Ancillary will be notified as down |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 631 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 632 | final DefaultPortDescription desc4 = new DefaultPortDescription(P2, true); |
| 633 | DeviceEvent event4 = deviceStore.updatePortStatus(PIDA, DID1, desc4); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 634 | assertEquals(PORT_ADDED, event4.type()); |
| 635 | assertDevice(DID1, SW1, event4.subject()); |
| 636 | assertEquals(P2, event4.port().number()); |
| 637 | assertAnnotationsEquals(event4.port().annotations()); |
| 638 | assertFalse("Port is disabled if not given from primary provider", |
| 639 | event4.port().isEnabled()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 640 | verify(clusterCommunicator); |
| 641 | // TODO: verify broadcast message content |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 642 | assertInternalPortStatusEvent(NID1, DID1, PIDA, desc4, NO_ANNOTATION, message, subject, encoder); |
| 643 | assertTrue(message.hasCaptured()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 644 | } |
| 645 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 646 | private void assertInternalPortStatusEvent(NodeId sender, |
| 647 | DeviceId did, |
| 648 | ProviderId pid, |
| 649 | DefaultPortDescription expectedDesc, |
| 650 | List<SparseAnnotations> expectedAnnotations, |
| 651 | Capture<InternalPortStatusEvent> actualEvent, |
| 652 | Capture<MessageSubject> actualSubject, |
| 653 | Capture<Function<InternalPortStatusEvent, byte[]>> actualEncoder) { |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 654 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 655 | assertTrue(actualEvent.hasCaptured()); |
| 656 | assertTrue(actualSubject.hasCaptured()); |
| 657 | assertTrue(actualEncoder.hasCaptured()); |
| 658 | |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 659 | assertEquals(GossipDeviceStoreMessageSubjects.PORT_STATUS_UPDATE, |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 660 | actualSubject.getValue()); |
| 661 | assertEquals(did, actualEvent.getValue().deviceId()); |
| 662 | assertEquals(pid, actualEvent.getValue().providerId()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 663 | assertPortDescriptionEquals(expectedDesc, expectedAnnotations, |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 664 | actualEvent.getValue().portDescription().value()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | private void assertPortDescriptionEquals( |
| 668 | PortDescription expectedDesc, |
| 669 | List<SparseAnnotations> expectedAnnotations, |
| 670 | PortDescription actual) { |
| 671 | |
| 672 | assertEquals(expectedDesc.portNumber(), actual.portNumber()); |
| 673 | assertEquals(expectedDesc.isEnabled(), actual.isEnabled()); |
| 674 | |
| 675 | assertAnnotationsEquals(actual.annotations(), |
| 676 | expectedAnnotations.toArray(new SparseAnnotations[0])); |
| 677 | } |
| 678 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 679 | private <T> void resetCommunicatorExpectingNoBroadcast( |
| 680 | Capture<T> message, |
| 681 | Capture<MessageSubject> subject, |
| 682 | Capture<Function<T, byte[]>> encoder) { |
| 683 | message.reset(); |
| 684 | subject.reset(); |
| 685 | encoder.reset(); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 686 | reset(clusterCommunicator); |
| 687 | replay(clusterCommunicator); |
| 688 | } |
| 689 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 690 | private <T> void resetCommunicatorExpectingSingleBroadcast( |
| 691 | Capture<T> message, |
| 692 | Capture<MessageSubject> subject, |
| 693 | Capture<Function<T, byte[]>> encoder) { |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 694 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 695 | message.reset(); |
| 696 | subject.reset(); |
| 697 | encoder.reset(); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 698 | reset(clusterCommunicator); |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 699 | clusterCommunicator.broadcast( |
| 700 | capture(message), |
| 701 | capture(subject), |
| 702 | capture(encoder)); |
| 703 | expectLastCall().once(); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 704 | replay(clusterCommunicator); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | @Test |
| 708 | public final void testGetPorts() { |
| 709 | putDevice(DID1, SW1); |
| 710 | putDevice(DID2, SW1); |
| 711 | List<PortDescription> pds = Arrays.<PortDescription>asList( |
| 712 | new DefaultPortDescription(P1, true), |
| 713 | new DefaultPortDescription(P2, true) |
| 714 | ); |
| 715 | deviceStore.updatePorts(PID, DID1, pds); |
| 716 | |
| 717 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); |
| 718 | List<Port> ports = deviceStore.getPorts(DID1); |
| 719 | for (Port port : ports) { |
| 720 | assertTrue("Port is enabled", port.isEnabled()); |
| 721 | assertTrue("PortNumber is one of expected", |
| 722 | expectedPorts.remove(port.number())); |
| 723 | } |
| 724 | assertTrue("Event for all expectedport appeared", expectedPorts.isEmpty()); |
| 725 | |
| 726 | |
| 727 | assertTrue("DID2 has no ports", deviceStore.getPorts(DID2).isEmpty()); |
| 728 | } |
| 729 | |
| 730 | @Test |
| 731 | public final void testGetPort() { |
| 732 | putDevice(DID1, SW1); |
| 733 | putDevice(DID2, SW1); |
| 734 | List<PortDescription> pds = Arrays.<PortDescription>asList( |
| 735 | new DefaultPortDescription(P1, true), |
| 736 | new DefaultPortDescription(P2, false) |
| 737 | ); |
| 738 | deviceStore.updatePorts(PID, DID1, pds); |
| 739 | |
| 740 | Port port1 = deviceStore.getPort(DID1, P1); |
| 741 | assertEquals(P1, port1.number()); |
| 742 | assertTrue("Port is enabled", port1.isEnabled()); |
| 743 | |
| 744 | Port port2 = deviceStore.getPort(DID1, P2); |
| 745 | assertEquals(P2, port2.number()); |
| 746 | assertFalse("Port is disabled", port2.isEnabled()); |
| 747 | |
| 748 | Port port3 = deviceStore.getPort(DID1, P3); |
| 749 | assertNull("P3 not expected", port3); |
| 750 | } |
| 751 | |
| 752 | @Test |
| 753 | public final void testRemoveDevice() { |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 754 | putDevice(DID1, SW1, A1); |
| 755 | List<PortDescription> pds = Arrays.<PortDescription>asList( |
| 756 | new DefaultPortDescription(P1, true, A2) |
| 757 | ); |
| 758 | deviceStore.updatePorts(PID, DID1, pds); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 759 | putDevice(DID2, SW1); |
| 760 | |
| 761 | assertEquals(2, deviceStore.getDeviceCount()); |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 762 | assertEquals(1, deviceStore.getPorts(DID1).size()); |
| 763 | assertAnnotationsEquals(deviceStore.getDevice(DID1).annotations(), A1); |
| 764 | assertAnnotationsEquals(deviceStore.getPort(DID1, P1).annotations(), A2); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 765 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 766 | Capture<InternalDeviceEvent> message = new Capture<>(); |
| 767 | Capture<MessageSubject> subject = new Capture<>(); |
| 768 | Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>(); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 769 | |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 770 | resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 771 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 772 | DeviceEvent event = deviceStore.removeDevice(DID1); |
| 773 | assertEquals(DEVICE_REMOVED, event.type()); |
| 774 | assertDevice(DID1, SW1, event.subject()); |
| 775 | |
| 776 | assertEquals(1, deviceStore.getDeviceCount()); |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 777 | assertEquals(0, deviceStore.getPorts(DID1).size()); |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 778 | verify(clusterCommunicator); |
| 779 | // TODO: verify broadcast message |
Madan Jampani | 2bfa94c | 2015-04-11 05:03:49 -0700 | [diff] [blame] | 780 | assertTrue(message.hasCaptured()); |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 781 | |
| 782 | // putBack Device, Port w/o annotation |
| 783 | putDevice(DID1, SW1); |
| 784 | List<PortDescription> pds2 = Arrays.<PortDescription>asList( |
| 785 | new DefaultPortDescription(P1, true) |
| 786 | ); |
| 787 | deviceStore.updatePorts(PID, DID1, pds2); |
| 788 | |
| 789 | // annotations should not survive |
| 790 | assertEquals(2, deviceStore.getDeviceCount()); |
| 791 | assertEquals(1, deviceStore.getPorts(DID1).size()); |
| 792 | assertAnnotationsEquals(deviceStore.getDevice(DID1).annotations()); |
| 793 | assertAnnotationsEquals(deviceStore.getPort(DID1, P1).annotations()); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | // If Delegates should be called only on remote events, |
| 797 | // then Simple* should never call them, thus not test required. |
| 798 | // TODO add test for Port events when we have them |
| 799 | @Ignore("Ignore until Delegate spec. is clear.") |
| 800 | @Test |
| 801 | public final void testEvents() throws InterruptedException { |
| 802 | final CountDownLatch addLatch = new CountDownLatch(1); |
| 803 | DeviceStoreDelegate checkAdd = new DeviceStoreDelegate() { |
| 804 | @Override |
| 805 | public void notify(DeviceEvent event) { |
| 806 | assertEquals(DEVICE_ADDED, event.type()); |
| 807 | assertDevice(DID1, SW1, event.subject()); |
| 808 | addLatch.countDown(); |
| 809 | } |
| 810 | }; |
| 811 | final CountDownLatch updateLatch = new CountDownLatch(1); |
| 812 | DeviceStoreDelegate checkUpdate = new DeviceStoreDelegate() { |
| 813 | @Override |
| 814 | public void notify(DeviceEvent event) { |
| 815 | assertEquals(DEVICE_UPDATED, event.type()); |
| 816 | assertDevice(DID1, SW2, event.subject()); |
| 817 | updateLatch.countDown(); |
| 818 | } |
| 819 | }; |
| 820 | final CountDownLatch removeLatch = new CountDownLatch(1); |
| 821 | DeviceStoreDelegate checkRemove = new DeviceStoreDelegate() { |
| 822 | @Override |
| 823 | public void notify(DeviceEvent event) { |
| 824 | assertEquals(DEVICE_REMOVED, event.type()); |
| 825 | assertDevice(DID1, SW2, event.subject()); |
| 826 | removeLatch.countDown(); |
| 827 | } |
| 828 | }; |
| 829 | |
| 830 | DeviceDescription description = |
| 831 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 832 | HW, SW1, SN, CID); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 833 | deviceStore.setDelegate(checkAdd); |
| 834 | deviceStore.createOrUpdateDevice(PID, DID1, description); |
| 835 | assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); |
| 836 | |
| 837 | |
| 838 | DeviceDescription description2 = |
| 839 | new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 840 | HW, SW2, SN, CID); |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 841 | deviceStore.unsetDelegate(checkAdd); |
| 842 | deviceStore.setDelegate(checkUpdate); |
| 843 | deviceStore.createOrUpdateDevice(PID, DID1, description2); |
| 844 | assertTrue("Update event fired", updateLatch.await(1, TimeUnit.SECONDS)); |
| 845 | |
| 846 | deviceStore.unsetDelegate(checkUpdate); |
| 847 | deviceStore.setDelegate(checkRemove); |
| 848 | deviceStore.removeDevice(DID1); |
| 849 | assertTrue("Remove event fired", removeLatch.await(1, TimeUnit.SECONDS)); |
| 850 | } |
| 851 | |
Yuta HIGUCHI | e8252bb | 2014-10-22 09:41:01 -0700 | [diff] [blame] | 852 | private final class TestMastershipService extends MastershipServiceAdapter { |
| 853 | @Override |
| 854 | public NodeId getMasterFor(DeviceId deviceId) { |
| 855 | return NID1; |
| 856 | } |
| 857 | } |
| 858 | |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 859 | private static final class TestGossipDeviceStore extends GossipDeviceStore { |
| 860 | |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 861 | public TestGossipDeviceStore( |
Yuta HIGUCHI | 093e83e | 2014-10-10 22:26:11 -0700 | [diff] [blame] | 862 | DeviceClockService deviceClockService, |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 863 | ClusterService clusterService, |
| 864 | ClusterCommunicationService clusterCommunicator) { |
Yuta HIGUCHI | 093e83e | 2014-10-10 22:26:11 -0700 | [diff] [blame] | 865 | this.deviceClockService = deviceClockService; |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 866 | this.clusterService = clusterService; |
Madan Jampani | 47c9373 | 2014-10-06 20:46:08 -0700 | [diff] [blame] | 867 | this.clusterCommunicator = clusterCommunicator; |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 868 | } |
Madan Jampani | 47c9373 | 2014-10-06 20:46:08 -0700 | [diff] [blame] | 869 | } |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 870 | |
Yuta HIGUCHI | 3e5d11a | 2014-11-04 14:16:44 -0800 | [diff] [blame] | 871 | private static final class TestClusterService extends StaticClusterService { |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 872 | |
| 873 | public TestClusterService() { |
Yuta HIGUCHI | 3e5d11a | 2014-11-04 14:16:44 -0800 | [diff] [blame] | 874 | localNode = ONOS1; |
Yuta HIGUCHI | 47c4088 | 2014-10-10 18:44:37 -0700 | [diff] [blame] | 875 | nodes.put(NID1, ONOS1); |
| 876 | nodeStates.put(NID1, ACTIVE); |
| 877 | |
| 878 | nodes.put(NID2, ONOS2); |
| 879 | nodeStates.put(NID2, ACTIVE); |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 880 | } |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 881 | } |
Yuta HIGUCHI | 67a527f | 2014-10-02 22:23:54 -0700 | [diff] [blame] | 882 | } |