k1LoW/runn

Is there way runn test of grpc with using "buf/validate/validate.proto" in proto ?

mztnnrt opened this issue ยท 5 comments

At First

At first we want to express our appreciate this great oss, we use every day thanks. ๐Ÿ™


Question

Now we want to gRPC E2E test using https://buf.build,
But we use buf.build/bufbuild/protovalidate as dependency for proto validate.

buf.gen.yaml
version: v1
managed:
  enabled: true
plugins:
  - plugin: go
    out: ../go/backend/shared/generated/proto
    opt:
      - paths=source_relative
  - plugin: connect-go
    out: ../go/backend/shared/generated/proto
    opt:
      - paths=source_relative
      - require_unimplemented_servers=false
buf.yaml
version: v1
deps:
  - buf.build/googleapis/googleapis
  - buf.build/bufbuild/protovalidate # ๐Ÿ’ก using protovalidate.
breaking:
  use:
    - FILE
lint:
  use:
    - DEFAULT
  except:
    - PACKAGE_DIRECTORY_MATCH
    - PACKAGE_VERSION_SUFFIX
  ignore: []
  rpc_allow_google_protobuf_empty_requests: true
  rpc_allow_google_protobuf_empty_responses: true
service.proto
syntax = "proto3";

package pingpb;
+ import "buf/validate/validate.proto";

option go_package = "github.com/path/to/generated/proto/pingpb";
import "google/protobuf/empty.proto";
import "shared/shared.proto";

service Service {
  rpc Ping(PingRequest) returns (PingResponse) {};
}

message PingRequest {
  google.protobuf.Empty empty = 1;
}

message PingResponse {
  bool backend  = 1;
}

If remove import "buf/validate/validate.proto"; from above proto file, below runn command is success !

runn run ./e2e/backend/grpc.yaml --grpc-no-tls --grpc-import-path ./proto --grpc-proto ./proto/pingpb/service.proto
1 scenario, 0 skipped, 0 failures

But if import this import "buf/validate/validate.proto",
runn command is failure, because validate.proto: no such file or directory.

runn run ./e2e/backend/grpc.yaml --grpc-no-tls --grpc-import-path ./proto --grpc-proto ./proto/pingpb/service.proto
1) ./e2e/backend/grpc.yaml aef9bc8f868dadf4c516cc3e4a7478693555f41b
  Failure/Error: gRPC request failed on "package pingpb".steps[0]: pingpb/service.proto:4:8: 
open /Users/path/to/monorepo/proto/buf/validate/validate.proto: no such file or directory

1 scenario, 0 skipped, 1 failure

Is there approach, runn test with using https://buf.build dependencies ?

Hi @mztnnrt. Thank you for your report.

Currently, runn does not support the special behavior of buf.

Therefore import "buf/validate/validate.proto"; is treated the same as import "shared/shared.proto";

In other words, the solution is to create a buf/validate directory in the import path and put validate.proto flie there.

(I also use buf, so if this problem can be solved, it is an issue I would like to solve.)

@k1LoW

Thanks for your reply ! we are helpful and glad to know the current status. ๐Ÿ™
as you say, we noticed that there is the solution that import from local.

Already we tried based on your comment, it's work runn testing using validate.proto.

Thanks for your advice and reply, you can closed this issue anytime.


Note

maybe it's a little different from the issue in runn, but I'll write the solution about above.
we hope it helps someone.

approach we did

Step 1.

Remove deps buf.build/bufbuild/protovalidate from buf.yaml and run $ buf mod update

Step 2.

Pulling validate.proto etc, using buf export command.

dir_located_buf_yaml = ./proto
buf export buf.build/bufbuild/protovalidate --path buf/validate --output $dir_located_buf_yaml

Step 3.

Add import "buf/validate/validate.proto"; into proto file.

Step 4.

runn run ./e2e/backend/grpc.yaml --grpc-no-tls --grpc-import-path ./proto --grpc-proto ./proto/pingpb/service.proto
1 scenario, 0 skipped, 0 failures

buf generate, runn test, validate message work correctly our environment, thanks.

@mztnnrt
Hi.
We now support the Buf Schema Registry in v0.105.1.
You can use --grpc-buf-lock path/to/buf.lock to resolve buf/validate/validate.proto.

Hi @k1LoW

Amazing ! We appreciate for your work !

Currently we tried --grpc-buf-lock flag, and working correctly ๐Ÿ™Œ
Thanks for it, we could remove the validate.proto which is pulled by manually, and we no longer need to manage.

Thanks so much ! ๐Ÿ™

Hi @mztnnrt.

Since V0.106.0, in many cases this can be resolved by simply specifying --grpc-buf-dir.

runn run ./e2e/backend/grpc.yaml --grpc-no-tls --grpc-buf-dir ./proto

Try it out ๐Ÿ‘