From 9a2a75f83018f3829bdd6fd03f119cb76fc47cc8 Mon Sep 17 00:00:00 2001 From: Chengyuan Zhang Date: Fri, 6 Nov 2020 14:33:49 -0800 Subject: [PATCH] Directly use enum values defined in the message instead of doing string conversion. --- tools/run_tests/run_xds_tests.py | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/tools/run_tests/run_xds_tests.py b/tools/run_tests/run_xds_tests.py index ede07dd15ee..fe49271f5b9 100755 --- a/tools/run_tests/run_xds_tests.py +++ b/tools/run_tests/run_xds_tests.py @@ -341,23 +341,10 @@ def configure_client(rpc_types, metadata): (host, args.stats_port)) as channel: stub = test_pb2_grpc.XdsUpdateClientConfigureServiceStub(channel) request = messages_pb2.ClientConfigureRequest() - for rpc_type in rpc_types: - if rpc_type not in ['empty_call', 'unary_call']: - continue - request.types.append( - messages_pb2.ClientConfigureRequest.RpcType.EMPTY_CALL - if rpc_type == 'empty_call' - else messages_pb2.ClientConfigureRequest.RpcType.UNARY_CALL - ) + request.types.extend(rpc_types) for rpc_type, md_key, md_value in metadata: - if rpc_type not in ['empty_call', 'unary_call']: - continue md = request.metadata.add() - md.type = ( - messages_pb2.ClientConfigureRequest.RpcType.EMPTY_CALL - if rpc_type == 'empty_call' - else messages_pb2.ClientConfigureRequest.RpcType.UNARY_CALL - ) + md.type = rpc_type md.key = md_key md.value = md_value logger.debug('Invoking XdsUpdateClientConfigureService RPC to %s:%d: %s', @@ -1083,14 +1070,15 @@ def test_circuit_breaking(gcp, patch_url_map_backend_service(gcp, alternate_backend_service) wait_until_all_rpcs_go_to_given_backends(alternate_backend_instances, _WAIT_FOR_URL_MAP_PATCH_SEC) - - # Make unary calls open. - configure_client(rpc_types=['unary_call'], - metadata=[('unary_call', 'rpc-behavior', 'keep-open')]) + + # Make unary calls keep-open. + configure_client([messages_pb2.ClientConfigureRequest.RpcType.UNARY_CALL], + [(messages_pb2.ClientConfigureRequest.RpcType.UNARY_CALL, + 'rpc-behavior', 'keep-open')]) wait_until_all_rpcs_fail(int(_WAIT_FOR_STATS_SEC + _NUM_TEST_RPCS / args.qps), _NUM_TEST_RPCS) _assert_rpcs_in_flight(max_requests) - + # Increment circuit breakers max_requests threshold. max_requests = _NUM_TEST_RPCS * 2 patch_backend_service(gcp, alternate_backend_service,