Search in sources :

Example 36 with DefaultHost

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

the class IntManagerTest method testWithHostEvent.

/**
 * Test when receving an host event with IP address of the collector.
 */
@Test
public void testWithHostEvent() {
    testActivateWithConfig();
    Host host = new DefaultHost(new ProviderId("of", "foo"), HostId.hostId("00:00:00:00:00:01/None"), MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE, new HostLocation(ConnectPoint.fromString("device:leaf1/1"), 0), ImmutableSet.of(COLLECTOR_IP));
    HostListener listener = hostListener.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.getAvailableDevices()).andReturn(ImmutableList.of(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);
    HostEvent hostEvent = new HostEvent(HostEvent.Type.HOST_ADDED, host);
    listener.event(hostEvent);
    try {
        completableFuture.get(1, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        fail("Didn't get expected call within 1 second.");
    }
    verifyAll();
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) Host(org.onosproject.net.Host) DefaultHost(org.onosproject.net.DefaultHost) HostListener(org.onosproject.net.host.HostListener) TestUtils.getIntReportConfig(org.stratumproject.fabric.tna.utils.TestUtils.getIntReportConfig) DefaultHost(org.onosproject.net.DefaultHost) HostEvent(org.onosproject.net.host.HostEvent) CompletableFuture(java.util.concurrent.CompletableFuture) HostLocation(org.onosproject.net.HostLocation) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Aggregations

DefaultHost (org.onosproject.net.DefaultHost)36 Host (org.onosproject.net.Host)28 Test (org.junit.Test)27 HostEvent (org.onosproject.net.host.HostEvent)20 HostLocation (org.onosproject.net.HostLocation)13 IpAddress (org.onlab.packet.IpAddress)9 MacAddress (org.onlab.packet.MacAddress)8 ProviderId (org.onosproject.net.provider.ProviderId)6 VlanId (org.onlab.packet.VlanId)4 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)4 HostId (org.onosproject.net.HostId)4 JsonObject (com.eclipsesource.json.JsonObject)3 HashSet (java.util.HashSet)3 WebTarget (javax.ws.rs.client.WebTarget)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Before (org.junit.Before)3 Annotations (org.onosproject.net.Annotations)3 DeviceId (org.onosproject.net.DeviceId)2 TestUtils.getIntReportConfig (org.stratumproject.fabric.tna.utils.TestUtils.getIntReportConfig)2 JsonArray (com.eclipsesource.json.JsonArray)1