-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Batfish: unusableVlanShutdown should only count active interfaces (#6368
) If an interface is shutdown, it will not keep a Vlan up. (The autostate flag is still supported below).
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
projects/batfish/src/test/java/org/batfish/main/VlanInterfacesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.batfish.main; | ||
|
||
import static org.hamcrest.Matchers.containsInAnyOrder; | ||
import static org.hamcrest.Matchers.hasKey; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
import org.batfish.common.plugin.IBatfish; | ||
import org.batfish.datamodel.Configuration; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public class VlanInterfacesTest { | ||
private static final String TESTCONFIGS_PREFIX = "org/batfish/main/testconfigs/"; | ||
@Rule public TemporaryFolder _folder = new TemporaryFolder(); | ||
|
||
private Configuration parseConfig(String hostname) { | ||
try { | ||
IBatfish batfish = | ||
BatfishTestUtils.getBatfishForTextConfigs(_folder, TESTCONFIGS_PREFIX + hostname); | ||
Map<String, Configuration> configs = batfish.loadConfigurations(batfish.getSnapshot()); | ||
assertThat(configs, hasKey(hostname.toLowerCase())); | ||
return configs.get(hostname.toLowerCase()); | ||
} catch (IOException e) { | ||
throw new AssertionError("Failed to parse " + hostname, e); | ||
} | ||
} | ||
|
||
/** Tests Batfish#disableUnusableVlanInterfaces. */ | ||
@Test | ||
public void testDisableUnusableInterfaces() { | ||
Configuration c = parseConfig("vlan"); | ||
assertThat( | ||
c.getAllInterfaces().keySet(), | ||
containsInAnyOrder("Ethernet1", "Ethernet2", "Vlan1", "Vlan2")); | ||
assertThat(c.getActiveInterfaces().keySet(), containsInAnyOrder("Ethernet1", "Vlan1")); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
projects/batfish/src/test/resources/org/batfish/main/testconfigs/vlan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
!RANCID-CONTENT-TYPE: cisco | ||
hostname vlan | ||
! | ||
interface Vlan1 | ||
no shutdown | ||
! | ||
interface Ethernet1 | ||
no shutdown | ||
switchport mode access | ||
switchport access vlan 1 | ||
! | ||
interface Vlan2 | ||
no shutdown | ||
! | ||
interface Ethernet2 | ||
shutdown | ||
switchport mode access | ||
switchport access vlan 2 | ||
! |