Skip to content

Commit f37faff

Browse files
committed
fix grpc: fix race in congestion control tests
commit_hash:91a0bc6c6788acb67f344314a10f12408db03796
1 parent ae6d4e8 commit f37faff

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

grpc/functional_tests/basic_chaos/tests-nonchaos/test_basic.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ def tp_congestion_control(data):
1717
def tp_congestion_control_apply(data):
1818
return {}
1919

20-
# wait until server obtains the new limit, up to 1 second
2120
await service_client.enable_testpoints()
21+
22+
# wait until server obtains the new limit, up to 1 second
2223
await tp_congestion_control.wait_call()
24+
await tp_congestion_control_apply.wait_call()
2325

2426
# Random non-ping handler is throttled
2527
with pytest.raises(grpc.RpcError) as error:
@@ -34,6 +36,7 @@ def tp_congestion_control_disable(data):
3436
return {'force-rps-limit': None}
3537

3638
await tp_congestion_control_disable.wait_call()
39+
await tp_congestion_control_apply.wait_call()
3740

3841

3942
async def test_grpc_congestion_control_activate(grpc_client, service_client, testpoint):
@@ -53,18 +56,21 @@ def tp_congestion_control(data):
5356
def tp_congestion_control_apply(data):
5457
return {}
5558

56-
# is_overloaded -> true
5759
await service_client.enable_testpoints()
60+
61+
# is_overloaded -> true
5862
await tp_congestion_control_sensor.wait_call()
5963
await tp_congestion_control.wait_call()
64+
await tp_congestion_control_apply.wait_call()
6065

6166
# current_limit -> 1
6267
await tp_congestion_control_sensor.wait_call()
6368
await tp_congestion_control.wait_call()
69+
await tp_congestion_control_apply.wait_call()
6470

6571
with pytest.raises(grpc.RpcError) as error:
6672
for i in range(0, 2):
67-
request = greeter_pb2.GreetingRequest(name=f'Name0{i}/1')
73+
request = greeter_pb2.GreetingRequest(name=f'Name{i}/1')
6874
await grpc_client.SayHello(request, wait_for_ready=True)
6975
assert error.value.details() == 'Congestion control: rate limit exceeded'
7076
assert error.value.code() == grpc.StatusCode.RESOURCE_EXHAUSTED
@@ -80,10 +86,12 @@ def tp_congestion_control_sensor_disable(data):
8086
# current_limit -> 1
8187
await tp_congestion_control_sensor_disable.wait_call()
8288
await tp_congestion_control.wait_call()
89+
await tp_congestion_control_apply.wait_call()
8390

8491
# current_limit -> null
8592
await tp_congestion_control_sensor_disable.wait_call()
8693
await tp_congestion_control.wait_call()
94+
await tp_congestion_control_apply.wait_call()
8795

8896
for i in range(1, 10):
8997
request = greeter_pb2.GreetingRequest(name=f'Name{i}/2')

0 commit comments

Comments
 (0)