[interop] Add absl dependency to interop clients (#34666)

Similar to https://github.com/grpc/grpc/pull/33830 but adds the absl
dependency on the client side.

Requires a cherrypick
pull/34657/head^2
Vignesh Babu 1 year ago committed by GitHub
parent 352c33986e
commit 21c92da7ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/python/grpcio_tests/commands.py
  2. 1
      src/python/grpcio_tests/tests/interop/BUILD.bazel
  3. 14
      src/python/grpcio_tests/tests/interop/client.py
  4. 13
      src/python/grpcio_tests/tests/stress/client.py
  5. 3
      src/python/grpcio_tests/tests_aio/interop/client.py

@ -202,7 +202,7 @@ class RunInterop(test.test):
from tests.interop import client from tests.interop import client
sys.argv[1:] = self.args.split() sys.argv[1:] = self.args.split()
client.test_interoperability() client.test_interoperability(client.parse_interop_client_args(sys.argv))
class RunFork(test.test): class RunFork(test.test):

@ -33,6 +33,7 @@ py_library(
":resources", ":resources",
"//src/proto/grpc/testing:py_test_proto", "//src/proto/grpc/testing:py_test_proto",
"//src/python/grpcio/grpc:grpcio", "//src/python/grpcio/grpc:grpcio",
requirement("absl-py"),
requirement("google-auth"), requirement("google-auth"),
], ],
) )

@ -13,9 +13,10 @@
# limitations under the License. # limitations under the License.
"""The Python implementation of the GRPC interoperability test client.""" """The Python implementation of the GRPC interoperability test client."""
import argparse
import os import os
from absl import app
from absl.flags import argparse_flags
from google import auth as google_auth from google import auth as google_auth
from google.auth import jwt as google_auth_jwt from google.auth import jwt as google_auth_jwt
import grpc import grpc
@ -25,8 +26,8 @@ from tests.interop import methods
from tests.interop import resources from tests.interop import resources
def parse_interop_client_args(): def parse_interop_client_args(argv):
parser = argparse.ArgumentParser() parser = argparse_flags.ArgumentParser()
parser.add_argument( parser.add_argument(
"--server_host", "--server_host",
default="localhost", default="localhost",
@ -92,7 +93,7 @@ def parse_interop_client_args():
" round_robin " + "or pick_first)." " round_robin " + "or pick_first)."
), ),
) )
return parser.parse_args() return parser.parse_args(argv[1:])
def _create_call_credentials(args): def _create_call_credentials(args):
@ -214,8 +215,7 @@ def _test_case_from_arg(test_case_arg):
raise ValueError('No test case "%s"!' % test_case_arg) raise ValueError('No test case "%s"!' % test_case_arg)
def test_interoperability(): def test_interoperability(args):
args = parse_interop_client_args()
channel = _create_channel(args) channel = _create_channel(args)
stub = create_stub(channel, args) stub = create_stub(channel, args)
test_case = _test_case_from_arg(args.test_case) test_case = _test_case_from_arg(args.test_case)
@ -223,4 +223,4 @@ def test_interoperability():
if __name__ == "__main__": if __name__ == "__main__":
test_interoperability() app.run(test_interoperability, flags_parser=parse_interop_client_args)

@ -13,11 +13,12 @@
# limitations under the License. # limitations under the License.
"""Entry point for running stress tests.""" """Entry point for running stress tests."""
import argparse
from concurrent import futures from concurrent import futures
import queue import queue
import threading import threading
from absl import app
from absl.flags import argparse_flags
import grpc import grpc
from src.proto.grpc.testing import metrics_pb2_grpc from src.proto.grpc.testing import metrics_pb2_grpc
@ -29,10 +30,8 @@ from tests.stress import metrics_server
from tests.stress import test_runner from tests.stress import test_runner
def _args(): def _args(argv):
parser = argparse.ArgumentParser( parser = argparse_flags.ArgumentParser()
description="gRPC Python stress test client"
)
parser.add_argument( parser.add_argument(
"--server_addresses", "--server_addresses",
help="comma separated list of hostname:port to run servers on", help="comma separated list of hostname:port to run servers on",
@ -83,7 +82,7 @@ def _args():
help="the server host to which to claim to connect", help="the server host to which to claim to connect",
type=str, type=str,
) )
return parser.parse_args() return parser.parse_args(argv[1:])
def _test_case_from_arg(test_case_arg): def _test_case_from_arg(test_case_arg):
@ -174,4 +173,4 @@ def run_test(args):
if __name__ == "__main__": if __name__ == "__main__":
run_test(_args()) app.run(run_test, flags_parser=_args)

@ -16,6 +16,7 @@ import argparse
import asyncio import asyncio
import logging import logging
import os import os
import sys
import grpc import grpc
from grpc.experimental import aio from grpc.experimental import aio
@ -53,7 +54,7 @@ def _test_case_from_arg(test_case_arg):
async def test_interoperability(): async def test_interoperability():
args = interop_client_lib.parse_interop_client_args() args = interop_client_lib.parse_interop_client_args(sys.argv)
channel = _create_channel(args) channel = _create_channel(args)
stub = interop_client_lib.create_stub(channel, args) stub = interop_client_lib.create_stub(channel, args)
test_case = _test_case_from_arg(args.test_case) test_case = _test_case_from_arg(args.test_case)

Loading…
Cancel
Save