Search in sources :

Example 71 with Intent

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

the class DomainIntentInstallerTest method testUninstall.

/**
 * Uninstall domain Intents.
 */
@Test
public void testUninstall() {
    List<Intent> intentsToUninstall = createDomainIntents();
    List<Intent> intentsToInstall = Lists.newArrayList();
    IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.WITHDRAWING, new WallClockTimestamp());
    IntentData toInstall = null;
    toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
    IntentOperationContext<DomainIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    assertEquals(intentInstallCoordinator.successContext, operationContext);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) DomainIntent(org.onosproject.net.domain.DomainIntent) Intent(org.onosproject.net.intent.Intent) DomainIntent(org.onosproject.net.domain.DomainIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Example 72 with Intent

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

the class FlowObjectiveIntentInstallerTest method createUninstallContext.

/**
 * Creates Intent operation context for uninstall Intents.
 *
 * @return the context
 */
private IntentOperationContext createUninstallContext() {
    List<Intent> intentsToUninstall = createFlowObjectiveIntents();
    List<Intent> intentsToInstall = Lists.newArrayList();
    IntentData toInstall = null;
    IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
    toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    return new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
}
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) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext)

Example 73 with Intent

use of org.onosproject.net.intent.Intent 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 74 with Intent

use of org.onosproject.net.intent.Intent 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 75 with Intent

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

the class FlowRuleIntentInstallerTest method testUninstallAndInstallNonDisruptive.

/**
 * Testing the non-disruptive reallocation.
 */
@Test
public void testUninstallAndInstallNonDisruptive() throws InterruptedException {
    installer.flowRuleService = flowRuleServiceNonDisruptive;
    List<Intent> intentsToInstall = createAnotherFlowRuleIntentsNonDisruptive();
    List<Intent> intentsToUninstall = createFlowRuleIntentsNonDisruptive();
    IntentData toInstall = new IntentData(createP2PIntentNonDisruptive(), IntentState.INSTALLING, new WallClockTimestamp());
    toInstall = IntentData.compiled(toInstall, intentsToInstall);
    IntentData toUninstall = new IntentData(createP2PIntentNonDisruptive(), IntentState.INSTALLED, new WallClockTimestamp());
    toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
    IntentOperationContext<FlowRuleIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    // A single FlowRule is evaluated for every non-disruptive stage
    TrafficSelector selector = DefaultTrafficSelector.builder().matchInPhyPort(CP1.port()).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(CP3.port()).build();
    FlowRule firstStageInstalledRule = DefaultFlowRule.builder().forDevice(CP1.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY - 1).makePermanent().build();
    // race conditions and failing builds
    synchronized (flowRuleServiceNonDisruptive) {
        while (!verifyFlowRule(ADD, firstStageInstalledRule)) {
            flowRuleServiceNonDisruptive.wait();
        }
    }
    assertTrue(flowRuleServiceNonDisruptive.flowRulesAdd.contains(firstStageInstalledRule));
    selector = DefaultTrafficSelector.builder().matchInPhyPort(CP4_2.port()).build();
    treatment = DefaultTrafficTreatment.builder().setOutput(CP4_1.port()).build();
    FlowRule secondStageUninstalledRule = DefaultFlowRule.builder().forDevice(CP4_1.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().build();
    synchronized (flowRuleServiceNonDisruptive) {
        while (!verifyFlowRule(REMOVE, secondStageUninstalledRule)) {
            flowRuleServiceNonDisruptive.wait();
        }
    }
    assertTrue(flowRuleServiceNonDisruptive.flowRulesRemove.contains(secondStageUninstalledRule));
    selector = DefaultTrafficSelector.builder().matchInPhyPort(CP4_3.port()).build();
    treatment = DefaultTrafficTreatment.builder().setOutput(CP4_1.port()).build();
    FlowRule thirdStageInstalledRule = DefaultFlowRule.builder().forDevice(CP4_1.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().build();
    synchronized (flowRuleServiceNonDisruptive) {
        while (!verifyFlowRule(ADD, thirdStageInstalledRule)) {
            flowRuleServiceNonDisruptive.wait();
        }
    }
    assertTrue(flowRuleServiceNonDisruptive.flowRulesAdd.contains(thirdStageInstalledRule));
    selector = DefaultTrafficSelector.builder().matchInPhyPort(CP2_1.port()).build();
    treatment = DefaultTrafficTreatment.builder().setOutput(CP2_2.port()).build();
    FlowRule lastStageUninstalledRule = DefaultFlowRule.builder().forDevice(CP2_1.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().build();
    synchronized (flowRuleServiceNonDisruptive) {
        while (!verifyFlowRule(REMOVE, lastStageUninstalledRule)) {
            flowRuleServiceNonDisruptive.wait();
        }
    }
    assertTrue(flowRuleServiceNonDisruptive.flowRulesRemove.contains(lastStageUninstalledRule));
    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) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Aggregations

Intent (org.onosproject.net.intent.Intent)282 Test (org.junit.Test)176 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)133 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)110 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)108 FlowRule (org.onosproject.net.flow.FlowRule)90 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)87 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)84 ConnectPoint (org.onosproject.net.ConnectPoint)78 DeviceId (org.onosproject.net.DeviceId)77 List (java.util.List)75 Collectors (java.util.stream.Collectors)71 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)70 PathIntent (org.onosproject.net.intent.PathIntent)70 Collection (java.util.Collection)60 VlanId (org.onlab.packet.VlanId)60 TrafficSelector (org.onosproject.net.flow.TrafficSelector)60 CoreService (org.onosproject.core.CoreService)59 Collections (java.util.Collections)57 ImmutableSet (com.google.common.collect.ImmutableSet)54