Skip to content

Commit

Permalink
Merge branch 'openconfig:main' into certz1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
priyacj authored Aug 14, 2024
2 parents 7cd532a + 6a634f0 commit d3f276f
Show file tree
Hide file tree
Showing 44 changed files with 967 additions and 484 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ platform_exceptions: {
skip_set_rp_match_set_options: true
bgp_community_set_refs_unsupported: true
bgp_conditions_match_community_set_unsupported: true
skip_prefix_set_mode: true
bgp_community_member_is_a_string: true
skip_bgp_send_community_type: true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package container_lifecycle
package container_lifecycle_test

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ import (
"github.com/openconfig/featureprofiles/internal/attrs"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/gnoi"
gpb "github.com/openconfig/gnmi/proto/gnmi"
gnps "github.com/openconfig/gnoi/system"
"github.com/openconfig/gnoigo/system"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ondatra/gnmi/oc/acl"
"github.com/openconfig/ondatra/gnoi"
"github.com/openconfig/ondatra/ixnet"
"github.com/openconfig/ygnmi/ygnmi"
"github.com/openconfig/ygot/ygot"
Expand Down Expand Up @@ -192,12 +190,6 @@ var (
IPv4Len: plenIPv4,
IPv6Len: plenIPv6,
}
routingDaemon = map[ondatra.Vendor]string{
ondatra.JUNIPER: "rpd",
ondatra.ARISTA: "Bgp-main",
ondatra.CISCO: "emsd",
ondatra.NOKIA: "sr_bgp_mgr",
}
)

func configureRoutePolicy(t *testing.T, dut *ondatra.DUTDevice, name string, pr oc.E_RoutingPolicy_PolicyResultType) {
Expand Down Expand Up @@ -652,56 +644,6 @@ func removeNewPeers(t *testing.T, dut *ondatra.DUTDevice, nbrs []*bgpNeighbor) {
fptest.LogQuery(t, "DUT BGP Config", dutConfPath.Config(), gnmi.Get(t, dut, dutConfPath.Config()))
}

func restartRoutingProcess(t *testing.T, dut *ondatra.DUTDevice) {
t.Helper()
if _, ok := routingDaemon[dut.Vendor()]; !ok {
t.Fatalf("Please add support for vendor %v in var routingDaemon", dut.Vendor())
}
t.Run("KillGRIBIDaemon", func(t *testing.T) {
// Find the PID of routing Daemon.
var pId uint64
pName := routingDaemon[dut.Vendor()]
t.Run("FindroutingDaemonPid", func(t *testing.T) {
pId = findProcessByName(t, dut, pName)
if pId == 0 {
t.Fatalf("Couldn't find pid of routing daemon '%s'", pName)
} else {
t.Logf("Pid of routing daemon '%s' is '%d'", pName, pId)
}
})

// Kill routing daemon through gNOI Kill Request.
t.Run("ExecuteGnoiKill", func(t *testing.T) {
// TODO - pid type is uint64 in oc-system model, but uint32 in gNOI Kill Request proto.
// Until the models are brought in line, typecasting the uint64 to uint32.
gNOIKillProcess(t, dut, pName, uint32(pId))
// Wait for a bit for routing daemon on the DUT to restart.
time.Sleep(30 * time.Second)
})
})
}

// findProcessByName uses telemetry to find out the PID of a process
func findProcessByName(t *testing.T, dut *ondatra.DUTDevice, pName string) uint64 {
t.Helper()
pList := gnmi.GetAll(t, dut, gnmi.OC().System().ProcessAny().State())
var pID uint64
for _, proc := range pList {
if proc.GetName() == pName {
pID = proc.GetPid()
t.Logf("Pid of daemon '%s' is '%d'", pName, pID)
}
}
return pID
}

// gNOIKillProcess kills a daemon on the DUT, given its name and pid.
func gNOIKillProcess(t *testing.T, dut *ondatra.DUTDevice, pName string, pID uint32) {
t.Helper()
killResponse := gnoi.Execute(t, dut, system.NewKillProcessOperation().Name(pName).PID(pID).Signal(gnps.KillProcessRequest_SIGNAL_TERM).Restart(true))
t.Logf("Got kill process response: %v\n\n", killResponse)
}

// setBgpPolicy is used to configure routing policy on DUT.
func setBgpPolicy(t *testing.T, dut *ondatra.DUTDevice, d *oc.Root) {
t.Helper()
Expand Down Expand Up @@ -943,7 +885,7 @@ func TestTrafficWithGracefulRestartLLGR(t *testing.T) {
})

t.Run("Restart routing", func(t *testing.T) {
restartRoutingProcess(t, dut)
gnoi.KillProcess(t, dut, gnoi.ROUTING, true)
})

var bgpIxPeer []*ixnet.BGP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func validateRouteCommunityV4Prefix(t *testing.T, td testData, community, v4Pref
t.Errorf("ERROR lb Bandwidth want :2G, got=%v", ygot.BinaryToFloat32(lbSubType.GetBandwidth()))
}
}
if deviations.BgpExtendedCommunityIndexUnsupported(td.dut) {
if !deviations.BgpExtendedCommunityIndexUnsupported(td.dut) {
verifyExtCommunityIndexV4(t, td, v4Prefix)
}
}
Expand Down Expand Up @@ -410,7 +410,7 @@ func validateRouteCommunityV6Prefix(t *testing.T, td testData, community, v6Pref
t.Errorf("ERROR lb Bandwidth want :2G, got=%v", ygot.BinaryToFloat32(lbSubType.GetBandwidth()))
}
}
if deviations.BgpExtendedCommunityIndexUnsupported(td.dut) {
if !deviations.BgpExtendedCommunityIndexUnsupported(td.dut) {
verifyExtCommunityIndexV6(t, td, v6Prefix)
}
}
Expand Down Expand Up @@ -621,7 +621,7 @@ func configureExtCommunityRoutingPolicy(t *testing.T, dut *ondatra.DUTDevice) {
case ondatra.CISCO:
var communityCLIConfig string
communityCLIConfig = fmt.Sprintf("community-set %v\n dfa-regex '%v', \n match invert \n end-set", "regex_match_comm100", CommunitySet["regex_match_comm100"])
policySetCLIConfig := fmt.Sprintf("route-policy %v \n #statement-1 1-megabit-match \n if community in %v then \n set extcommunity bandwidth %v \n endif \n pass \n #statement-2 accept_all_routes \n done \n end-policy", "not_match_100_set_linkbw_1M", "regex_match_comm100", "linkbw_1M")
policySetCLIConfig := fmt.Sprintf("route-policy %v \n #statement-1 1-megabit-match \n if community is-empty then \n pass \n elseif community in %v then \n set extcommunity bandwidth %v \n endif \n pass \n #statement-2 accept_all_routes \n done \n end-policy", "not_match_100_set_linkbw_1M", "regex_match_comm100", "linkbw_1M")
helpers.GnmiCLIConfig(t, dut, communityCLIConfig)
helpers.GnmiCLIConfig(t, dut, policySetCLIConfig)
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ Ensure that gRIBI entries are persisted over daemon failure.

* Issuing a gRIBI Get RPC results in 203.0.113.0/24 being returned.

## Protocol/RPC Parameter Coverage

* gRIBI
* ModifyRequest
* GetRequest
## OpenConfig Path and RPC Coverage
```yaml
rpcs:
gribi:
gRIBI.Get:
gRIBI.Modify:
gRIBI.Flush:
```
## Telemetry Parameter Coverage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ import (
"github.com/openconfig/featureprofiles/internal/attrs"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/gnoi"
"github.com/openconfig/featureprofiles/internal/gribi"
"github.com/openconfig/featureprofiles/internal/otgutils"
gnps "github.com/openconfig/gnoi/system"
"github.com/openconfig/gnoigo/system"
grps "github.com/openconfig/gribi/v1/proto/service"
grpb "github.com/openconfig/gribi/v1/proto/service"
"github.com/openconfig/gribigo/fluent"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ondatra/gnoi"
"github.com/openconfig/ygnmi/ygnmi"
"github.com/openconfig/ygot/ygot"
)
Expand Down Expand Up @@ -88,13 +86,6 @@ var (
IPv4: "192.0.2.6",
IPv4Len: ipv4PrefixLen,
}

gRIBIDaemons = map[ondatra.Vendor]string{
ondatra.ARISTA: "Gribi",
ondatra.CISCO: "emsd",
ondatra.JUNIPER: "rpd",
ondatra.NOKIA: "sr_grpc_server",
}
)

// configInterfaceDUT configures the DUT interfaces.
Expand Down Expand Up @@ -235,7 +226,7 @@ func verifyGRIBIGet(ctx context.Context, t *testing.T, clientA *gribi.Client, du
entries := getResponse.GetEntry()
var found bool
for _, entry := range entries {
v := entry.Entry.(*grps.AFTEntry_Ipv4)
v := entry.Entry.(*grpb.AFTEntry_Ipv4)
if prefix := v.Ipv4.GetPrefix(); prefix != "" {
if prefix == ateDstNetCIDR {
found = true
Expand All @@ -249,36 +240,12 @@ func verifyGRIBIGet(ctx context.Context, t *testing.T, clientA *gribi.Client, du
}
}

// gNOIKillProcess kills a daemon on the DUT, given its name and pid.
func gNOIKillProcess(ctx context.Context, t *testing.T, args *testArgs, pName string, pID uint32) {
killResponse := gnoi.Execute(t, args.dut, system.NewKillProcessOperation().Name(pName).PID(pID).Signal(gnps.KillProcessRequest_SIGNAL_TERM).Restart(true))
t.Logf("Got kill process response: %v\n\n", killResponse)
}

// findProcessByName uses telemetry to find out the PID of a process
func findProcessByName(ctx context.Context, t *testing.T, dut *ondatra.DUTDevice, pName string) uint64 {
pList := gnmi.GetAll(t, dut, gnmi.OC().System().ProcessAny().State())
var pID uint64
for _, proc := range pList {
if proc.GetName() == pName {
pID = proc.GetPid()
t.Logf("Pid of daemon '%s' is '%d'", pName, pID)
}
}
return pID
}

func TestDUTDaemonFailure(t *testing.T) {

start := time.Now()
dut := ondatra.DUT(t, "dut")
ctx := context.Background()

// Check if vendor specific gRIBI daemon name has been added to gRIBIDaemons var
if _, ok := gRIBIDaemons[dut.Vendor()]; !ok {
t.Fatalf("Please add support for vendor %v in var gRIBIDaemons", dut.Vendor())
}

// Configure the DUT.
t.Logf("Configure DUT")
configureDUT(t, dut)
Expand Down Expand Up @@ -343,30 +310,7 @@ func TestDUTDaemonFailure(t *testing.T) {
})

t.Run("KillGRIBIDaemon", func(t *testing.T) {

// Find the PID of gRIBI Daemon.
var pId uint64
pName := gRIBIDaemons[dut.Vendor()]
t.Run("FindGRIBIDaemonPid", func(t *testing.T) {

pId = findProcessByName(ctx, t, dut, pName)
if pId == 0 {
t.Fatalf("Couldn't find pid of gRIBI daemon '%s'", pName)
} else {
t.Logf("Pid of gRIBI daemon '%s' is '%d'", pName, pId)
}
})

// Kill gRIBI daemon through gNOI Kill Request.
t.Run("ExecuteGnoiKill", func(t *testing.T) {
// TODO - pid type is uint64 in oc-system model, but uint32 in gNOI Kill Request proto.
// Until the models are brought in line, typecasting the uint64 to uint32.
gNOIKillProcess(ctx, t, args, pName, uint32(pId))

// Wait for a bit for gRIBI daemon on the DUT to restart.
time.Sleep(30 * time.Second)

})
gnoi.KillProcess(t, dut, gnoi.GRIBI, true)

t.Logf("Time check: %s", time.Since(start))

Expand Down
Loading

0 comments on commit d3f276f

Please sign in to comment.