use of org.batfish.datamodel.Configuration.DEFAULT_VRF_NAME in project batfish by batfish.
the class BdpDataPlanePluginTest method testIbgpRejectSameNeighborID.
@Test
public void testIbgpRejectSameNeighborID() throws IOException {
String testrigName = "ibgp-reject-routerid-match";
List<String> configurationNames = ImmutableList.of("r1", "r2", "r3", "r4");
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> r2Routes = routes.get("r2").get(DEFAULT_VRF_NAME);
SortedSet<AbstractRoute> r3Routes = routes.get("r3").get(DEFAULT_VRF_NAME);
Set<Prefix> r2Prefixes = r2Routes.stream().map(r -> r.getNetwork()).collect(Collectors.toSet());
Set<Prefix> r3Prefixes = r3Routes.stream().map(r -> r.getNetwork()).collect(Collectors.toSet());
// 9.9.9.9/32 is the prefix we test with
Prefix r1AdvertisedPrefix = Prefix.parse("9.9.9.9/32");
// Ensure that the prefix is accepted by r2, because router ids are different
assertThat(r1AdvertisedPrefix, isIn(r2Prefixes));
// Ensure that the prefix is rejected by r3, because router ids are the same
assertThat(r1AdvertisedPrefix, not(isIn(r3Prefixes)));
}
use of org.batfish.datamodel.Configuration.DEFAULT_VRF_NAME in project batfish by batfish.
the class BdpDataPlanePluginTest method testEbgpAcceptSameNeighborID.
@Test
public void testEbgpAcceptSameNeighborID() throws IOException {
String testrigName = "ebgp-accept-routerid-match";
List<String> configurationNames = ImmutableList.of("r1", "r2", "r3");
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> r1Routes = routes.get("r1").get(DEFAULT_VRF_NAME);
SortedSet<AbstractRoute> r3Routes = routes.get("r3").get(DEFAULT_VRF_NAME);
Set<Prefix> r1Prefixes = r1Routes.stream().map(r -> r.getNetwork()).collect(Collectors.toSet());
Set<Prefix> r3Prefixes = r3Routes.stream().map(r -> r.getNetwork()).collect(Collectors.toSet());
Prefix r1Loopback0Prefix = Prefix.parse("1.0.0.1/32");
Prefix r3Loopback0Prefix = Prefix.parse("3.0.0.3/32");
// Ensure that r3loopback was accepted by r1
assertThat(r3Loopback0Prefix, isIn(r1Prefixes));
// Check the other direction (r1loopback is accepted by r3)
assertThat(r1Loopback0Prefix, isIn(r3Prefixes));
}
Aggregations