Search in sources :

Example 26 with Batfish

use of org.batfish.main.Batfish in project batfish by batfish.

the class CiscoGrammarTest method testInterfaceNames.

@Test
public void testInterfaceNames() throws IOException {
    String testrigName = "interface-names";
    String iosHostname = "ios";
    String i1Name = "Ethernet0/0";
    List<String> configurationNames = ImmutableList.of(iosHostname);
    Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
    Map<String, Configuration> configurations = batfish.loadConfigurations();
    Interface i1 = configurations.get(iosHostname).getInterfaces().get(i1Name);
    assertThat(i1, hasDeclaredNames("Ethernet0/0", "e0/0", "Eth0/0", "ether0/0-1"));
}
Also used : Configuration(org.batfish.datamodel.Configuration) Batfish(org.batfish.main.Batfish) Interface(org.batfish.datamodel.Interface) ConfigurationMatchers.hasInterface(org.batfish.datamodel.matchers.ConfigurationMatchers.hasInterface) Test(org.junit.Test)

Example 27 with Batfish

use of org.batfish.main.Batfish in project batfish by batfish.

the class FlatJuniperGrammarTest method testAutonomousSystem.

@Test
public void testAutonomousSystem() throws IOException {
    String testrigName = "autonomous-system";
    String c1Name = "as1";
    String c2Name = "as2";
    String c3Name = "as3";
    Prefix neighborPrefix = Prefix.parse("1.0.0.1/32");
    List<String> configurationNames = ImmutableList.of(c1Name, c2Name, c3Name);
    Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
    Map<String, Configuration> configurations = batfish.loadConfigurations();
    Configuration c1 = configurations.get(c1Name);
    Configuration c2 = configurations.get(c2Name);
    Configuration c3 = configurations.get(c3Name);
    assertThat(c1, hasDefaultVrf(hasBgpProcess(hasNeighbor(neighborPrefix, hasLocalAs(1)))));
    assertThat(c2, hasDefaultVrf(hasBgpProcess(hasNeighbor(neighborPrefix, hasLocalAs(1)))));
    assertThat(c3, hasDefaultVrf(hasBgpProcess(hasNeighbor(neighborPrefix, hasLocalAs(1)))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) Prefix(org.batfish.datamodel.Prefix) Batfish(org.batfish.main.Batfish) Test(org.junit.Test)

Example 28 with Batfish

use of org.batfish.main.Batfish in project batfish by batfish.

the class FlatJuniperGrammarTest method testBgpMultipathMultipleAs.

@Test
public void testBgpMultipathMultipleAs() throws IOException {
    String testrigName = "multipath-multiple-as";
    List<String> configurationNames = ImmutableList.of("multiple_as_disabled", "multiple_as_enabled", "multiple_as_mixed");
    Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
    Map<String, Configuration> configurations = batfish.loadConfigurations();
    MultipathEquivalentAsPathMatchMode multipleAsDisabled = configurations.get("multiple_as_disabled").getDefaultVrf().getBgpProcess().getMultipathEquivalentAsPathMatchMode();
    MultipathEquivalentAsPathMatchMode multipleAsEnabled = configurations.get("multiple_as_enabled").getDefaultVrf().getBgpProcess().getMultipathEquivalentAsPathMatchMode();
    MultipathEquivalentAsPathMatchMode multipleAsMixed = configurations.get("multiple_as_mixed").getDefaultVrf().getBgpProcess().getMultipathEquivalentAsPathMatchMode();
    assertThat(multipleAsDisabled, equalTo(MultipathEquivalentAsPathMatchMode.FIRST_AS));
    assertThat(multipleAsEnabled, equalTo(MultipathEquivalentAsPathMatchMode.PATH_LENGTH));
    assertThat(multipleAsMixed, equalTo(MultipathEquivalentAsPathMatchMode.FIRST_AS));
}
Also used : Configuration(org.batfish.datamodel.Configuration) Batfish(org.batfish.main.Batfish) MultipathEquivalentAsPathMatchMode(org.batfish.datamodel.MultipathEquivalentAsPathMatchMode) Test(org.junit.Test)

Example 29 with Batfish

use of org.batfish.main.Batfish in project batfish by batfish.

the class FlatJuniperGrammarTest method testBgpClusterId.

@Test
public void testBgpClusterId() throws IOException {
    String testrigName = "rr";
    String configName = "rr";
    Ip neighbor1Ip = new Ip("2.2.2.2");
    Ip neighbor2Ip = new Ip("4.4.4.4");
    List<String> configurationNames = ImmutableList.of(configName);
    Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
    Map<String, Configuration> configurations = batfish.loadConfigurations();
    Configuration rr = configurations.get(configName);
    BgpProcess proc = rr.getDefaultVrf().getBgpProcess();
    BgpNeighbor neighbor1 = proc.getNeighbors().get(new Prefix(neighbor1Ip, Prefix.MAX_PREFIX_LENGTH));
    BgpNeighbor neighbor2 = proc.getNeighbors().get(new Prefix(neighbor2Ip, Prefix.MAX_PREFIX_LENGTH));
    assertThat(neighbor1, hasClusterId(new Ip("3.3.3.3").asLong()));
    assertThat(neighbor2, hasClusterId(new Ip("1.1.1.1").asLong()));
}
Also used : BgpNeighbor(org.batfish.datamodel.BgpNeighbor) Configuration(org.batfish.datamodel.Configuration) BgpProcess(org.batfish.datamodel.BgpProcess) VrfMatchers.hasBgpProcess(org.batfish.datamodel.matchers.VrfMatchers.hasBgpProcess) Ip(org.batfish.datamodel.Ip) Prefix(org.batfish.datamodel.Prefix) Batfish(org.batfish.main.Batfish) Test(org.junit.Test)

Example 30 with Batfish

use of org.batfish.main.Batfish in project batfish by batfish.

the class NodJobTest method setupDataPlane.

private void setupDataPlane() throws IOException {
    TemporaryFolder tmp = new TemporaryFolder();
    tmp.create();
    Batfish batfish = BatfishTestUtils.getBatfish(_configs, tmp);
    _bdpDataPlanePlugin = new BdpDataPlanePlugin();
    _bdpDataPlanePlugin.initialize(batfish);
    batfish.registerDataPlanePlugin(_bdpDataPlanePlugin, "bdp");
    batfish.computeDataPlane(false);
    _dataPlane = batfish.loadDataPlane();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) BdpDataPlanePlugin(org.batfish.bdp.BdpDataPlanePlugin) Batfish(org.batfish.main.Batfish)

Aggregations

Batfish (org.batfish.main.Batfish)32 Test (org.junit.Test)25 Configuration (org.batfish.datamodel.Configuration)20 Prefix (org.batfish.datamodel.Prefix)10 SortedMap (java.util.SortedMap)9 AbstractRoute (org.batfish.datamodel.AbstractRoute)8 Matchers.containsString (org.hamcrest.Matchers.containsString)8 SortedSet (java.util.SortedSet)7 Interface (org.batfish.datamodel.Interface)7 Ip (org.batfish.datamodel.Ip)7 TemporaryFolder (org.junit.rules.TemporaryFolder)7 Set (java.util.Set)6 MultipathEquivalentAsPathMatchMode (org.batfish.datamodel.MultipathEquivalentAsPathMatchMode)6 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)5 InterfaceAddress (org.batfish.datamodel.InterfaceAddress)5 Vrf (org.batfish.datamodel.Vrf)5 ImmutableList (com.google.common.collect.ImmutableList)4 IOException (java.io.IOException)4 Collection (java.util.Collection)4 List (java.util.List)4