Search in sources :

Example 11 with Batfish

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

the class CiscoGrammarTest method testNxosOspfAreaParameters.

@Test
public void testNxosOspfAreaParameters() throws IOException {
    String testrigName = "nxos-ospf";
    String hostname = "nxos-ospf-area";
    String ifaceName = "Ethernet1";
    long areaNum = 1L;
    List<String> configurationNames = ImmutableList.of(hostname);
    Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationText(TESTRIGS_PREFIX + testrigName, configurationNames).build(), _folder);
    Map<String, Configuration> configurations = batfish.loadConfigurations();
    /* Ensure bidirectional references between OSPF area and interface */
    assertThat(configurations, hasKey(hostname));
    Configuration c = configurations.get(hostname);
    assertThat(c, hasDefaultVrf(hasOspfProcess(hasAreas(hasKey(areaNum)))));
    OspfArea area = c.getDefaultVrf().getOspfProcess().getAreas().get(areaNum);
    assertThat(area, OspfAreaMatchers.hasInterfaces(hasItem(ifaceName)));
    assertThat(c, hasInterface(ifaceName, hasOspfArea(sameInstance(area))));
    assertThat(c, hasInterface(ifaceName, isOspfPassive(equalTo(false))));
    assertThat(c, hasInterface(ifaceName, isOspfPointToPoint()));
}
Also used : OspfArea(org.batfish.datamodel.OspfArea) InterfaceMatchers.hasOspfArea(org.batfish.datamodel.matchers.InterfaceMatchers.hasOspfArea) Configuration(org.batfish.datamodel.Configuration) Batfish(org.batfish.main.Batfish) Test(org.junit.Test)

Example 12 with Batfish

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

the class FlatJuniperGrammarTest method testEthernetSwitchingFilterReference.

@Test
public void testEthernetSwitchingFilterReference() throws IOException {
    String hostname = "ethernet-switching-filter";
    Batfish batfish = getBatfishForConfigurationNames(hostname);
    SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>> unusedStructures = batfish.loadConvertConfigurationAnswerElementOrReparse().getUnusedStructures();
    /* esfilter should not be unused, whuile esfilter2 should be unused */
    assertThat(unusedStructures, hasKey(hostname));
    SortedMap<String, SortedMap<String, SortedSet<Integer>>> byType = unusedStructures.get(hostname);
    assertThat(byType, hasKey(JuniperStructureType.FIREWALL_FILTER.getDescription()));
    SortedMap<String, SortedSet<Integer>> byName = byType.get(JuniperStructureType.FIREWALL_FILTER.getDescription());
    assertThat(byName, hasKey("esfilter2"));
    assertThat(byName, not(hasKey("esfilter")));
}
Also used : SortedMap(java.util.SortedMap) SortedSet(java.util.SortedSet) Batfish(org.batfish.main.Batfish) Test(org.junit.Test)

Example 13 with Batfish

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

the class HostTest method testNatIpsecVpnsHelper.

public Map<String, Configuration> testNatIpsecVpnsHelper(String hostFilename) throws IOException {
    String testrigResourcePrefix = TESTRIG_PREFIX + "ipsec-vpn-host-aws-cisco";
    List<String> awsFilenames = ImmutableList.of("AvailabilityZones-us-west-2.json", "CustomerGateways-us-west-2.json", "InternetGateways-us-west-2.json", "NetworkAcls-us-west-2.json", "NetworkInterfaces-us-west-2.json", "RouteTables-us-west-2.json", "SecurityGroups-us-west-2.json", "Subnets-us-west-2.json", "VpcEndpoints-us-west-2.json", "Vpcs-us-west-2.json", "VpnConnections-us-west-2.json", "VpnGateways-us-west-2.json");
    List<String> configurationFilenames = ImmutableList.of("cisco_host");
    List<String> hostFilenames = ImmutableList.of(hostFilename);
    Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setAwsText(testrigResourcePrefix, awsFilenames).setConfigurationText(testrigResourcePrefix, configurationFilenames).setHostsText(testrigResourcePrefix, hostFilenames).build(), _folder);
    return batfish.loadConfigurations();
}
Also used : Batfish(org.batfish.main.Batfish)

Example 14 with Batfish

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

the class RdsInstanceTest method loadAwsConfigurations.

public Map<String, Configuration> loadAwsConfigurations() throws IOException {
    List<String> awsFilenames = ImmutableList.of("RdsInstances.json", "SecurityGroups.json", "Subnets.json", "Vpcs.json", "NetworkAcls.json", "NetworkInterfaces.json", "Reservations.json");
    Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setAwsText("org/batfish/representation/aws/test", awsFilenames).build(), _folder);
    return batfish.loadConfigurations();
}
Also used : Batfish(org.batfish.main.Batfish)

Example 15 with Batfish

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

the class NodJobChunkingTest method setupDataPlane.

private void setupDataPlane() throws IOException {
    TemporaryFolder tmp = new TemporaryFolder();
    tmp.create();
    Batfish batfish = BatfishTestUtils.getBatfish(_configs, tmp);
    BdpDataPlanePlugin 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