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);
}
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()));
}
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);
}
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());
}
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);
}
}
Aggregations