-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RT 7.11: Updated the script with deviation for ASpath set #3365
Open
s-nandu
wants to merge
8
commits into
openconfig:main
Choose a base branch
from
s-nandu:policy_tc_update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6fd590d
Updated the scipt with deviation for ASpath set
s-nandu 95dab0e
Merge branch 'main' into policy_tc_update
s-nandu a1d50c1
Add deviation next_statemen_policy_termination_unsupported
s-nandu a44e8b4
updated deviation:
cprabha 913e2ad
Merge branch 'main' into policy_tc_update
cprabha 514e887
updated README
cprabha 91cf476
Merge branch 'main' into policy_tc_update
s-nandu 99e2047
Revert changes to 7.4
s-nandu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,8 +66,8 @@ const ( | |
bgpActionMethod = oc.SetCommunity_Method_REFERENCE | ||
bgpSetCommunityOptionType = oc.BgpPolicy_BgpSetCommunityOptionType_ADD | ||
prefixSetNameSetOptions = oc.RoutingPolicy_MatchSetOptionsRestrictedType_ANY | ||
matchAny = oc.BgpPolicy_MatchSetOptionsType_ANY | ||
matchInvert = oc.BgpPolicy_MatchSetOptionsType_INVERT | ||
matchAny = oc.RoutingPolicy_MatchSetOptionsType_ANY | ||
matchInvert = oc.RoutingPolicy_MatchSetOptionsType_INVERT | ||
rejectResult = oc.RoutingPolicy_PolicyResultType_REJECT_ROUTE | ||
nextstatementResult = oc.RoutingPolicy_PolicyResultType_NEXT_STATEMENT | ||
) | ||
|
@@ -181,13 +181,29 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond | |
addCommunitiesSetRefsAction := []string{"add-communities"} | ||
setCommunitySetRefs := []string{"add_comm_60", "add_comm_70"} | ||
myCommunitySets := []string{"50:1"} | ||
addComm60Set := []string{"60:1"} | ||
addComm70Set := []string{"70:1"} | ||
if deviations.BgpCommunityMemberIsAString(dut) { | ||
regexCommunities = []string{"(^|\\s)30:[0-9]+($|\\s)"} | ||
} | ||
|
||
root := &oc.Root{} | ||
rp := root.GetOrCreateRoutingPolicy() | ||
|
||
pdef := rp.GetOrCreatePolicyDefinition("PERMIT-ALL") | ||
stmt, err := pdef.AppendNewStatement("20") | ||
if err != nil { | ||
t.Fatalf("AppendNewStatement(%s) failed: %v", "routePolicyStatement", err) | ||
} | ||
stmt.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE | ||
|
||
pdefrp := rp.GetOrCreatePolicyDefinition("routePolicy") | ||
stmtrp, err := pdefrp.AppendNewStatement("routePolicyStatement") | ||
if err != nil { | ||
t.Fatalf("AppendNewStatement(%s) failed: %v", "routePolicyStatement", err) | ||
} | ||
stmtrp.GetOrCreateActions().SetPolicyResult(oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE) | ||
|
||
// Configure the policy match_community_regex which will be called from multi_policy | ||
|
||
pdef2 := rp.GetOrCreatePolicyDefinition(callPolicy) | ||
|
@@ -210,7 +226,6 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond | |
} | ||
} | ||
communitySetRegex.SetCommunityMember(pd2cs1) | ||
communitySetRegex.SetMatchSetOptions(matchAny) | ||
} | ||
|
||
var communitySetCLIConfig string | ||
|
@@ -228,14 +243,12 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond | |
pd2stmt1.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(regexCommunitySet) | ||
} else { | ||
pd2stmt1.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(regexCommunitySet) | ||
pd2stmt1.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetMatchSetOptions(matchAny) | ||
} | ||
|
||
if !deviations.SkipSettingStatementForPolicy(dut) { | ||
pd2stmt1.GetOrCreateActions().SetPolicyResult(nextstatementResult) | ||
} | ||
pd2stmt1.GetOrCreateActions().SetPolicyResult(oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE) | ||
|
||
// Configure the parent policy multi_policy. | ||
|
||
pdef1 := rp.GetOrCreatePolicyDefinition(parentPolicy) | ||
|
||
// Configure multi_policy:STATEMENT1: reject_route_community | ||
|
@@ -254,12 +267,12 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond | |
} | ||
} | ||
communitySetReject.SetCommunityMember(cs1) | ||
communitySetReject.SetMatchSetOptions(matchAny) | ||
|
||
if deviations.BGPConditionsMatchCommunitySetUnsupported(dut) { | ||
stmt1.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(rejectCommunitySet) | ||
} else { | ||
stmt1.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(rejectCommunitySet) | ||
stmt1.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetMatchSetOptions(matchAny) | ||
} | ||
|
||
stmt1.GetOrCreateActions().SetPolicyResult(rejectResult) | ||
|
@@ -286,12 +299,12 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond | |
} | ||
} | ||
communitySetNestedReject.SetCommunityMember(cs2) | ||
communitySetNestedReject.SetMatchSetOptions(matchInvert) | ||
|
||
if deviations.BGPConditionsMatchCommunitySetUnsupported(dut) { | ||
stmt2.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(nestedRejectCommunitySet) | ||
} else { | ||
stmt2.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(nestedRejectCommunitySet) | ||
stmt2.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetMatchSetOptions(matchInvert) | ||
} | ||
|
||
stmt2.GetOrCreateActions().SetPolicyResult(rejectResult) | ||
|
@@ -307,13 +320,12 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond | |
communitySetRefsAddCommunities := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(addCommunitiesSetRefs) | ||
|
||
cs3 := []oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{} | ||
for _, commMatch4 := range addCommunitiesRefs { | ||
if commMatch4 != "" { | ||
cs3 = append(cs3, oc.UnionString(commMatch4)) | ||
for _, commMatch3 := range addCommunitiesRefs { | ||
if commMatch3 != "" { | ||
cs3 = append(cs3, oc.UnionString(commMatch3)) | ||
} | ||
} | ||
communitySetRefsAddCommunities.SetCommunityMember(cs3) | ||
communitySetRefsAddCommunities.SetMatchSetOptions(matchInvert) | ||
|
||
if deviations.BGPConditionsMatchCommunitySetUnsupported(dut) { | ||
stmt3.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(addCommunitiesSetRefs) | ||
|
@@ -340,13 +352,33 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond | |
communitySetMatchCommPrefixAddCommu := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(myCommunitySet) | ||
|
||
cs4 := []oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{} | ||
for _, commMatch5 := range myCommunitySets { | ||
if commMatch5 != "" { | ||
cs4 = append(cs4, oc.UnionString(commMatch5)) | ||
for _, commMatch4 := range myCommunitySets { | ||
if commMatch4 != "" { | ||
cs4 = append(cs4, oc.UnionString(commMatch4)) | ||
} | ||
} | ||
communitySetMatchCommPrefixAddCommu.SetCommunityMember(cs4) | ||
communitySetMatchCommPrefixAddCommu.SetMatchSetOptions(matchAny) | ||
// communitySetMatchCommPrefixAddCommu.SetMatchSetOptions(oc.BgpPolicy_MatchSetOptionsType_ANY) | ||
|
||
// Configure add_comm_60 [ "60:1"] to match_comm_and_prefix_add_2_community_sets statement | ||
communitySetAdd60 := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet("add_comm_60") | ||
cs5 := []oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{} | ||
for _, commMatch5 := range addComm60Set { | ||
if commMatch5 != "" { | ||
cs5 = append(cs5, oc.UnionString(commMatch5)) | ||
} | ||
} | ||
communitySetAdd60.SetCommunityMember(cs5) | ||
|
||
// Configure add_comm_70 [ "70:1"] to match_comm_and_prefix_add_2_community_sets statement | ||
communitySetAdd70 := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet("add_comm_70") | ||
cs6 := []oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{} | ||
for _, commMatch6 := range addComm70Set { | ||
if commMatch6 != "" { | ||
cs6 = append(cs6, oc.UnionString(commMatch6)) | ||
} | ||
} | ||
communitySetAdd70.SetCommunityMember(cs6) | ||
|
||
// Configure multi_policy:STATEMENT4: match_comm_and_prefix_add_2_community_sets statement | ||
|
||
|
@@ -364,7 +396,9 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond | |
stmt6.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(myCommunitySet) | ||
} else { | ||
stmt4.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(myCommunitySet) | ||
stmt4.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetMatchSetOptions(matchAny) | ||
stmt6.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(myCommunitySet) | ||
stmt6.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetMatchSetOptions(matchAny) | ||
} | ||
|
||
// configure match-prefix-set: prefix-set-5 to match_comm_and_prefix_add_2_community_sets statement | ||
|
@@ -415,7 +449,14 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond | |
t.Fatalf("AppendNewStatement(%s) failed: %v", matchAspathSetMedStatement, err) | ||
} | ||
|
||
// TODO create as-path-set on the DUT, match-as-path-set not support. | ||
// Configure my_aspath: [ "65512" ] to match_aspath_set_med statement | ||
if !deviations.BgpAspathsetUnsupported(dut) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There needs to be some alternative to using aspath to achieve similar behavior. Without this, I can't accept this deviation. |
||
myAspath := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateAsPathSet(myAsPathName) | ||
myAspath.SetAsPathSetMember([]string{strconv.Itoa(int(cfgplugins.AteAS2))}) | ||
|
||
stmt5.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchAsPathSet().SetAsPathSet(myAsPathName) | ||
stmt5.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchAsPathSet().SetMatchSetOptions(matchAny) | ||
} | ||
// Configure set-med 100 | ||
stmt5.GetOrCreateActions().GetOrCreateBgpActions().SetMed = oc.UnionUint32(medValue) | ||
|
||
|
@@ -603,14 +644,17 @@ func verifyTrafficV4AndV6(t *testing.T, bs *cfgplugins.BGPSession, testResults [ | |
t.Errorf("FAIL- got %v%% packet loss for %s flow and prefixes: [%s, %s]; want < 0%% traffic loss", lossPct, "flow"+"ipv4"+strconv.Itoa(index), prefixPairV4[0], prefixPairV4[1]) | ||
} else if rxPackets != 0 && !testResults[index] { | ||
t.Errorf("FAIL- got %v%% packet loss for %s flow and prefixes: [%s, %s]; want >100%% traffic loss", lossPct, "flow"+"ipv4"+strconv.Itoa(index), prefixPairV4[0], prefixPairV4[1]) | ||
} else if txPackets6 != rxPackets6 && testResults[index] { | ||
} else { | ||
t.Logf("Traffic validation successful for Prefixes: [%s, %s]. Result: [%t] PacketsTx: %d PacketsRx: %d", prefixPairV4[0], prefixPairV4[1], testResults[index], txPackets, rxPackets) | ||
} | ||
|
||
if txPackets6 != rxPackets6 && testResults[index] { | ||
t.Errorf("FAIL- got %v%% packet loss for %s flow and prefixes: [%s, %s]; want < 0%% traffic loss", lossPct6, "flow"+"ipv6"+strconv.Itoa(index), prefixesV6[index][0], prefixesV6[index][1]) | ||
} else if rxPackets6 != 0 && !testResults[index] { | ||
t.Errorf("FAIL- got %v%% packet loss for %s flow and prefixes: [%s, %s]; want >100%% traffic loss", lossPct6, "flow"+"ipv6"+strconv.Itoa(index), prefixesV6[index][0], prefixesV6[index][1]) | ||
} else { | ||
t.Logf("Traffic validation successful for Prefixes: [%s, %s]. Result: [%t] PacketsTx: %d PacketsRx: %d", prefixesV6[index][0], prefixesV6[index][1], testResults[index], txPackets6, rxPackets6) | ||
} | ||
|
||
} | ||
} | ||
|
||
|
@@ -731,7 +775,9 @@ func validateOTGBgpPrefixV6AndASLocalPrefMED(t *testing.T, otg *otg.OTG, dut *on | |
t.Logf("For Prefix %v, got AS Path %d want AS Path %d", bgpPrefix.GetAddress(), bgpPrefix.AsPath[0].GetAsNumbers(), metric) | ||
} | ||
case otglocalPref: | ||
validateLocalPreferenceV6(t, dut, ipAddr, metric[0]) | ||
if !deviations.BGPRibOcPathUnsupported(dut) { | ||
validateLocalPreferenceV6(t, dut, ipAddr, metric[0]) | ||
} | ||
case otgCommunity: | ||
t.Logf("For Prefix %v, Community received on OTG: %v", bgpPrefix.GetAddress(), bgpPrefix.Community) | ||
for _, gotCommunity := range bgpPrefix.Community { | ||
|
@@ -792,7 +838,9 @@ func validateOTGBgpPrefixV4AndASLocalPrefMED(t *testing.T, otg *otg.OTG, dut *on | |
t.Logf("For Prefix %v, got AS Path %d want AS Path %d are equal", bgpPrefix.GetAddress(), bgpPrefix.AsPath[0].GetAsNumbers(), metric) | ||
} | ||
case otglocalPref: | ||
validateLocalPreferenceV4(t, dut, ipAddr, metric[0]) | ||
if !deviations.BGPRibOcPathUnsupported(dut) { | ||
validateLocalPreferenceV4(t, dut, ipAddr, metric[0]) | ||
} | ||
case otgCommunity: | ||
t.Logf("For Prefix %v, Community received on OTG: %v", bgpPrefix.GetAddress(), bgpPrefix.Community) | ||
for _, gotCommunity := range bgpPrefix.Community { | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.