From 0db2f1abcd1f6086883407489b1445636adae6f0 Mon Sep 17 00:00:00 2001 From: sabevzenko Date: Thu, 19 Oct 2023 14:25:53 +0300 Subject: [PATCH] fix grpc provider scan fix grpc provider scan --- cli/cli.go | 2 +- components/guns/grpc/core.go | 4 ++-- components/providers/grpc/grpcjson/provider.go | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index d43fc9a20..9bedb5827 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -24,7 +24,7 @@ import ( "go.uber.org/zap/zapcore" ) -const Version = "0.5.11" +const Version = "0.5.12" const defaultConfigFile = "load" const stdinConfigSelector = "-" diff --git a/components/guns/grpc/core.go b/components/guns/grpc/core.go index 65609947a..d590b6f16 100644 --- a/components/guns/grpc/core.go +++ b/components/guns/grpc/core.go @@ -88,7 +88,7 @@ func (g *Gun) WarmUp(opts *warmup.Options) (interface{}, error) { refClient := grpcreflect.NewClientAuto(refCtx, conn) listServices, err := refClient.ListServices() if err != nil { - g.GunDeps.Log.Error("failed to get services list", zap.Error(err)) + opts.Log.Error("failed to get services list", zap.Error(err)) // WarmUp calls before Bind() return nil, fmt.Errorf("refClient.ListServices err: %w", err) } services := make(map[string]desc.MethodDescriptor) @@ -98,7 +98,7 @@ func (g *Gun) WarmUp(opts *warmup.Options) (interface{}, error) { if grpcreflect.IsElementNotFoundError(err) { continue } - g.GunDeps.Log.Error("cant resolveService", zap.String("service_name", s), zap.Error(err)) + opts.Log.Error("cant resolveService", zap.String("service_name", s), zap.Error(err)) // WarmUp calls before Bind() return nil, fmt.Errorf("cant resolveService %s; err: %w", s, err) } listMethods := service.GetMethods() diff --git a/components/providers/grpc/grpcjson/provider.go b/components/providers/grpc/grpcjson/provider.go index 5da127e6c..8fefd1c0f 100644 --- a/components/providers/grpc/grpcjson/provider.go +++ b/components/providers/grpc/grpcjson/provider.go @@ -82,10 +82,14 @@ func (p *Provider) start(ctx context.Context, ammoFile afero.File) error { return nil } } + err := scanner.Err() + if err != nil { + return errors.Wrap(err, "gPRC Provider scan() err") + } if p.Passes != 0 && passNum >= p.Passes { break } - _, err := ammoFile.Seek(0, 0) + _, err = ammoFile.Seek(0, 0) if err != nil { return errors.Wrap(err, "Failed to seek ammo file") }