From c90906608221e5b8ab2ba5374847d8a0b82414b3 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Mon, 28 Aug 2023 15:49:50 +1100 Subject: [PATCH] add test for grpcio issue --- recipe/meta.yaml | 7 +++++++ recipe/test_grpcio_helloworld.py | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 recipe/test_grpcio_helloworld.py diff --git a/recipe/meta.yaml b/recipe/meta.yaml index b5425d50..775afe1e 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -155,10 +155,13 @@ outputs: - {{ pin_subpackage('libgrpc', exact=True) }} - __osx >={{ MACOSX_DEPLOYMENT_TARGET|default("10.9") }} # [osx and x86_64] test: + source_files: + - examples/ files: - grpcio_distribtest.py requires: - pip + - grpcio-tools imports: - grpc - grpc._cython @@ -173,6 +176,10 @@ outputs: commands: - python -m pip check - python grpcio_distribtest.py + # generate helloworld, see https://grpc.io/docs/languages/python/quickstart/#generate-grpc-code + - cd examples/python/helloworld + - python -m grpc_tools.protoc -I../../protos --python_out=. --pyi_out=. --grpc_python_out=. ../../protos/helloworld.proto + - python test_grpcio_helloworld.py about: home: https://grpc.io/ diff --git a/recipe/test_grpcio_helloworld.py b/recipe/test_grpcio_helloworld.py new file mode 100644 index 00000000..014d5b6d --- /dev/null +++ b/recipe/test_grpcio_helloworld.py @@ -0,0 +1,12 @@ +# this test assumes it is being run in examples/python/helloworld, +# after having generated the helloworld_pb2{,_grpc} modules (see meta.yaml) +import grpc +import helloworld_pb2 +import helloworld_pb2_grpc + +# run this a couple times because it happens randomly, see +# https://github.com/conda-forge/grpc-cpp-feedstock/issues/281 +for _ in range(1000): + with grpc.insecure_channel('localhost:50051') as channel: + stub = helloworld_pb2_grpc.GreeterStub(channel) + response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))