use of org.onosproject.net.config.NetworkConfigEvent in project onos by opennetworkinglab.
the class TestCodecService method testPushIntAppConfig.
@Test
public void testPushIntAppConfig() throws IOException {
IntReportConfig config = getIntReportConfig("/report-config.json");
NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, APP_ID, config, null, IntReportConfig.class);
networkConfigListener.event(event);
// We expected that the manager will store the device config which
// converted from the app config.
IntDeviceConfig expectedConfig = createIntDeviceConfig();
IntDeviceConfig actualConfig = manager.getConfig();
assertEquals(expectedConfig, actualConfig);
// Install watch subnets via netcfg
// In the report-config.json, there are 3 subnets we want to watch
// For subnet 0.0.0.0/0, the IntManager will create only one IntIntent with an empty selector.
Set<IntIntent> expectedIntIntents = Sets.newHashSet();
ConsistentMap<IntIntentId, IntIntent> intentMap = TestUtils.getField(manager, "intentMap");
IntIntent.Builder baseIntentBuilder = IntIntent.builder().withReportType(IntIntent.IntReportType.TRACKED_FLOW).withReportType(IntIntent.IntReportType.DROPPED_PACKET).withReportType(IntIntent.IntReportType.CONGESTED_QUEUE).withTelemetryMode(IntIntent.TelemetryMode.POSTCARD);
// Watch IP Src == subnet 1
TrafficSelector expectedSelector = DefaultTrafficSelector.builder().matchIPSrc(IpPrefix.valueOf(WATCHED_SUBNET_1)).build();
expectedIntIntents.add(baseIntentBuilder.withSelector(expectedSelector).build());
// Watch IP Dst == subnet 1
expectedSelector = DefaultTrafficSelector.builder().matchIPDst(IpPrefix.valueOf(WATCHED_SUBNET_1)).build();
expectedIntIntents.add(baseIntentBuilder.withSelector(expectedSelector).build());
// Watch IP Src == subnet 2
expectedSelector = DefaultTrafficSelector.builder().matchIPSrc(IpPrefix.valueOf(WATCHED_SUBNET_2)).build();
expectedIntIntents.add(baseIntentBuilder.withSelector(expectedSelector).build());
// Watch IP Dst == subnet 2
expectedSelector = DefaultTrafficSelector.builder().matchIPDst(IpPrefix.valueOf(WATCHED_SUBNET_2)).build();
expectedIntIntents.add(baseIntentBuilder.withSelector(expectedSelector).build());
// Any packets
expectedSelector = DefaultTrafficSelector.emptySelector();
expectedIntIntents.add(baseIntentBuilder.withSelector(expectedSelector).build());
// The INT intent installation order can be random, so we need to collect
// all expected INT intents and check if actual intent exists.
assertAfter(50, 100, () -> assertEquals(5, intentMap.size()));
intentMap.entrySet().forEach(entry -> {
IntIntent actualIntIntent = entry.getValue().value();
assertTrue(expectedIntIntents.contains(actualIntIntent));
});
}
use of org.onosproject.net.config.NetworkConfigEvent in project onos by opennetworkinglab.
the class ControlPlaneRedirectManagerTest method testUpdateNetworkConfig.
/**
* Tests adding while updating the networkConfig.
*/
@Test
public void testUpdateNetworkConfig() {
ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4));
List<InterfaceIpAddress> interfaceIpAddresses = new ArrayList<>();
interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24")));
interfaceIpAddresses.add(new InterfaceIpAddress(IpAddress.valueOf("2000::ff"), IpPrefix.valueOf("2000::ff/120")));
Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses, MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE);
interfaces.add(sw1Eth4);
EasyMock.reset(flowObjectiveService);
setUpFlowObjectiveService();
networkConfigListener.event(new NetworkConfigEvent(Type.CONFIG_UPDATED, dev3, RoutingService.ROUTER_CONFIG_CLASS));
networkConfigService.addListener(networkConfigListener);
verify(flowObjectiveService);
}
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 InterfaceManagerTest method testUpdateInterface.
@Test
public void testUpdateInterface() throws Exception {
ConnectPoint cp = createConnectPoint(1);
// Create an interface that is the same as the existing one, but adds a
// new IP address
Interface intf = createInterface(1);
List<InterfaceIpAddress> addresses = Lists.newArrayList(intf.ipAddressesList());
addresses.add(InterfaceIpAddress.valueOf("192.168.100.1/24"));
intf = new Interface(Interface.NO_INTERFACE_NAME, intf.connectPoint(), addresses, intf.mac(), intf.vlan());
// Create a new interface on the same connect point as the existing one
InterfaceIpAddress newAddr = InterfaceIpAddress.valueOf("192.168.101.1/24");
Interface newIntf = new Interface(Interface.NO_INTERFACE_NAME, cp, Collections.singletonList(newAddr), MacAddress.valueOf(101), VlanId.vlanId((short) 101));
Set<Interface> interfaces = Sets.newHashSet(intf, newIntf);
// New interface config updates the existing interface and adds a new
// interface to the same connect point
InterfaceConfig oldIc = new TestInterfaceConfig(cp, Sets.newHashSet(intf));
InterfaceConfig ic = new TestInterfaceConfig(cp, interfaces);
configs.put(cp, ic);
NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_UPDATED, cp, ic, oldIc, CONFIG_CLASS);
// Send in the event signalling the interfaces for this connect point
// have been updated
listener.event(event);
assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size());
assertEquals(interfaces, interfaceManager.getInterfacesByPort(cp));
}
Aggregations