Search in sources :

Example 21 with HostEvent

use of org.onosproject.net.host.HostEvent in project onos by opennetworkinglab.

the class VplsManagerTest method hostRemoveEventTest.

/**
 * Trigger host event listener by HOST_REMOVED event.
 */
@Test
public void hostRemoveEventTest() {
    VplsData vplsData = vplsManager.createVpls(VPLS1, NONE);
    vplsManager.addInterface(vplsData, V100H1);
    HostEvent hostEvent = new HostEvent(HostEvent.Type.HOST_REMOVED, V100HOST1);
    hostService.postHostEvent(hostEvent);
    vplsData = vplsStore.getVpls(VPLS1);
    assertEquals(UPDATING, vplsData.state());
}
Also used : HostEvent(org.onosproject.net.host.HostEvent) VplsData(org.onosproject.vpls.api.VplsData) Test(org.junit.Test)

Example 22 with HostEvent

use of org.onosproject.net.host.HostEvent in project trellis-control by opennetworkinglab.

the class RouteHandlerTest method testSingleHomedToDualHomedSingleLeafPair.

@Test
public void testSingleHomedToDualHomedSingleLeafPair() {
    srManager.setInfraDeviceIds(List.of());
    testDualHomedSingleLocationFailSingleLeafPair();
    reset(srManager.deviceConfiguration);
    expect(srManager.deviceConfiguration.getBatchedSubnets(H3S.id())).andReturn(Lists.<Set<IpPrefix>>newArrayList(Sets.newHashSet(P1)));
    srManager.deviceConfiguration.addSubnet(CP2, P1);
    expectLastCall().once();
    replay(srManager.deviceConfiguration);
    HostEvent he = new HostEvent(HostEvent.Type.HOST_MOVED, H3D, H3S);
    routeHandler.processHostMovedEvent(he);
    assertEquals(2, ROUTING_TABLE.size());
    MockRoutingTableValue rtv1 = ROUTING_TABLE.get(new MockRoutingTableKey(CP1.deviceId(), P1));
    MockRoutingTableValue rtv2 = ROUTING_TABLE.get(new MockRoutingTableKey(CP2.deviceId(), P1));
    assertEquals(M3, rtv1.macAddress);
    assertEquals(M3, rtv2.macAddress);
    assertEquals(V3, rtv1.vlanId);
    assertEquals(V3, rtv2.vlanId);
    assertEquals(CP1.port(), rtv1.portNumber);
    assertEquals(CP2.port(), rtv2.portNumber);
    assertEquals(2, SUBNET_TABLE.size());
    assertTrue(SUBNET_TABLE.get(CP1).contains(P1));
    assertTrue(SUBNET_TABLE.get(CP2).contains(P1));
    verify(srManager.deviceConfiguration);
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) HostEvent(org.onosproject.net.host.HostEvent) Test(org.junit.Test)

Example 23 with HostEvent

use of org.onosproject.net.host.HostEvent in project trellis-control by opennetworkinglab.

the class RouteHandlerTest method testSingleHomedToDualHomed.

@Test
public void testSingleHomedToDualHomed() {
    testDualHomedSingleLocationFail();
    reset(srManager.deviceConfiguration);
    expect(srManager.deviceConfiguration.getBatchedSubnets(H3S.id())).andReturn(Lists.<Set<IpPrefix>>newArrayList(Sets.newHashSet(P1)));
    srManager.deviceConfiguration.addSubnet(CP2, P1);
    expectLastCall().once();
    replay(srManager.deviceConfiguration);
    HostEvent he = new HostEvent(HostEvent.Type.HOST_MOVED, H3D, H3S);
    routeHandler.processHostMovedEvent(he);
    assertEquals(2, ROUTING_TABLE.size());
    MockRoutingTableValue rtv1 = ROUTING_TABLE.get(new MockRoutingTableKey(CP1.deviceId(), P1));
    MockRoutingTableValue rtv2 = ROUTING_TABLE.get(new MockRoutingTableKey(CP2.deviceId(), P1));
    assertEquals(M3, rtv1.macAddress);
    assertEquals(M3, rtv2.macAddress);
    assertEquals(V3, rtv1.vlanId);
    assertEquals(V3, rtv2.vlanId);
    assertEquals(CP1.port(), rtv1.portNumber);
    assertEquals(CP2.port(), rtv2.portNumber);
    assertEquals(2, SUBNET_TABLE.size());
    assertTrue(SUBNET_TABLE.get(CP1).contains(P1));
    assertTrue(SUBNET_TABLE.get(CP2).contains(P1));
    verify(srManager.deviceConfiguration);
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) HostEvent(org.onosproject.net.host.HostEvent) Test(org.junit.Test)

Example 24 with HostEvent

use of org.onosproject.net.host.HostEvent in project trellis-control by opennetworkinglab.

the class RouteHandlerTest method testDualHomedSingleLocationFail.

// TODO Add test cases for two single homed next hop at same location
@Test
public void testDualHomedSingleLocationFail() {
    testOneDualHomedAdded();
    ROUTE_STORE.put(P1, Sets.newHashSet(RR3));
    reset(srManager.deviceConfiguration);
    expect(srManager.deviceConfiguration.getBatchedSubnets(H3D.id())).andReturn(Lists.<Set<IpPrefix>>newArrayList(Sets.newHashSet(P1)));
    srManager.deviceConfiguration.removeSubnet(CP2, P1);
    expectLastCall().once();
    replay(srManager.deviceConfiguration);
    HostEvent he = new HostEvent(HostEvent.Type.HOST_MOVED, H3S, H3D);
    routeHandler.processHostMovedEvent(he);
    // We do not remove the route on CP2. Instead, we let the subnet population overrides it
    assertEquals(2, ROUTING_TABLE.size());
    MockRoutingTableValue rtv1 = ROUTING_TABLE.get(new MockRoutingTableKey(CP1.deviceId(), P1));
    assertEquals(M3, rtv1.macAddress);
    assertEquals(V3, rtv1.vlanId);
    assertEquals(CP1.port(), rtv1.portNumber);
    MockRoutingTableValue rtv2 = ROUTING_TABLE.get(new MockRoutingTableKey(CP2.deviceId(), P1));
    assertEquals(M3, rtv2.macAddress);
    assertEquals(V3, rtv2.vlanId);
    assertEquals(CP2.port(), rtv2.portNumber);
    // ECMP route table hasn't changed
    assertEquals(1, SUBNET_TABLE.size());
    assertTrue(SUBNET_TABLE.get(CP1).contains(P1));
    verify(srManager.deviceConfiguration);
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) HostEvent(org.onosproject.net.host.HostEvent) Test(org.junit.Test)

Example 25 with HostEvent

use of org.onosproject.net.host.HostEvent in project trellis-control by opennetworkinglab.

the class HostHandlerTest method testDualHomedHostAdded.

@Test
public void testDualHomedHostAdded() {
    // Add a dual-homed host that has 2 locations
    // Expect: add two routing rules and two bridging rules
    Host subject = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC11, HOST_LOC21), Sets.newHashSet(HOST_IP11), false);
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, subject));
    assertEquals(2, ROUTING_TABLE.size());
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP11.toIpPrefix())));
    assertEquals(2, BRIDGING_TABLE.size());
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV1, HOST_MAC, INTF_VLAN_UNTAGGED)));
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV2, HOST_MAC, INTF_VLAN_UNTAGGED)));
}
Also used : DefaultHost(org.onosproject.net.DefaultHost) HostEvent(org.onosproject.net.host.HostEvent) Host(org.onosproject.net.Host) DefaultHost(org.onosproject.net.DefaultHost) Test(org.junit.Test)

Aggregations

HostEvent (org.onosproject.net.host.HostEvent)37 Test (org.junit.Test)29 Host (org.onosproject.net.Host)25 DefaultHost (org.onosproject.net.DefaultHost)22 IpPrefix (org.onlab.packet.IpPrefix)8 List (java.util.List)4 IpAddress (org.onlab.packet.IpAddress)4 MacAddress (org.onlab.packet.MacAddress)4 VplsData (org.onosproject.vpls.api.VplsData)4 Sets (com.google.common.collect.Sets)3 Optional (java.util.Optional)3 Set (java.util.Set)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ExecutionException (java.util.concurrent.ExecutionException)3 Collectors (java.util.stream.Collectors)3 VlanId (org.onlab.packet.VlanId)3 HostLocation (org.onosproject.net.HostLocation)3 ResolvedRoute (org.onosproject.routeservice.ResolvedRoute)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 Lists (com.google.common.collect.Lists)2