Skip to content

Commit

Permalink
Create subtests supporting existing tests with VRF forwarding policy (o…
Browse files Browse the repository at this point in the history
  • Loading branch information
self-maurya authored Feb 6, 2024
1 parent f3f912e commit 401c8c9
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 210 deletions.
10 changes: 7 additions & 3 deletions feature/experimental/gribi/otg_tests/backup_nhg_action/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ Different test scenarios requires different setups.
traffic with decapsulated traffic with destination IP as `InnerDstIP_1`
at ATE port-4.

[TODO]: Repeat the above tests with one additional scenario with the following changes, and it should not change the expected test result.
Repeat the above tests with one additional scenario with the following changes,
and it should not change the expected test result.

* Add an empty decap VRF, `DECAP_TE_VRF`.
* Add 4 empty encap VRFs, `ENCAP_TE_VRF_A`, `ENCAP_TE_VRF_B`, `ENCAP_TE_VRF_C` and `ENCAP_TE_VRF_D`.
* Replace the existing VRF selection policy with `vrf_selection_policy_w` as in <https://github.com/openconfig/featureprofiles/pull/2217>
* Add 4 empty encap VRFs, `ENCAP_TE_VRF_A`, `ENCAP_TE_VRF_B`, `ENCAP_TE_VRF_C`
and `ENCAP_TE_VRF_D`.
* Replace the existing VRF selection policy with `vrf_selection_policy_w` as
in <https://github.com/openconfig/featureprofiles/pull/2217>

## Config Parameter coverage

Expand All @@ -113,3 +116,4 @@ No new telemetry covered.
## Minimum DUT platform requirement

vRX if the vendor implementation supports FIB-ACK simulation, otherwise FFF.

Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// 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 backup_nhg_action_test

import (
Expand Down Expand Up @@ -27,7 +41,6 @@ const (
ipv6PrefixLen = 126
mask = "32"
outerDstIP1 = "198.51.100.1"
outerSrcIP1 = "198.51.100.2"
outerDstIP2 = "203.0.113.1"
outerSrcIP2 = "203.0.113.2"
innerDstIP1 = "198.18.0.1"
Expand Down Expand Up @@ -62,7 +75,6 @@ const (
ipOverIPProtocol = 4
srcTrackingName = "ipSrcTracking"
dstTrackingName = "ipDstTracking"
vrfPolW = "vrf_selection_policy_w"
decapFlowSrc = "198.51.100.111"
dscpEncapA1 = 10
)
Expand Down Expand Up @@ -266,16 +278,16 @@ func TestBackupNHGAction(t *testing.T) {
desc: "Usecase with 2 NHOP Groups - Backup Pointing to Decap",
fn: testBackupDecap,
},
{
name: "testDecapEncap",
desc: "Usecase with 3 NHOP Groups - Redirect pointing to back up DecapEncap and its Backup Pointing to Decap",
fn: testDecapEncap,
},
{
name: "testBackupDecapWithVrfPolW",
desc: "Usecase with 2 NHOP Groups - Backup Pointing to Decap with vrf policy W",
fn: testBackupDecapWithVrfPolW,
},
{
name: "testDecapEncap",
desc: "Usecase with 3 NHOP Groups - Redirect pointing to back up DecapEncap and its Backup Pointing to Decap",
fn: testDecapEncap,
},
{
name: "testDecapEncapWithVrfPolW",
desc: "Usecase with 3 NHOP Groups - Redirect pointing to back up DecapEncap and its Backup Pointing to Decap with vrf policy W",
Expand Down Expand Up @@ -481,12 +493,12 @@ func testDecapEncap(ctx context.Context, t *testing.T, args *testArgs) {
}

func testBackupDecapWithVrfPolW(ctx context.Context, t *testing.T, args *testArgs) {
configureVrfSelectionPolicyW(t, args.dut)
vrfpolicy.ConfigureVRFSelectionPolicyW(t, args.dut)
testBackupDecap(ctx, t, args)
}

func testDecapEncapWithVrfPolW(ctx context.Context, t *testing.T, args *testArgs) {
configureVrfSelectionPolicyW(t, args.dut)
vrfpolicy.ConfigureVRFSelectionPolicyW(t, args.dut)
testDecapEncap(ctx, t, args)
}

Expand Down Expand Up @@ -585,28 +597,3 @@ func validateTrafficFlows(t *testing.T, ate *ondatra.ATEDevice, good []gosnappi.
}
}
}

func configureVrfSelectionPolicyW(t *testing.T, dut *ondatra.DUTDevice) {
p1 := dut.Port(t, "port1")
gnmi.Delete(t, dut, gnmi.OC().NetworkInstance(vrfA).Interface(p1.Name()).Config())
t.Log("Delete existing vrf selection policy and Apply vrf selectioin policy W")
gnmi.Delete(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding().Config())

interfaceID := p1.Name()
if deviations.InterfaceRefInterfaceIDFormat(dut) {
interfaceID = interfaceID + ".0"
}

niP := vrfpolicy.BuildVRFSelectionPolicyW(t, dut, deviations.DefaultNetworkInstance(dut))
dutPolFwdPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding()
gnmi.Replace(t, dut, dutPolFwdPath.Config(), niP)

intf := niP.GetOrCreateInterface(interfaceID)
intf.ApplyVrfSelectionPolicy = ygot.String(vrfPolW)
intf.GetOrCreateInterfaceRef().Interface = ygot.String(p1.Name())
intf.GetOrCreateInterfaceRef().Subinterface = ygot.Uint32(0)
if deviations.InterfaceRefConfigUnsupported(dut) {
intf.InterfaceRef = nil
}
gnmi.Replace(t, dut, dutPolFwdPath.Interface(interfaceID).Config(), intf)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ Configure ATE and DUT:
192.0.2.74 and default gateways as 192.0.2.5, 192.0.2.9, ..., 192.0.2.73
respectively.

* On DUT port-1 and ATE port-1 create a single L3 interface.
* On DUT port-1 and ATE port-1 create a single L3 interface.

* On DUT, create a policy-based forwarding rule to redirect all traffic received from DUT port-1 into VRF-1 (based on src. IP match criteria).
* On DUT, create a policy-based forwarding rule to redirect all traffic
received from DUT port-1 into VRF-1 (based on src. IP match criteria).

Test case for basic hierarchical weight:

Expand Down Expand Up @@ -110,16 +111,20 @@ WCMP width of 16 nexthops:

* for each VLAN ID in 4...18:

* NH: (31/32) * (16/241) ~ 6.432% traffic received by ATE port-2 VLAN ID
* NH: (31/32) * (16/241) ~ 6.432% traffic received by ATE port-2 VLAN
ID

* A tolerance of 0.2% is allowed for each VLAN for now, since we only test
for 2 mins.

[TODO]: Repeat the above tests with one additional scenario with the following changes, and it should not change the expected test result.
Repeat the above tests with one additional scenario with the following changes,
and it should not change the expected test result.

* Add an empty decap VRF, `DECAP_TE_VRF`.
* Add 4 empty encap VRFs, `ENCAP_TE_VRF_A`, `ENCAP_TE_VRF_B`, `ENCAP_TE_VRF_C` and `ENCAP_TE_VRF_D`.
* Replace the existing VRF selection policy with `vrf_selection_policy_w` as in <https://github.com/openconfig/featureprofiles/pull/2217>
* Add 4 empty encap VRFs, `ENCAP_TE_VRF_A`, `ENCAP_TE_VRF_B`, `ENCAP_TE_VRF_C`
and `ENCAP_TE_VRF_D`.
* Replace the existing VRF selection policy with `vrf_selection_policy_w` as
in <https://github.com/openconfig/featureprofiles/pull/2217>

## Config Parameter Coverage

Expand All @@ -143,3 +148,4 @@ TODO:
## Minimum DUT platform requirement

vRX

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const (
nonDefaultVRF = "TE_VRF_111"
policyName = "redirect-to-VRF1"
ipipProtocol = 4
vrfPolW = "vrf_selection_policy_w"
decapFlowSrc = "198.51.100.111"
dscpEncapA1 = 10
)
Expand Down Expand Up @@ -696,43 +695,19 @@ func TestHierarchicalWeightResolution(t *testing.T) {
testBasicHierarchicalWeight(ctx, t, dut, ate, top, gRIBI)
})

t.Run("TestHierarchicalWeightBoundaryScenario", func(t *testing.T) {
testHierarchicalWeightBoundaryScenario(ctx, t, dut, ate, top, gRIBI)
})

t.Run("TestBasicHierarchicalWeightWithVrfPolW", func(t *testing.T) {
configureVrfSelectionPolicyW(t, dut)
vrfpolicy.ConfigureVRFSelectionPolicyW(t, dut)
testBasicHierarchicalWeight(ctx, t, dut, ate, top, gRIBI)
})

t.Run("TestHierarchicalWeightBoundaryScenario", func(t *testing.T) {
testHierarchicalWeightBoundaryScenario(ctx, t, dut, ate, top, gRIBI)
})

t.Run("TestHierarchicalWeightBoundaryScenarioWithVrfPolW", func(t *testing.T) {
configureVrfSelectionPolicyW(t, dut)
vrfpolicy.ConfigureVRFSelectionPolicyW(t, dut)
testHierarchicalWeightBoundaryScenario(ctx, t, dut, ate, top, gRIBI)
})

top.StopProtocols(t)
}

func configureVrfSelectionPolicyW(t *testing.T, dut *ondatra.DUTDevice) {
t.Log("Delete existing vrf selection policy and Apply vrf selectioin policy W")
gnmi.Delete(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding().Config())

p1 := dut.Port(t, "port1")
interfaceID := p1.Name()
if deviations.InterfaceRefInterfaceIDFormat(dut) {
interfaceID = interfaceID + ".0"
}

niP := vrfpolicy.BuildVRFSelectionPolicyW(t, dut, deviations.DefaultNetworkInstance(dut))
dutPolFwdPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding()
gnmi.Replace(t, dut, dutPolFwdPath.Config(), niP)

intf := niP.GetOrCreateInterface(interfaceID)
intf.ApplyVrfSelectionPolicy = ygot.String(vrfPolW)
intf.GetOrCreateInterfaceRef().Interface = ygot.String(p1.Name())
intf.GetOrCreateInterfaceRef().Subinterface = ygot.Uint32(0)
if deviations.InterfaceRefConfigUnsupported(dut) {
intf.InterfaceRef = nil
}
gnmi.Replace(t, dut, dutPolFwdPath.Interface(interfaceID).Config(), intf)
}
10 changes: 7 additions & 3 deletions feature/gribi/otg_tests/backup_nhg_multiple_nh_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ Ensure that backup NHGs are honoured with NextHopGroup entries containing >1 NH.
* Disable ATE port-3. Ensure that traffic for the destination is received at
ATE port-4.

[TODO]: Repeat the above tests with one additional scenario with the following changes, and it should not change the expected test result.
Repeat the above tests with one additional scenario with the following changes,
and it should not change the expected test result.

* Add an empty decap VRF, `DECAP_TE_VRF`.
* Add 4 empty encap VRFs, `ENCAP_TE_VRF_A`, `ENCAP_TE_VRF_B`, `ENCAP_TE_VRF_C` and `ENCAP_TE_VRF_D`.
* Replace the existing VRF selection policy with `vrf_selection_policy_w` as in <https://github.com/openconfig/featureprofiles/pull/2217>
* Add 4 empty encap VRFs, `ENCAP_TE_VRF_A`, `ENCAP_TE_VRF_B`, `ENCAP_TE_VRF_C`
and `ENCAP_TE_VRF_D`.
* Replace the existing VRF selection policy with `vrf_selection_policy_w` as
in <https://github.com/openconfig/featureprofiles/pull/2217>

## Config Parameter coverage

Expand All @@ -52,3 +55,4 @@ Ensure that backup NHGs are honoured with NextHopGroup entries containing >1 NH.
## Minimum DUT platform requirement

vRX

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const (
fps = 1000000 // traffic frames per second
switchovertime = 250.0 // switchovertime during interface shut in milliseconds
ethernetCsmacd = oc.IETFInterfaces_InterfaceType_ethernetCsmacd
vrfPolW = "vrf_selection_policy_w"
decapFlowSrc = "198.51.100.111"
dscpEncapA1 = 10
)
Expand Down Expand Up @@ -273,47 +272,42 @@ func TestBackup(t *testing.T) {
t.Fatalf("gRIBI Connection can not be established")
}

tests := []struct {
name string
desc string
vrfPolicy bool
}{
{
name: "IPv4BackUpSwitch",
desc: "Set primary and backup path with gribi and shutdown the primary path validating traffic switching over backup path",
vrfPolicy: false,
},
{
name: "IPv4BackUpSwitchWithVrfPolicyW",
desc: "Set primary and backup path with gribi and shutdown the primary path validating traffic switching over backup path with vrf policy W",
vrfPolicy: true,
},
}
// Make client leader
client.BecomeLeader(t)

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Logf("Name: %s", tt.name)
t.Logf("Description: %s", tt.desc)
// Make client leader
client.BecomeLeader(t)

// Flush past entries before running the tc
client.FlushAll(t)

tcArgs := &testArgs{
ctx: ctx,
client: &client,
dut: dut,
ate: ate,
top: top,
}

if tt.vrfPolicy {
configureVrfSelectionPolicyW(t, dut)
}
tcArgs.testIPv4BackUpSwitch(t)
})
}
// Flush past entries before running the tc
client.FlushAll(t)

t.Run("IPv4BackUpSwitch", func(t *testing.T) {
t.Logf("Name: IPv4BackUpSwitch")
t.Logf("Description: Set primary and backup path with gribi and shutdown the primary path validating traffic switching over backup path")

tcArgs := &testArgs{
ctx: ctx,
client: &client,
dut: dut,
ate: ate,
top: top,
}

tcArgs.testIPv4BackUpSwitch(t)
})

t.Run("IPv4BackUpSwitchWithVrfPolicyW", func(t *testing.T) {
t.Logf("Name: IPv4BackUpSwitchWithVrfPolicyW")
t.Logf("Description: Set primary and backup path with gribi and shutdown the primary path validating traffic switching over backup path with vrf policy W")

tcArgs := &testArgs{
ctx: ctx,
client: &client,
dut: dut,
ate: ate,
top: top,
}

vrfpolicy.ConfigureVRFSelectionPolicyW(t, dut)
tcArgs.testIPv4BackUpSwitch(t)
})
}

// testIPv4BackUpSwitch Ensure that backup NHGs are honoured with NextHopGroup entries containing >1 NH
Expand Down Expand Up @@ -523,28 +517,3 @@ func (a *testArgs) aftCheck(t testing.TB, prefix string, instance string) {
t.Fatalf("Prefix %s references a NHG that has neither NH or backup NHG", prefix)
}
}

func configureVrfSelectionPolicyW(t *testing.T, dut *ondatra.DUTDevice) {
p1 := dut.Port(t, "port1")
gnmi.Delete(t, dut, gnmi.OC().NetworkInstance(vrf1).Interface(p1.Name()).Config())
t.Log("Delete existing vrf selection policy and Apply vrf selectioin policy W")
gnmi.Delete(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding().Config())

interfaceID := p1.Name()
if deviations.InterfaceRefInterfaceIDFormat(dut) {
interfaceID = interfaceID + ".0"
}

niP := vrfpolicy.BuildVRFSelectionPolicyW(t, dut, deviations.DefaultNetworkInstance(dut))
dutPolFwdPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding()
gnmi.Replace(t, dut, dutPolFwdPath.Config(), niP)

intf := niP.GetOrCreateInterface(interfaceID)
intf.ApplyVrfSelectionPolicy = ygot.String(vrfPolW)
intf.GetOrCreateInterfaceRef().Interface = ygot.String(p1.Name())
intf.GetOrCreateInterfaceRef().Subinterface = ygot.Uint32(0)
if deviations.InterfaceRefConfigUnsupported(dut) {
intf.InterfaceRef = nil
}
gnmi.Replace(t, dut, dutPolFwdPath.Interface(interfaceID).Config(), intf)
}
Loading

0 comments on commit 401c8c9

Please sign in to comment.