Skip to content

Commit

Permalink
Merge branch 'main' into gribigo_compliance_test
Browse files Browse the repository at this point in the history
  • Loading branch information
robshakir authored Jul 30, 2024
2 parents 0dc1737 + f0c6d02 commit 11f61ca
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 92 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
24 changes: 18 additions & 6 deletions feature/gnoi/factory_reset/tests/factory_reset_test/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
# gNOI-6.1: Factory Reset
# gNOI-6.1: Factory Reset

## Summary

Performs Factory Reset

## Procedure

### 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.
* 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 Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
package factoryreset
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package factory_reset_test

import (
"context"
Expand All @@ -25,9 +39,8 @@ var (
ondatra.CISCO: "/misc/disk1/",
ondatra.NOKIA: "/tmp/",
ondatra.JUNIPER: "/var/tmp/",
ondatra.ARISTA: "/mnt/flash/",
}
afterReset = false
fileName = "devrandom.log"
)

const maxRebootTime = 40 // 40 mins wait time for the factory reset and sztp to kick in
Expand Down Expand Up @@ -117,7 +130,7 @@ func gNOIPutFile(t *testing.T, dut *ondatra.DUTDevice, gnoiClient gnoigo.Clients
}
}

func gNOIStatFile(t *testing.T, dut *ondatra.DUTDevice, fName string) {
func gNOIStatFile(t *testing.T, dut *ondatra.DUTDevice, fName string, reset bool) {
dutVendor := dut.Vendor()
fullPath := filepath.Join(remoteFilePath[dutVendor], fName)
gnoiClient, err := dut.RawAPIs().BindingDUT().DialGNOI(context.Background())
Expand Down Expand Up @@ -150,40 +163,62 @@ func gNOIStatFile(t *testing.T, dut *ondatra.DUTDevice, fName string) {
}
}
if isCreatedFile {
if !afterReset {
if !reset {
t.Logf("gNOI PUT successfully created file: %s", fullPath)
} else {
t.Errorf("gNOI PUT file was found after Factory Reset: %s", fullPath)
}
}
if !isCreatedFile {
if !afterReset {
if !reset {
t.Error("gNOI PUT file was never Created")
} else {
t.Logf("Did not find %s in the list of files", fullPath)
}
}
}

func factoryReset(t *testing.T, dut *ondatra.DUTDevice) {
gnoiClient, err := dut.RawAPIs().BindingDUT().DialGNOI(context.Background())
if err != nil {
t.Fatalf("Error dialing gNOI: %v", err)
}
gNOIPutFile(t, dut, gnoiClient, fileName)
gNOIStatFile(t, dut, fileName)
facRe, err := gnoiClient.FactoryReset().Start(context.Background(), &frpb.StartRequest{FactoryOs: false, ZeroFill: false})
if err != nil {
t.Fatalf("Failed to initiate Factory Reset on the device, Error : %v ", err)
}
t.Logf("Factory reset Response %v ", facRe)
time.Sleep(2 * time.Minute)
deviceBootStatus(t, dut)
afterReset = true
gNOIStatFile(t, dut, fileName)
}

func TestFactoryReset(t *testing.T) {
dut := ondatra.DUT(t, "dut")
factoryReset(t, dut)

testCases := []struct {
name string
fileName string
fileExist bool
}{
{
name: "Random file",
fileName: "devrandom.log",
fileExist: false,
},
{
name: "Startup config",
fileName: "startup-config",
fileExist: true,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
gnoiClient, err := dut.RawAPIs().BindingDUT().DialGNOI(context.Background())
if err != nil {
t.Fatalf("Error dialing gNOI: %v", err)
}

if !tc.fileExist {
gNOIPutFile(t, dut, gnoiClient, tc.fileName)
}
gNOIStatFile(t, dut, tc.fileName, tc.fileExist)

res, err := gnoiClient.FactoryReset().Start(context.Background(), &frpb.StartRequest{FactoryOs: false, ZeroFill: false})
if err != nil {
t.Fatalf("Failed to initiate Factory Reset on the device, Error : %v ", err)
}
t.Logf("Factory reset Response %v ", res)
time.Sleep(2 * time.Minute)

deviceBootStatus(t, dut)
gNOIStatFile(t, dut, tc.fileName, true)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,16 @@ func TestBaseHierarchicalNHGUpdate(t *testing.T) {
desc: "Usecase for NHG update in hierarchical resolution scenario",
fn: testBaseHierarchialNHG,
},
{
name: "testRecursiveIPv4EntrywithVRFSelectionPolW",
desc: "Usecase for NHG update in hierarchical resolution scenario with VRF Selection Policy W",
fn: testBaseHierarchialNHGwithVrfPolW,
},
{
name: "testImplementDrain",
desc: "Usecase for Implementing Drain test",
fn: testImplementDrain,
},
{
name: "testRecursiveIPv4EntrywithVRFSelectionPolW",
desc: "Usecase for NHG update in hierarchical resolution scenario with VRF Selection Policy W",
fn: testBaseHierarchialNHGwithVrfPolW,
},
}
// Configure the gRIBI client
client := gribi.Client{
Expand Down Expand Up @@ -285,6 +285,9 @@ func testBaseHierarchialNHGwithVrfPolW(ctx context.Context, t *testing.T, args *
}
vrfpolicy.ConfigureVRFSelectionPolicy(t, args.dut, vrfpolicy.VRFPolicyW)

// Remove interface from VRF-1.
gnmi.Delete(t, args.dut, gnmi.OC().NetworkInstance(vrfName).Config())

ctx = context.WithValue(ctx, transitKey{}, true)
testBaseHierarchialNHG(ctx, t, args)
//Delete Policy-forwarding PolicyW from the ingress interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func configureDUTLinkLocalInterface(t *testing.T, dut *ondatra.DUTDevice, p *ond
}
s.GetOrCreateIpv6().GetOrCreateAutoconf()
gnmi.Replace(t, dut, gnmi.OC().Interface(p.Name()).Config(), intf)
if deviations.ExplicitInterfaceInDefaultVRF(dut) {
fptest.AssignToNetworkInstance(t, dut, intf.GetName(), deviations.DefaultNetworkInstance(dut), 0)
}
}

func getAllIPv6Addresses(t *testing.T, dut *ondatra.DUTDevice, p *ondatra.Port) []string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
uuid: "22ba3cd3-0dcb-4aba-9a09-d7180785e92c"
plan_id: "RT-5.10"
description: "IPv6 Link Local generated by SLAAC"
testbed: TESTBED_DUT
testbed: TESTBED_DUT_ATE_2LINKS
tags: TAGS_TRANSIT
tags: TAGS_DATACENTER_EDGE

Expand Down Expand Up @@ -32,6 +32,7 @@ platform_exceptions: {
}
deviations: {
interface_enabled: true
explicit_interface_in_default_vrf: true
}
}
platform_exceptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ platform_exceptions: {
ipv6_static_route_with_ipv4_next_hop_requires_static_arp: true
routing_policy_tag_set_embedded: true
same_policy_attached_to_all_afis: true
match_tag_set_condition_unsupported: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ func TestStaticToISISRedistribution(t *testing.T) {
}}

for _, tc := range cases {
if deviations.MatchTagSetConditionUnsupported(ts.DUT) && tc.TagSetCondition {
t.Skipf("Skipping test case %s due to match tag set condition not supported", tc.desc)
}

dni := deviations.DefaultNetworkInstance(ts.DUT)

t.Run(tc.desc, func(t *testing.T) {
Expand Down
42 changes: 42 additions & 0 deletions feature/mpls/otg_tests/static_lsp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# TE-9.2: MPLS based forwarding Static LSP

## Summary

Validate static lsp functionality.

## Procedure

* Create topology ATE1–DUT1-ATE2
* Enable MPLS forwarding and create egress static LSP to pop the label and forward to ATE2:
* Match incoming label (1000001)
* Set IP next-hop
* Set egress interface
* Set the action to pop label
* Start 2 traffic flows with specified MPLS tags IPv4-MPLS[1000002]-MPLS[1000001]
* Verify that traffic is received at ATE2 with MPLS label [1000001] removed

## OpenConfig Path and RPC Coverage

The below yaml defines the OC paths intended to be covered by this test. OC
paths used for test setup are not listed here.

```yaml
paths:
## Config paths
/network-instances/network-instance/mpls/lsps/static-lsps/static-lsp/egress/config/next-hop:
/network-instances/network-instance/mpls/lsps/static-lsps/static-lsp/egress/config/incoming-label:
/network-instances/network-instance/mpls/lsps/static-lsps/static-lsp/egress/config/push-label:

## State paths
/network-instances/network-instance/mpls/lsps/static-lsps/static-lsp/egress/state/next-hop:
/network-instances/network-instance/mpls/lsps/static-lsps/static-lsp/egress/state/incoming-label:
/network-instances/network-instance/mpls/lsps/static-lsps/static-lsp/egress/state/push-label:
/network-instances/network-instance/mpls/lsps/static-lsps/static-lsp/egress/state/metric:
/network-instances/network-instance/mpls/lsps/static-lsps/static-lsp/egress/state/interface:
/network-instances/network-instance/mpls/lsps/static-lsps/static-lsp/egress/state/subinterface:

rpcs:
gnmi:
gNMI.Set:
gNMI.Subscribe:
```
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ platform_exceptions: {
backplane_facing_capacity_unsupported: true
install_position_and_install_component_unsupported: true
model_name_unsupported: true
skip_controller_card_power_admin: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1069,12 +1069,13 @@ func TestDefaultPowerAdminState(t *testing.T) {
t.Errorf("Component %s PowerAdminState is unset", linecards[0].GetName())
}
}

if len(supervisors) != 0 {
pas := gnmi.Get(t, dut, gnmi.OC().Component(supervisors[0].GetName()).ControllerCard().PowerAdminState().Config())
t.Logf("Component %s PowerAdminState: %v", supervisors[0].GetName(), pas)
if pas == oc.Platform_ComponentPowerType_UNSET {
t.Errorf("Component %s PowerAdminState is unset", supervisors[0].GetName())
if !deviations.SkipControllerCardPowerAdmin(dut) {
if len(supervisors) != 0 {
pas := gnmi.Get(t, dut, gnmi.OC().Component(supervisors[0].GetName()).ControllerCard().PowerAdminState().Config())
t.Logf("Component %s PowerAdminState: %v", supervisors[0].GetName(), pas)
if pas == oc.Platform_ComponentPowerType_UNSET {
t.Errorf("Component %s PowerAdminState is unset", supervisors[0].GetName())
}
}
}
}
5 changes: 5 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,3 +1103,8 @@ func QOSInQueueDropCounterUnsupported(dut *ondatra.DUTDevice) bool {
func BgpExplicitExtendedCommunityEnable(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpExplicitExtendedCommunityEnable()
}

// MatchTagSetConditionUnsupported returns true if match tag set condition is not supported
func MatchTagSetConditionUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetMatchTagSetConditionUnsupported()
}
2 changes: 2 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ message Metadata {
bool qos_inqueue_drop_counter_unsupported = 207;
// Devices that need bgp extended community enable explicitly
bool bgp_explicit_extended_community_enable = 208;
// devices that do not support match tag set condition
bool match_tag_set_condition_unsupported = 209;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19, 36, 35;
Expand Down
Loading

0 comments on commit 11f61ca

Please sign in to comment.