Search in sources :

Example 11 with DefaultPort

use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.

the class OpenstackSwitchingHostProviderTest method testProcessPortAddedForUpdate.

/**
 * Tests the process port added method for updating case.
 */
@Test
public void testProcessPortAddedForUpdate() {
    org.onosproject.net.Port addedPort = new DefaultPort(DEV1, P1, true, ANNOTATIONS);
    DeviceEvent addedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, addedPort);
    target.portAddedHelper(addedEvent);
    // org.onosproject.net.Port updatedPort = new DefaultPort(DEV1, P2, true, ANNOTATIONS);
    // DeviceEvent updatedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, updatedPort);
    target.portAddedHelper(addedEvent);
    HostId hostId = HostId.hostId(HOST_MAC);
    HostDescription hostDesc = new DefaultHostDescription(HOST_MAC, VlanId.NONE, new HostLocation(CP11, System.currentTimeMillis()), ImmutableSet.of(HOST_IP11), ANNOTATIONS);
    verifyHostResult(hostId, hostDesc);
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostLocation(org.onosproject.net.HostLocation) HostId(org.onosproject.net.HostId) DefaultPort(org.onosproject.net.DefaultPort) DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostDescription(org.onosproject.net.host.HostDescription) Test(org.junit.Test)

Example 12 with DefaultPort

use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.

the class OpenstackSwitchingHostProviderTest method testProcessPortRemoved.

@Test
public void testProcessPortRemoved() {
    org.onosproject.net.Port addedPort = new DefaultPort(DEV1, P1, true, ANNOTATIONS);
    DeviceEvent addedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, addedPort);
    target.portAddedHelper(addedEvent);
    org.onosproject.net.Port removedPort = new DefaultPort(DEV2, P1, true, ANNOTATIONS);
    DeviceEvent removedEvent = new DeviceEvent(DeviceEvent.Type.PORT_REMOVED, DEV2, removedPort);
    target.portRemovedHelper(removedEvent);
    assertNull(target.hostService.getHost(HostId.hostId(HOST_MAC)));
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 13 with DefaultPort

use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.

the class NetworkConfigLinksProviderTest method testAddPort.

/**
 * Tests adding a new port via an event.
 */
@Test
public void testAddPort() {
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.PORT_ADDED, 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 14 with DefaultPort

use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.

the class HostLocationProviderTest method removeHostByDevicePortDown.

@Test
public void removeHostByDevicePortDown() {
    provider.modified(CTX_FOR_REMOVE);
    testProcessor.process(new TestArpPacketContext(DEV1));
    testProcessor.process(new TestArpPacketContext(DEV4));
    Device device = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 1, providerService.locationRemoveCount);
    device = new DefaultDevice(ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 2, providerService.locationRemoveCount);
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) ChassisId(org.onlab.packet.ChassisId) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 15 with DefaultPort

use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.

the class DeviceEventTest method withoutTime.

@Override
@Test
public void withoutTime() {
    Device device = createDevice();
    Port port = new DefaultPort(device, PortNumber.portNumber(123), true);
    long before = System.currentTimeMillis();
    DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device, port);
    long after = System.currentTimeMillis();
    validateEvent(event, DeviceEvent.Type.DEVICE_ADDED, device, before, after);
}
Also used : Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Port(org.onosproject.net.Port) DefaultPort(org.onosproject.net.DefaultPort) AbstractEventTest(org.onosproject.event.AbstractEventTest) Test(org.junit.Test)

Aggregations

DefaultPort (org.onosproject.net.DefaultPort)33 Test (org.junit.Test)25 Port (org.onosproject.net.Port)21 Device (org.onosproject.net.Device)12 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)10 DefaultDevice (org.onosproject.net.DefaultDevice)8 DeviceEvent (org.onosproject.net.device.DeviceEvent)8 PortNumber (org.onosproject.net.PortNumber)7 Annotations (org.onosproject.net.Annotations)6 ConnectPoint (org.onosproject.net.ConnectPoint)5 DeviceId (org.onosproject.net.DeviceId)4 ProviderId (org.onosproject.net.provider.ProviderId)4 Iterator (java.util.Iterator)3 Frequency (org.onlab.util.Frequency)3 HostId (org.onosproject.net.HostId)3 PortDescription (org.onosproject.net.device.PortDescription)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2 Supplier (com.google.common.base.Supplier)2 Sets (com.google.common.collect.Sets)2