Search in sources :

Example 1 with PreOut

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))));
}
Also used : PreOut(org.batfish.z3.state.PreOut) PreOutEdge(org.batfish.z3.state.PreOutEdge) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) PostInVrf(org.batfish.z3.state.PostInVrf) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 2 with PreOut

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))));
}
Also used : PreOut(org.batfish.z3.state.PreOut) NodeDropNoRoute(org.batfish.z3.state.NodeDropNoRoute) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) NotExpr(org.batfish.z3.expr.NotExpr) PostInVrf(org.batfish.z3.state.PostInVrf) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 3 with PreOut

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))));
}
Also used : PreOut(org.batfish.z3.state.PreOut) NodeDropNullRoute(org.batfish.z3.state.NodeDropNullRoute) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) PostInVrf(org.batfish.z3.state.PostInVrf) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 4 with PreOut

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))));
}
Also used : PreOut(org.batfish.z3.state.PreOut) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) NodeNeighborUnreachable(org.batfish.z3.state.NodeNeighborUnreachable) PostInVrf(org.batfish.z3.state.PostInVrf) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 5 with PreOut

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))));
}
Also used : IpWildcard(org.batfish.datamodel.IpWildcard) PostIn(org.batfish.z3.state.PostIn) PreOut(org.batfish.z3.state.PreOut) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) NotExpr(org.batfish.z3.expr.NotExpr) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Aggregations

MockSynthesizerInput (org.batfish.z3.MockSynthesizerInput)5 SynthesizerInput (org.batfish.z3.SynthesizerInput)5 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)5 RuleStatement (org.batfish.z3.expr.RuleStatement)5 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)5 PreOut (org.batfish.z3.state.PreOut)5 Test (org.junit.Test)5 PostInVrf (org.batfish.z3.state.PostInVrf)4 NotExpr (org.batfish.z3.expr.NotExpr)2 IpWildcard (org.batfish.datamodel.IpWildcard)1 NodeDropNoRoute (org.batfish.z3.state.NodeDropNoRoute)1 NodeDropNullRoute (org.batfish.z3.state.NodeDropNullRoute)1 NodeNeighborUnreachable (org.batfish.z3.state.NodeNeighborUnreachable)1 PostIn (org.batfish.z3.state.PostIn)1 PreOutEdge (org.batfish.z3.state.PreOutEdge)1