Skip to content

Commit b296be6

Browse files
obecnymayurkale22
authored andcommitted
chore: fixing flaky test for batch span processor (#480)
1 parent a382767 commit b296be6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import * as assert from 'assert';
18+
import * as sinon from 'sinon';
1819
import {
1920
Span,
2021
BasicTracer,
@@ -107,6 +108,7 @@ describe('BatchSpanProcessor', () => {
107108
});
108109

109110
it('should force flush when timeout exceeded', done => {
111+
const clock = sinon.useFakeTimers();
110112
const processor = new BatchSpanProcessor(exporter, defaultBufferConfig);
111113
for (let i = 0; i < defaultBufferConfig.bufferSize; i++) {
112114
const span = createSampledSpan(`${name}_${i}`);
@@ -118,6 +120,10 @@ describe('BatchSpanProcessor', () => {
118120
assert.strictEqual(exporter.getFinishedSpans().length, 5);
119121
done();
120122
}, defaultBufferConfig.bufferTimeout + 1000);
121-
}).timeout(defaultBufferConfig.bufferTimeout * 2);
123+
124+
clock.tick(defaultBufferConfig.bufferTimeout + 1000);
125+
126+
clock.restore();
127+
});
122128
});
123129
});

0 commit comments

Comments
 (0)