Search in sources :

Example 26 with IntentInstallationContext

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

the class FlowRuleIntentInstallerTest method testFailed.

/**
 * Test if the flow installation failed.
 */
@Test
public void testFailed() {
    installer.flowRuleService = new TestFailedFlowRuleService();
    List<Intent> intentsToUninstall = Lists.newArrayList();
    List<Intent> intentsToInstall = createFlowRuleIntents();
    IntentData toUninstall = null;
    IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
    toInstall = IntentData.compiled(toInstall, intentsToInstall);
    IntentOperationContext<FlowRuleIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    IntentOperationContext failedContext = intentInstallCoordinator.failedContext;
    assertEquals(failedContext, operationContext);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 27 with IntentInstallationContext

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

the class FlowRuleIntentInstallerTest method testRuleModify.

/**
 * Test intents with same match rules, should do modify instead of add.
 */
@Test
public void testRuleModify() {
    List<Intent> intentsToInstall = createFlowRuleIntents();
    List<Intent> intentsToUninstall = createFlowRuleIntentsWithSameMatch();
    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<FlowRuleIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    flowRuleService.load(operationContext.intentsToUninstall());
    installer.apply(operationContext);
    IntentOperationContext successContext = intentInstallCoordinator.successContext;
    assertEquals(successContext, operationContext);
    assertEquals(0, flowRuleService.flowRulesRemove.size());
    assertEquals(0, flowRuleService.flowRulesAdd.size());
    assertEquals(1, flowRuleService.flowRulesModify.size());
    FlowRuleIntent installedIntent = (FlowRuleIntent) intentsToInstall.get(0);
    assertEquals(flowRuleService.flowRulesModify.size(), installedIntent.flowRules().size());
    assertTrue(flowRuleService.flowRulesModify.containsAll(installedIntent.flowRules()));
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 28 with IntentInstallationContext

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

the class DomainIntentInstallerTest method testNoAnyIntentToApply.

/**
 * Nothing to uninstall or install.
 */
@Test
public void testNoAnyIntentToApply() {
    IntentData toInstall = null;
    IntentData toUninstall = null;
    IntentOperationContext<DomainIntent> 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) DomainIntent(org.onosproject.net.domain.DomainIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Example 29 with IntentInstallationContext

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

the class FlowRuleIntentInstallerTest method testUninstallAndInstallSameMissing.

/**
 * Do both install and uninstall Intents with same flow rule Intent. However, the flow rules do not exist
 * in the FlowRuleService.
 */
@Test
public void testUninstallAndInstallSameMissing() {
    List<Intent> intentsToInstall = createFlowRuleIntents();
    List<Intent> intentsToUninstall = intentsToInstall;
    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<FlowRuleIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    IntentOperationContext successContext = intentInstallCoordinator.successContext;
    assertEquals(successContext, operationContext);
    assertEquals(0, flowRuleService.flowRulesRemove.size());
    assertEquals(1, flowRuleService.flowRulesAdd.size());
    assertEquals(0, flowRuleService.flowRulesModify.size());
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 30 with IntentInstallationContext

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

the class VirtualIntentInstallCoordinator method success.

/**
 * Handles success operation context.
 *
 * @param context the operation context
 */
public void success(IntentOperationContext context) {
    IntentInstallationContext intentInstallationContext = context.intentInstallationContext();
    intentInstallationContext.removePendingContext(context);
    if (intentInstallationContext.isPendingContextsEmpty()) {
        finish(intentInstallationContext);
    }
}
Also used : IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext)

Aggregations

IntentInstallationContext (org.onosproject.net.intent.IntentInstallationContext)36 IntentOperationContext (org.onosproject.net.intent.IntentOperationContext)32 IntentData (org.onosproject.net.intent.IntentData)30 Test (org.junit.Test)28 Intent (org.onosproject.net.intent.Intent)28 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)26 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)14 PathIntent (org.onosproject.net.intent.PathIntent)13 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)5 FlowRule (org.onosproject.net.flow.FlowRule)5 ProtectionEndpointIntent (org.onosproject.net.intent.ProtectionEndpointIntent)5 Collection (java.util.Collection)4 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)4 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)4 TrafficSelector (org.onosproject.net.flow.TrafficSelector)4 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)4 ImmutableList (com.google.common.collect.ImmutableList)3 Lists (com.google.common.collect.Lists)3 Maps (com.google.common.collect.Maps)3 Sets (com.google.common.collect.Sets)3