Skip to content

Commit 1234b93

Browse files
committed
add tests
Signed-off-by: emdneto <[email protected]>
1 parent 439defc commit 1234b93

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_metrics_exporter.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,19 @@ def test_shutdown_wait_last_export(self):
874874
finally:
875875
export_thread.join()
876876

877+
def test_export_over_closed_grpc_channel(self):
878+
add_MetricsServiceServicer_to_server(
879+
MetricsServiceServicerSUCCESS(), self.server
880+
)
881+
self.exporter.export(self.metrics["sum_int"])
882+
self.exporter.shutdown()
883+
data = self.exporter._translate_data(self.metrics["sum_int"])
884+
with self.assertRaises(ValueError) as err:
885+
self.exporter._client.Export(request=data)
886+
self.assertEqual(
887+
str(err.exception),
888+
"Cannot invoke RPC on closed channel!"
889+
)
877890
def test_aggregation_temporality(self):
878891
# pylint: disable=protected-access
879892

exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_trace_exporter.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,19 @@ def test_shutdown_wait_last_export(self):
10171017
finally:
10181018
export_thread.join()
10191019

1020+
def test_export_over_closed_grpc_channel(self):
1021+
add_TraceServiceServicer_to_server(
1022+
TraceServiceServicerSUCCESS(), self.server
1023+
)
1024+
self.exporter.export([self.span])
1025+
self.exporter.shutdown()
1026+
data = self.exporter._translate_data([self.span])
1027+
with self.assertRaises(ValueError) as err:
1028+
self.exporter._client.Export(request=data)
1029+
self.assertEqual(
1030+
str(err.exception),
1031+
"Cannot invoke RPC on closed channel!"
1032+
)
10201033

10211034
def _create_span_with_status(status: SDKStatus):
10221035
span = _Span(

0 commit comments

Comments
 (0)