Skip to content

Commit

Permalink
Merge branch 'main' into AP-rt1dot30
Browse files Browse the repository at this point in the history
  • Loading branch information
trathod1 authored Dec 17, 2024
2 parents 0cc5886 + 5ccd97e commit 8bcc6eb
Show file tree
Hide file tree
Showing 12 changed files with 240 additions and 119 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/required_approvals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflow is to make sure we have 1 LGTM for business logic and 1 LGTM for code style
name: PR Approval Workflow
on:
pull_request_target:
branches:
- main
jobs:
check-approvals:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: read
steps:
- name: Check for required approvals
id: check-approvals
uses: skymoore/required-approvals@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
read_org_scoped_token: ${{ secrets.READ_ORG_SCOPED_TOKEN }}
org_name: openconfig
min_approvals: 2
approval_mode: ALL
pr_number: ${{ github.event.number }}
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,21 @@ import (
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ondatra/otg"
"github.com/openconfig/ygot/ygot"
)

const (
prefixV4Len = uint32(24)
prefixV6Len = uint32(64)
v4Network = "192.168.10.0"
v6Network = "2024:db8:64:64::"
pathID = 1
prefixesCount = 1
bgpName = "BGP"
dutAS = uint32(64656)
ateAS = uint32(64657)
peerGrpNamev4 = "BGP-PEER-GROUP-V4"
peerGrpNamev6 = "BGP-PEER-GROUP-V6"
ateSysID = "640000000001"
ateAreaAddress = "49.0002"
lossTolerance = 1
prefixV4Len = uint32(24)
prefixV6Len = uint32(64)
v4Network = "192.168.10.0"
v6Network = "2024:db8:64:64::"
prefixesCount = 1
bgpName = "BGP"
dutAS = uint32(64656)
ateAS = uint32(64657)
peerGrpNameV4 = "BGP-PEER-GROUP-V4"
peerGrpNameV6 = "BGP-PEER-GROUP-V6"
lossTolerance = 1
)

var (
Expand All @@ -69,8 +65,8 @@ var (
IPv6Len: 126,
}

advertisedIPv4 ipAddr = ipAddr{address: v4Network, prefix: prefixV4Len}
advertisedIPv6 ipAddr = ipAddr{address: v6Network, prefix: prefixV6Len}
advertisedIPv4 = ipAddr{address: v4Network, prefix: prefixV4Len}
advertisedIPv6 = ipAddr{address: v6Network, prefix: prefixV6Len}
)

type ipAddr struct {
Expand All @@ -86,7 +82,7 @@ func TestMain(m *testing.M) {
func TestAdminDistance(t *testing.T) {
ts := isissession.MustNew(t).WithISIS()
configurePort3(t, ts)
advertisePrefixFromISISPort(t, ts)
advertisePrefixFromISISPort(ts)
t.Run("ISIS Setup", func(t *testing.T) {
ts.PushAndStart(t)
ts.MustAdjacency(t)
Expand Down Expand Up @@ -147,8 +143,8 @@ func TestAdminDistance(t *testing.T) {
}

ts.ATETop.Flows().Clear()
createFlow(t, ts.ATETop, ts.ATE.OTG(), false)
createFlow(t, ts.ATETop, ts.ATE.OTG(), true)
createFlow(t, ts.ATETop, false)
createFlow(t, ts.ATETop, true)
ts.ATE.OTG().PushConfig(t, ts.ATETop)
ts.ATE.OTG().StartProtocols(t)
otgutils.WaitForARP(t, ts.ATE.OTG(), ts.ATETop, "IPv4")
Expand Down Expand Up @@ -217,7 +213,7 @@ func configurePort3(t *testing.T, ts *isissession.TestSession) {
atePort3.AddToOTG(ts.ATETop, ap3, dutPort3)
}

func createFlow(t *testing.T, config gosnappi.Config, otg *otg.OTG, isV6 bool) {
func createFlow(t *testing.T, config gosnappi.Config, isV6 bool) {
t.Helper()

flowName := "flowV4"
Expand Down Expand Up @@ -270,21 +266,21 @@ func setupEBGPAndAdvertise(t *testing.T, ts *isissession.TestSession) {
g.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
g.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)

pgv4 := bgp.GetOrCreatePeerGroup(peerGrpNamev4)
pgv4 := bgp.GetOrCreatePeerGroup(peerGrpNameV4)
pgv4.PeerAs = ygot.Uint32(dutAS)
pgv4.PeerGroupName = ygot.String(peerGrpNamev4)
pgv6 := bgp.GetOrCreatePeerGroup(peerGrpNamev6)
pgv4.PeerGroupName = ygot.String(peerGrpNameV4)
pgv6 := bgp.GetOrCreatePeerGroup(peerGrpNameV6)
pgv6.PeerAs = ygot.Uint32(dutAS)
pgv6.PeerGroupName = ygot.String(peerGrpNamev6)
pgv6.PeerGroupName = ygot.String(peerGrpNameV6)

nV4 := bgp.GetOrCreateNeighbor(isissession.ATETrafficAttrs.IPv4)
nV4.SetPeerAs(ateAS)
nV4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
nV4.PeerGroup = ygot.String(peerGrpNamev4)
nV4.PeerGroup = ygot.String(peerGrpNameV4)
nV6 := bgp.GetOrCreateNeighbor(isissession.ATETrafficAttrs.IPv6)
nV6.SetPeerAs(ateAS)
nV6.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)
nV6.PeerGroup = ygot.String(peerGrpNamev6)
nV6.PeerGroup = ygot.String(peerGrpNameV6)

// Configure Import Allow-All policy
configureRoutePolicy(t, ts.DUT, "ALLOW", oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE)
Expand Down Expand Up @@ -313,22 +309,22 @@ func setupEBGPAndAdvertise(t *testing.T, ts *isissession.TestSession) {
bgp6Peer.SetPeerAddress(isissession.DUTTrafficAttrs.IPv6).SetAsNumber(ateAS).SetAsType(gosnappi.BgpV6PeerAsType.EBGP)

// configure emulated IPv4 and IPv6 networks
netv4 := bgp4Peer.V4Routes().Add().SetName("v4-bgpNet-dev")
netv4.Addresses().Add().SetAddress(advertisedIPv4.address).SetPrefix(advertisedIPv4.prefix).SetCount(uint32(prefixesCount))
netV4 := bgp4Peer.V4Routes().Add().SetName("v4-bgpNet-dev")
netV4.Addresses().Add().SetAddress(advertisedIPv4.address).SetPrefix(advertisedIPv4.prefix).SetCount(uint32(prefixesCount))

netv6 := bgp6Peer.V6Routes().Add().SetName("v6-bgpNet-dev")
netv6.Addresses().Add().SetAddress(advertisedIPv6.address).SetPrefix(advertisedIPv6.prefix).SetCount(uint32(prefixesCount))
netV6 := bgp6Peer.V6Routes().Add().SetName("v6-bgpNet-dev")
netV6.Addresses().Add().SetAddress(advertisedIPv6.address).SetPrefix(advertisedIPv6.prefix).SetCount(uint32(prefixesCount))

ts.ATE.OTG().PushConfig(t, ts.ATETop)
ts.ATE.OTG().StartProtocols(t)
otgutils.WaitForARP(t, ts.ATE.OTG(), ts.ATETop, "IPv4")
otgutils.WaitForARP(t, ts.ATE.OTG(), ts.ATETop, "IPv6")
}

func advertisePrefixFromISISPort(t *testing.T, ts *isissession.TestSession) {
netv4 := ts.ATEIntf1.Isis().V4Routes().Add().SetName("netv4").SetLinkMetric(10).SetOriginType(gosnappi.IsisV4RouteRangeOriginType.EXTERNAL)
netv4.Addresses().Add().SetAddress(advertisedIPv4.address).SetPrefix(advertisedIPv4.prefix).SetCount(uint32(prefixesCount))
func advertisePrefixFromISISPort(ts *isissession.TestSession) {
netV4 := ts.ATEIntf1.Isis().V4Routes().Add().SetName("netv4").SetLinkMetric(10).SetOriginType(gosnappi.IsisV4RouteRangeOriginType.EXTERNAL)
netV4.Addresses().Add().SetAddress(advertisedIPv4.address).SetPrefix(advertisedIPv4.prefix).SetCount(uint32(prefixesCount))

netv6 := ts.ATEIntf1.Isis().V6Routes().Add().SetName("netv6").SetLinkMetric(10).SetOriginType(gosnappi.IsisV6RouteRangeOriginType.EXTERNAL)
netv6.Addresses().Add().SetAddress(advertisedIPv6.address).SetPrefix(advertisedIPv6.prefix).SetCount(uint32(prefixesCount))
netV6 := ts.ATEIntf1.Isis().V6Routes().Add().SetName("netv6").SetLinkMetric(10).SetOriginType(gosnappi.IsisV6RouteRangeOriginType.EXTERNAL)
netV6.Addresses().Add().SetAddress(advertisedIPv6.address).SetPrefix(advertisedIPv6.prefix).SetCount(uint32(prefixesCount))
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package isis_interface_level_passive_test

import (
"fmt"
"net"
"testing"
"time"
Expand All @@ -23,8 +24,10 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/helpers"
"github.com/openconfig/featureprofiles/internal/isissession"
"github.com/openconfig/featureprofiles/internal/otgutils"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ygot/ygot"
Expand Down Expand Up @@ -99,8 +102,8 @@ func configureISIS(t *testing.T, ts *isissession.TestSession) {
// Interface level configs.
isisIntfLevel2 := intf.GetOrCreateLevel(2)
isisIntfLevel2.LevelNumber = ygot.Uint8(2)
isisIntfLevel2.SetEnabled(true)
isisIntfLevel2.Enabled = ygot.Bool(true)
isisIntfLevel2.Passive = ygot.Bool(true)

isisIntfLevel2.GetOrCreateHelloAuthentication().Enabled = ygot.Bool(true)
isisIntfLevel2.GetHelloAuthentication().AuthPassword = ygot.String(password)
Expand Down Expand Up @@ -170,39 +173,67 @@ func configureOTG(t *testing.T, ts *isissession.TestSession) {
func TestISISLevelPassive(t *testing.T) {
ts := isissession.MustNew(t).WithISIS()
configureISIS(t, ts)

dut := ts.DUT
configureOTG(t, ts)
otg := ts.ATE.OTG()

pcl := ts.DUTConf.GetNetworkInstance(deviations.DefaultNetworkInstance(ts.DUT)).GetProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, isissession.ISISName)
fptest.LogQuery(t, "Protocol ISIS", isissession.ProtocolPath(ts.DUT).Config(), pcl)

ts.PushAndStart(t)
time.Sleep(time.Minute * 2)

statePath := isissession.ISISPath(ts.DUT)
intfName := ts.DUTPort1.Name()
if deviations.ExplicitInterfaceInDefaultVRF(ts.DUT) {
intfName += ".0"
}
t.Run("Isis telemetry", func(t *testing.T) {
time.Sleep(time.Minute * 1)
var isispassiveconfig string
t.Run("Passive checks", func(t *testing.T) {
// Passive should be true.
if got := gnmi.Get(t, ts.DUT, statePath.Interface(intfName).Level(2).Passive().State()); got != true {
t.Errorf("FAIL- Expected level 2 passive state not found, got %t, want %t", got, true)
if deviations.IsisInterfaceLevelPassiveUnsupported(ts.DUT) {
switch dut.Vendor() {
case ondatra.CISCO:
isispassiveconfig = fmt.Sprintf("router isis DEFAULT\n interface %s\n passive\n", intfName)
default:
t.Fatalf("Unsupported vendor %s for deviation 'IsisInterfaceLevelPassiveUnsupported'", dut.Vendor())
}
helpers.GnmiCLIConfig(t, dut, isispassiveconfig)
} else {
gnmi.Update(t, ts.DUT, statePath.Interface(intfName).Level(2).Passive().Config(), true)
}
if !deviations.IsisInterfaceLevelPassiveUnsupported(ts.DUT) {
// Passive should be true.
if got := gnmi.Get(t, ts.DUT, statePath.Interface(intfName).Level(2).Passive().State()); got != true {
t.Errorf("FAIL- Expected level 2 passive state not found, got %t, want %t", got, true)
}
}
t.Logf("Adjacency state after passive update is %s", statePath.Interface(intfName).Level(2).AdjacencyAny().AdjacencyState().State())
// Adjacency should be down.
for _, val := range gnmi.LookupAll(t, ts.DUT, statePath.Interface(intfName).LevelAny().AdjacencyAny().AdjacencyState().State()) {
if v, _ := val.Val(); v == oc.Isis_IsisInterfaceAdjState_UP {
t.Fatalf("Adjacency should not be up as level 2 is passive")
}
}
// Updating passive config to false on dut.
gnmi.Update(t, ts.DUT, statePath.Interface(intfName).Level(2).Passive().Config(), false)
time.Sleep(time.Second * 5)

if got := gnmi.Get(t, ts.DUT, statePath.Interface(intfName).Level(2).Passive().State()); got != false {
t.Errorf("FAIL- Expected level 2 passive state not found, got %t, want %t", got, true)
if deviations.IsisInterfaceLevelPassiveUnsupported(ts.DUT) {
switch dut.Vendor() {
case ondatra.CISCO:
isispassiveconfig = fmt.Sprintf("router isis DEFAULT\n interface %s\n no passive\n", intfName)
default:
t.Fatalf("Unsupported vendor %s for deviation 'IsisInterfaceLevelPassiveUnsupported'", dut.Vendor())
}
helpers.GnmiCLIConfig(t, dut, isispassiveconfig)
} else {
gnmi.Update(t, ts.DUT, statePath.Interface(intfName).Level(2).Passive().Config(), false)
}
if !deviations.IsisInterfaceLevelPassiveUnsupported(ts.DUT) {
if got := gnmi.Get(t, ts.DUT, statePath.Interface(intfName).Level(2).Passive().State()); got != false {
t.Errorf("FAIL- Expected level 2 passive state not found, got %t, want %t", got, true)
}
}
t.Logf("Adjacency state after passive update is %s", statePath.Interface(intfName).LevelAny().AdjacencyAny().AdjacencyState().State())
// Level 2 adjacency should be up.
_, err := ts.AwaitAdjacency()
if err != nil {
Expand Down Expand Up @@ -244,8 +275,10 @@ func TestISISLevelPassive(t *testing.T) {
if got := gnmi.Get(t, ts.DUT, adjPath.AreaAddress().State()); !cmp.Equal(got, want, cmpopts.SortSlices(func(a, b string) bool { return a < b })) {
t.Errorf("FAIL- Expected area address not found, got %s, want %s", got, want)
}
if got := gnmi.Get(t, ts.DUT, adjPath.DisSystemId().State()); got != "0000.0000.0000" {
t.Errorf("FAIL- Expected dis system id not found, got %s, want %s", got, "0000.0000.0000")
if !deviations.IsisDisSysidUnsupported(ts.DUT) {
if got := gnmi.Get(t, ts.DUT, adjPath.DisSystemId().State()); got != "0000.0000.0000" {
t.Errorf("FAIL- Expected dis system id not found, got %s, want %s", got, "0000.0000.0000")
}
}
if got := gnmi.Get(t, ts.DUT, adjPath.LocalExtendedCircuitId().State()); got == 0 {
t.Errorf("FAIL- Expected local extended circuit id not found,expected non-zero value, got %d", got)
Expand Down Expand Up @@ -298,8 +331,10 @@ func TestISISLevelPassive(t *testing.T) {
if got := gnmi.Get(t, ts.DUT, statePath.Level(2).SystemLevelCounters().CorruptedLsps().State()); got != 0 {
t.Errorf("FAIL- Not expecting any corrupted lsps, got %d, want %d", got, 0)
}
if got := gnmi.Get(t, ts.DUT, statePath.Level(2).SystemLevelCounters().DatabaseOverloads().State()); got != 0 {
t.Errorf("FAIL- Not expecting non zero database_overloads, got %d, want %d", got, 0)
if !deviations.IsisDatabaseOverloadsUnsupported(ts.DUT) {
if got := gnmi.Get(t, ts.DUT, statePath.Level(2).SystemLevelCounters().DatabaseOverloads().State()); got != 0 {
t.Errorf("FAIL- Not expecting non zero database_overloads, got %d, want %d", got, 0)
}
}
if got := gnmi.Get(t, ts.DUT, statePath.Level(2).SystemLevelCounters().ExceedMaxSeqNums().State()); got != 0 {
t.Errorf("FAIL- Not expecting non zero max_seqnum counter, got %d, want %d", got, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ platform_exceptions: {
deviations: {
ipv4_missing_enabled: true
isis_interface_level1_disable_required: true
isis_dis_sysid_unsupported: true
isis_database_overloads_unsupported: true
}
}
platform_exceptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1055,23 +1055,23 @@ func TestDefaultPowerAdminState(t *testing.T) {
t.Logf("Supervisors: %v", supervisors)

if len(fabrics) != 0 {
pas := gnmi.Get(t, dut, gnmi.OC().Component(fabrics[0].GetName()).Fabric().PowerAdminState().Config())
pas := gnmi.Get(t, dut, gnmi.OC().Component(fabrics[0].GetName()).Fabric().PowerAdminState().State())
t.Logf("Component %s PowerAdminState: %v", fabrics[0].GetName(), pas)
if pas == oc.Platform_ComponentPowerType_UNSET {
t.Errorf("Component %s PowerAdminState is unset", fabrics[0].GetName())
}
}

if len(linecards) != 0 {
pas := gnmi.Get(t, dut, gnmi.OC().Component(linecards[0].GetName()).Linecard().PowerAdminState().Config())
pas := gnmi.Get(t, dut, gnmi.OC().Component(linecards[0].GetName()).Linecard().PowerAdminState().State())
t.Logf("Component %s PowerAdminState: %v", linecards[0].GetName(), pas)
if pas == oc.Platform_ComponentPowerType_UNSET {
t.Errorf("Component %s PowerAdminState is unset", linecards[0].GetName())
}
}
if !deviations.SkipControllerCardPowerAdmin(dut) {
if len(supervisors) != 0 {
pas := gnmi.Get(t, dut, gnmi.OC().Component(supervisors[0].GetName()).ControllerCard().PowerAdminState().Config())
pas := gnmi.Get(t, dut, gnmi.OC().Component(supervisors[0].GetName()).ControllerCard().PowerAdminState().State())
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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1645,8 +1645,10 @@ func testJuniperSchedulerPoliciesConfig(t *testing.T) {
if got, want := gnmi.Get(t, dut, scheduler.Sequence().State()), tc.sequence; got != want {
t.Errorf("scheduler.Sequence().State(): got %v, want %v", got, want)
}
if got, want := gnmi.Get(t, dut, scheduler.Priority().State()), tc.priority; got != want {
t.Errorf("scheduler.Priority().State(): got %v, want %v", got, want)
if tc.priority == oc.Scheduler_Priority_STRICT {
if got, want := gnmi.Get(t, dut, scheduler.Priority().State()), tc.priority; got != want {
t.Errorf("scheduler.Priority().State(): got %v, want %v", got, want)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ func TestManagementHA1(t *testing.T) {
})

t.Run("traffic received by port1", func(t *testing.T) {
createFlowV6(t, bs)
gnmi.Replace(t, dut, gnmi.OC().Interface(p1.Name()).Enabled().Config(), true)
gnmi.Await(t, dut, gnmi.OC().Interface(p1.Name()).AdminStatus().State(), 30*time.Second, oc.Interface_AdminStatus_UP)
createFlowV6(t, bs)
time.Sleep(30 * time.Second)
bs.ATE.OTG().StartTraffic(t)
time.Sleep(30 * time.Second)
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ require (
github.com/spf13/viper v1.19.0
github.com/yoheimuta/go-protoparser/v4 v4.9.0
github.com/yuin/goldmark v1.4.13
golang.org/x/crypto v0.27.0
golang.org/x/crypto v0.31.0
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8
golang.org/x/text v0.18.0
golang.org/x/text v0.21.0
google.golang.org/api v0.171.0
google.golang.org/grpc v1.66.2
google.golang.org/protobuf v1.34.2
Expand Down Expand Up @@ -154,9 +154,9 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
Expand Down
Loading

0 comments on commit 8bcc6eb

Please sign in to comment.