Search in sources :

Example 6 with DefaultHost

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

the class HostHandlerTest method testDualHomedHostUpdated.

@Test
public void testDualHomedHostUpdated() {
    Host host1 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC11, HOST_LOC21), Sets.newHashSet(HOST_IP11, HOST_IP12), false);
    Host host2 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC11, HOST_LOC21), Sets.newHashSet(HOST_IP11, HOST_IP21), false);
    Host host3 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC11, HOST_LOC21), Sets.newHashSet(HOST_IP13, HOST_IP14), false);
    // Add a dual-homed host with two locations and two IPs
    // Expect: add four new routing rules. Add two new bridging rules
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, host1));
    assertEquals(4, ROUTING_TABLE.size());
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP12.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP11.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP12.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)));
    // Update both host IPs
    // Expect: update routing rules with new IP. No change to bridging rule.
    hostHandler.processHostUpdatedEvent(new HostEvent(HostEvent.Type.HOST_UPDATED, host3, host1));
    assertEquals(4, ROUTING_TABLE.size());
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP12.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP13.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP14.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP11.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP12.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP13.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP14.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)));
    // Update one of the host IP to different subnet
    // Expect: update routing rule with new IP. No change to bridging rule.
    hostHandler.processHostUpdatedEvent(new HostEvent(HostEvent.Type.HOST_UPDATED, host2, host3));
    assertEquals(2, ROUTING_TABLE.size());
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP21.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP12.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP11.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP21.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP12.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)

Example 7 with DefaultHost

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

the class HostHandlerTest method testHostMoved.

@Test
public void testHostMoved() {
    Host host1 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC11), Sets.newHashSet(HOST_IP11), false);
    Host host2 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC21), Sets.newHashSet(HOST_IP11), false);
    Host host3 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC13), Sets.newHashSet(HOST_IP11), false);
    // Add a host
    // Expect: add one new routing rule, one new bridging rule
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, host1));
    assertEquals(1, ROUTING_TABLE.size());
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP21.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP13.toIpPrefix())));
    assertEquals(1, BRIDGING_TABLE.size());
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV1, HOST_MAC, INTF_VLAN_UNTAGGED)));
    assertNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV2, HOST_MAC, INTF_VLAN_UNTAGGED)));
    // Move the host to CP13, which has different subnet setting
    // Expect: remove routing rule. Change vlan in bridging rule.
    hostHandler.processHostMovedEvent(new HostEvent(HostEvent.Type.HOST_MOVED, host3, host1));
    assertEquals(0, ROUTING_TABLE.size());
    assertEquals(1, BRIDGING_TABLE.size());
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV1, HOST_MAC, INTF_VLAN_NATIVE)));
    assertNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV1, HOST_MAC, INTF_VLAN_UNTAGGED)));
    // Move the host to CP21, which has same subnet setting
    // Expect: add a new routing rule. Change vlan in bridging rule.
    hostHandler.processHostMovedEvent(new HostEvent(HostEvent.Type.HOST_MOVED, host2, host3));
    assertEquals(1, ROUTING_TABLE.size());
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP11.toIpPrefix())));
    assertEquals(1, BRIDGING_TABLE.size());
    assertNull(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)

Example 8 with DefaultHost

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

the class HostHandlerTest method testDualHomedHostMoveTransient.

@Test
public void testDualHomedHostMoveTransient() {
    Host host1 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC31, HOST_LOC41), Sets.newHashSet(HOST_IP11), false);
    Host host2 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC32, HOST_LOC41), Sets.newHashSet(HOST_IP11), false);
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, host1));
    // Mock DefaultRoutingHandler
    DefaultRoutingHandler mockDefaultRoutingHandler = createMock(DefaultRoutingHandler.class);
    hostHandler.srManager.defaultRoutingHandler = mockDefaultRoutingHandler;
    // Host moved from [1A/1, 1B/1] to [1A/2, 1B/1]
    // We should expect only one bridging flow and one routing flow programmed on 1A
    expect(mockDefaultRoutingHandler.populateBridging(DEV3, P2, HOST_MAC, HOST_VLAN_UNTAGGED)).andReturn(CompletableFuture.completedFuture(null)).once();
    expect(mockDefaultRoutingHandler.populateRoute(DEV3, HOST_IP11.toIpPrefix(), HOST_MAC, HOST_VLAN_UNTAGGED, P2, true)).andReturn(CompletableFuture.completedFuture(null)).once();
    replay(mockDefaultRoutingHandler);
    hostHandler.processHostMovedEvent(new HostEvent(HostEvent.Type.HOST_MOVED, host2, host1));
    verify(mockDefaultRoutingHandler);
}
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)

Example 9 with DefaultHost

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

the class HostHandlerTest method testDualHomedHostAddedOneByOne.

@Test
public void testDualHomedHostAddedOneByOne() {
    Host host1 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC31), Sets.newHashSet(HOST_IP11), false);
    Host host2 = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED, Sets.newHashSet(HOST_LOC31, HOST_LOC41), Sets.newHashSet(HOST_IP11), false);
    // Add a dual-homed host with one location
    // Expect: the pair link is utilized temporarily before the second location is discovered
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, host1));
    assertEquals(2, ROUTING_TABLE.size());
    assertEquals(P1, ROUTING_TABLE.get(new MockRoutingTableKey(DEV3, HOST_IP11.toIpPrefix())).portNumber);
    assertEquals(P9, ROUTING_TABLE.get(new MockRoutingTableKey(DEV4, HOST_IP11.toIpPrefix())).portNumber);
    assertEquals(2, BRIDGING_TABLE.size());
    assertEquals(P1, BRIDGING_TABLE.get(new MockBridgingTableKey(DEV3, HOST_MAC, INTF_VLAN_UNTAGGED)).portNumber);
    assertEquals(P9, BRIDGING_TABLE.get(new MockBridgingTableKey(DEV4, HOST_MAC, INTF_VLAN_UNTAGGED)).portNumber);
    // Expect probe to be sent out on pair device
    assertTrue(mockLocationProbingService.verifyProbe(host1, CP41, ProbeMode.DISCOVER));
    // Add the second location of dual-homed host
    // Expect: no longer use the pair link
    hostHandler.processHostMovedEvent(new HostEvent(HostEvent.Type.HOST_MOVED, host2, host1));
    assertEquals(2, ROUTING_TABLE.size());
    assertEquals(P1, ROUTING_TABLE.get(new MockRoutingTableKey(DEV3, HOST_IP11.toIpPrefix())).portNumber);
    assertEquals(P1, ROUTING_TABLE.get(new MockRoutingTableKey(DEV4, HOST_IP11.toIpPrefix())).portNumber);
    assertEquals(2, BRIDGING_TABLE.size());
    assertEquals(P1, BRIDGING_TABLE.get(new MockBridgingTableKey(DEV3, HOST_MAC, INTF_VLAN_UNTAGGED)).portNumber);
    assertEquals(P1, BRIDGING_TABLE.get(new MockBridgingTableKey(DEV4, HOST_MAC, INTF_VLAN_UNTAGGED)).portNumber);
}
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)

Example 10 with DefaultHost

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

the class HostHandlerTest method testEffectiveLocations.

@Test
public void testEffectiveLocations() {
    Host regularHost = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_TAGGED, Sets.newHashSet(HOST_LOC11, HOST_LOC12), Sets.newHashSet(HOST_IP11), false);
    Host auxHost = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_TAGGED, Sets.newHashSet(HOST_LOC11, HOST_LOC12), Sets.newHashSet(HOST_LOC21, HOST_LOC22), Sets.newHashSet(HOST_IP11), VlanId.NONE, EthType.EtherType.UNKNOWN.ethType(), false, false);
    assertEquals(Sets.newHashSet(HOST_LOC11, HOST_LOC12), hostHandler.effectiveLocations(regularHost));
    assertEquals(Sets.newHashSet(HOST_LOC21, HOST_LOC22), hostHandler.effectiveLocations(auxHost));
}
Also used : DefaultHost(org.onosproject.net.DefaultHost) Host(org.onosproject.net.Host) DefaultHost(org.onosproject.net.DefaultHost) 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