Skip to content

Commit

Permalink
[Python Aio] Fix test_cancel_after_done_writing (grpc#37651)
Browse files Browse the repository at this point in the history
This test is flaky, example failure: https://fusion2.corp.google.com/invocations/31bcd70f-650d-40be-8ec4-6fafc3cd3724, error message:
```
Traceback (most recent call last):
  File "/usr/lib/python3.9/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/lib/python3.9/unittest/case.py", line 593, in run
    self._callTestMethod(testMethod)
  File "/usr/lib/python3.9/unittest/case.py", line 550, in _callTestMethod
    method()
  File "/var/local/git/grpc/src/python/grpcio_tests/tests_aio/unit/_test_base.py", line 31, in wrapper
    return loop.run_until_complete(f(*args, **kwargs))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/var/local/git/grpc/src/python/grpcio_tests/tests_aio/unit/call_test.py", line 820, in test_cancel_after_done_writing
    self.assertFalse(call.done())
  File "/usr/lib/python3.9/unittest/case.py", line 676, in assertFalse
    raise self.failureException(msg)
AssertionError: True is not false
```

We're expecting call to NOT finish immediately after `await call.done_writing()` which is not correct.
* `call.done_writing()` only notifies server that the client is done sending messages, while `call.done()` checks if the RPC call itself has finished.

Thus removing assert check for `call.done()`.

<!--

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 grpc#37651

COPYBARA_INTEGRATE_REVIEW=grpc#37651 from XuanWang-Amos:fix_aio_cancel_after_done_writing 42add84
PiperOrigin-RevId: 671834305
  • Loading branch information
XuanWang-Amos authored and copybara-github committed Sep 6, 2024
1 parent fe0b31c commit 7293191
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/python/grpcio_tests/tests_aio/unit/call_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,6 @@ async def test_cancel_after_done_writing(self):
await call.done_writing()

# Cancels the RPC
self.assertFalse(call.done())
self.assertFalse(call.cancelled())
self.assertTrue(call.cancel())
self.assertTrue(call.cancelled())
Expand Down

0 comments on commit 7293191

Please sign in to comment.