Skip to content

Commit

Permalink
Merge branch 'main' into traceroute_packetin_with_vrf_selection_test
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulsy26 authored Jul 31, 2024
2 parents 0f6f6f9 + f0c6d02 commit b7603f2
Show file tree
Hide file tree
Showing 17 changed files with 404 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,6 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond
stmt3.GetOrCreateActions().SetPolicyResult(nextstatementResult)
}

// Configure multi_policy:STATEMENT4: match_comm_and_prefix_add_2_community_sets statement

stmt4, err := pdef1.AppendNewStatement(matchCommPrefixAddCommuStatement)
if err != nil {
t.Fatalf("AppendNewStatement(%s) failed: %v", matchCommPrefixAddCommuStatement, err)
}

// Configure my_community: [ "50:1" ] to match_comm_and_prefix_add_2_community_sets statement
communitySetMatchCommPrefixAddCommu := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(myCommunitySet)

Expand All @@ -355,15 +348,30 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond
communitySetMatchCommPrefixAddCommu.SetCommunityMember(cs4)
communitySetMatchCommPrefixAddCommu.SetMatchSetOptions(matchAny)

// Configure multi_policy:STATEMENT4: match_comm_and_prefix_add_2_community_sets statement

stmt4, err := pdef1.AppendNewStatement(matchCommPrefixAddCommuStatement)
if err != nil {
t.Fatalf("AppendNewStatement(%s) failed: %v", matchCommPrefixAddCommuStatement, err)
}
stmt6, err := pdef1.AppendNewStatement(matchCommPrefixAddCommuStatement + "_V6")
if err != nil {
t.Fatalf("AppendNewStatement(%s) failed: %v", matchCommPrefixAddCommuStatement, err)
}

if deviations.BGPConditionsMatchCommunitySetUnsupported(dut) {
stmt4.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(myCommunitySet)
stmt6.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(myCommunitySet)
} else {
stmt4.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(myCommunitySet)
stmt6.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(myCommunitySet)
}

// configure match-prefix-set: prefix-set-5 to match_comm_and_prefix_add_2_community_sets statement
stmt4.GetOrCreateConditions().GetOrCreateMatchPrefixSet().SetPrefixSet(prefixSetName)
stmt4.GetOrCreateConditions().GetOrCreateMatchPrefixSet().SetMatchSetOptions(prefixSetNameSetOptions)
stmt6.GetOrCreateConditions().GetOrCreateMatchPrefixSet().SetPrefixSet(prefixSetName + "_V6")
stmt6.GetOrCreateConditions().GetOrCreateMatchPrefixSet().SetMatchSetOptions(prefixSetNameSetOptions)

pset := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet(prefixSetName)
pset.GetOrCreatePrefix(prefixesV4[4][0]+"/29", "29..30")
Expand All @@ -387,12 +395,18 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond
stmt4.GetOrCreateActions().GetOrCreateBgpActions().GetOrCreateSetCommunity().GetOrCreateReference().SetCommunitySetRefs(setCommunitySetRefs)
stmt4.GetOrCreateActions().GetOrCreateBgpActions().GetOrCreateSetCommunity().SetMethod(oc.SetCommunity_Method_REFERENCE)
stmt4.GetOrCreateActions().GetOrCreateBgpActions().GetOrCreateSetCommunity().SetOptions(oc.BgpPolicy_BgpSetCommunityOptionType_ADD)

stmt6.GetOrCreateActions().GetOrCreateBgpActions().GetOrCreateSetCommunity().GetOrCreateReference().SetCommunitySetRefs(setCommunitySetRefs)
stmt6.GetOrCreateActions().GetOrCreateBgpActions().GetOrCreateSetCommunity().SetMethod(oc.SetCommunity_Method_REFERENCE)
stmt6.GetOrCreateActions().GetOrCreateBgpActions().GetOrCreateSetCommunity().SetOptions(oc.BgpPolicy_BgpSetCommunityOptionType_ADD)
}
// set-local-pref = 5
stmt4.GetOrCreateActions().GetOrCreateBgpActions().SetSetLocalPref(localPref)
stmt6.GetOrCreateActions().GetOrCreateBgpActions().SetSetLocalPref(localPref)

if !deviations.SkipSettingStatementForPolicy(dut) {
stmt4.GetOrCreateActions().SetPolicyResult(nextstatementResult)
stmt6.GetOrCreateActions().SetPolicyResult(nextstatementResult)
}

// Configure multi_policy:STATEMENT5: match_aspath_set_med statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/open-traffic-generator/snappi/gosnappi"
"github.com/openconfig/featureprofiles/internal/attrs"
"github.com/openconfig/featureprofiles/internal/cfgplugins"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/helpers"
Expand Down Expand Up @@ -181,6 +182,9 @@ func TestBGPLinkBandwidth(t *testing.T) {
}
baseSetupConfigAndVerification(t, td)
configureExtCommunityRoutingPolicy(t, dut)
if deviations.BgpExplicitExtendedCommunityEnable(dut) {
enableExtCommunityCLIConfig(t, dut)
}
testCases := []testCase{
{
name: "Policy set not_match_100_set_linkbw_1M",
Expand Down Expand Up @@ -224,6 +228,17 @@ func TestBGPLinkBandwidth(t *testing.T) {
}
}

func enableExtCommunityCLIConfig(t *testing.T, dut *ondatra.DUTDevice) {
var extCommunityEnableCLIConfig string
switch dut.Vendor() {
case ondatra.CISCO:
extCommunityEnableCLIConfig = fmt.Sprintf("router bgp %v instance BGP neighbor-group %v \n ebgp-recv-extcommunity-dmz \n ebgp-send-extcommunity-dmz\n", dutAS, cfgplugins.BGPPeerGroup1)
default:
t.Fatalf("Unsupported vendor %s for deviation 'BgpExplicitExtendedCommunityEnable'", dut.Vendor())
}
helpers.GnmiCLIConfig(t, dut, extCommunityEnableCLIConfig)
}

func applyPolicyDut(t *testing.T, dut *ondatra.DUTDevice, policyName string) {
// Apply ipv4 policy to bgp neighbour.
root := &oc.Root{}
Expand All @@ -241,6 +256,17 @@ func applyPolicyDut(t *testing.T, dut *ondatra.DUTDevice, policyName string) {
policy = root.GetOrCreateNetworkInstance(dni).GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, bgpName).GetOrCreateBgp().GetOrCreateNeighbor(atePort1.IPv6).GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).GetOrCreateApplyPolicy()
policy.SetImportPolicy([]string{policyName})
gnmi.Replace(t, dut, path.Config(), policy)

ni := root.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut))
niProto := ni.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP")
bgp := niProto.GetOrCreateBgp()
bgp.GetOrCreatePeerGroup(cfgplugins.BGPPeerGroup1).GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
bgp.GetOrCreatePeerGroup(cfgplugins.BGPPeerGroup1).GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)
bgpNbrV4 := bgp.GetOrCreateNeighbor(atePort1.IPv4)
bgpNbrV4.PeerGroup = ygot.String(cfgplugins.BGPPeerGroup1)
bgpNbrV6 := bgp.GetOrCreateNeighbor(atePort1.IPv6)
bgpNbrV6.PeerGroup = ygot.String(cfgplugins.BGPPeerGroup1)
gnmi.Update(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Config(), niProto)
}

func validatPolicyDut(t *testing.T, dut *ondatra.DUTDevice, policyName string) {
Expand Down Expand Up @@ -292,6 +318,10 @@ func validateRouteCommunityV4Prefix(t *testing.T, td testData, community, v4Pref
}
}
default:
if len(bgpPrefix.ExtendedCommunity) == 0 {
t.Errorf("ERROR extended community is empty, expected %v", community)
return
}
for _, ec := range bgpPrefix.ExtendedCommunity {
lbSubType := ec.Structured.NonTransitive_2OctetAsType.LinkBandwidthSubtype
listCommunity := strings.Split(community, ":")
Expand Down Expand Up @@ -359,6 +389,10 @@ func validateRouteCommunityV6Prefix(t *testing.T, td testData, community, v6Pref
}
}
default:
if len(bgpPrefix.ExtendedCommunity) == 0 {
t.Errorf("ERROR extended community is empty, expected %v", community)
return
}
for _, ec := range bgpPrefix.ExtendedCommunity {
lbSubType := ec.Structured.NonTransitive_2OctetAsType.LinkBandwidthSubtype
listCommunity := strings.Split(community, ":")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ platform_exceptions: {
skip_bgp_send_community_type: true
bgp_extended_community_index_unsupported: true
bgp_conditions_match_community_set_unsupported: true
bgp_explicit_extended_community_enable: true
}
}
tags: TAGS_AGGREGATION
Expand Down
31 changes: 22 additions & 9 deletions feature/gnoi/factory_reset/tests/factory_reset_test/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
# gNOI-6.1: Factory Reset
# gNOI-6.1: Factory Reset

## Summary
Performs Factory Reset with and without disk-encryption

Performs Factory Reset

## Procedure
* Create dummy files in the harddisk of the router using bash dd
* Checks for disk-encryption status and performs reset on both the scenarios
* Secure ZTP server should be up and running in the background for the router to boot up with the base config once factory reset command is sent on the box.
* Send out Factory reset via GNOI Raw API
* Wait for the box to boot up via Secure ZTP
* The base config is updated on the box via Secure ZTP
* Connect to the router and check if the files in the harddisk are removed as a part of verifying Factory reset.

### Scenario 1

* Create a sample file in the harddisk of the router using gNOI PUT RPC
* Secure ZTP server should be up and running in the background for the router
to boot up with the base config once factory reset command is sent on the
box.
* Send out Factory reset via GNOI Raw API
* Wait for the box to boot up via Secure ZTP
* The base config is updated on the box via Secure ZTP
* Send a gNOI file STAT RPC to check if the file in the harddisk are removed
as a part of verifying Factory reset.

### Scenario 2

* Check startup-config file exists in mount path.
* Perform the same steps are `Scenario 1` for startup-config file.

## OpenConfig Path and RPC Coverage

Expand All @@ -21,4 +32,6 @@ paths used for test setup are not listed here.
rpcs:
gnoi:
factory_reset.FactoryReset.Start:
file.File.Put:
file.File.Stat:
```
Loading

0 comments on commit b7603f2

Please sign in to comment.