use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCompilerTest method testMultiEgressCompilation.
/**
* Tests multiple egress points that share a common path to the ingress
* point.
*/
@Test
public void testMultiEgressCompilation() {
FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
FilteredConnectPoint egressOne = new FilteredConnectPoint(new ConnectPoint(DID_3, PORT_2));
FilteredConnectPoint egressTwo = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
FilteredConnectPoint egressThree = new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2));
Set<FilteredConnectPoint> egress = Sets.newHashSet(egressOne, egressTwo, egressThree);
SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
assertThat(intent, is(notNullValue()));
final String[] hops = { S2 };
SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
assertThat(linkIntent.links(), hasSize(4));
assertThat(linkIntent.links(), linksHasPath(S1, S2));
assertThat(linkIntent.links(), linksHasPath(S2, S3));
assertThat(linkIntent.links(), linksHasPath(S2, S4));
assertThat(linkIntent.links(), linksHasPath(S2, S5));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCompilerTest method testTwoEgressCompilation.
/**
* Tests a simple topology where two egress points share some path segments
* and some path segments are not shared.
*/
@Test
public void testTwoEgressCompilation() {
FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
FilteredConnectPoint egressOne = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
FilteredConnectPoint egressTwo = new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2));
Set<FilteredConnectPoint> egress = Sets.newHashSet(egressOne, egressTwo);
SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
assertThat(intent, is(notNullValue()));
final String[] hops = { S2, S3 };
SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
assertThat(linkIntent.links(), hasSize(4));
assertThat(linkIntent.links(), linksHasPath(S1, S2));
assertThat(linkIntent.links(), linksHasPath(S2, S3));
assertThat(linkIntent.links(), linksHasPath(S3, S4));
assertThat(linkIntent.links(), linksHasPath(S3, S5));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCompilerTest method testSameDeviceCompilation.
/**
* Tests ingress and egress on the same device.
*/
@Test
public void testSameDeviceCompilation() {
FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
Set<FilteredConnectPoint> egress = Sets.newHashSet(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_2)), new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_3)));
SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
assertThat(intent, is(notNullValue()));
final String[] hops = {};
SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent, instanceOf(LinkCollectionIntent.class));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
assertThat(linkIntent.links(), hasSize(0));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCompilerTest method testPartialFailureConstraintSuccess.
/**
* Tests if all expected links are present when a partial failure
* constraint is used and one ingress is not present.
*/
@Test
public void testPartialFailureConstraintSuccess() {
FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2)), new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2)));
final List<Constraint> constraints = Collections.singletonList(new PartialFailureConstraint());
SinglePointToMultiPointIntent intent = makeIntent(ingress, egress, constraints);
String[] hops = { S3 };
SinglePointToMultiPointIntentCompiler compiler = makeCompiler(null, new IntentTestsMocks.FixedMP2MPMockPathService(hops), null);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent, instanceOf(LinkCollectionIntent.class));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
assertThat(linkIntent.links(), hasSize(2));
assertThat(linkIntent.links(), linksHasPath(S1, S3));
assertThat(linkIntent.links(), linksHasPath(S3, S4));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Aggregations