Search in sources :

Example 11 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainEndP2P.

/**
 * We test the proper compilation of a domain ending with a domain device.
 */
@Test
public void testCompilationDomainEndP2P() {
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d1p0, d2p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).constraints(domainConstraint).build();
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(2));
    DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
    ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
    assertThat(ingress, equalTo(d2p0));
    ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
    assertThat(egress, equalTo(d2p10));
    assertThat(domainIntent.links(), hasSize(0));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
    assertThat(rules, hasSize(1));
    sut.deactivate();
}
Also used : DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 12 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainStartP2P.

/**
 * We test the proper compilation of a domain starting with a domain device.
 */
@Test
public void testCompilationDomainStartP2P() {
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d2p0, d1p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).constraints(domainConstraint).build();
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(2));
    DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
    ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
    assertThat(ingress, equalTo(d2p10));
    ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
    assertThat(egress, equalTo(d2p0));
    assertThat(domainIntent.links(), hasSize(0));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
    assertThat(rules, hasSize(1));
    sut.deactivate();
}
Also used : DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 13 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainFullP2P.

/**
 * We test the proper compilation of a path fully inside of a domain.
 */
@Test
public void testCompilationDomainFullP2P() {
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d2p0, d4p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d4p10))).constraints(domainConstraint).build();
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
    ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
    assertThat(ingress, equalTo(d2p10));
    ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
    assertThat(egress, equalTo(d4p10));
    assertThat(domainIntent.links(), hasSize(1));
    sut.deactivate();
}
Also used : DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test)

Example 14 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationMultiHopDomainP2P.

/**
 * We test the proper compilation of a domain with two devices.
 */
@Test
public void testCompilationMultiHopDomainP2P() {
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(domainP2Plinks).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10))).constraints(domainConstraint).build();
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(2));
    DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
    ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
    assertThat(ingress, equalTo(d2p0));
    ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
    assertThat(egress, equalTo(d4p0));
    assertThat(domainIntent.links(), hasSize(1));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
    assertThat(rules, hasSize(2));
    sut.deactivate();
}
Also used : DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 15 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerP2PTest method testMplsEncapsulationForP2P.

/**
 * We test the proper compilation of p2p with the MPLS
 * encapsulation and trivial filtered points.
 */
@Test
public void testMplsEncapsulationForP2P() {
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).constraints(constraintsForMPLS).links(linksForMp2Sp).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10, mpls200Selector))).build();
    sut.activate();
    /*
         * We use the FIRST_FIT to simplify tests.
         */
    LinkCollectionCompiler.labelAllocator.setLabelSelection(LABEL_SELECTION);
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    assertThat(rules, hasSize(3));
    Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
    assertThat(rulesS1, hasSize(1));
    FlowRule ruleS1 = rulesS1.iterator().next();
    assertThat(ruleS1.selector(), is(DefaultTrafficSelector.builder(vlan100Selector).matchInPort(d1p10.port()).build()));
    assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().popVlan().pushMpls().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d1p0.port()).build()));
    Collection<FlowRule> rulesS2 = rules.stream().filter(rule -> rule.deviceId().equals(d2p0.deviceId())).collect(Collectors.toSet());
    assertThat(rulesS2, hasSize(1));
    FlowRule ruleS2 = rulesS2.iterator().next();
    assertThat(ruleS2.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p0.port()).matchMplsLabel(MplsLabel.mplsLabel(LABEL)).matchEthType(Ethernet.MPLS_UNICAST).build()));
    assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d2p1.port()).build()));
    Collection<FlowRule> rulesS3 = rules.stream().filter(rule -> rule.deviceId().equals(d3p0.deviceId())).collect(Collectors.toSet());
    assertThat(rulesS3, hasSize(1));
    FlowRule ruleS3 = rulesS3.iterator().next();
    assertThat(ruleS3.selector(), is(DefaultTrafficSelector.builder().matchInPort(d3p0.port()).matchMplsLabel(MplsLabel.mplsLabel(LABEL)).matchEthType(Ethernet.MPLS_UNICAST).build()));
    assertThat(ruleS3.treatment(), is(DefaultTrafficTreatment.builder().setMpls(((MplsCriterion) mpls200Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d3p10.port()).build()));
    sut.deactivate();
}
Also used : MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) APP_ID(org.onosproject.net.NetTestTools.APP_ID) CoreService(org.onosproject.core.CoreService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Is(org.hamcrest.core.Is) Ethernet(org.onlab.packet.Ethernet) DomainService(org.onosproject.net.domain.DomainService) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) Is.is(org.hamcrest.core.Is.is) Intent(org.onosproject.net.intent.Intent) Matchers.hasSize(org.hamcrest.Matchers.hasSize) LOCAL(org.onosproject.net.domain.DomainId.LOCAL) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MockResourceService(org.onosproject.net.resource.MockResourceService) Before(org.junit.Before) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) MplsLabel(org.onlab.packet.MplsLabel) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) VLAN_VID(org.onosproject.net.flow.criteria.Criterion.Type.VLAN_VID) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Test(org.junit.Test) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) EasyMock(org.easymock.EasyMock) Collectors(java.util.stream.Collectors) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) MPLS_LABEL(org.onosproject.net.flow.criteria.Criterion.Type.MPLS_LABEL) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Aggregations

FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)161 Test (org.junit.Test)101 Intent (org.onosproject.net.intent.Intent)101 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)92 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)87 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)80 TrafficSelector (org.onosproject.net.flow.TrafficSelector)65 ConnectPoint (org.onosproject.net.ConnectPoint)64 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)53 List (java.util.List)52 Collectors (java.util.stream.Collectors)52 VlanId (org.onlab.packet.VlanId)52 DeviceId (org.onosproject.net.DeviceId)50 FlowRule (org.onosproject.net.flow.FlowRule)50 DomainService (org.onosproject.net.domain.DomainService)48 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)48 ImmutableSet (com.google.common.collect.ImmutableSet)47 LOCAL (org.onosproject.net.domain.DomainId.LOCAL)47 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)47 Before (org.junit.Before)46