From 74a8884dc7054bd22c38f492e52fa41ac4b22df4 Mon Sep 17 00:00:00 2001 From: prinikasn <117314826+prinikasn@users.noreply.github.com> Date: Tue, 24 Oct 2023 09:48:22 -0700 Subject: [PATCH] update to ondatra/gnoi api (#2265) * update to ondatra/gnoi api * Update p4rt_daemon_failure_test.go formatting file * format file --- .../bgp_long_lived_graceful_restart_test.go | 9 +++------ .../dut_daemon_failure_test.go | 9 +++------ .../route_addition_during_failover_test.go | 18 +++++------------- .../route_removal_during_failover_test.go | 19 +++++-------------- .../p4rt_daemon_failure_test.go | 15 +++------------ .../supervisor_failure_test.go | 16 ++++------------ go.mod | 1 + go.sum | 2 ++ 8 files changed, 26 insertions(+), 63 deletions(-) diff --git a/feature/experimental/bgp/ate_tests/bgp_long_lived_graceful_restart/bgp_long_lived_graceful_restart_test.go b/feature/experimental/bgp/ate_tests/bgp_long_lived_graceful_restart/bgp_long_lived_graceful_restart_test.go index 8b1903a4cb3..87f79cb7a88 100644 --- a/feature/experimental/bgp/ate_tests/bgp_long_lived_graceful_restart/bgp_long_lived_graceful_restart_test.go +++ b/feature/experimental/bgp/ate_tests/bgp_long_lived_graceful_restart/bgp_long_lived_graceful_restart_test.go @@ -26,10 +26,12 @@ import ( "github.com/openconfig/featureprofiles/internal/fptest" 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" @@ -906,13 +908,8 @@ func findProcessByName(t *testing.T, dut *ondatra.DUTDevice, pName string) uint6 // 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() - gnoiClient := dut.RawAPIs().GNOI(t) - killRequest := &gnps.KillProcessRequest{Name: pName, Pid: pID, Signal: gnps.KillProcessRequest_SIGNAL_TERM, Restart: true} - killResponse, err := gnoiClient.System().KillProcess(context.Background(), killRequest) + 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) - if err != nil { - t.Fatalf("Failed to execute gNOI Kill Process, error received: %v", err) - } } // setBgpPolicy is used to configure routing policy on DUT. diff --git a/feature/experimental/gribi/otg_tests/dut_daemon_failure/dut_daemon_failure_test.go b/feature/experimental/gribi/otg_tests/dut_daemon_failure/dut_daemon_failure_test.go index 8a22e056a3a..1207b3b0346 100644 --- a/feature/experimental/gribi/otg_tests/dut_daemon_failure/dut_daemon_failure_test.go +++ b/feature/experimental/gribi/otg_tests/dut_daemon_failure/dut_daemon_failure_test.go @@ -26,11 +26,13 @@ import ( "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" "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" ) @@ -249,13 +251,8 @@ 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) { - gnoiClient := args.dut.RawAPIs().GNOI(t) - killRequest := &gnps.KillProcessRequest{Name: pName, Pid: pID, Signal: gnps.KillProcessRequest_SIGNAL_TERM, Restart: true} - killResponse, err := gnoiClient.System().KillProcess(context.Background(), killRequest) + 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) - if err != nil { - t.Fatalf("Failed to execute gNOI Kill Process, error received: %v", err) - } } // findProcessByName uses telemetry to find out the PID of a process diff --git a/feature/experimental/gribi/otg_tests/route_addition_during_failover_test/route_addition_during_failover_test.go b/feature/experimental/gribi/otg_tests/route_addition_during_failover_test/route_addition_during_failover_test.go index 15a7a26b33d..66b7d054625 100644 --- a/feature/experimental/gribi/otg_tests/route_addition_during_failover_test/route_addition_during_failover_test.go +++ b/feature/experimental/gribi/otg_tests/route_addition_during_failover_test/route_addition_during_failover_test.go @@ -32,6 +32,7 @@ import ( "github.com/openconfig/featureprofiles/internal/fptest" "github.com/openconfig/featureprofiles/internal/gribi" "github.com/openconfig/featureprofiles/internal/otgutils" + "github.com/openconfig/gnoigo/system" "github.com/openconfig/gribigo/chk" "github.com/openconfig/gribigo/constants" "github.com/openconfig/gribigo/fluent" @@ -39,11 +40,11 @@ import ( "github.com/openconfig/ondatra/binding" "github.com/openconfig/ondatra/gnmi" "github.com/openconfig/ondatra/gnmi/oc" + "github.com/openconfig/ondatra/gnoi" "github.com/openconfig/testt" "github.com/openconfig/ygot/ygot" fpb "github.com/openconfig/gnoi/file" - spb "github.com/openconfig/gnoi/system" aftspb "github.com/openconfig/gribi/v1/proto/service" ) @@ -625,17 +626,11 @@ func TestRouteAdditionDuringFailover(t *testing.T) { awaitSwitchoverReady(t, dut, primaryBeforeSwitch) t.Logf("Controller %q is ready for switchover before test.", primaryBeforeSwitch) - gnoiClient := dut.RawAPIs().GNOI(t) - useNameOnly := deviations.GNOISubcomponentPath(dut) - switchoverRequest := &spb.SwitchControlProcessorRequest{ - ControlProcessor: cmp.GetSubcomponentPath(secondaryBeforeSwitch, useNameOnly), - } - t.Logf("switchoverRequest: %v", switchoverRequest) - // Concurrently run switchover and gribi route addition in ipBlock2. virtualIPsBlock2 := createIPv4Entries(t, ipBlock2FlowArgs.ipBlock) // Check for coredumps in the DUT and validate that none are present on DUT before switchover. + gnoiClient := dut.RawAPIs().GNOI(t) coreFileCheck(t, dut, gnoiClient, sysConfigTime, false) wg := new(sync.WaitGroup) @@ -649,11 +644,8 @@ func TestRouteAdditionDuringFailover(t *testing.T) { go func() { defer wg.Done() - switchoverResponse, err := gnoiClient.System().SwitchControlProcessor(context.Background(), switchoverRequest) - if err != nil { - t.Logf("Failed to perform control processor switchover with unexpected err: %v", err) - } - t.Logf("gnoiClient.System().SwitchControlProcessor() response: %v, err: %v", switchoverResponse, err) + switchoverResponse := gnoi.Execute(t, dut, system.NewSwitchControlProcessorOperation().Path(cmp.GetSubcomponentPath(secondaryBeforeSwitch, deviations.GNOISubcomponentPath(dut)))) + t.Logf("swtichover process response: %v", switchoverResponse) }() wg.Wait() t.Log("Concurrent switchover and route addition is completed, validate switchoverStatus now.") diff --git a/feature/experimental/gribi/otg_tests/route_removal_during_failover_test/route_removal_during_failover_test.go b/feature/experimental/gribi/otg_tests/route_removal_during_failover_test/route_removal_during_failover_test.go index de9fce39c18..70829940afb 100644 --- a/feature/experimental/gribi/otg_tests/route_removal_during_failover_test/route_removal_during_failover_test.go +++ b/feature/experimental/gribi/otg_tests/route_removal_during_failover_test/route_removal_during_failover_test.go @@ -32,6 +32,7 @@ import ( "github.com/openconfig/featureprofiles/internal/fptest" "github.com/openconfig/featureprofiles/internal/gribi" "github.com/openconfig/featureprofiles/internal/otgutils" + "github.com/openconfig/gnoigo/system" gpb "github.com/openconfig/gribi/v1/proto/service" "github.com/openconfig/gribigo/chk" "github.com/openconfig/gribigo/constants" @@ -40,11 +41,11 @@ import ( "github.com/openconfig/ondatra/binding" "github.com/openconfig/ondatra/gnmi" "github.com/openconfig/ondatra/gnmi/oc" + "github.com/openconfig/ondatra/gnoi" "github.com/openconfig/testt" "github.com/openconfig/ygot/ygot" fpb "github.com/openconfig/gnoi/file" - spb "github.com/openconfig/gnoi/system" ) func TestMain(m *testing.M) { @@ -585,13 +586,6 @@ func TestRouteRemovalDuringFailover(t *testing.T) { switchoverReady(t, dut, primaryBeforeSwitch) t.Logf("Controller %q is ready for switchover before test.", primaryBeforeSwitch) - var gnoiClient binding.GNOIClients = dut.RawAPIs().GNOI(t) - useNameOnly := deviations.GNOISubcomponentPath(dut) - switchoverRequest := &spb.SwitchControlProcessorRequest{ - ControlProcessor: cmp.GetSubcomponentPath(secondaryBeforeSwitch, useNameOnly), - } - t.Logf("switchoverRequest: %v", switchoverRequest) - entriesBefore := checkNIHasNEntries(ctx, client, deviations.DefaultNetworkInstance(dut), t) // Concurrently run switchover and gribi route flush. @@ -608,11 +602,8 @@ func TestRouteRemovalDuringFailover(t *testing.T) { }("gRIBi Flush") go func(msg string) { - switchoverResponse, err := gnoiClient.System().SwitchControlProcessor(context.Background(), switchoverRequest) - if err != nil { - t.Logf("Failed to perform control processor switchover with unexpected err: %v", err) - } - t.Logf("gnoiClient.System().SwitchControlProcessor() response: %v, err: %v", switchoverResponse, err) + switchoverResponse := gnoi.Execute(t, dut, system.NewSwitchControlProcessorOperation().Path(cmp.GetSubcomponentPath(secondaryBeforeSwitch, deviations.GNOISubcomponentPath(dut)))) + t.Logf("gnoiClient.System().SwitchControlProcessor() response: %v", switchoverResponse) }("Master Switchover") // Check the response of gribi flush call. If-else loop for further verification @@ -680,7 +671,7 @@ func TestRouteRemovalDuringFailover(t *testing.T) { // Check for coredumps in the DUT and validate that none are present post failover. // Reconnect gnoi connection after switchover. - gnoiClient, err = dut.RawAPIs().BindingDUT().DialGNOI(context.Background()) + gnoiClient, err := dut.RawAPIs().BindingDUT().DialGNOI(context.Background()) if err != nil { t.Fatalf("Error dialing gNOI: %v", err) } diff --git a/feature/experimental/p4rt/otg_tests/p4rt_daemon_failure_test/p4rt_daemon_failure_test.go b/feature/experimental/p4rt/otg_tests/p4rt_daemon_failure_test/p4rt_daemon_failure_test.go index 103cf8fe9c8..9fe7cc47dd6 100644 --- a/feature/experimental/p4rt/otg_tests/p4rt_daemon_failure_test/p4rt_daemon_failure_test.go +++ b/feature/experimental/p4rt/otg_tests/p4rt_daemon_failure_test/p4rt_daemon_failure_test.go @@ -15,7 +15,6 @@ package p4rt_daemon_failure_test import ( - "context" "fmt" "testing" "time" @@ -26,10 +25,12 @@ import ( "github.com/openconfig/featureprofiles/internal/fptest" "github.com/openconfig/featureprofiles/internal/gribi" "github.com/openconfig/featureprofiles/internal/p4rtutils" + "github.com/openconfig/gnoigo/system" "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" @@ -281,18 +282,8 @@ func TestP4RTDaemonFailure(t *testing.T) { t.Fatal(err) } - c := dut.RawAPIs().GNOI(t) - req := &syspb.KillProcessRequest{ - Name: p4rtD, - Pid: uint32(pID), - Signal: syspb.KillProcessRequest_SIGNAL_TERM, - Restart: true, - } - resp, err := c.System().KillProcess(context.Background(), req) + resp := gnoi.Execute(t, dut, system.NewKillProcessOperation().Name(p4rtD).PID(uint32(pID)).Signal(syspb.KillProcessRequest_SIGNAL_TERM).Restart(true)) t.Logf("Got kill process response: %v", resp) - if err != nil { - t.Fatalf("Failed to execute gNOI.KillProcess, error received: %v", err) - } // let traffic keep running for another 10 seconds. time.Sleep(10 * time.Second) diff --git a/feature/gribi/otg_tests/supervisor_failure_test/supervisor_failure_test.go b/feature/gribi/otg_tests/supervisor_failure_test/supervisor_failure_test.go index a75db54fd78..091c7b0c78e 100644 --- a/feature/gribi/otg_tests/supervisor_failure_test/supervisor_failure_test.go +++ b/feature/gribi/otg_tests/supervisor_failure_test/supervisor_failure_test.go @@ -26,14 +26,15 @@ import ( "github.com/openconfig/featureprofiles/internal/fptest" "github.com/openconfig/featureprofiles/internal/gribi" "github.com/openconfig/featureprofiles/internal/otgutils" + "github.com/openconfig/gnoigo/system" "github.com/openconfig/gribigo/fluent" "github.com/openconfig/ondatra" "github.com/openconfig/testt" "github.com/openconfig/ygot/ygot" - spb "github.com/openconfig/gnoi/system" "github.com/openconfig/ondatra/gnmi" "github.com/openconfig/ondatra/gnmi/oc" + "github.com/openconfig/ondatra/gnoi" "github.com/openconfig/ygnmi/ygnmi" ) @@ -327,17 +328,8 @@ func TestSupFailure(t *testing.T) { t.Fatalf("Controller %q did not become switchover-ready before test.", primaryBeforeSwitch) } - gnoiClient := dut.RawAPIs().GNOI(t) - useNameOnly := deviations.GNOISubcomponentPath(dut) - switchoverRequest := &spb.SwitchControlProcessorRequest{ - ControlProcessor: cmp.GetSubcomponentPath(secondaryBeforeSwitch, useNameOnly), - } - t.Logf("switchoverRequest: %v", switchoverRequest) - switchoverResponse, err := gnoiClient.System().SwitchControlProcessor(context.Background(), switchoverRequest) - if err != nil { - t.Fatalf("Failed to perform control processor switchover with unexpected err: %v", err) - } - t.Logf("gnoiClient.System().SwitchControlProcessor() response: %v, err: %v", switchoverResponse, err) + switchoverResponse := gnoi.Execute(t, dut, system.NewSwitchControlProcessorOperation().Path(cmp.GetSubcomponentPath(secondaryBeforeSwitch, deviations.GNOISubcomponentPath(dut)))) + t.Logf("gnoiClient.System().SwitchControlProcessor() response: %v", switchoverResponse) startSwitchover := time.Now() t.Logf("Wait for new Primary controller to boot up by polling the telemetry output.") diff --git a/go.mod b/go.mod index af7c1a3bc81..5ffbbdb1cdd 100644 --- a/go.mod +++ b/go.mod @@ -99,6 +99,7 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/networkop/meshnet-cni v0.3.1-0.20230525201116-d7c306c635cf // indirect github.com/open-traffic-generator/ixia-c-operator v0.3.4 // indirect + github.com/openconfig/gnoigo v0.0.0-20231012221859-8e2e9ed42daf // indirect github.com/openconfig/grpctunnel v0.0.0-20220819142823-6f5422b8ca70 // indirect github.com/openconfig/lemming/operator v0.2.0 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible // indirect diff --git a/go.sum b/go.sum index 09315d2551d..f88dce250f6 100644 --- a/go.sum +++ b/go.sum @@ -1142,6 +1142,8 @@ github.com/openconfig/gnmi v0.10.0 h1:kQEZ/9ek3Vp2Y5IVuV2L/ba8/77TgjdXg505QXvYmg github.com/openconfig/gnmi v0.10.0/go.mod h1:Y9os75GmSkhHw2wX8sMsxfI7qRGAEcDh8NTa5a8vj6E= github.com/openconfig/gnoi v0.1.0 h1:7Odq6UyieHuXW3PYfDBj/dUWgFrL9KVMm0iooQoFLdw= github.com/openconfig/gnoi v0.1.0/go.mod h1:ZMRwQ7maVNSOjie3Jn67fW5WY7UDrFSiYSlV/GxthQs= +github.com/openconfig/gnoigo v0.0.0-20231012221859-8e2e9ed42daf h1:dBfRZxlBin+uce9hhUktwogTnvt5DUhSLL24M8vi8fg= +github.com/openconfig/gnoigo v0.0.0-20231012221859-8e2e9ed42daf/go.mod h1:zF1zdUBtlwkzecPyNQk5GSlY+wtjObWeDUE2fA/9UFE= github.com/openconfig/gnsi v1.2.3 h1:Y/fBMQOn5xqdo9xuT7AK2YHSRejx/ws4sDOMBCHQG6w= github.com/openconfig/gnsi v1.2.3/go.mod h1:QikTHkm468uc2rq/kVhETfyZ6FPeM+zitubrHBbB0HE= github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b h1:NSYuxdlOWLldNpid1dThR6Dci96juXioUguMho6aliI=