Skip to content
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

Add RT-7.2.3 - Update community set and validate #3436

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion feature/bgp/policybase/otg_tests/community_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ BGP policy configuration for Community Sets
* Verify traffic is received on ATE port 1 for accepted prefixes.
* Verify traffic is not received on ATE port 1 for rejected prefixes.

* RT-7.2.3 - Update community set and validate
1. Configure a community-set named `update_comm_set` with "100:1" as member.

2. Create a `policy-definition` named 'community-match' with the following `statements`
* statement[name='accept_update_comm_set']/
* conditions/bgp-conditions/match-community-set/config/community-set = 'update_comm_set'
* conditions/bgp-conditions/match-community-set/config/match-set-options = INVERT
* actions/config/policy-result = ACCEPT_ROUTE

3. Send traffic from ATE port-2 to all prefix-sets.
* Verify traffic is received on ATE port 1 for accepted prefixes for all community set except "100:1".
* Verify traffic is not received on ATE port 1 for rejected prefixes for community set "100:1".

4. Update the community-set named `update_comm_set` with "200:2" as member.

5. Send traffic from ATE port-2 to all prefix-sets.
* Verify traffic is received on ATE port 1 for accepted prefixes for all community set except "200:1".
* Verify traffic is not received on ATE port 1 for rejected prefixes for community set "200:1".



### Expected community matches

| prefix-set | any_my_3_comms | all_3_comms | no_3_comms | any_my_regex_comms |
Expand Down Expand Up @@ -155,4 +176,4 @@ rpcs:
gnmi:
gNMI.Set:
gNMI.Subscribe:
```
```
103 changes: 77 additions & 26 deletions feature/bgp/policybase/otg_tests/community_test/community_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,32 +225,7 @@ type testCase struct {
}

func TestCommunitySet(t *testing.T) {
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount2, nil)
bs.WithEBGP(t, []oc.E_BgpTypes_AFI_SAFI_TYPE{oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST}, []string{"port2"}, true, true)

var communityMembers = [][][]int{
{
{100, 1}, {200, 2}, {300, 3},
},
{
{100, 1}, {101, 1}, {200, 2},
},
{
{107, 1}, {108, 1}, {109, 1},
},
{
{400, 1}, {500, 1}, {600, 1},
},
}

configureOTG(t, bs, prefixesV4, prefixesV6, communityMembers)
bs.PushAndStart(t)

t.Log("Verify DUT BGP sessions up")
cfgplugins.VerifyDUTBGPEstablished(t, bs.DUT)
t.Log("Verify OTG BGP sessions up")
cfgplugins.VerifyOTGBGPEstablished(t, bs.ATE)

bs := testSetup(t)
ipv4 := bs.ATETop.Devices().Items()[1].Ethernets().Items()[0].Ipv4Addresses().Items()[0].Address()
ipv6 := bs.ATETop.Devices().Items()[1].Ethernets().Items()[0].Ipv6Addresses().Items()[0].Address()

Expand Down Expand Up @@ -319,3 +294,79 @@ func TestCommunitySet(t *testing.T) {
})
}
}

func testSetup(t *testing.T) *cfgplugins.BGPSession {
t.Helper()

bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount2, nil)
bs.WithEBGP(t, []oc.E_BgpTypes_AFI_SAFI_TYPE{oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST}, []string{"port2"}, true, true)

var communityMembers = [][][]int{
{
{100, 1}, {200, 2}, {300, 3},
},
{
{100, 1}, {101, 1}, {200, 2},
},
{
{107, 1}, {108, 1}, {109, 1},
},
{
{400, 1}, {500, 1}, {600, 1},
},
}

configureOTG(t, bs, prefixesV4, prefixesV6, communityMembers)
bs.PushAndStart(t)

t.Log("Verify DUT BGP sessions up")
cfgplugins.VerifyDUTBGPEstablished(t, bs.DUT)
t.Log("Verify OTG BGP sessions up")
cfgplugins.VerifyOTGBGPEstablished(t, bs.ATE)

return bs
}

func TestCommunitySetUpdate(t *testing.T) {
bs := testSetup(t)
ipv4 := bs.ATETop.Devices().Items()[1].Ethernets().Items()[0].Ipv4Addresses().Items()[0].Address()
ipv6 := bs.ATETop.Devices().Items()[1].Ethernets().Items()[0].Ipv6Addresses().Items()[0].Address()

commMatch := [3]string{"100:1"}
configureImportBGPPolicy(t, bs.DUT, ipv4, ipv6, "update_comm_set", commMatch, oc.BgpPolicy_MatchSetOptionsType_INVERT)
validateCommunitySetUpdateTraffic(t, bs)

// change community match set
commMatch = [3]string{"200:2"}
configureImportBGPPolicy(t, bs.DUT, ipv4, ipv6, "update_comm_set", commMatch, oc.BgpPolicy_MatchSetOptionsType_INVERT)
validateCommunitySetUpdateTraffic(t, bs)
}

func validateCommunitySetUpdateTraffic(t *testing.T, bs *cfgplugins.BGPSession) {
t.Helper()

sleepTime := time.Duration(totalPackets/trafficPps) + 2
bs.ATETop.Flows().Clear()
for index, prefixPairV4 := range prefixesV4 {
configureFlow(t, bs, prefixPairV4, "ipv4", index)
configureFlow(t, bs, prefixesV6[index], "ipv6", index)
}
bs.PushAndStartATE(t)

// Verify BGP session after its reset with OTG push config & start
cfgplugins.VerifyDUTBGPEstablished(t, bs.DUT)

t.Logf("Starting traffic for IPv4 and v6")
bs.ATE.OTG().StartTraffic(t)
time.Sleep(sleepTime * time.Second)
bs.ATE.OTG().StopTraffic(t)
otgutils.LogFlowMetrics(t, bs.ATE.OTG(), bs.ATETop)

testResults := [4]bool{false, false, true, true}
for index, prefixPairV4 := range prefixesV4 {
t.Logf("Validating traffic test for IPv4 prefixes: [%s, %s]. Expected Result: [%t]", prefixPairV4[0], prefixPairV4[1], testResults[index])
verifyTraffic(t, bs.ATE, "ipv4", testResults[index], index)
t.Logf("Validating traffic test for IPv6 prefixes: [%s, %s]. Expected Result: [%t]", prefixesV6[index][0], prefixesV6[index][1], testResults[index])
verifyTraffic(t, bs.ATE, "ipv6", testResults[index], index)
}
}
Loading