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());
}
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);
}
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);
}
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);
}
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)));
}
Aggregations