Skip to content

Commit

Permalink
Separate tests for shutdown and force_flush
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciovasquezbernal committed Feb 4, 2020
1 parent 4cf3c3c commit dba213d
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions opentelemetry-sdk/tests/trace/export/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,25 @@ def _create_start_and_end_span(name, span_processor):


class TestBatchExportSpanProcessor(unittest.TestCase):
def test_batch_span_processor(self):
def test_shutdown(self):
spans_names_list = []

my_exporter = MySpanExporter(destination=spans_names_list)
span_processor = export.BatchExportSpanProcessor(my_exporter)

span_names = ["xxx", "bar", "foo"]

for name in span_names:
_create_start_and_end_span(name, span_processor)

span_processor.shutdown()
self.assertTrue(my_exporter.is_shutdown)

# check that spans are exported without an explicitly call to
# force_flush()
self.assertListEqual(span_names, spans_names_list)

def test_flush(self):
spans_names_list = []

my_exporter = MySpanExporter(destination=spans_names_list)
Expand All @@ -116,12 +134,11 @@ def test_batch_span_processor(self):
for name in span_names1:
_create_start_and_end_span(name, span_processor)

span_processor.shutdown()
self.assertTrue(my_exporter.is_shutdown)

# check that processor is flushed after shutdown()
span_processor.force_flush()
self.assertListEqual(span_names0 + span_names1, spans_names_list)

span_processor.shutdown()

def test_batch_span_processor_lossless(self):
"""Test that no spans are lost when sending max_queue_size spans"""
spans_names_list = []
Expand Down

0 comments on commit dba213d

Please sign in to comment.