Search in sources :

Example 6 with NetworkConfigEvent

use of org.onosproject.net.config.NetworkConfigEvent in project onos by opennetworkinglab.

the class VplsConfigManagerTest method testReloadConfigUpdateVpls.

/**
 * Updates VPLSs by sending new VPLS config.
 */
@Test
public void testReloadConfigUpdateVpls() {
    ((TestVpls) vplsConfigManager.vpls).initSampleData();
    VplsAppConfig vplsAppConfig = new VplsAppConfig();
    final ObjectMapper mapper = new ObjectMapper();
    final ConfigApplyDelegate delegate = new VplsAppConfigTest.MockCfgDelegate();
    JsonNode tree = null;
    try {
        tree = new ObjectMapper().readTree(TestConfigService.EMPTY_JSON_TREE);
    } catch (IOException e) {
        e.printStackTrace();
    }
    vplsAppConfig.init(APPID, APP_NAME, tree, mapper, delegate);
    VplsConfig vplsConfig = new VplsConfig(VPLS1, ImmutableSet.of(V100H1.name()), EncapsulationType.MPLS);
    vplsAppConfig.addVpls(vplsConfig);
    ((TestConfigService) vplsConfigManager.configService).setConfig(vplsAppConfig);
    NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, null, VplsAppConfig.class);
    ((TestConfigService) vplsConfigManager.configService).sendEvent(event);
    Collection<VplsData> vplss = vplsConfigManager.vpls.getAllVpls();
    assertEquals(1, vplss.size());
    VplsData expect = VplsData.of(VPLS1, EncapsulationType.MPLS);
    expect.addInterfaces(ImmutableSet.of(V100H1));
    expect.state(VplsData.VplsState.ADDED);
    assertTrue(vplss.contains(expect));
}
Also used : NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VplsData(org.onosproject.vpls.api.VplsData) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) VplsTest(org.onosproject.vpls.VplsTest) Test(org.junit.Test)

Example 7 with NetworkConfigEvent

use of org.onosproject.net.config.NetworkConfigEvent in project onos by opennetworkinglab.

the class VplsConfigManagerTest method testRemoveConfig.

/**
 * Remvoes all VPLS by sending CONFIG_REMOVED event.
 */
@Test
public void testRemoveConfig() {
    NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_REMOVED, null, VplsAppConfig.class);
    ((TestConfigService) vplsConfigManager.configService).sendEvent(event);
    Collection<VplsData> vplss = vplsConfigManager.vpls.getAllVpls();
    assertEquals(0, vplss.size());
}
Also used : NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VplsData(org.onosproject.vpls.api.VplsData) VplsTest(org.onosproject.vpls.VplsTest) Test(org.junit.Test)

Example 8 with NetworkConfigEvent

use of org.onosproject.net.config.NetworkConfigEvent 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 9 with NetworkConfigEvent

use of org.onosproject.net.config.NetworkConfigEvent in project onos by opennetworkinglab.

the class LldpLinkProviderTest method portSuppressedByPortBlacklist.

@Test
public void portSuppressedByPortBlacklist() {
    // add device in stub DeviceService without suppression configured
    deviceService.putDevice(device(DID3));
    deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
    final long portno3 = 3L;
    final Port port3 = port(DID3, portno3, true);
    final ConnectPoint cpDid3no3 = new ConnectPoint(DID3, PortNumber.portNumber(portno3));
    portBlacklist.add(cpDid3no3);
    // suppressed port added to non-suppressed device
    deviceService.putPorts(DID3, port3);
    deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID3, port3));
    configListener.event(new NetworkConfigEvent(Type.CONFIG_ADDED, cpDid3no3, LinkDiscoveryFromPort.class));
    // discovery helper should be there turned on
    assertFalse("Discoverer is expected to start", provider.discoverers.get(DID3).isStopped());
    // but port is not a discovery target
    assertFalse("Discoverer should not contain the port there", provider.discoverers.get(DID3).containsPort(portno3));
}
Also used : NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) Port(org.onosproject.net.Port) DefaultPort(org.onosproject.net.DefaultPort) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 10 with NetworkConfigEvent

use of org.onosproject.net.config.NetworkConfigEvent in project onos by opennetworkinglab.

the class NetworkConfigLinksProviderTest method testConfiguredLink.

/**
 * Tests discovery of an expected link.
 */
@Test
public void testConfiguredLink() {
    LinkKey key = LinkKey.linkKey(src, dst);
    configListener.event(new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, key, BasicLinkConfig.class));
    PacketContext pktCtx = new TestPacketContext(src, dst);
    testProcessor.process(pktCtx);
    assertThat(providerService.discoveredLinks().entrySet(), hasSize(1));
    DeviceId destination = providerService.discoveredLinks().get(dev1.id());
    assertThat(destination, notNullValue());
    LinkDescription linkDescription = providerService.discoveredLinkDescriptions().get(key);
    assertThat(linkDescription, notNullValue());
    assertThat(linkDescription.isExpected(), is(true));
}
Also used : LinkKey(org.onosproject.net.LinkKey) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) LinkDescription(org.onosproject.net.link.LinkDescription) DeviceId(org.onosproject.net.DeviceId) PacketContext(org.onosproject.net.packet.PacketContext) BasicLinkConfig(org.onosproject.net.config.basics.BasicLinkConfig) Test(org.junit.Test)

Aggregations

NetworkConfigEvent (org.onosproject.net.config.NetworkConfigEvent)18 Test (org.junit.Test)16 ConnectPoint (org.onosproject.net.ConnectPoint)5 VplsTest (org.onosproject.vpls.VplsTest)4 VplsData (org.onosproject.vpls.api.VplsData)4 Interface (org.onosproject.net.intf.Interface)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 LinkKey (org.onosproject.net.LinkKey)2 NetworkConfigListener (org.onosproject.net.config.NetworkConfigListener)2 BasicLinkConfig (org.onosproject.net.config.basics.BasicLinkConfig)2 InterfaceConfig (org.onosproject.net.config.basics.InterfaceConfig)2 InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)2 LinkDiscovery (org.onosproject.provider.lldpcommon.LinkDiscovery)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 VlanId (org.onlab.packet.VlanId)1