From b9357d7ee2b37b475521db639f0c738f02ca8e57 Mon Sep 17 00:00:00 2001 From: Anthony Mirabella Date: Mon, 21 Sep 2020 16:30:49 -0400 Subject: [PATCH] Remove flaky BatchSpanProcessor.ForceFlush() test (#1189) It is unreliable with no clear good way to make it reliable. The ForceFlush() method is a simple passthrough to bsp.exportSpans() and the existing tests of that method should suffice. Co-authored-by: Tyler Yahn --- sdk/trace/batch_span_processor_test.go | 47 -------------------------- 1 file changed, 47 deletions(-) diff --git a/sdk/trace/batch_span_processor_test.go b/sdk/trace/batch_span_processor_test.go index b25499c87..b0260d47f 100644 --- a/sdk/trace/batch_span_processor_test.go +++ b/sdk/trace/batch_span_processor_test.go @@ -181,53 +181,6 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) { } } -func TestBatchSpanProcessorForceFlush(t *testing.T) { - option := testOption{ - name: "ForceFlush()", - o: []sdktrace.BatchSpanProcessorOption{ - sdktrace.WithBatchTimeout(10 * time.Second), - sdktrace.WithMaxQueueSize(2000), - sdktrace.WithMaxExportBatchSize(2000), - }, - wantNumSpans: 205, - wantBatchCount: 1, - genNumSpans: 205, - } - - te := testBatchExporter{} - tp := basicProvider(t) - ssp := createAndRegisterBatchSP(option, &te) - if ssp == nil { - t.Fatalf("%s: Error creating new instance of BatchSpanProcessor\n", option.name) - } - tp.RegisterSpanProcessor(ssp) - tr := tp.Tracer("BatchSpanProcessorWithOptions") - - generateSpan(t, false, tr, option) - - ssp.ForceFlush() - - gotNumOfSpans := te.len() - if 0 == gotNumOfSpans { - t.Errorf("number of flushed spans is zero") - } - - tp.UnregisterSpanProcessor(ssp) - - gotNumOfSpans = te.len() - if option.wantNumSpans != gotNumOfSpans { - t.Errorf("number of exported span: got %+v, want %+v\n", - gotNumOfSpans, option.wantNumSpans) - } - - gotBatchCount := te.getBatchCount() - if gotBatchCount < option.wantBatchCount { - t.Errorf("number batches: got %+v, want >= %+v\n", - gotBatchCount, option.wantBatchCount) - t.Errorf("Batches %v\n", te.sizes) - } -} - func createAndRegisterBatchSP(option testOption, te *testBatchExporter) *sdktrace.BatchSpanProcessor { // Always use blocking queue to avoid flaky tests. options := append(option.o, sdktrace.WithBlocking())