Search in sources :

Example 61 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class DefaultTopologyProviderTest method eventDriven.

@Test
public void eventDriven() throws InterruptedException, TimeoutException {
    assertEquals(1, topologyChangedCounts.awaitAdvanceInterruptibly(0, 1, TimeUnit.SECONDS));
    validateSubmission();
    deviceService.postEvent(new DeviceEvent(DEVICE_ADDED, device("z"), null));
    linkService.postEvent(new LinkEvent(LINK_ADDED, link("z", 1, "a", 4)));
    assertThat(topologyChangedCounts.awaitAdvanceInterruptibly(1, 1, TimeUnit.SECONDS), is(greaterThanOrEqualTo(2)));
    // Note: posting event, to trigger topologyChanged call,
    // but dummy topology will not change.
    validateSubmission();
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) LinkEvent(org.onosproject.net.link.LinkEvent) Test(org.junit.Test)

Example 62 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class NetworkConfigLinksProviderTest method testDeviceAvailabilityChanged.

/**
 * Tests changing device availability via an event.
 */
@Test
public void testDeviceAvailabilityChanged() {
    assertThat(providerService.vanishedDpid(), hasSize(0));
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, dev3));
    assertThat(providerService.vanishedDpid(), hasSize(0));
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED, dev3));
    assertThat(providerService.vanishedDpid(), hasSize(1));
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) Test(org.junit.Test)

Example 63 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class NetworkConfigLinksProviderTest method testAddDevice.

/**
 * Tests adding a new device via an event.
 */
@Test
public void testAddDevice() {
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, dev3));
    assertThat(provider.discoverers.entrySet(), hasSize(3));
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) Test(org.junit.Test)

Example 64 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class NetworkConfigLinksProviderTest method testRemovePort.

/**
 * Tests removing a port via an event.
 */
@Test
public void testRemovePort() {
    assertThat(provider.discoverers.entrySet(), hasSize(2));
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.PORT_ADDED, dev3, new DefaultPort(dev3, portNumber3, true)));
    assertThat(provider.discoverers.entrySet(), hasSize(3));
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.PORT_REMOVED, dev3, new DefaultPort(dev3, portNumber3, true)));
    assertThat(provider.discoverers.entrySet(), hasSize(3));
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 65 with DeviceEvent

use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.

the class SimpleDeviceStoreTest method testCreateOrUpdateDevice.

@Test
public final void testCreateOrUpdateDevice() {
    DeviceDescription description = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW1, SN, CID);
    DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description);
    assertEquals(DEVICE_ADDED, event.type());
    assertDevice(DID1, SW1, event.subject());
    DeviceDescription description2 = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW2, SN, CID);
    DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2);
    assertEquals(DEVICE_UPDATED, event2.type());
    assertDevice(DID1, SW2, event2.subject());
    assertNull("No change expected", deviceStore.createOrUpdateDevice(PID, DID1, description2));
}
Also used : DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) Test(org.junit.Test)

Aggregations

DeviceEvent (org.onosproject.net.device.DeviceEvent)77 Test (org.junit.Test)42 Device (org.onosproject.net.Device)26 DefaultDevice (org.onosproject.net.DefaultDevice)17 DefaultPort (org.onosproject.net.DefaultPort)17 PortDescription (org.onosproject.net.device.PortDescription)14 PortNumber (org.onosproject.net.PortNumber)11 Port (org.onosproject.net.Port)10 DefaultPortDescription (org.onosproject.net.device.DefaultPortDescription)10 ProviderId (org.onosproject.net.provider.ProviderId)10 ArrayList (java.util.ArrayList)8 ConnectPoint (org.onosproject.net.ConnectPoint)8 Timestamp (org.onosproject.store.Timestamp)8 MessageSubject (org.onosproject.store.cluster.messaging.MessageSubject)8 MastershipBasedTimestamp (org.onosproject.store.impl.MastershipBasedTimestamp)8 MultiValuedTimestamp (org.onosproject.store.service.MultiValuedTimestamp)8 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)8 BiFunction (java.util.function.BiFunction)7 Function (java.util.function.Function)7 DeviceDescription (org.onosproject.net.device.DeviceDescription)7