Search in sources :

Example 46 with MultiPointToSinglePointIntent

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);
}
Also used : InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 47 with MultiPointToSinglePointIntent

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);
}
Also used : InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 48 with MultiPointToSinglePointIntent

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;
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 49 with MultiPointToSinglePointIntent

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);
}
Also used : RouteEvent(org.onosproject.routeservice.RouteEvent) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 50 with MultiPointToSinglePointIntent

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);
}
Also used : RouteEvent(org.onosproject.routeservice.RouteEvent) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Aggregations

MultiPointToSinglePointIntent (org.onosproject.net.intent.MultiPointToSinglePointIntent)52 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)31 ConnectPoint (org.onosproject.net.ConnectPoint)25 Test (org.junit.Test)21 TrafficSelector (org.onosproject.net.flow.TrafficSelector)21 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)20 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)20 Intent (org.onosproject.net.intent.Intent)16 Key (org.onosproject.net.intent.Key)14 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)12 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)12 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)11 HashSet (java.util.HashSet)10 Constraint (org.onosproject.net.intent.Constraint)9 PartialFailureConstraint (org.onosproject.net.intent.constraint.PartialFailureConstraint)9 Interface (org.onosproject.net.intf.Interface)9 Map (java.util.Map)8 IpPrefix (org.onlab.packet.IpPrefix)8 MacAddress (org.onlab.packet.MacAddress)8 ResolvedRoute (org.onosproject.routeservice.ResolvedRoute)6