[Python test] Add test timestamp (#37703)

`grpc/core/master/macos/grpc_basictests_python` test is flaky, all test cases passed by the test itself [failed with timeout](https://btx.cloud.google.com/invocations/33bdec48-e17b-431b-b473-c8a335e1650c/log):
```
2024-09-11 16:48:57,385 TIMEOUT: py38.asyncio.tests_aio.unit.done_callback_test.TestServerSideDoneCallback [pid=11128, time=486.5sec]
```

This PR does two things:
1. Increase timeout for test case from `480s` to `600s`.
2. Add timestamp to test starting and passing so we know which test case takes a long time to run.

Log before timestamp change:
```
Running       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_stream_stream
Running       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_stream_unary
Running       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_unary_stream
Running       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_unary_unary
Testing gRPC Python...
SUCCESS       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_error_in_callback
SUCCESS       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_error_in_handler
SUCCESS       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_stream_stream
SUCCESS       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_stream_unary
SUCCESS       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_unary_stream
SUCCESS       tests_aio.unit.done_callback_test.TestServerSideDoneCallback.test_unary_unary
```

Log after timestamp change:
```
Running       tests_aio.unit.done_callback_test.TestClientSideDoneCallback.test_stream_stream
Running       tests_aio.unit.done_callback_test.TestClientSideDoneCallback.test_stream_unary
Running       tests_aio.unit.done_callback_test.TestClientSideDoneCallback.test_unary_stream
Running       tests_aio.unit.done_callback_test.TestClientSideDoneCallback.test_unary_unary
[2024-09-12 10:47:13.877185]Testing gRPC Python...
[2024-09-12 10:47:13.901135]SUCCESS       tests_aio.unit.done_callback_test.TestClientSideDoneCallback.test_add_after_done
[2024-09-12 10:47:13.933705]SUCCESS       tests_aio.unit.done_callback_test.TestClientSideDoneCallback.test_stream_stream
[2024-09-12 10:47:13.962419]SUCCESS       tests_aio.unit.done_callback_test.TestClientSideDoneCallback.test_stream_unary
[2024-09-12 10:47:13.990368]SUCCESS       tests_aio.unit.done_callback_test.TestClientSideDoneCallback.test_unary_stream
```

<!--

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 #37703

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37703 from XuanWang-Amos:add_test_timestamp 4e13d29021
PiperOrigin-RevId: 675703890
pull/37747/head
Xuan Wang 2 months ago committed by Copybara-Service
parent 2c9b757462
commit 9a1ba9d15d
  1. 11
      src/python/grpcio_tests/tests/_result.py
  2. 2
      tools/run_tests/run_tests.py

@ -15,6 +15,7 @@
from __future__ import absolute_import
import collections
import datetime
import io
import itertools
import traceback
@ -295,7 +296,9 @@ class TerminalResult(CoverageResult):
"""See unittest.TestResult.startTestRun."""
super(TerminalResult, self).startTestRun()
self.out.write(
_Colors.HEADER + "Testing gRPC Python...\n" + _Colors.END
_Colors.HEADER
+ "[{}]Testing gRPC Python...\n".format(datetime.datetime.now())
+ _Colors.END
)
def stopTestRun(self):
@ -324,7 +327,11 @@ class TerminalResult(CoverageResult):
"""See unittest.TestResult.addSuccess."""
super(TerminalResult, self).addSuccess(test)
self.out.write(
_Colors.OK + "SUCCESS {}\n".format(test.id()) + _Colors.END
_Colors.OK
+ "[{}]SUCCESS {}\n".format(
datetime.datetime.now(), test.id()
)
+ _Colors.END
)
self.out.flush()

@ -719,7 +719,7 @@ class PythonLanguage(object):
self.config.job_spec(
python_config.run
+ [self._TEST_COMMAND[io_platform]],
timeout_seconds=8 * 60,
timeout_seconds=10 * 60,
environ=dict(
GRPC_PYTHON_TESTRUNNER_FILTER=str(test_case),
**environment,

Loading…
Cancel
Save