forked from batfish/batfish
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TransferBDD: Convert some community set regexes to community regexes (b…
…atfish#8724) This PR conservatively identifies community set regexes that can be treated as regexes on individual communities, and hence can be represented as such in the Batfish vendor-independent model. Doing so simplifies the analysis of such regexes and enables symbolic reasoning about route policies (e.g., SearchRoutePolicies and CompareRoutePolicies), which currently does not support reasoning about community set regexes due to their complex semantics.
- Loading branch information
Showing
27 changed files
with
179 additions
and
200 deletions.
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
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
55 changes: 55 additions & 0 deletions
55
...src/test/java/org/batfish/datamodel/routing_policy/communities/CommunitySetExprsTest.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,55 @@ | ||
package org.batfish.datamodel.routing_policy.communities; | ||
|
||
import static org.batfish.datamodel.routing_policy.communities.CommunitySetExprs.toMatchExpr; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.apache.commons.text.StringEscapeUtils; | ||
import org.batfish.datamodel.routing_policy.Common; | ||
import org.junit.Test; | ||
|
||
public final class CommunitySetExprsTest { | ||
|
||
@Test | ||
public void testCommunitySetMatchRegexUnoptimized() { | ||
assertEquals( | ||
toMatchExpr("^65000:123 65011:12[3]$"), | ||
new CommunitySetMatchRegex( | ||
new TypesFirstAscendingSpaceSeparated(ColonSeparatedRendering.instance()), | ||
"^65000:123 65011:12[3]$")); | ||
assertEquals( | ||
toMatchExpr("^$"), | ||
new CommunitySetMatchRegex( | ||
new TypesFirstAscendingSpaceSeparated(ColonSeparatedRendering.instance()), "^$")); | ||
} | ||
|
||
@Test | ||
public void testVisitCommunitySetMatchRegexOptimized() { | ||
|
||
String underscore = StringEscapeUtils.unescapeJava(Common.DEFAULT_UNDERSCORE_REPLACEMENT); | ||
|
||
assertEquals( | ||
toMatchExpr("53"), | ||
new HasCommunity(new CommunityMatchRegex(ColonSeparatedRendering.instance(), "53"))); | ||
assertEquals( | ||
toMatchExpr("53:"), | ||
new HasCommunity(new CommunityMatchRegex(ColonSeparatedRendering.instance(), "53:"))); | ||
assertEquals( | ||
toMatchExpr(underscore + "53:"), | ||
new HasCommunity( | ||
new CommunityMatchRegex(ColonSeparatedRendering.instance(), underscore + "53:"))); | ||
assertEquals( | ||
toMatchExpr(":53"), | ||
new HasCommunity(new CommunityMatchRegex(ColonSeparatedRendering.instance(), ":53"))); | ||
assertEquals( | ||
toMatchExpr(":53" + underscore), | ||
new HasCommunity( | ||
new CommunityMatchRegex(ColonSeparatedRendering.instance(), ":53" + underscore))); | ||
assertEquals( | ||
toMatchExpr("[0-9]+:"), | ||
new HasCommunity(new CommunityMatchRegex(ColonSeparatedRendering.instance(), "[0-9]+:"))); | ||
assertEquals( | ||
toMatchExpr("[0-9]+:[123]*"), | ||
new HasCommunity( | ||
new CommunityMatchRegex(ColonSeparatedRendering.instance(), "[0-9]+:[123]*"))); | ||
} | ||
} |
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
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
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
Oops, something went wrong.