[Python tests] Allow passing kwargs to grpc.server in test_server (#36455)

Allow passing `kwargs` to `grpc.server` in test server.

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #36455

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36455 from XuanWang-Amos:disable_reflection_in_tests d9a7e3d7fa
PiperOrigin-RevId: 629149234
pull/36446/head^2
Xuan Wang 7 months ago committed by Copybara-Service
parent 79e42f9837
commit 4318b7e1c4
  1. 5
      src/python/grpcio_tests/tests/unit/test_common.py

@ -13,8 +13,10 @@
# limitations under the License.
"""Common code used throughout tests of gRPC."""
import ast
import collections
from concurrent import futures
import os
import threading
import grpc
@ -110,9 +112,12 @@ def test_server(max_workers=10, reuse_port=False):
These servers have SO_REUSEPORT disabled to prevent cross-talk.
"""
server_kwargs = os.environ.get("GRPC_ADDITIONAL_SERVER_KWARGS", "{}")
server_kwargs = ast.literal_eval(server_kwargs)
return grpc.server(
futures.ThreadPoolExecutor(max_workers=max_workers),
options=(("grpc.so_reuseport", int(reuse_port)),),
**server_kwargs,
)

Loading…
Cancel
Save