Search in sources :

Example 1 with LINK_UPDATED

use of org.onosproject.net.link.LinkEvent.Type.LINK_UPDATED in project onos by opennetworkinglab.

the class ECLinkStoreTest method testEvents.

// If Delegates should be called only on remote events,
// then Simple* should never call them, thus not test required.
@Ignore("Ignore until Delegate spec. is clear.")
@Test
public final void testEvents() throws InterruptedException {
    final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
    final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
    final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
    final CountDownLatch addLatch = new CountDownLatch(1);
    LinkStoreDelegate checkAdd = event -> {
        assertEquals(LINK_ADDED, event.type());
        assertLink(linkId1, INDIRECT, event.subject());
        addLatch.countDown();
    };
    final CountDownLatch updateLatch = new CountDownLatch(1);
    LinkStoreDelegate checkUpdate = event -> {
        assertEquals(LINK_UPDATED, event.type());
        assertLink(linkId1, DIRECT, event.subject());
        updateLatch.countDown();
    };
    final CountDownLatch removeLatch = new CountDownLatch(1);
    LinkStoreDelegate checkRemove = event -> {
        assertEquals(LINK_REMOVED, event.type());
        assertLink(linkId1, DIRECT, event.subject());
        removeLatch.countDown();
    };
    linkStore.setDelegate(checkAdd);
    putLink(linkId1, INDIRECT);
    assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
    linkStore.unsetDelegate(checkAdd);
    linkStore.setDelegate(checkUpdate);
    putLink(linkId1, DIRECT);
    assertTrue("Update event fired", updateLatch.await(1, TimeUnit.SECONDS));
    linkStore.unsetDelegate(checkUpdate);
    linkStore.setDelegate(checkRemove);
    linkStore.removeLink(d1P1, d2P2);
    assertTrue("Remove event fired", removeLatch.await(1, TimeUnit.SECONDS));
}
Also used : LINK_ADDED(org.onosproject.net.link.LinkEvent.Type.LINK_ADDED) DeviceClockServiceAdapter(org.onosproject.net.device.DeviceClockServiceAdapter) PortNumber(org.onosproject.net.PortNumber) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) Link(org.onosproject.net.Link) DefaultControllerNode(org.onosproject.cluster.DefaultControllerNode) ConnectPoint(org.onosproject.net.ConnectPoint) LINK_REMOVED(org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED) INDIRECT(org.onosproject.net.Link.Type.INDIRECT) After(org.junit.After) Map(java.util.Map) MessageSubject(org.onosproject.store.cluster.messaging.MessageSubject) DeviceId.deviceId(org.onosproject.net.DeviceId.deviceId) LinkKey(org.onosproject.net.LinkKey) NodeId(org.onosproject.cluster.NodeId) LinkDescription(org.onosproject.net.link.LinkDescription) AfterClass(org.junit.AfterClass) LinkStoreDelegate(org.onosproject.net.link.LinkStoreDelegate) Set(java.util.Set) CountDownLatch(java.util.concurrent.CountDownLatch) DeviceClockService(org.onosproject.net.device.DeviceClockService) SparseAnnotations(org.onosproject.net.SparseAnnotations) ClusterCommunicationService(org.onosproject.store.cluster.messaging.ClusterCommunicationService) DeviceId(org.onosproject.net.DeviceId) DIRECT(org.onosproject.net.Link.Type.DIRECT) Iterables(com.google.common.collect.Iterables) BeforeClass(org.junit.BeforeClass) LinkEvent(org.onosproject.net.link.LinkEvent) HashMap(java.util.HashMap) ControllerNode(org.onosproject.cluster.ControllerNode) NetTestTools.assertAnnotationsEquals(org.onosproject.net.NetTestTools.assertAnnotationsEquals) Timestamp(org.onosproject.store.Timestamp) ACTIVE(org.onosproject.cluster.ControllerNode.State.ACTIVE) ExecutorService(java.util.concurrent.ExecutorService) LINK_UPDATED(org.onosproject.net.link.LinkEvent.Type.LINK_UPDATED) Before(org.junit.Before) IpAddress(org.onlab.packet.IpAddress) StaticClusterService(org.onosproject.store.cluster.StaticClusterService) ClusterMessageHandler(org.onosproject.store.cluster.messaging.ClusterMessageHandler) Test(org.junit.Test) ProviderId(org.onosproject.net.provider.ProviderId) MastershipBasedTimestamp(org.onosproject.store.impl.MastershipBasedTimestamp) EasyMock(org.easymock.EasyMock) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Ignore(org.junit.Ignore) EDGE(org.onosproject.net.Link.Type.EDGE) LinkStore(org.onosproject.net.link.LinkStore) MastershipServiceAdapter(org.onosproject.mastership.MastershipServiceAdapter) Assert(org.junit.Assert) Type(org.onosproject.net.Link.Type) LinkKey(org.onosproject.net.LinkKey) LinkStoreDelegate(org.onosproject.net.link.LinkStoreDelegate) CountDownLatch(java.util.concurrent.CountDownLatch) ConnectPoint(org.onosproject.net.ConnectPoint) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Iterables (com.google.common.collect.Iterables)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 EasyMock (org.easymock.EasyMock)1 After (org.junit.After)1 AfterClass (org.junit.AfterClass)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 IpAddress (org.onlab.packet.IpAddress)1 ControllerNode (org.onosproject.cluster.ControllerNode)1 ACTIVE (org.onosproject.cluster.ControllerNode.State.ACTIVE)1 DefaultControllerNode (org.onosproject.cluster.DefaultControllerNode)1