Search in sources :

Example 16 with IntentInstallationContext

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

the class FlowRuleIntentInstallerTest method testUninstallAndInstallUnchangedMissing.

/**
 * Do both install and uninstall Intents with same flow rules.  However, the flow rules do not exist
 * in the FlowRuleService.
 */
@Test
public void testUninstallAndInstallUnchangedMissing() {
    List<Intent> intentsToInstall = createFlowRuleIntents();
    List<Intent> intentsToUninstall = createFlowRuleIntents();
    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 17 with IntentInstallationContext

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

the class FlowRuleIntentInstallerTest method testUninstallAndInstallMissing.

/**
 * Do both install and uninstall Intents with different flow rules.  However, the flow rules do not exist
 * in the FlowRuleService.
 */
@Test
public void testUninstallAndInstallMissing() {
    List<Intent> intentsToInstall = createAnotherFlowRuleIntents();
    List<Intent> intentsToUninstall = createFlowRuleIntents();
    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);
    Set<FlowRule> expectedFlowRules = Sets.newHashSet();
    assertEquals(expectedFlowRules, flowRuleService.flowRulesRemove);
    expectedFlowRules = intentsToInstall.stream().map(intent -> (FlowRuleIntent) intent).map(FlowRuleIntent::flowRules).flatMap(Collection::stream).collect(Collectors.toSet());
    assertEquals(expectedFlowRules, flowRuleService.flowRulesAdd);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Collection(java.util.Collection) 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) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 18 with IntentInstallationContext

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

the class FlowRuleIntentInstallerTest method testNoAnyIntentToApply.

/**
 * Nothing to uninstall or install.
 */
@Test
public void testNoAnyIntentToApply() {
    IntentData toInstall = null;
    IntentData toUninstall = null;
    IntentOperationContext<FlowRuleIntent> 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);
    assertEquals(0, flowRuleService.flowRulesRemove.size());
    assertEquals(0, flowRuleService.flowRulesAdd.size());
    assertEquals(0, flowRuleService.flowRulesModify.size());
}
Also used : IntentData(org.onosproject.net.intent.IntentData) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 19 with IntentInstallationContext

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

the class FlowRuleIntentInstallerTest method testUninstallAndInstallSame.

/**
 * Do both install and uninstall Intents with same flow rule Intent.
 */
@Test
public void testUninstallAndInstallSame() {
    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);
    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(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 20 with IntentInstallationContext

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

the class FlowRuleIntentInstallerTest method testUninstallOnlyMissing.

/**
 * Uninstalls Intents only, no Intents to be install.  However, the flow rules do not exist
 * in the FlowRuleService.
 */
@Test
public void testUninstallOnlyMissing() {
    List<Intent> intentsToInstall = Lists.newArrayList();
    List<Intent> intentsToUninstall = createFlowRuleIntents();
    IntentData toInstall = null;
    IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.WITHDRAWING, 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(0, 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)

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