Search in sources :

Example 26 with StaticRoute

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

the class AbstractRibTest method testRepeatedAdd.

/**
 * Ensure that only one copy of a routes is stored, regardless of how many times we add it)
 */
@Test
public void testRepeatedAdd() {
    // Setup
    StaticRoute route = new StaticRoute(Prefix.parse("10.0.0.0/11"), Ip.ZERO, null, 0, 0);
    // Test
    for (int i = 0; i < 5; i++) {
        _rib.mergeRoute(route);
    }
    // Assertions
    // Ensure only one route is stored
    assertThat(_rib.getRoutes().size(), is(1));
    // Check that containsRoute works as expected for this simple case
    assertThat(_rib.containsRoute(route), is(true));
}
Also used : StaticRoute(org.batfish.datamodel.StaticRoute) Test(org.junit.Test)

Example 27 with StaticRoute

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

the class BdpDataPlanePluginTest method testStaticInterfaceRoutesWithoutEdge.

@Test
public void testStaticInterfaceRoutesWithoutEdge() {
    NetworkFactory nf = new NetworkFactory();
    Configuration c = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS).build();
    Vrf vrf = nf.vrfBuilder().setOwner(c).setName(DEFAULT_VRF_NAME).build();
    Interface i = nf.interfaceBuilder().setOwner(c).setVrf(vrf).setAddress(new InterfaceAddress("10.0.0.0/24")).setActive(true).build();
    StaticRoute srBoth = StaticRoute.builder().setNetwork(Prefix.parse("10.0.1.0/24")).setNextHopInterface(i.getName()).setNextHopIp(new Ip("10.0.0.1")).build();
    vrf.getStaticRoutes().add(srBoth);
    StaticRoute srJustInterface = StaticRoute.builder().setNetwork(Prefix.parse("10.0.2.0/24")).setNextHopInterface(i.getName()).build();
    vrf.getStaticRoutes().add(srJustInterface);
    BdpEngine engine = new BdpEngine(new MockBdpSettings(), new BatfishLogger(BatfishLogger.LEVELSTR_DEBUG, false), (a, b) -> new AtomicInteger());
    Topology topology = new Topology(Collections.emptySortedSet());
    BdpDataPlane dp = engine.computeDataPlane(false, ImmutableMap.of(c.getName(), c), topology, Collections.emptySet(), new BdpAnswerElement());
    // generating fibs should not crash
    dp.getFibs();
}
Also used : StaticRoute(org.batfish.datamodel.StaticRoute) BdpAnswerElement(org.batfish.datamodel.answers.BdpAnswerElement) Configuration(org.batfish.datamodel.Configuration) BatfishLogger(org.batfish.common.BatfishLogger) InterfaceAddress(org.batfish.datamodel.InterfaceAddress) Ip(org.batfish.datamodel.Ip) RoutesByVrf(org.batfish.datamodel.collections.RoutesByVrf) Vrf(org.batfish.datamodel.Vrf) Topology(org.batfish.datamodel.Topology) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NetworkFactory(org.batfish.datamodel.NetworkFactory) Interface(org.batfish.datamodel.Interface) Test(org.junit.Test)

Example 28 with StaticRoute

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

the class ElasticsearchDomainTest method testDefaultRoute.

@Test
public void testDefaultRoute() throws IOException {
    Map<String, Configuration> configurations = loadAwsConfigurations();
    StaticRoute defaultRoute1 = _staticRouteBuilder.setNextHopIp(new Ip("172.31.0.1")).build();
    StaticRoute defaultRoute2 = _staticRouteBuilder.setNextHopIp(new Ip("192.168.2.17")).build();
    // checking that both default routes exist(to both the subnets) in RDS instance
    assertThat(configurations, hasKey("es-domain"));
    assertThat(configurations.get("es-domain").getDefaultVrf().getStaticRoutes(), containsInAnyOrder(defaultRoute1, defaultRoute2));
}
Also used : StaticRoute(org.batfish.datamodel.StaticRoute) Configuration(org.batfish.datamodel.Configuration) Ip(org.batfish.datamodel.Ip) Test(org.junit.Test)

Example 29 with StaticRoute

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

the class RdsInstanceTest method testDefaultRoute.

@Test
public void testDefaultRoute() throws IOException {
    Map<String, Configuration> configurations = loadAwsConfigurations();
    StaticRoute defaultRoute1 = _staticRouteBuilder.setNextHopIp(new Ip("172.31.0.1")).build();
    StaticRoute defaultRoute2 = _staticRouteBuilder.setNextHopIp(new Ip("192.168.2.17")).build();
    // checking that both default routes exist(to both the subnets) in RDS instance
    assertThat(configurations, hasKey("test-rds"));
    assertThat(configurations.get("test-rds").getDefaultVrf().getStaticRoutes(), containsInAnyOrder(defaultRoute1, defaultRoute2));
}
Also used : StaticRoute(org.batfish.datamodel.StaticRoute) Configuration(org.batfish.datamodel.Configuration) Ip(org.batfish.datamodel.Ip) Test(org.junit.Test)

Example 30 with StaticRoute

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

the class BatfishCompressionTest method compressibleNetwork.

/**
 * Build a network that can be easily compressed.
 */
private SortedMap<String, Configuration> compressibleNetwork() {
    NetworkFactory nf = new NetworkFactory();
    Configuration.Builder cb = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS);
    _compressedNode1 = cb.build();
    _compressedNode2 = cb.build();
    _compressedNode3 = cb.build();
    Vrf.Builder vb = nf.vrfBuilder().setName(Configuration.DEFAULT_VRF_NAME);
    Vrf v1 = vb.setOwner(_compressedNode1).build();
    Vrf v3 = vb.setOwner(_compressedNode3).build();
    // add a vrf to c2 too
    vb.setOwner(_compressedNode2).build();
    Prefix p = Prefix.parse("10.23.0.0/31");
    Interface.Builder ib = nf.interfaceBuilder().setActive(true);
    ib.setOwner(_compressedNode1).setVrf(v1).setAddress(new InterfaceAddress(p.getStartIp(), p.getPrefixLength())).build();
    ib.setOwner(_compressedNode3).setVrf(v3).setAddress(new InterfaceAddress(p.getStartIp(), p.getPrefixLength())).build();
    StaticRoute staticRoute = StaticRoute.builder().setNetwork(p).setNextHopIp(p.getEndIp()).build();
    v1.getStaticRoutes().add(staticRoute);
    v3.getStaticRoutes().add(staticRoute);
    return new TreeMap<>(ImmutableSortedMap.of(_compressedNode1.getName(), _compressedNode1, _compressedNode2.getName(), _compressedNode2, _compressedNode3.getName(), _compressedNode3));
}
Also used : StaticRoute(org.batfish.datamodel.StaticRoute) Configuration(org.batfish.datamodel.Configuration) InterfaceAddress(org.batfish.datamodel.InterfaceAddress) NetworkFactory(org.batfish.datamodel.NetworkFactory) Vrf(org.batfish.datamodel.Vrf) Prefix(org.batfish.datamodel.Prefix) TreeMap(java.util.TreeMap) Interface(org.batfish.datamodel.Interface)

Aggregations

StaticRoute (org.batfish.datamodel.StaticRoute)31 Configuration (org.batfish.datamodel.Configuration)17 Interface (org.batfish.datamodel.Interface)14 InterfaceAddress (org.batfish.datamodel.InterfaceAddress)13 Ip (org.batfish.datamodel.Ip)12 Test (org.junit.Test)10 Prefix (org.batfish.datamodel.Prefix)9 ArrayList (java.util.ArrayList)4 RoutingPolicy (org.batfish.datamodel.routing_policy.RoutingPolicy)4 List (java.util.List)3 TreeSet (java.util.TreeSet)3 BatfishException (org.batfish.common.BatfishException)3 IpAccessList (org.batfish.datamodel.IpAccessList)3 NetworkFactory (org.batfish.datamodel.NetworkFactory)3 Vrf (org.batfish.datamodel.Vrf)3 BoolExpr (com.microsoft.z3.BoolExpr)2 TreeMap (java.util.TreeMap)2 BgpNeighbor (org.batfish.datamodel.BgpNeighbor)2 CommunityList (org.batfish.datamodel.CommunityList)2 Conjunction (org.batfish.datamodel.routing_policy.expr.Conjunction)2