use of org.onosproject.net.intent.Constraint in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testSuggestedPathBandwidthConstrainedIntentSuccess.
/**
* Tests that requests with suggested path
* and with sufficient available bandwidth succeed.
*/
@Test
public void testSuggestedPathBandwidthConstrainedIntentSuccess() {
final double bpsTotal = 1000.0;
final double bpsToReserve = 100.0;
final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(bpsToReserve)));
String[] suggestedPathHops = { S1, S4, S5, S3 };
List<Link> suggestedPath = NetTestTools.createPath(suggestedPathHops).links();
final PointToPointIntent intent = makeIntentSuggestedPath(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), suggestedPath, constraints);
String[][] hops = { { S1, S2, S3 }, suggestedPathHops };
final PointToPointIntentCompiler compiler = makeCompilerSuggestedPath(hops, resourceService);
final List<Intent> compiledIntents = compiler.compile(intent, null);
assertThat(compiledIntents, Matchers.notNullValue());
assertThat(compiledIntents, hasSize(1));
assertThat("key is inherited", compiledIntents.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
}
use of org.onosproject.net.intent.Constraint in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testBandwidthConstrainedIntentAllocation.
/**
* Tests if bandwidth resources get allocated correctly. An intent with a
* key only is submitted.
*/
@Test
public void testBandwidthConstrainedIntentAllocation() {
final double bpsTotal = 1000.0;
String[] hops = { S1, S2, S3 };
final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(BPS_TO_RESERVE)));
final PointToPointIntent intent = makeIntent(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), constraints);
PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);
compiler.compile(intent, null);
Key intentKey = intent.key();
ResourceAllocation rAOne = new ResourceAllocation(RESOURCE_SW1_P1, intentKey);
ResourceAllocation rATwo = new ResourceAllocation(RESOURCE_SW1_P2, intentKey);
ResourceAllocation rAThree = new ResourceAllocation(RESOURCE_SW2_P1, intentKey);
ResourceAllocation rAFour = new ResourceAllocation(RESOURCE_SW2_P2, intentKey);
ResourceAllocation rAFive = new ResourceAllocation(RESOURCE_SW3_P1, intentKey);
ResourceAllocation rASix = new ResourceAllocation(RESOURCE_SW3_P2, intentKey);
Set<ResourceAllocation> expectedresourceAllocations = ImmutableSet.of(rAOne, rATwo, rAThree, rAFour, rAFive, rASix);
Set<ResourceAllocation> resourceAllocations = ImmutableSet.copyOf(resourceService.getResourceAllocations(intentKey));
assertThat(resourceAllocations, hasSize(6));
assertEquals(expectedresourceAllocations, resourceAllocations);
}
use of org.onosproject.net.intent.Constraint in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testTwoBandwidthConstrainedIntentAllocation.
/**
* Tests that bandwidth resources don't get allocated twice if the intent
* is submitted twice.
*/
@Test
public void testTwoBandwidthConstrainedIntentAllocation() {
final double bpsTotal = 1000.0;
String[] hops = { S1, S2, S3 };
final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(BPS_TO_RESERVE)));
final PointToPointIntent intent = makeIntent(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), constraints);
PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);
compiler.compile(intent, null);
// Resubmit the same intent
compiler.compile(intent, null);
Key intentKey = intent.key();
ResourceAllocation rAOne = new ResourceAllocation(RESOURCE_SW1_P1, intentKey);
ResourceAllocation rATwo = new ResourceAllocation(RESOURCE_SW1_P2, intentKey);
ResourceAllocation rAThree = new ResourceAllocation(RESOURCE_SW2_P1, intentKey);
ResourceAllocation rAFour = new ResourceAllocation(RESOURCE_SW2_P2, intentKey);
ResourceAllocation rAFive = new ResourceAllocation(RESOURCE_SW3_P1, intentKey);
ResourceAllocation rASix = new ResourceAllocation(RESOURCE_SW3_P2, intentKey);
Set<ResourceAllocation> expectedresourceAllocations = ImmutableSet.of(rAOne, rATwo, rAThree, rAFour, rAFive, rASix);
Set<ResourceAllocation> resourceAllocations = ImmutableSet.copyOf(resourceService.getResourceAllocations(intentKey));
assertThat(resourceAllocations, hasSize(6));
assertEquals(expectedresourceAllocations, resourceAllocations);
}
use of org.onosproject.net.intent.Constraint in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testRGBandwidthConstrainedIntentAllocation.
/**
* Tests if bandwidth resources get allocated correctly using the resource
* group. An intent with a resource group is submitted.
*/
@Test
public void testRGBandwidthConstrainedIntentAllocation() {
final double bpsTotal = 1000.0;
ResourceGroup resourceGroup = ResourceGroup.of(100);
String[] hops = { S1, S2, S3 };
final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(BPS_TO_RESERVE)));
final PointToPointIntent intent = makeIntent(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), constraints, resourceGroup);
PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);
compiler.compile(intent, null);
ResourceAllocation rAOne = new ResourceAllocation(RESOURCE_SW1_P1, resourceGroup);
ResourceAllocation rATwo = new ResourceAllocation(RESOURCE_SW1_P2, resourceGroup);
ResourceAllocation rAThree = new ResourceAllocation(RESOURCE_SW2_P1, resourceGroup);
ResourceAllocation rAFour = new ResourceAllocation(RESOURCE_SW2_P2, resourceGroup);
ResourceAllocation rAFive = new ResourceAllocation(RESOURCE_SW3_P1, resourceGroup);
ResourceAllocation rASix = new ResourceAllocation(RESOURCE_SW3_P2, resourceGroup);
Set<ResourceAllocation> expectedresourceAllocations = ImmutableSet.of(rAOne, rATwo, rAThree, rAFour, rAFive, rASix);
Set<ResourceAllocation> resourceAllocations = ImmutableSet.copyOf(resourceService.getResourceAllocations(resourceGroup));
assertThat(resourceAllocations, hasSize(6));
assertEquals(expectedresourceAllocations, resourceAllocations);
}
use of org.onosproject.net.intent.Constraint 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;
}
Aggregations