use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class PathIntentCompilerTest method testVlanEncapCompileEdgeVlan.
/**
* Tests the compilation behavior of the path intent compiler in case of
* VLAN {@link EncapsulationType} encapsulation constraint {@link EncapsulationConstraint}
* and edge communication. Ingress VLAN. Egress VLAN.
*/
@Test
public void testVlanEncapCompileEdgeVlan() {
sut.activate();
List<Intent> compiled = sut.compile(edgeIntentVlan, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
FlowRule rule = rules.stream().filter(x -> x.deviceId().equals(d1p2.deviceId())).findFirst().get();
verifyIdAndPriority(rule, d1p2.deviceId());
assertThat(rule.selector(), is(DefaultTrafficSelector.builder().matchInPort(d1p2.port()).matchVlanId(ingressVlan).build()));
assertThat(rule.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(egressVlan).setOutput(d1p3.port()).build()));
Set<L2ModificationInstruction.ModVlanIdInstruction> vlanMod = rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).map(x -> (L2ModificationInstruction.ModVlanIdInstruction) x).collect(Collectors.toSet());
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).collect(Collectors.toSet()), hasSize(1));
assertThat(vlanMod.iterator().next().vlanId(), is(egressVlan));
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanHeaderInstruction).collect(Collectors.toSet()), hasSize(0));
sut.deactivate();
}
use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class PathIntentCompilerTest method testVlanEncapCompileSingleHopIndirectIngressVlan.
/**
* Tests the compilation behavior of the path intent compiler in case of
* VLAN {@link EncapsulationType} encapsulation constraint {@link EncapsulationConstraint}
* and single-hop-indirect-link scenario. Ingress VLAN. No egress VLAN.
*/
@Test
public void testVlanEncapCompileSingleHopIndirectIngressVlan() {
sut.activate();
List<Intent> compiled = sut.compile(singleHopIndirectIntentIngressVlan, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
FlowRule rule = rules.stream().filter(x -> x.deviceId().equals(d2p2.deviceId())).findFirst().get();
verifyIdAndPriority(rule, d2p2.deviceId());
assertThat(rule.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p2.port()).matchVlanId(ingressVlan).build()));
assertThat(rule.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d2p3.port()).build()));
sut.deactivate();
}
use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class PathIntentCompilerTest method testVlanEncapCompileEdgeIngressVlan.
/**
* Tests the compilation behavior of the path intent compiler in case of
* VLAN {@link EncapsulationType} encapsulation constraint {@link EncapsulationConstraint}
* and edge communication. Ingress VLAN. No egress VLAN.
*/
@Test
public void testVlanEncapCompileEdgeIngressVlan() {
sut.activate();
List<Intent> compiled = sut.compile(edgeIntentIngressVlan, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
FlowRule rule = rules.stream().filter(x -> x.deviceId().equals(d1p2.deviceId())).findFirst().get();
verifyIdAndPriority(rule, d1p2.deviceId());
assertThat(rule.selector(), is(DefaultTrafficSelector.builder().matchInPort(d1p2.port()).matchVlanId(ingressVlan).build()));
assertThat(rule.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d1p3.port()).build()));
sut.deactivate();
}
use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class PathIntentCompilerTest method testVlanEncapCompileSingleHopDirectEgressVlan.
/**
* Tests the compilation behavior of the path intent compiler in case of
* VLAN {@link EncapsulationType} encapsulation constraint {@link EncapsulationConstraint}
* and single-hop-direct-link scenario. No ingress VLAN. Egress VLAN.
*/
@Test
public void testVlanEncapCompileSingleHopDirectEgressVlan() {
sut.activate();
List<Intent> compiled = sut.compile(singleHopDirectIntentEgressVlan, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
FlowRule rule = rules.stream().filter(x -> x.deviceId().equals(d2p4.deviceId())).findFirst().get();
verifyIdAndPriority(rule, d2p4.deviceId());
assertThat(rule.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p4.port()).build()));
assertThat(rule.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(egressVlan).setOutput(d2p5.port()).build()));
Set<L2ModificationInstruction.ModVlanIdInstruction> vlanMod = rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).map(x -> (L2ModificationInstruction.ModVlanIdInstruction) x).collect(Collectors.toSet());
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).collect(Collectors.toSet()), hasSize(1));
assertThat(vlanMod.iterator().next().vlanId(), is(egressVlan));
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanHeaderInstruction).collect(Collectors.toSet()), hasSize(0));
sut.deactivate();
}
use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class PathIntentCompilerTest method testVlanEncapCompileSingleHopIndirectNoVlan.
/**
* Tests the compilation behavior of the path intent compiler in case of
* VLAN {@link EncapsulationType} encapsulation constraint {@link EncapsulationConstraint}
* and single-hop-indirect-link scenario. No ingress VLAN. No egress VLAN.
*/
@Test
public void testVlanEncapCompileSingleHopIndirectNoVlan() {
sut.activate();
List<Intent> compiled = sut.compile(singleHopIndirectIntentNoVlan, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
FlowRule rule = rules.stream().filter(x -> x.deviceId().equals(d2p2.deviceId())).findFirst().get();
verifyIdAndPriority(rule, d2p2.deviceId());
assertThat(rule.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p2.port()).build()));
assertThat(rule.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d2p3.port()).build()));
sut.deactivate();
}
Aggregations