Search in sources :

Example 16 with NetworkConfigEvent

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

the class VplsConfigManagerTest method testReloadConfig.

/**
 * Reloads network configuration by sending a network config event.
 */
@Test
public void testReloadConfig() {
    NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, null, VplsAppConfig.class);
    ((TestConfigService) vplsConfigManager.configService).sendEvent(event);
    Collection<VplsData> vplss = vplsConfigManager.vpls.getAllVpls();
    assertEquals(2, vplss.size());
    VplsData expect = VplsData.of(VPLS1);
    expect.addInterfaces(ImmutableSet.of(V100H1, V100H2));
    expect.state(VplsData.VplsState.ADDED);
    assertTrue(vplss.contains(expect));
    expect = VplsData.of(VPLS2, EncapsulationType.VLAN);
    expect.addInterfaces(ImmutableSet.of(V200H1, V200H2));
    expect.state(VplsData.VplsState.ADDED);
    System.out.println(vplss);
    assertTrue(vplss.contains(expect));
}
Also used : NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VplsData(org.onosproject.vpls.api.VplsData) VplsTest(org.onosproject.vpls.VplsTest) Test(org.junit.Test)

Example 17 with NetworkConfigEvent

use of org.onosproject.net.config.NetworkConfigEvent in project fabric-tna by stratum.

the class IntManagerTest method testUpdateIntConfig.

/**
 * Test updating the INT configuration with the config listener.
 */
@Test
public void testUpdateIntConfig() {
    testActivateWithoutConfig();
    NetworkConfigListener listener = intConfigListener.getValue();
    CompletableFuture<Void> completableFuture = new CompletableFuture<>();
    reset(intProgrammable);
    expect(intProgrammable.setUpIntConfig(INT_CONFIG_2)).andAnswer(() -> {
        completableFuture.complete(null);
        return true;
    }).once();
    replay(intProgrammable);
    NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_UPDATED, APP_ID, INT_CONFIG_2, INT_CONFIG_1, IntReportConfig.class);
    assertTrue(listener.isRelevant(event));
    listener.event(event);
    try {
        completableFuture.get(1, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        fail("Didn't get expected call within 1 second.");
    }
    verifyAll();
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) ExecutionException(java.util.concurrent.ExecutionException) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 18 with NetworkConfigEvent

use of org.onosproject.net.config.NetworkConfigEvent in project fabric-tna by stratum.

the class IntManagerTest method testUpdateSrConfig.

/**
 * Test updating the segment routing device configuration with the config listener.
 */
@Test
public void testUpdateSrConfig() {
    testActivateWithoutConfig();
    NetworkConfigListener listener = srConfigListener.getValue();
    CompletableFuture<Void> completableFuture = new CompletableFuture<>();
    reset(intProgrammable, netcfgService, deviceService, mastershipService);
    expect(netcfgService.getConfig(APP_ID, IntReportConfig.class)).andReturn(INT_CONFIG_1).anyTimes();
    expect(intProgrammable.setUpIntConfig(INT_CONFIG_1)).andAnswer(() -> {
        completableFuture.complete(null);
        return true;
    }).once();
    expect(deviceService.getDevice(DEVICE_ID_1)).andReturn(mockDevice).anyTimes();
    expect(deviceService.isAvailable(DEVICE_ID_1)).andReturn(true).anyTimes();
    expect(mastershipService.isLocalMaster(DEVICE_ID_1)).andReturn(true).anyTimes();
    replay(intProgrammable, netcfgService, deviceService, mastershipService);
    NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, APP_ID, SR_CONFIG_1, null, SegmentRoutingDeviceConfig.class);
    assertTrue(listener.isRelevant(event));
    listener.event(event);
    try {
        completableFuture.get(1, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        fail("Didn't get expected call within 1 second.");
    }
    verifyAll();
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) TestUtils.getIntReportConfig(org.stratumproject.fabric.tna.utils.TestUtils.getIntReportConfig) ExecutionException(java.util.concurrent.ExecutionException) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) TimeoutException(java.util.concurrent.TimeoutException) 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