Search in sources :

Example 1 with LinkDiscovery

use of org.onosproject.provider.lldpcommon.LinkDiscovery in project onos by opennetworkinglab.

the class LldpLinkProviderTest method portSuppressedByDeviceAnnotationConfig.

/**
 * Checks that discovery on reconfigured switch are properly restarted.
 */
@Test
public void portSuppressedByDeviceAnnotationConfig() {
    // / When Device is configured with suppression:ON, Port also is same
    // add device in stub DeviceService with suppression configured
    deviceService.putDevice(device(DID3, DefaultAnnotations.builder().set(LldpLinkProvider.NO_LLDP, "true").build()));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
    // non-suppressed port added to suppressed device
    final long portno3 = 3L;
    deviceService.putPorts(DID3, port(DID3, portno3, true));
    deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID3, port(DID3, portno3, true)));
    // discovery on device is expected to be stopped
    LinkDiscovery linkDiscovery = provider.discoverers.get(DID3);
    if (linkDiscovery != null) {
        assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped());
    }
    // / When Device is reconfigured without suppression:OFF,
    // / Port should be included for discovery
    // update device in stub DeviceService without suppression configured
    deviceService.putDevice(device(DID3));
    // update the Port in stub DeviceService. (Port has reference to Device)
    deviceService.putPorts(DID3, port(DID3, portno3, true));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_UPDATED, DID3));
    // discovery should come back on
    assertFalse("Discoverer is expected to start", provider.discoverers.get(DID3).isStopped());
    assertTrue("Discoverer should contain the port there", provider.discoverers.get(DID3).containsPort(portno3));
}
Also used : LinkDiscovery(org.onosproject.provider.lldpcommon.LinkDiscovery) Test(org.junit.Test)

Example 2 with LinkDiscovery

use of org.onosproject.provider.lldpcommon.LinkDiscovery in project onos by opennetworkinglab.

the class LldpLinkProviderTest method switchSuppressByBlacklist.

@Test
public void switchSuppressByBlacklist() {
    // add device in stub DeviceService
    deviceService.putDevice(device(DID3));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
    // add deviveId to device blacklist
    deviceBlacklist.add(DID3);
    configListener.event(new NetworkConfigEvent(Type.CONFIG_ADDED, DID3, LinkDiscoveryFromDevice.class));
    assertAfter(EVENT_MS, () -> {
        // discovery helper for device is expected to be gone or stopped
        LinkDiscovery linkDiscovery = provider.discoverers.get(DID3);
        if (linkDiscovery != null) {
            assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped());
        }
    });
}
Also used : NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) LinkDiscovery(org.onosproject.provider.lldpcommon.LinkDiscovery) Test(org.junit.Test)

Example 3 with LinkDiscovery

use of org.onosproject.provider.lldpcommon.LinkDiscovery in project onos by opennetworkinglab.

the class LldpLinkProviderTest method portSuppressedByDeviceTypeConfig.

/**
 * Checks that discovery on reconfigured switch are properly restarted.
 */
@Test
public void portSuppressedByDeviceTypeConfig() {
    // / When Device is configured without suppression:OFF,
    // / Port should be included for discovery
    // add device in stub DeviceService without suppression configured
    deviceService.putDevice(device(DID1, Device.Type.SWITCH));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
    // non-suppressed port added to suppressed device
    final long portno3 = 3L;
    deviceService.putPorts(DID1, port(DID1, portno3, true));
    deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID1, port(DID1, portno3, true)));
    // add device in stub DeviceService with suppression configured
    deviceService.putDevice(device(DID2, Device.Type.ROADM));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID2));
    // non-suppressed port added to suppressed device
    final long portno4 = 4L;
    deviceService.putPorts(DID2, port(DID2, portno4, true));
    deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID2, port(DID2, portno4, true)));
    // discovery should succeed for this device
    assertFalse("Discoverer is expected to start", provider.discoverers.get(DID1).isStopped());
    assertTrue("Discoverer should contain the port there", provider.discoverers.get(DID1).containsPort(portno3));
    // discovery on device is expected to be stopped for this device
    LinkDiscovery linkDiscovery = provider.discoverers.get(DID2);
    if (linkDiscovery != null) {
        assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped());
    }
}
Also used : LinkDiscovery(org.onosproject.provider.lldpcommon.LinkDiscovery) Test(org.junit.Test)

Example 4 with LinkDiscovery

use of org.onosproject.provider.lldpcommon.LinkDiscovery in project onos by opennetworkinglab.

the class LldpLinkProviderTest method switchSuppressedByAnnotation.

/**
 * Checks that links on a reconfigured switch are properly removed.
 */
@Test
public void switchSuppressedByAnnotation() {
    // add device to stub DeviceService
    deviceService.putDevice(device(DID3));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
    assertFalse("Device not added", provider.discoverers.isEmpty());
    // update device in stub DeviceService with suppression config
    deviceService.putDevice(device(DID3, DefaultAnnotations.builder().set(LldpLinkProvider.NO_LLDP, "true").build()));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_UPDATED, DID3));
    // discovery on device is expected to be gone or stopped
    LinkDiscovery linkDiscovery = provider.discoverers.get(DID3);
    if (linkDiscovery != null) {
        assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped());
    }
}
Also used : LinkDiscovery(org.onosproject.provider.lldpcommon.LinkDiscovery) Test(org.junit.Test)

Example 5 with LinkDiscovery

use of org.onosproject.provider.lldpcommon.LinkDiscovery in project onos by opennetworkinglab.

the class LldpLinkProviderTest method switchRemove.

@Test
public void switchRemove() {
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_REMOVED, DID1));
    final LinkDiscovery linkDiscovery = provider.discoverers.get(DID1);
    if (linkDiscovery != null) {
        // If LinkDiscovery helper is there after DEVICE_REMOVED,
        // it should be stopped
        assertTrue("Discoverer is not stopped", linkDiscovery.isStopped());
    }
    assertTrue("Device is not gone.", vanishedDpid(DID1));
}
Also used : LinkDiscovery(org.onosproject.provider.lldpcommon.LinkDiscovery) Test(org.junit.Test)

Aggregations

LinkDiscovery (org.onosproject.provider.lldpcommon.LinkDiscovery)9 Test (org.junit.Test)6 Device (org.onosproject.net.Device)2 NetworkConfigEvent (org.onosproject.net.config.NetworkConfigEvent)2 LinkedList (java.util.LinkedList)1 LinkKey (org.onosproject.net.LinkKey)1