Search in sources :

Example 1 with NetworkConfigEvent

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));
    });
}
Also used : NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) IntDeviceConfig(org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig) IntIntent(org.onosproject.inbandtelemetry.api.IntIntent) IntIntentId(org.onosproject.inbandtelemetry.api.IntIntentId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IntReportConfig(org.onosproject.net.behaviour.inbandtelemetry.IntReportConfig) Test(org.junit.Test)

Example 2 with NetworkConfigEvent

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);
}
Also used : NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) ArrayList(java.util.ArrayList) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test)

Example 3 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 4 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 5 with NetworkConfigEvent

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));
}
Also used : InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) ConnectPoint(org.onosproject.net.ConnectPoint) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Test(org.junit.Test)

Aggregations

NetworkConfigEvent (org.onosproject.net.config.NetworkConfigEvent)16 Test (org.junit.Test)14 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 LinkKey (org.onosproject.net.LinkKey)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 IntIntent (org.onosproject.inbandtelemetry.api.IntIntent)1 IntIntentId (org.onosproject.inbandtelemetry.api.IntIntentId)1 DefaultPort (org.onosproject.net.DefaultPort)1 DeviceId (org.onosproject.net.DeviceId)1