use of org.batfish.z3.state.PreOut in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitPreOutEdge.
@Test
public void testVisitPreOutEdge() {
SynthesizerInput input = MockSynthesizerInput.builder().setArpTrueEdge(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(1), INTERFACE4, b(2)), NODE4, ImmutableMap.of(INTERFACE3, b(3))), INTERFACE2, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(4)))), VRF2, ImmutableMap.of(INTERFACE3, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(5))))), NODE2, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(6))))))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PreOutEdge.State.INSTANCE)));
// DestinationRouting
assertThat(rules, hasItem(new BasicRuleStatement(b(1), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE1, NODE3, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(2), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE1, NODE3, INTERFACE4))));
assertThat(rules, hasItem(new BasicRuleStatement(b(3), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE1, NODE4, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(4), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE2, NODE3, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(5), ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE3, NODE3, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(6), ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new PreOutEdge(NODE2, INTERFACE1, NODE3, INTERFACE3))));
}
use of org.batfish.z3.state.PreOut in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitNodeDropNoRoute.
@Test
public void testVisitNodeDropNoRoute() {
SynthesizerInput input = MockSynthesizerInput.builder().setRoutableIps(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, B1, VRF2, B2), NODE2, ImmutableMap.of(VRF1, B1, VRF2, B2))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeDropNoRoute.State.INSTANCE)));
// DestinationRouting
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B1), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new NodeDropNoRoute(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B2), ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new NodeDropNoRoute(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B1), ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new NodeDropNoRoute(NODE2))));
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(B2), ImmutableSet.of(new PostInVrf(NODE2, VRF2), new PreOut(NODE2)), new NodeDropNoRoute(NODE2))));
}
use of org.batfish.z3.state.PreOut in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitNodeDropNullRoute.
@Test
public void testVisitNodeDropNullRoute() {
SynthesizerInput input = MockSynthesizerInput.builder().setNullRoutedIps(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, B1, VRF2, B2), NODE2, ImmutableMap.of(VRF1, B1, VRF2, B2))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeDropNullRoute.State.INSTANCE)));
// DestinationRouting
assertThat(rules, hasItem(new BasicRuleStatement(B1, ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new NodeDropNullRoute(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(B2, ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new NodeDropNullRoute(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(B1, ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new NodeDropNullRoute(NODE2))));
assertThat(rules, hasItem(new BasicRuleStatement(B2, ImmutableSet.of(new PostInVrf(NODE2, VRF2), new PreOut(NODE2)), new NodeDropNullRoute(NODE2))));
}
use of org.batfish.z3.state.PreOut in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitNodeNeighborUnreachable.
@Test
public void testVisitNodeNeighborUnreachable() {
SynthesizerInput input = MockSynthesizerInput.builder().setNeighborUnreachable(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, b(1), INTERFACE2, b(2)), VRF2, ImmutableMap.of(INTERFACE3, b(3))), NODE2, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, b(4))))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeNeighborUnreachable.State.INSTANCE)));
assertThat(rules, hasItem(new BasicRuleStatement(b(1), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new NodeNeighborUnreachable(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(b(2), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new NodeNeighborUnreachable(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(b(3), ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new NodeNeighborUnreachable(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(b(4), ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new NodeNeighborUnreachable(NODE2))));
}
use of org.batfish.z3.state.PreOut in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitPreOut.
@Test
public void testVisitPreOut() {
SynthesizerInput input = MockSynthesizerInput.builder().setIpsByHostname(ImmutableMap.of(NODE1, ImmutableSet.of(IP1, IP2), NODE2, ImmutableSet.of(IP3, IP4))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PreOut.State.INSTANCE)));
// PostInNotMine
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP1), new IpWildcard(IP2)))), ImmutableSet.of(new PostIn(NODE1)), new PreOut(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP3), new IpWildcard(IP4)))), ImmutableSet.of(new PostIn(NODE2)), new PreOut(NODE2))));
}
Aggregations