use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class FlatJuniperGrammarTest method testOspfMetric.
@Test
public void testOspfMetric() throws IOException {
Configuration config = BatfishTestUtils.parseTextConfigs(_folder, "org/batfish/grammar/juniper/testconfigs/ospfmetric").get("ospfmetric");
OspfAreaSummary summary = config.getDefaultVrf().getOspfProcess().getAreas().get(1L).getSummaries().get(Prefix.parse("10.0.0.0/16"));
assertThat(summary, not(isAdvertised()));
assertThat(summary, hasMetric(123L));
// Defaults
summary = config.getDefaultVrf().getOspfProcess().getAreas().get(2L).getSummaries().get(Prefix.parse("10.0.0.0/16"));
assertThat(summary, isAdvertised());
assertThat(summary, hasMetric(nullValue()));
// Interface override
assertThat(config, hasInterface("fe-1/0/1.0", hasOspfCost(equalTo(17))));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class FlatJuniperGrammarTest method testInterfaceMtu.
@Test
public void testInterfaceMtu() throws IOException {
Configuration c = parseConfig("interfaceMtu");
/* Properly configured interfaces should be present in respective areas. */
assertThat(c.getInterfaces().keySet(), equalTo(Collections.singleton("xe-0/0/0:0.0")));
assertThat(c, hasInterface("xe-0/0/0:0.0", hasMtu(9000)));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class BatfishStorageTest method loadOldConfigurationsReturnsNull.
@Test
public void loadOldConfigurationsReturnsNull() {
ConvertConfigurationAnswerElement oldConvertAnswer = new ConvertConfigurationAnswerElement();
oldConvertAnswer.setVersion(INCOMPATIBLE_VERSION);
assertThat("should not be compatible with current code", Version.isCompatibleVersion("current", "old test", oldConvertAnswer.getVersion()), equalTo(false));
String trname = "sometr";
Map<String, Configuration> configs = new HashMap<>();
configs.put("node1", new Configuration("node1", ConfigurationFormat.CISCO_IOS));
_storage.storeConfigurations(configs, oldConvertAnswer, trname);
assertThat(_storage.loadConfigurations(trname), nullValue());
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class BatfishStorageTest method roundTripConfigurationsSucceeds.
@Test
public void roundTripConfigurationsSucceeds() {
Map<String, Configuration> configs = new HashMap<>();
configs.put("node1", new Configuration("node1", ConfigurationFormat.CISCO_IOS));
_storage.storeConfigurations(configs, new ConvertConfigurationAnswerElement(), "sometr");
Map<String, Configuration> deserialized = _storage.loadConfigurations("sometr");
assertThat(deserialized, not(nullValue()));
assertThat(deserialized.keySet(), equalTo(Sets.newHashSet("node1")));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class BatfishTest method testOverlayIptables.
@Test
public void testOverlayIptables() throws IOException {
SortedMap<String, String> configurationsText = new TreeMap<>();
String[] configurationNames = new String[] { "host1.cfg" };
String testConfigsPrefix = "org/batfish/grammar/host/testrigs/router-iptables/configs/";
SortedMap<String, String> hostsText = new TreeMap<>();
String[] hostNames = new String[] { "host1.json" };
String testHostsPrefix = "org/batfish/grammar/host/testrigs/router-iptables/hosts/";
SortedMap<String, String> iptablesFilesText = new TreeMap<>();
String[] iptablesNames = new String[] { "host1.iptables" };
String testIptablesPrefix = "org/batfish/grammar/host/testrigs/router-iptables/iptables/";
for (String configurationName : configurationNames) {
String configurationText = CommonUtil.readResource(testConfigsPrefix + configurationName);
configurationsText.put(configurationName, configurationText);
}
for (String hostName : hostNames) {
String hostText = CommonUtil.readResource(testHostsPrefix + hostName);
hostsText.put(hostName, hostText);
}
for (String iptablesName : iptablesNames) {
String iptablesText = CommonUtil.readResource(testIptablesPrefix + iptablesName);
iptablesFilesText.put(iptablesName, iptablesText);
}
Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(configurationsText).setHostsText(hostsText).setIptablesFilesText(iptablesFilesText).build(), _folder);
Map<String, Configuration> configurations = batfish.loadConfigurations();
assertThat(configurations.get("host1").getInterfaces().get("Ethernet0").getIncomingFilterName(), is(notNullValue()));
}
Aggregations