use of org.openkilda.model.SwitchProperties in project open-kilda by telstra.
the class NetworkIslServiceTest method lookupSwitchCreateMockIfAbsent.
private Switch lookupSwitchCreateMockIfAbsent(SwitchId datapath, boolean multiTable) {
Switch entry = allocatedSwitches.get(datapath);
if (entry == null) {
entry = Switch.builder().switchId(datapath).status(SwitchStatus.ACTIVE).description("autogenerated switch mock").build();
SwitchProperties switchProperties = SwitchProperties.builder().switchObj(entry).supportedTransitEncapsulation(SwitchProperties.DEFAULT_FLOW_ENCAPSULATION_TYPES).multiTable(multiTable).build();
allocatedSwitches.put(datapath, entry);
when(switchRepository.findById(datapath)).thenReturn(Optional.of(entry));
when(switchPropertiesRepository.findBySwitchId(datapath)).thenReturn(Optional.of(switchProperties));
}
return entry;
}
use of org.openkilda.model.SwitchProperties in project open-kilda by telstra.
the class RuleManagerServiceRulesTest method shouldUseCorrectServiceRuleGeneratorsForSwitchInSingleTableMode.
@Test
public void shouldUseCorrectServiceRuleGeneratorsForSwitchInSingleTableMode() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
SwitchId switchId = sw.getSwitchId();
SwitchProperties switchProperties = buildSwitchProperties(sw, false);
List<RuleGenerator> generators = ruleManager.getServiceRuleGenerators(switchId, buildAdapter(switchId, switchProperties, new HashSet<>(), false));
assertEquals(7, generators.size());
assertTrue(generators.stream().anyMatch(g -> g instanceof TableDefaultRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof BroadCastDiscoveryRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof UniCastDiscoveryRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof DropDiscoveryLoopRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof BfdCatchRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof RoundTripLatencyRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof UnicastVerificationVxlanRuleGenerator));
}
use of org.openkilda.model.SwitchProperties in project open-kilda by telstra.
the class RuleManagerServiceRulesTest method shouldUseCorrectServiceRuleGeneratorsForSwitchInMultiTableModeWithSwitchArpAndLldp.
@Test
public void shouldUseCorrectServiceRuleGeneratorsForSwitchInMultiTableModeWithSwitchArpAndLldp() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
SwitchId switchId = sw.getSwitchId();
SwitchProperties switchProperties = buildSwitchProperties(sw, true, true, true);
List<RuleGenerator> generators = ruleManager.getServiceRuleGenerators(switchId, buildAdapter(switchId, switchProperties, new HashSet<>(), false));
assertEquals(24, generators.size());
assertTrue(generators.stream().anyMatch(g -> g instanceof BroadCastDiscoveryRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof UniCastDiscoveryRuleGenerator));
assertEquals(4, generators.stream().filter(g -> g instanceof TableDefaultRuleGenerator).count());
assertEquals(2, generators.stream().filter(g -> g instanceof TablePassThroughDefaultRuleGenerator).count());
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpPostIngressRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpPostIngressVxlanRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpPostIngressOneSwitchRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpPostIngressRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpPostIngressVxlanRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpPostIngressOneSwitchRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpTransitRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpInputPreDropRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpIngressRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpTransitRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpInputPreDropRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpIngressRuleGenerator));
}
use of org.openkilda.model.SwitchProperties in project open-kilda by telstra.
the class RuleManagerServiceRulesTest method shouldUseCorrectServiceRuleGeneratorsForSwitchInMultiTableModeWithAllRules.
@Test
public void shouldUseCorrectServiceRuleGeneratorsForSwitchInMultiTableModeWithAllRules() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
SwitchId switchId = sw.getSwitchId();
SwitchProperties switchProperties = buildSwitchProperties(sw, true, true, true, true, RttState.ENABLED);
List<RuleGenerator> generators = ruleManager.getServiceRuleGenerators(switchId, buildAdapter(switchId, switchProperties, Sets.newHashSet(ISL_PORT), true));
assertEquals(34, generators.size());
assertTrue(generators.stream().anyMatch(g -> g instanceof BroadCastDiscoveryRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof UniCastDiscoveryRuleGenerator));
assertEquals(4, generators.stream().filter(g -> g instanceof TableDefaultRuleGenerator).count());
assertEquals(2, generators.stream().filter(g -> g instanceof TablePassThroughDefaultRuleGenerator).count());
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpPostIngressRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpPostIngressVxlanRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpPostIngressOneSwitchRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpPostIngressRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpPostIngressVxlanRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpPostIngressOneSwitchRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpTransitRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpInputPreDropRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpIngressRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpTransitRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpInputPreDropRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpIngressRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof Server42FlowRttTurningRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof Server42FlowRttVxlanTurningRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof Server42FlowRttOutputVlanRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof Server42FlowRttOutputVxlanRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof Server42IslRttInputRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof Server42IslRttTurningRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof Server42IslRttOutputRuleGenerator));
}
use of org.openkilda.model.SwitchProperties in project open-kilda by telstra.
the class RuleManagerServiceRulesTest method shouldUseCorrectServiceRuleGeneratorsForSwitchInMultiTableMode.
@Test
public void shouldUseCorrectServiceRuleGeneratorsForSwitchInMultiTableMode() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
SwitchId switchId = sw.getSwitchId();
SwitchProperties switchProperties = buildSwitchProperties(sw, true);
List<RuleGenerator> generators = ruleManager.getServiceRuleGenerators(switchId, buildAdapter(switchId, switchProperties, new HashSet<>(), false));
assertEquals(18, generators.size());
assertTrue(generators.stream().anyMatch(g -> g instanceof BroadCastDiscoveryRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof UniCastDiscoveryRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof DropDiscoveryLoopRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof BfdCatchRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof RoundTripLatencyRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof UnicastVerificationVxlanRuleGenerator));
assertEquals(4, generators.stream().filter(g -> g instanceof TableDefaultRuleGenerator).count());
assertEquals(2, generators.stream().filter(g -> g instanceof TablePassThroughDefaultRuleGenerator).count());
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpPostIngressRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpPostIngressVxlanRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof LldpPostIngressOneSwitchRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpPostIngressRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpPostIngressVxlanRuleGenerator));
assertTrue(generators.stream().anyMatch(g -> g instanceof ArpPostIngressOneSwitchRuleGenerator));
}
Aggregations