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));
}
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();
}
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));
}
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));
}
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));
}
Aggregations