From bd54de81bf5f299ba4e363d4825637c88afe1cc2 Mon Sep 17 00:00:00 2001 From: Nisha Sadhasivam Date: Tue, 10 Sep 2024 06:06:17 +0000 Subject: [PATCH 1/2] Adding a retry to startprotocol to avoid errors --- otg/otg.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/otg/otg.go b/otg/otg.go index 9cb136c1..bf2a4d15 100644 --- a/otg/otg.go +++ b/otg/otg.go @@ -129,7 +129,16 @@ func (o *OTG) StartProtocols(t testing.TB) { t = events.ActionStarted(t, "Starting protocols on %s", o.ate) warns, err := o.setProtocolState(context.Background(), gosnappi.StateProtocolAllState.START) if err != nil { - t.Fatalf("StartProtocols(t) on %s: %v", o.ate, err) + time.Sleep(1 * time.Minute) + t.Helper() + t = events.ActionStarted(t, "Retry Starting protocols on %s", o.ate) + warnsRetry, errRetry := o.setProtocolState(context.Background(), gosnappi.StateProtocolAllState.START) + if errRetry != nil { + t.Fatalf("Retry StartProtocols(t) on %s: %v", o.ate, errRetry) + } + if len(warnsRetry) > 0 { + t.Logf("StartProtocols(t) on %s non-fatal warnings on retry: %v", o.ate, warnsRetry) + } } if len(warns) > 0 { t.Logf("StartProtocols(t) on %s non-fatal warnings: %v", o.ate, warns) From f73c5616720c9b25009de317d6e05281f9eb9bea Mon Sep 17 00:00:00 2001 From: Nisha Sadhasivam Date: Tue, 10 Sep 2024 06:22:35 +0000 Subject: [PATCH 2/2] added timeout --- otg/otg.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/otg/otg.go b/otg/otg.go index bf2a4d15..7b4be2cf 100644 --- a/otg/otg.go +++ b/otg/otg.go @@ -28,6 +28,7 @@ import ( "time" "golang.org/x/net/context" + "google.golang.org/grpc" "github.com/open-traffic-generator/snappi/gosnappi" "github.com/openconfig/ondatra/binding" @@ -126,19 +127,11 @@ func getConfig(ctx context.Context, ate binding.ATE) (gosnappi.Config, error) { // StartProtocols starts protocols on the ATE. func (o *OTG) StartProtocols(t testing.TB) { t.Helper() + rawapis.CommonDialOpts = append(rawapis.CommonDialOpts, grpc.Timeout(2*time.Minute)) t = events.ActionStarted(t, "Starting protocols on %s", o.ate) warns, err := o.setProtocolState(context.Background(), gosnappi.StateProtocolAllState.START) if err != nil { - time.Sleep(1 * time.Minute) - t.Helper() - t = events.ActionStarted(t, "Retry Starting protocols on %s", o.ate) - warnsRetry, errRetry := o.setProtocolState(context.Background(), gosnappi.StateProtocolAllState.START) - if errRetry != nil { - t.Fatalf("Retry StartProtocols(t) on %s: %v", o.ate, errRetry) - } - if len(warnsRetry) > 0 { - t.Logf("StartProtocols(t) on %s non-fatal warnings on retry: %v", o.ate, warnsRetry) - } + t.Fatalf("StartProtocols(t) on %s: %v", o.ate, err) } if len(warns) > 0 { t.Logf("StartProtocols(t) on %s non-fatal warnings: %v", o.ate, warns)