use of org.batfish.main.Batfish in project batfish by batfish.
the class CiscoGrammarTest method testBgpMultipathRelax.
@Test
public void testBgpMultipathRelax() throws IOException {
String testrigName = "bgp-multipath-relax";
List<String> configurationNames = ImmutableList.of("arista_disabled", "arista_enabled", "nxos_disabled", "nxos_enabled");
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);
MultipathEquivalentAsPathMatchMode aristaDisabled = configurations.get("arista_disabled").getDefaultVrf().getBgpProcess().getMultipathEquivalentAsPathMatchMode();
MultipathEquivalentAsPathMatchMode aristaEnabled = configurations.get("arista_enabled").getDefaultVrf().getBgpProcess().getMultipathEquivalentAsPathMatchMode();
MultipathEquivalentAsPathMatchMode nxosDisabled = configurations.get("nxos_disabled").getDefaultVrf().getBgpProcess().getMultipathEquivalentAsPathMatchMode();
MultipathEquivalentAsPathMatchMode nxosEnabled = configurations.get("nxos_enabled").getDefaultVrf().getBgpProcess().getMultipathEquivalentAsPathMatchMode();
assertThat(aristaDisabled, equalTo(MultipathEquivalentAsPathMatchMode.EXACT_PATH));
assertThat(aristaEnabled, equalTo(MultipathEquivalentAsPathMatchMode.PATH_LENGTH));
assertThat(nxosDisabled, equalTo(MultipathEquivalentAsPathMatchMode.EXACT_PATH));
assertThat(nxosEnabled, equalTo(MultipathEquivalentAsPathMatchMode.PATH_LENGTH));
}
use of org.batfish.main.Batfish in project batfish by batfish.
the class CiscoGrammarTest method testParsingRecoveryNoInfiniteLoopDuringAdaptivePredictionAtEof.
@Test
public void testParsingRecoveryNoInfiniteLoopDuringAdaptivePredictionAtEof() throws IOException {
String testrigName = "parsing-recovery";
String hostname = "ios-blankish-file";
List<String> configurationNames = ImmutableList.of(hostname);
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
batfish.getSettings().setDisableUnrecognized(false);
Map<String, Configuration> configurations = batfish.loadConfigurations();
/* Hostname is unknown, but a file should be generated nonetheless */
assertThat(configurations.entrySet(), hasSize(1));
}
use of org.batfish.main.Batfish in project batfish by batfish.
the class CiscoGrammarTest method testIpsecVpnIos.
@Test
public void testIpsecVpnIos() throws IOException {
String testrigName = "ipsec-vpn-ios";
List<String> configurationNames = ImmutableList.of("r1", "r2", "r3");
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
Map<String, Configuration> configurations = batfish.loadConfigurations();
assertThat(configurations.values().stream().mapToLong(c -> c.getIpsecVpns().values().size()).sum(), equalTo(6L));
configurations.values().stream().flatMap(c -> c.getIpsecVpns().values().stream()).forEach(iv -> assertThat(iv.getRemoteIpsecVpn(), not(nullValue())));
/* Two tunnels should not be established because of a password mismatch between r1 and r3 */
assertThat(configurations.values().stream().flatMap(c -> c.getInterfaces().values().stream()).filter(i -> i.getInterfaceType().equals(InterfaceType.TUNNEL) && i.getActive()).count(), equalTo(4L));
}
use of org.batfish.main.Batfish in project batfish by batfish.
the class CiscoGrammarTest method testParsingRecovery.
@Test
public void testParsingRecovery() throws IOException {
String testrigName = "parsing-recovery";
String hostname = "ios-recovery";
List<String> configurationNames = ImmutableList.of(hostname);
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
batfish.getSettings().setDisableUnrecognized(false);
Map<String, Configuration> configurations = batfish.loadConfigurations();
Configuration iosRecovery = configurations.get(hostname);
Map<String, Interface> iosRecoveryInterfaces = iosRecovery.getInterfaces();
Set<String> iosRecoveryInterfaceNames = iosRecoveryInterfaces.keySet();
Set<InterfaceAddress> l3Prefixes = iosRecoveryInterfaces.get("Loopback3").getAllAddresses();
Set<InterfaceAddress> l4Prefixes = iosRecoveryInterfaces.get("Loopback4").getAllAddresses();
assertThat("Loopback0", isIn(iosRecoveryInterfaceNames));
assertThat("Loopback1", isIn(iosRecoveryInterfaceNames));
assertThat("Loopback2", not(isIn(iosRecoveryInterfaceNames)));
assertThat("Loopback3", isIn(iosRecoveryInterfaceNames));
assertThat(new InterfaceAddress("10.0.0.1/32"), not(isIn(l3Prefixes)));
assertThat(new InterfaceAddress("10.0.0.2/32"), isIn(l3Prefixes));
assertThat("Loopback4", isIn(iosRecoveryInterfaceNames));
assertThat(new InterfaceAddress("10.0.0.3/32"), not(isIn(l4Prefixes)));
assertThat(new InterfaceAddress("10.0.0.4/32"), isIn(l4Prefixes));
}
use of org.batfish.main.Batfish in project batfish by batfish.
the class CiscoGrammarTest method testOspfMaxMetric.
@Test
public void testOspfMaxMetric() throws IOException {
String testrigName = "ospf-max-metric";
String iosMaxMetricName = "ios-max-metric";
String iosMaxMetricCustomName = "ios-max-metric-custom";
String iosMaxMetricOnStartupName = "ios-max-metric-on-startup";
List<String> configurationNames = ImmutableList.of(iosMaxMetricName, iosMaxMetricCustomName, iosMaxMetricOnStartupName);
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
Map<String, Configuration> configurations = batfish.loadConfigurations();
Configuration iosMaxMetric = configurations.get(iosMaxMetricName);
Configuration iosMaxMetricCustom = configurations.get(iosMaxMetricCustomName);
Configuration iosMaxMetricOnStartup = configurations.get(iosMaxMetricOnStartupName);
OspfProcess proc = iosMaxMetric.getDefaultVrf().getOspfProcess();
OspfProcess procCustom = iosMaxMetricCustom.getDefaultVrf().getOspfProcess();
OspfProcess procOnStartup = iosMaxMetricOnStartup.getDefaultVrf().getOspfProcess();
long expectedMaxMetricRouterLsa = org.batfish.representation.cisco.OspfProcess.MAX_METRIC_ROUTER_LSA;
long expectedMaxMetricStub = org.batfish.representation.cisco.OspfProcess.MAX_METRIC_ROUTER_LSA;
long expectedMaxMetricExternal = org.batfish.representation.cisco.OspfProcess.DEFAULT_MAX_METRIC_EXTERNAL_LSA;
long expectedMaxMetricSummary = org.batfish.representation.cisco.OspfProcess.DEFAULT_MAX_METRIC_SUMMARY_LSA;
long expectedCustomMaxMetricExternal = 12345L;
long expectedCustomMaxMetricSummary = 23456L;
assertThat(proc.getMaxMetricTransitLinks(), equalTo(expectedMaxMetricRouterLsa));
assertThat(proc.getMaxMetricStubNetworks(), equalTo(expectedMaxMetricStub));
assertThat(proc.getMaxMetricExternalNetworks(), equalTo(expectedMaxMetricExternal));
assertThat(proc.getMaxMetricSummaryNetworks(), equalTo(expectedMaxMetricSummary));
assertThat(procCustom.getMaxMetricTransitLinks(), equalTo(expectedMaxMetricRouterLsa));
assertThat(procCustom.getMaxMetricStubNetworks(), equalTo(expectedMaxMetricStub));
assertThat(procCustom.getMaxMetricExternalNetworks(), equalTo(expectedCustomMaxMetricExternal));
assertThat(procCustom.getMaxMetricSummaryNetworks(), equalTo(expectedCustomMaxMetricSummary));
assertThat(procOnStartup.getMaxMetricTransitLinks(), is(nullValue()));
assertThat(procOnStartup.getMaxMetricStubNetworks(), is(nullValue()));
assertThat(procOnStartup.getMaxMetricExternalNetworks(), is(nullValue()));
assertThat(procOnStartup.getMaxMetricSummaryNetworks(), is(nullValue()));
}
Aggregations