use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class AbstractIntentInstallerTest method createP2PIntent.
/**
* Creates point to point Intent for test.
*
* @return the point to point Intent
*/
public PointToPointIntent createP2PIntent() {
PointToPointIntent intent;
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
FilteredConnectPoint ingress = new FilteredConnectPoint(CP1);
FilteredConnectPoint egress = new FilteredConnectPoint(CP2);
intent = PointToPointIntent.builder().selector(selector).treatment(treatment).filteredIngressPoint(ingress).filteredEgressPoint(egress).appId(APP_ID).build();
return intent;
}
use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class AbstractIntentInstallerTest method createP2PIntentNonDisruptive.
/**
* Creates point to point Intent for testing non-disruptive reallocation.
*
* @return the point to point Intent
*/
public PointToPointIntent createP2PIntentNonDisruptive() {
PointToPointIntent intent;
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
FilteredConnectPoint ingress = new FilteredConnectPoint(CP1);
FilteredConnectPoint egress = new FilteredConnectPoint(CP4_1);
List<Constraint> constraints = ImmutableList.of(nonDisruptive());
intent = PointToPointIntent.builder().selector(selector).treatment(treatment).filteredIngressPoint(ingress).filteredEgressPoint(egress).constraints(constraints).appId(APP_ID).build();
return intent;
}
use of org.onosproject.net.flow.TrafficSelector 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);
}
use of org.onosproject.net.flow.TrafficSelector 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);
}
use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.
the class FlowRuleIntentInstallerTest method createFlowRuleIntentsNonDisruptive.
/**
* Generates FlowRuleIntents for testing non-disruptive reallocation.
*
* @return the FlowRuleIntents for test
*/
public List<Intent> createFlowRuleIntentsNonDisruptive() {
Map<ConnectPoint, ConnectPoint> portsAssociation = Maps.newHashMap();
portsAssociation.put(CP1, CP2);
portsAssociation.put(CP2_1, CP2_2);
portsAssociation.put(CP4_2, CP4_1);
List<FlowRule> flowRules = Lists.newArrayList();
for (ConnectPoint srcPoint : portsAssociation.keySet()) {
TrafficSelector selector = DefaultTrafficSelector.builder().matchInPhyPort(srcPoint.port()).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(portsAssociation.get(srcPoint).port()).build();
FlowRule flowRule = DefaultFlowRule.builder().forDevice(srcPoint.deviceId()).withSelector(selector).withTreatment(treatment).fromApp(APP_ID).withPriority(DEFAULT_PRIORITY).makePermanent().build();
flowRules.add(flowRule);
}
List<NetworkResource> resources = ImmutableList.of(S1_S2, S2_S4);
FlowRuleIntent intent = new FlowRuleIntent(APP_ID, KEY1, flowRules, resources, PathIntent.ProtectionType.PRIMARY, RG1);
List<Intent> flowRuleIntents = Lists.newArrayList();
flowRuleIntents.add(intent);
return flowRuleIntents;
}
Aggregations