Search in sources :

Example 11 with Topology

use of org.batfish.datamodel.Topology in project batfish by batfish.

the class ElasticsearchDomainTest method testEsSubnetEdge.

@Test
public void testEsSubnetEdge() throws IOException {
    Map<String, Configuration> configurations = loadAwsConfigurations();
    Topology topology = CommonUtil.synthesizeTopology(configurations);
    // check that ES instance is a neighbor of both  subnets in which its interfaces are
    assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-073b8061", "subnet-073b8061"), new NodeInterfacePair("es-domain", "es-domain-subnet-073b8061"))));
    assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-1f315846", "subnet-1f315846"), new NodeInterfacePair("es-domain", "es-domain-subnet-1f315846"))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) NodeInterfacePair(org.batfish.datamodel.collections.NodeInterfacePair) Topology(org.batfish.datamodel.Topology) Edge(org.batfish.datamodel.Edge) Test(org.junit.Test)

Example 12 with Topology

use of org.batfish.datamodel.Topology in project batfish by batfish.

the class RdsInstanceTest method testRdsSubnetEdge.

@Test
public void testRdsSubnetEdge() throws IOException {
    Map<String, Configuration> configurations = loadAwsConfigurations();
    Topology topology = CommonUtil.synthesizeTopology(configurations);
    // check that RDS instance is a neighbor of both  subnets in which its interfaces are
    assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-073b8061", "subnet-073b8061"), new NodeInterfacePair("test-rds", "test-rds-subnet-073b8061"))));
    assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-1f315846", "subnet-1f315846"), new NodeInterfacePair("test-rds", "test-rds-subnet-1f315846"))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) NodeInterfacePair(org.batfish.datamodel.collections.NodeInterfacePair) Topology(org.batfish.datamodel.Topology) Edge(org.batfish.datamodel.Edge) Test(org.junit.Test)

Example 13 with Topology

use of org.batfish.datamodel.Topology in project batfish by batfish.

the class SynthesizerInputImplTest method testComputeNeighborUnreachable.

@Test
public void testComputeNeighborUnreachable() {
    Configuration node = _cb.build();
    Vrf vrf = _vb.setOwner(node).build();
    Interface iface1 = _ib.setOwner(node).setVrf(vrf).build();
    Interface iface2 = _ib.build();
    IpSpace ipSpace1 = Ip.ZERO;
    IpSpace ipSpace2 = Ip.MAX;
    IpSpaceMatchExpr m1 = new IpSpaceMatchExpr(ipSpace1, false, true);
    IpSpaceMatchExpr m2 = new IpSpaceMatchExpr(ipSpace2, false, true);
    SynthesizerInput inputWithoutDataPlane = _inputBuilder.setConfigurations(ImmutableMap.of(node.getName(), node)).build();
    SynthesizerInput inputWithDataPlane = _inputBuilder.setForwardingAnalysis(MockForwardingAnalysis.builder().setNeighborUnreachable(ImmutableMap.of(node.getName(), ImmutableMap.of(vrf.getName(), ImmutableMap.of(iface1.getName(), ipSpace1, iface2.getName(), ipSpace2)))).build()).setTopology(new Topology(ImmutableSortedSet.of())).build();
    assertThat(inputWithoutDataPlane, hasNeighborUnreachable(nullValue()));
    assertThat(inputWithDataPlane, hasNeighborUnreachable(equalTo(ImmutableMap.of(node.getHostname(), ImmutableMap.of(vrf.getName(), ImmutableMap.of(iface1.getName(), m1, iface2.getName(), m2))))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) IpSpace(org.batfish.datamodel.IpSpace) IpSpaceMatchExpr(org.batfish.z3.expr.IpSpaceMatchExpr) Vrf(org.batfish.datamodel.Vrf) Topology(org.batfish.datamodel.Topology) Interface(org.batfish.datamodel.Interface) Test(org.junit.Test)

Example 14 with Topology

use of org.batfish.datamodel.Topology in project batfish by batfish.

the class SynthesizerInputImplTest method testComputeIpsByHostname.

@Test
public void testComputeIpsByHostname() {
    Configuration c = _cb.build();
    Vrf v = _vb.setOwner(c).build();
    // Enabled but not flow sink. Should not appear in enabledFlowSinks.
    Ip ipEnabled1 = new Ip("1.1.1.1");
    Ip ipEnabled2 = new Ip("2.2.2.2");
    Ip ipDisabled = new Ip("3.3.3.3");
    // enabledInterface1
    _ib.setOwner(c).setVrf(v).setAddress(new InterfaceAddress(ipEnabled1, Prefix.MAX_PREFIX_LENGTH)).build();
    // enabledInterface1
    _ib.setAddress(new InterfaceAddress(ipEnabled2, Prefix.MAX_PREFIX_LENGTH)).build();
    // disabledInterface
    _ib.setAddress(new InterfaceAddress(ipDisabled, Prefix.MAX_PREFIX_LENGTH)).setActive(false).build();
    SynthesizerInput inputWithoutDataPlane = _inputBuilder.setConfigurations(ImmutableMap.of(c.getName(), c)).build();
    SynthesizerInput inputWithDataPlane = _inputBuilder.setForwardingAnalysis(MockForwardingAnalysis.builder().build()).setTopology(new Topology(ImmutableSortedSet.of())).build();
    assertThat(inputWithoutDataPlane, hasIpsByHostname(nullValue()));
    assertThat(inputWithDataPlane, hasIpsByHostname(equalTo(ImmutableMap.of(c.getName(), ImmutableSet.of(ipEnabled1, ipEnabled2)))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) InterfaceAddress(org.batfish.datamodel.InterfaceAddress) Ip(org.batfish.datamodel.Ip) Vrf(org.batfish.datamodel.Vrf) Topology(org.batfish.datamodel.Topology) Test(org.junit.Test)

Example 15 with Topology

use of org.batfish.datamodel.Topology in project batfish by batfish.

the class SynthesizerInputImplTest method testComputeEnabledEdges.

@Test
public void testComputeEnabledEdges() {
    Configuration srcNode = _cb.build();
    Configuration nextHop = _cb.build();
    Vrf srcVrf = _vb.setOwner(srcNode).build();
    Vrf nextHopVrf = _vb.setOwner(nextHop).build();
    Interface srcInterface = _ib.setOwner(srcNode).setVrf(srcVrf).build();
    Interface nextHopInterface = _ib.setOwner(nextHop).setVrf(nextHopVrf).build();
    Interface disabledNextHopInterface = _ib.setActive(false).build();
    Edge expectedEnabledEdge = new Edge(srcInterface, nextHopInterface);
    Edge expectedDisabledEdge = new Edge(srcInterface, disabledNextHopInterface);
    SynthesizerInput inputWithoutDataPlane = _inputBuilder.setConfigurations(ImmutableMap.of(srcNode.getName(), srcNode, nextHop.getName(), nextHop)).build();
    SynthesizerInput inputWithDataPlane = _inputBuilder.setForwardingAnalysis(MockForwardingAnalysis.builder().build()).setTopology(new Topology(ImmutableSortedSet.of(expectedEnabledEdge, expectedDisabledEdge))).build();
    assertThat(inputWithDataPlane, hasEnabledEdges(hasItem(expectedEnabledEdge)));
    assertThat(inputWithDataPlane, hasEnabledEdges(not(hasItem(expectedDisabledEdge))));
    assertThat(inputWithDataPlane, hasEnabledEdges(not(hasItem(expectedDisabledEdge))));
    assertThat(inputWithoutDataPlane, hasEnabledEdges(nullValue()));
}
Also used : Configuration(org.batfish.datamodel.Configuration) Vrf(org.batfish.datamodel.Vrf) Topology(org.batfish.datamodel.Topology) Edge(org.batfish.datamodel.Edge) SynthesizerInputMatchers.hasArpTrueEdge(org.batfish.z3.matchers.SynthesizerInputMatchers.hasArpTrueEdge) Interface(org.batfish.datamodel.Interface) Test(org.junit.Test)

Aggregations

Topology (org.batfish.datamodel.Topology)35 Configuration (org.batfish.datamodel.Configuration)27 Test (org.junit.Test)19 Edge (org.batfish.datamodel.Edge)17 Vrf (org.batfish.datamodel.Vrf)17 Interface (org.batfish.datamodel.Interface)13 Ip (org.batfish.datamodel.Ip)10 InterfaceAddress (org.batfish.datamodel.InterfaceAddress)8 HashMap (java.util.HashMap)7 SynthesizerInputMatchers.hasArpTrueEdge (org.batfish.z3.matchers.SynthesizerInputMatchers.hasArpTrueEdge)7 Set (java.util.Set)6 SortedSet (java.util.SortedSet)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 BatfishLogger (org.batfish.common.BatfishLogger)6 BdpAnswerElement (org.batfish.datamodel.answers.BdpAnswerElement)6 Map (java.util.Map)5 SortedMap (java.util.SortedMap)5 TreeSet (java.util.TreeSet)5 IpAccessList (org.batfish.datamodel.IpAccessList)5 NodeInterfacePair (org.batfish.datamodel.collections.NodeInterfacePair)5