use of org.batfish.main.Batfish in project batfish by batfish.
the class BdpDataPlanePluginTest method testComputeFixedPoint.
@Test(timeout = 5000)
public void testComputeFixedPoint() throws IOException {
SortedMap<String, Configuration> configurations = new TreeMap<>();
// creating configurations with no vrfs
configurations.put("h1", BatfishTestUtils.createTestConfiguration("h1", ConfigurationFormat.HOST, "eth0"));
configurations.put("h2", BatfishTestUtils.createTestConfiguration("h2", ConfigurationFormat.HOST, "e0"));
Batfish batfish = BatfishTestUtils.getBatfish(configurations, _folder);
BdpDataPlanePlugin dataPlanePlugin = new BdpDataPlanePlugin();
dataPlanePlugin.initialize(batfish);
// Test that compute Data Plane finishes in a finite time
dataPlanePlugin.computeDataPlane(false);
}
use of org.batfish.main.Batfish in project batfish by batfish.
the class BdpDataPlanePluginTest method testBgpOscillation.
@Test
public void testBgpOscillation() throws IOException {
String testrigName = "bgp-oscillation";
List<String> configurationNames = ImmutableList.of("r1", "r2", "r3");
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
batfish.getSettings().setBdpMaxOscillationRecoveryAttempts(0);
BdpDataPlanePlugin dataPlanePlugin = new BdpDataPlanePlugin();
dataPlanePlugin.initialize(batfish);
_thrown.expect(BdpOscillationException.class);
dataPlanePlugin.computeDataPlane(false);
}
use of org.batfish.main.Batfish in project batfish by batfish.
the class BdpDataPlanePluginTest method testIbgpRejectOwnAs.
@Test
public void testIbgpRejectOwnAs() throws IOException {
String testrigName = "ibgp-reject-own-as";
List<String> configurationNames = ImmutableList.of("r1", "r2a", "r2b");
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
BdpDataPlanePlugin dataPlanePlugin = new BdpDataPlanePlugin();
dataPlanePlugin.initialize(batfish);
batfish.computeDataPlane(false);
SortedMap<String, SortedMap<String, SortedSet<AbstractRoute>>> routes = dataPlanePlugin.getRoutes(batfish.loadDataPlane());
SortedSet<AbstractRoute> r2aRoutes = routes.get("r2a").get(DEFAULT_VRF_NAME);
SortedSet<AbstractRoute> r2bRoutes = routes.get("r2b").get(DEFAULT_VRF_NAME);
Set<Prefix> r2aPrefixes = r2aRoutes.stream().map(AbstractRoute::getNetwork).collect(Collectors.toSet());
Set<Prefix> r2bPrefixes = r2bRoutes.stream().map(AbstractRoute::getNetwork).collect(Collectors.toSet());
Prefix r1Loopback0Prefix = Prefix.parse("1.0.0.1/32");
Prefix r1Loopback1Prefix = Prefix.parse("1.0.0.2/32");
assertTrue(r2aPrefixes.contains(r1Loopback0Prefix));
assertTrue(r2aPrefixes.contains(r1Loopback1Prefix));
/*
* 1.0.0.2/32 should be accepted r2b as a normal iBGP route forwarded from r1.
*/
assertTrue(r2bPrefixes.contains(r1Loopback1Prefix));
/*
* 1.0.0.1/32 should be rejected by r2b since it already contains AS#2 in its AS-path due to
* r2a prepending 2 in the matching route-map clause.
*/
assertFalse(r2bPrefixes.contains(r1Loopback0Prefix));
}
use of org.batfish.main.Batfish in project batfish by batfish.
the class RipAndBgpTest method testOutputRoutes.
@Test
public void testOutputRoutes() throws IOException {
String testrigResourcePrefix = TESTRIGS_PREFIX + "rip";
Set<String> configurations = ImmutableSet.of("r1", "r2", "r3");
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(testrigResourcePrefix, configurations).build(), _folder);
BdpDataPlanePlugin dataPlanePlugin = new BdpDataPlanePlugin();
dataPlanePlugin.initialize(batfish);
batfish.computeDataPlane(false);
SortedMap<String, SortedMap<String, SortedSet<AbstractRoute>>> routes = dataPlanePlugin.getRoutes(batfish.loadDataPlane());
SortedSet<AbstractRoute> r1Routes = routes.get("r1").get(Configuration.DEFAULT_VRF_NAME);
SortedSet<AbstractRoute> r2Routes = routes.get("r2").get(Configuration.DEFAULT_VRF_NAME);
SortedSet<AbstractRoute> r3Routes = routes.get("r3").get(Configuration.DEFAULT_VRF_NAME);
Set<Prefix> r1Prefixes = r1Routes.stream().map(AbstractRoute::getNetwork).collect(Collectors.toSet());
Set<Prefix> r2Prefixes = r2Routes.stream().map(AbstractRoute::getNetwork).collect(Collectors.toSet());
Set<Prefix> r3Prefixes = r3Routes.stream().map(AbstractRoute::getNetwork).collect(Collectors.toSet());
Prefix prefix1 = Prefix.parse("1.0.0.0/8");
Prefix prefix2 = Prefix.parse("2.0.0.0/8");
Prefix prefix3 = Prefix.parse("3.0.0.0/8");
assertThat(r1Prefixes, containsInAnyOrder(prefix1, prefix2, prefix3));
assertThat(r2Prefixes, containsInAnyOrder(prefix1, prefix2, prefix3));
assertThat(r3Prefixes, containsInAnyOrder(prefix1, prefix3));
}
use of org.batfish.main.Batfish in project batfish by batfish.
the class CiscoGrammarTest method testBgpLocalAs.
@Test
public void testBgpLocalAs() throws IOException {
String testrigName = "bgp-local-as";
List<String> configurationNames = ImmutableList.of("r1", "r2");
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
Map<String, Configuration> configurations = batfish.loadConfigurations();
Map<Ip, Set<String>> ipOwners = CommonUtil.computeIpOwners(configurations, true);
CommonUtil.initRemoteBgpNeighbors(configurations, ipOwners);
Configuration r1 = configurations.get("r1");
Configuration r2 = configurations.get("r2");
assertThat(r1.getDefaultVrf().getBgpProcess().getNeighbors().get(Prefix.parse("1.2.0.2/32")).getRemoteBgpNeighbor(), is(notNullValue()));
assertThat(r2.getDefaultVrf().getBgpProcess().getNeighbors().get(Prefix.parse("1.2.0.1/32")).getRemoteBgpNeighbor(), is(notNullValue()));
}
Aggregations