use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFibTest method testAddInterface.
/**
* Tests adding a new interface.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is withdrawn from the IntentService.
*/
@Test
public void testAddInterface() {
// Add a route first
testRouteAddToNoVlan();
// Create the new expected intent
MultiPointToSinglePointIntent addedIntent = createIntentToThreeSrcOneTwoFour(PREFIX1);
reset(intentSynchronizer);
intentSynchronizer.submit(eqExceptId(addedIntent));
expectLastCall().once();
replay(intentSynchronizer);
// Create the new interface and add notify it
Interface intf = new Interface("sw4-eth1", SW4_ETH1, Collections.singletonList(IIP4), MAC4, NO_VLAN);
InterfaceEvent intfEvent = new InterfaceEvent(InterfaceEvent.Type.INTERFACE_ADDED, intf);
interfaceListener.event(intfEvent);
verify(intentSynchronizer);
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFibTest method testRemoveEgressInterface.
/**
* Tests removing an existing egress interface.
*
* We first push an intent with destination sw3 and source sw1 and sw2. We
* then remove the egress interface on sw3.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is withdrawn from the IntentService.
*/
@Test
public void testRemoveEgressInterface() {
// Add a route first
testRouteAddToNoVlan();
// Create existing intent
MultiPointToSinglePointIntent removedIntent = createIntentToThreeSrcOneTwo(PREFIX1);
// Set up expectation
reset(intentSynchronizer);
// Setup the expected intents
intentSynchronizer.withdraw(eqExceptId(removedIntent));
replay(intentSynchronizer);
// Define the existing egress interface and remove it
Interface intf = new Interface("sw3-eth1", SW3_ETH1, Collections.singletonList(IIP3), MAC3, VlanId.NONE);
InterfaceEvent intfEvent = new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, intf);
interfaceListener.event(intfEvent);
verify(intentSynchronizer);
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFibTest method createIntentToThreeSrcOneTwo.
/*
* Builds a MultiPointToSinglePointIntent with dest sw3 (no VLAN Id) and src
* sw1, sw2.
*/
private MultiPointToSinglePointIntent createIntentToThreeSrcOneTwo(IpPrefix ipPrefix) {
// Build the expected treatment
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
treatmentBuilder.setEthDst(MAC3);
// Build the expected egress FilteredConnectPoint
FilteredConnectPoint egressFilteredCP = new FilteredConnectPoint(SW3_ETH1);
// Build the expected selectors
Set<FilteredConnectPoint> ingressFilteredCPs = Sets.newHashSet();
// Build the expected ingress FilteredConnectPoint for sw1
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchVlanId(VLAN10);
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPDst(ipPrefix);
FilteredConnectPoint ingressFilteredCP = new FilteredConnectPoint(SW1_ETH1, selector.build());
ingressFilteredCPs.add(ingressFilteredCP);
// Build the expected ingress FilteredConnectPoint for sw2
selector = DefaultTrafficSelector.builder();
selector.matchVlanId(VLAN20);
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPDst(ipPrefix);
ingressFilteredCP = new FilteredConnectPoint(SW2_ETH1, selector.build());
ingressFilteredCPs.add(ingressFilteredCP);
// Build the expected intent
MultiPointToSinglePointIntent intent = MultiPointToSinglePointIntent.builder().appId(APPID).key(Key.of(ipPrefix.toString(), APPID)).filteredIngressPoints(ingressFilteredCPs).filteredEgressPoint(egressFilteredCP).treatment(treatmentBuilder.build()).constraints(SdnIpFib.CONSTRAINTS).build();
return intent;
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFibTest method testRouteUpdatesToVlan.
/**
* Tests updating a route.
*
* We first add a route from a next-hop with no vlan. We then announce the
* same route from another next-hop with a vlan.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is submitted to the IntentService.
*/
@Test
public void testRouteUpdatesToVlan() {
// Add a route first to a destination with no VLAN
testRouteAddToNoVlan();
// Build the new route entries for prefix1 and prefix2
ResolvedRoute oldRoutePrefixOne = createRoute(PREFIX1, IP3, MAC3);
ResolvedRoute routePrefixOne = createRoute(PREFIX1, IP1, MAC1);
// Create the new expected intents
MultiPointToSinglePointIntent newPrefixOneIntent = createIntentToOne(PREFIX1);
// Set up test expectation
reset(intentSynchronizer);
// Setup the expected intents
intentSynchronizer.submit(eqExceptId(newPrefixOneIntent));
replay(intentSynchronizer);
// Send in the update events
routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_UPDATED, routePrefixOne, oldRoutePrefixOne));
verify(intentSynchronizer);
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SdnIpFibTest method testRouteUpdatesToNoVlan.
/**
* Tests updating a route.
*
* We first add a route from a next-hop with a vlan. We then announce the
* same route from another next-hop with no vlan.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is submitted to the IntentService.
*/
@Test
public void testRouteUpdatesToNoVlan() {
// Add a route first to a destination with no VLAN
testRouteAddToVlan();
// Build the new route entries for prefix1 and prefix2
ResolvedRoute oldRoutePrefix = createRoute(PREFIX2, IP1, MAC1);
ResolvedRoute routePrefix = createRoute(PREFIX2, IP3, MAC3);
// Create the new expected intents
MultiPointToSinglePointIntent newPrefixIntent = createIntentToThreeSrcOneTwo(PREFIX2);
// Set up test expectation
reset(intentSynchronizer);
// Setup the expected intents
intentSynchronizer.submit(eqExceptId(newPrefixIntent));
replay(intentSynchronizer);
// Send in the update events
routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_UPDATED, routePrefix, oldRoutePrefix));
verify(intentSynchronizer);
}
Aggregations