aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio_tests
diff options
context:
space:
mode:
authorGravatar Eric Gribkoff <ericgribkoff@google.com>2018-12-27 09:39:53 -0800
committerGravatar Eric Gribkoff <ericgribkoff@google.com>2018-12-27 09:39:53 -0800
commite678187996bb7239315f30d9e50734c50ee4027b (patch)
tree92e4e0f8d4f42de1c7e481cd8212c8400cac8973 /src/python/grpcio_tests
parentb74af8c70bad274c4955a0e242c725409872342d (diff)
use test constants, fix formatting
Diffstat (limited to 'src/python/grpcio_tests')
-rw-r--r--src/python/grpcio_tests/tests/health_check/_health_servicer_test.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
index 657ceef1e4..bf90fa15c0 100644
--- a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
+++ b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
@@ -22,11 +22,10 @@ from grpc_health.v1 import health_pb2
from grpc_health.v1 import health_pb2_grpc
from tests.unit import test_common
+from tests.unit.framework.common import test_constants
from six.moves import queue
-_QUEUE_TIMEOUT_S = 5
-
_SERVING_SERVICE = 'grpc.test.TestServiceServing'
_UNKNOWN_SERVICE = 'grpc.test.TestServiceUnknown'
_NOT_SERVING_SERVICE = 'grpc.test.TestServiceNotServing'
@@ -98,7 +97,7 @@ class HealthServicerTest(unittest.TestCase):
target=_consume_responses, args=(rendezvous, response_queue))
thread.start()
- response = response_queue.get(timeout=_QUEUE_TIMEOUT_S)
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
self.assertEqual(health_pb2.HealthCheckResponse.SERVING,
response.status)
@@ -114,19 +113,19 @@ class HealthServicerTest(unittest.TestCase):
target=_consume_responses, args=(rendezvous, response_queue))
thread.start()
- response = response_queue.get(timeout=_QUEUE_TIMEOUT_S)
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
response.status)
self._servicer.set(_WATCH_SERVICE,
health_pb2.HealthCheckResponse.SERVING)
- response = response_queue.get(timeout=_QUEUE_TIMEOUT_S)
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
self.assertEqual(health_pb2.HealthCheckResponse.SERVING,
response.status)
self._servicer.set(_WATCH_SERVICE,
health_pb2.HealthCheckResponse.NOT_SERVING)
- response = response_queue.get(timeout=_QUEUE_TIMEOUT_S)
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
self.assertEqual(health_pb2.HealthCheckResponse.NOT_SERVING,
response.status)
@@ -142,14 +141,14 @@ class HealthServicerTest(unittest.TestCase):
target=_consume_responses, args=(rendezvous, response_queue))
thread.start()
- response = response_queue.get(timeout=_QUEUE_TIMEOUT_S)
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
response.status)
self._servicer.set('some-other-service',
health_pb2.HealthCheckResponse.SERVING)
- with self.assertRaises(queue.Empty) as context:
- response_queue.get(timeout=_QUEUE_TIMEOUT_S)
+ with self.assertRaises(queue.Empty):
+ response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
rendezvous.cancel()
thread.join()
@@ -168,8 +167,8 @@ class HealthServicerTest(unittest.TestCase):
thread1.start()
thread2.start()
- response1 = response_queue1.get(timeout=_QUEUE_TIMEOUT_S)
- response2 = response_queue2.get(timeout=_QUEUE_TIMEOUT_S)
+ response1 = response_queue1.get(timeout=test_constants.SHORT_TIMEOUT)
+ response2 = response_queue2.get(timeout=test_constants.SHORT_TIMEOUT)
self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
response1.status)
self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
@@ -177,8 +176,8 @@ class HealthServicerTest(unittest.TestCase):
self._servicer.set(_WATCH_SERVICE,
health_pb2.HealthCheckResponse.SERVING)
- response1 = response_queue1.get(timeout=_QUEUE_TIMEOUT_S)
- response2 = response_queue2.get(timeout=_QUEUE_TIMEOUT_S)
+ response1 = response_queue1.get(timeout=test_constants.SHORT_TIMEOUT)
+ response2 = response_queue2.get(timeout=test_constants.SHORT_TIMEOUT)
self.assertEqual(health_pb2.HealthCheckResponse.SERVING,
response1.status)
self.assertEqual(health_pb2.HealthCheckResponse.SERVING,
@@ -199,7 +198,7 @@ class HealthServicerTest(unittest.TestCase):
target=_consume_responses, args=(rendezvous, response_queue))
thread.start()
- response = response_queue.get(timeout=_QUEUE_TIMEOUT_S)
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
response.status)