|
14 | 14 | import app_pb2_grpc as app_service |
15 | 15 | import docker |
16 | 16 | import grpc |
17 | | -from absl import logging |
18 | | - |
19 | 17 | try: |
20 | | - # Initialize the abseil logging system - this prevents the "WARNING: All log messages..." message |
21 | | - logging.set_verbosity(logging.INFO) |
22 | | - logging.use_absl_handler() |
| 18 | + from absl import logging as absl_logging |
| 19 | + # Prevent noisy "All log messages ..." banner |
| 20 | + absl_logging.set_verbosity(absl_logging.INFO) |
| 21 | + absl_logging.use_absl_handler() |
23 | 22 | except ImportError: |
| 23 | + # absl is optional – continue with stdlib logging defaults |
24 | 24 | pass |
25 | 25 |
|
26 | 26 |
|
@@ -131,10 +131,9 @@ def _setup_grpc(self): |
131 | 131 | self.grpcConn = grpc.insecure_channel("localhost:8081") |
132 | 132 | try: |
133 | 133 | grpc.channel_ready_future(self.grpcConn).result(timeout=10) |
134 | | - except grpc.FutureTimeoutError: |
135 | | - raise RuntimeError("Error connecting to gRPC server") |
| 134 | + except grpc.FutureTimeoutError as err: |
| 135 | + raise RuntimeError("Error connecting to gRPC server") from err |
136 | 136 | return self.grpcConn |
137 | | - |
138 | 137 | def tearDown(self): |
139 | 138 | self._stopDocker() |
140 | 139 | logdir = None |
@@ -267,18 +266,10 @@ def testGrpcPropagation(self): |
267 | 266 | app = app_service.AppStub(grpc_conn) |
268 | 267 | try: |
269 | 268 | app.CheckTraceHeader(app_messages.Empty()) |
270 | | - except Exception as e: |
271 | | - # Close the connection before allowing any exceptions to propagate |
272 | | - if self.grpcConn: |
| 269 | + finally: |
| 270 | + if self.grpcConn is not None: |
273 | 271 | self.grpcConn.close() |
274 | 272 | self.grpcConn = None |
275 | | - raise |
276 | | - |
277 | | - # Explicitly close the connection before stopping Docker |
278 | | - if self.grpcConn: |
279 | | - self.grpcConn.close() |
280 | | - self.grpcConn = None |
281 | | - |
282 | 273 | self._stopEnvironment() |
283 | 274 | self.assertEqual(len(self.nginx_traces), 2) |
284 | 275 |
|
|
0 commit comments