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));
}
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());
}
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());
}
});
}
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));
}
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));
}
Aggregations