Search in sources :

Example 1 with FlowObjectiveIntent

use of org.onosproject.net.intent.FlowObjectiveIntent in project onos by opennetworkinglab.

the class LinkCollectionIntentFlowObjectiveCompilerTest method singleHopTestForSp.

/**
 * Single point to multiple point intent with only one switch.
 * We test the proper compilation of sp2mp with
 * trivial selector, trivial treatment and 1 hop.
 */
@Test
public void singleHopTestForSp() {
    Set<Link> testLinks = ImmutableSet.of();
    Set<FilteredConnectPoint> ingress = ImmutableSet.of(new FilteredConnectPoint(of1p1, vlan100Selector));
    Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(of1p2, vlan100Selector), new FilteredConnectPoint(of1p3, vlan100Selector));
    LinkCollectionIntent intent = LinkCollectionIntent.builder().appId(appId).selector(ethDstSelector).treatment(treatment).links(testLinks).filteredIngressPoints(ingress).filteredEgressPoints(egress).applyTreatmentOnEgress(true).resourceGroup(resourceGroup2).build();
    List<Intent> result = compiler.compile(intent, Collections.emptyList());
    assertThat(result, hasSize(1));
    assertThat(result.get(0), instanceOf(FlowObjectiveIntent.class));
    FlowObjectiveIntent foIntent = (FlowObjectiveIntent) result.get(0);
    List<Objective> objectives = foIntent.objectives();
    assertThat(objectives, hasSize(3));
    TrafficSelector expectSelector = DefaultTrafficSelector.builder(ethDstSelector).matchInPort(PortNumber.portNumber(1)).matchVlanId(VLAN_100).build();
    List<TrafficTreatment> expectTreatments = ImmutableList.of(DefaultTrafficTreatment.builder().setOutput(PortNumber.portNumber(2)).build(), DefaultTrafficTreatment.builder().setOutput(PortNumber.portNumber(3)).build());
    /*
         * First set of objective
         */
    filteringObjective = (FilteringObjective) objectives.get(0);
    forwardingObjective = (ForwardingObjective) objectives.get(1);
    nextObjective = (NextObjective) objectives.get(2);
    PortCriterion inPortCriterion = (PortCriterion) expectSelector.getCriterion(Criterion.Type.IN_PORT);
    // test case for first filtering objective
    checkFiltering(filteringObjective, inPortCriterion, intent.priority(), null, appId, true, vlan100Selector.criteria());
    // test case for first next objective
    checkNext(nextObjective, BROADCAST, expectTreatments, expectSelector, ADD);
    // test case for first forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
}
Also used : FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Objective(org.onosproject.net.flowobjective.Objective) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test)

Example 2 with FlowObjectiveIntent

use of org.onosproject.net.intent.FlowObjectiveIntent in project onos by opennetworkinglab.

the class LinkCollectionIntentFlowObjectiveCompilerTest method singleHopTestForMp.

/**
 * Multiple point to single point intent with only one switch.
 * We test the proper compilation of mp2sp with
 * trivial selector, trivial treatment and 1 hop.
 */
@Test
public void singleHopTestForMp() {
    Set<Link> testLinks = ImmutableSet.of();
    Set<FilteredConnectPoint> ingress = ImmutableSet.of(new FilteredConnectPoint(of1p1, vlan100Selector), new FilteredConnectPoint(of1p2, vlan100Selector));
    Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(of1p3, vlan100Selector));
    LinkCollectionIntent intent = LinkCollectionIntent.builder().appId(appId).selector(ethDstSelector).treatment(treatment).links(testLinks).filteredIngressPoints(ingress).filteredEgressPoints(egress).build();
    List<Intent> result = compiler.compile(intent, Collections.emptyList());
    assertThat(result, hasSize(1));
    assertThat(result.get(0), instanceOf(FlowObjectiveIntent.class));
    FlowObjectiveIntent foIntent = (FlowObjectiveIntent) result.get(0);
    List<Objective> objectives = foIntent.objectives();
    assertThat(objectives, hasSize(6));
    TrafficSelector expectSelector = DefaultTrafficSelector.builder(ethDstSelector).matchInPort(PortNumber.portNumber(1)).matchVlanId(VLAN_100).build();
    TrafficTreatment expectTreatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.portNumber(3)).build();
    /*
         * First set of objective
         */
    filteringObjective = (FilteringObjective) objectives.get(0);
    forwardingObjective = (ForwardingObjective) objectives.get(1);
    nextObjective = (NextObjective) objectives.get(2);
    PortCriterion inPortCriterion = (PortCriterion) expectSelector.getCriterion(Criterion.Type.IN_PORT);
    // test case for first filtering objective
    checkFiltering(filteringObjective, inPortCriterion, intent.priority(), null, appId, true, vlan100Selector.criteria());
    // test case for first next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for first forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
    /*
         * Second set of objective
         */
    filteringObjective = (FilteringObjective) objectives.get(3);
    forwardingObjective = (ForwardingObjective) objectives.get(4);
    nextObjective = (NextObjective) objectives.get(5);
    expectSelector = DefaultTrafficSelector.builder(ethDstSelector).matchInPort(PortNumber.portNumber(2)).matchVlanId(VLAN_100).build();
    inPortCriterion = (PortCriterion) expectSelector.getCriterion(Criterion.Type.IN_PORT);
    // test case for first filtering objective
    checkFiltering(filteringObjective, inPortCriterion, intent.priority(), null, appId, true, vlan100Selector.criteria());
    // test case for first next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for first forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
}
Also used : FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Objective(org.onosproject.net.flowobjective.Objective) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test)

Example 3 with FlowObjectiveIntent

use of org.onosproject.net.intent.FlowObjectiveIntent in project onos by opennetworkinglab.

the class FlowObjectiveIntentInstallerTest method createFlowObjectiveIntents.

/**
 * Creates flow objective Intents.
 *
 * @return the flow objective intents
 */
private List<Intent> createFlowObjectiveIntents() {
    TrafficSelector selector = DefaultTrafficSelector.builder().matchInPort(CP1.port()).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(CP2.port()).build();
    FilteringObjective filt = DefaultFilteringObjective.builder().addCondition(selector.getCriterion(Criterion.Type.IN_PORT)).withPriority(DEFAULT_PRIORITY).fromApp(APP_ID).permit().add();
    NextObjective next = DefaultNextObjective.builder().withMeta(selector).addTreatment(treatment).makePermanent().withPriority(DEFAULT_PRIORITY).fromApp(APP_ID).withType(NextObjective.Type.SIMPLE).withId(NEXT_ID_1).add();
    ForwardingObjective fwd = DefaultForwardingObjective.builder().withSelector(selector).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().withFlag(ForwardingObjective.Flag.SPECIFIC).nextStep(NEXT_ID_1).add();
    List<Objective> objectives = ImmutableList.of(filt, next, fwd);
    List<DeviceId> deviceIds = ImmutableList.of(CP1.deviceId(), CP1.deviceId(), CP1.deviceId());
    List<NetworkResource> resources = ImmutableList.of(CP1.deviceId());
    Intent intent = new FlowObjectiveIntent(APP_ID, KEY1, deviceIds, objectives, resources, RG1);
    return ImmutableList.of(intent);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DeviceId(org.onosproject.net.DeviceId) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) NetworkResource(org.onosproject.net.NetworkResource) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective)

Example 4 with FlowObjectiveIntent

use of org.onosproject.net.intent.FlowObjectiveIntent in project onos by opennetworkinglab.

the class FlowObjectiveIntentInstallerTest method testUninstallAndInstallIntent.

/**
 * Do both uninstall and install flow objective Intents.
 */
@Test
public void testUninstallAndInstallIntent() {
    List<Intent> intentsToUninstall = createFlowObjectiveIntents();
    List<Intent> intentsToInstall = createAnotherFlowObjectiveIntents();
    IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
    toInstall = IntentData.compiled(toInstall, intentsToInstall);
    IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.INSTALLED, new WallClockTimestamp());
    toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
    IntentOperationContext<FlowObjectiveIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    IntentOperationContext successContext = intentInstallCoordinator.successContext;
    assertEquals(successContext, operationContext);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Example 5 with FlowObjectiveIntent

use of org.onosproject.net.intent.FlowObjectiveIntent in project onos by opennetworkinglab.

the class FlowObjectiveIntentInstallerTest method testNoAnyIntentToApply.

/**
 * Nothing to uninstall or install.
 */
@Test
public void testNoAnyIntentToApply() {
    IntentData toInstall = null;
    IntentData toUninstall = null;
    IntentOperationContext<FlowObjectiveIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext<>(ImmutableList.of(), ImmutableList.of(), context);
    installer.apply(operationContext);
    IntentOperationContext successContext = intentInstallCoordinator.successContext;
    assertEquals(successContext, operationContext);
}
Also used : IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Aggregations

FlowObjectiveIntent (org.onosproject.net.intent.FlowObjectiveIntent)17 Intent (org.onosproject.net.intent.Intent)14 Test (org.junit.Test)11 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)11 NextObjective (org.onosproject.net.flowobjective.NextObjective)11 Objective (org.onosproject.net.flowobjective.Objective)11 FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)10 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)9 TrafficSelector (org.onosproject.net.flow.TrafficSelector)9 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)9 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)9 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)8 Link (org.onosproject.net.Link)7 DefaultLink (org.onosproject.net.DefaultLink)6 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)6 DeviceId (org.onosproject.net.DeviceId)5 IntentData (org.onosproject.net.intent.IntentData)5 IntentInstallationContext (org.onosproject.net.intent.IntentInstallationContext)4 IntentOperationContext (org.onosproject.net.intent.IntentOperationContext)4