Skip to content

Commit 3d6a99b

Browse files
authored
test: resolved flaky rdkafka tests (#2001)
ref https://jsw.ibm.com/browse/INSTA-41047
1 parent e733ed2 commit 3d6a99b

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

packages/collector/test/tracing/messaging/node-rdkafka/consumer.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ function setupConsumer() {
9797
span.end();
9898
});
9999
} else {
100-
_consumer = new Kafka.KafkaConsumer(consumerOptions, {
101-
'auto.offset.reset': 'earliest'
102-
});
100+
_consumer = new Kafka.KafkaConsumer(consumerOptions);
101+
103102
_consumer.connect();
104103

105104
_consumer.on('ready', () => {

packages/collector/test/tracing/messaging/node-rdkafka/producer.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const express = require('express');
2121
const port = require('../../../test_util/app-port')();
2222
const enableDeliveryCb = process.env.RDKAFKA_PRODUCER_DELIVERY_CB === 'true';
2323
const isStream = process.env.RDKAFKA_PRODUCER_AS_STREAM === 'true';
24+
2425
const app = express();
2526
const topic = 'rdkafka-topic';
2627
let throwDeliveryErr = false;
@@ -113,6 +114,8 @@ let messageCounter = 0;
113114
const producer = getProducer();
114115

115116
/**
117+
* @param {boolean} bufferErrorSender
118+
* @param {string} method
116119
* @param {string} msg
117120
* @returns {{ wasSent: boolean, topic: string, msg: string, timestamp: number }}
118121
*/
@@ -175,25 +178,22 @@ function doProduce(bufferErrorSender = false, method, msg = 'Node rdkafka is gre
175178

176179
log('Sending message as standard on topic', topic);
177180

178-
setTimeout(() => {
179-
const wasSent = producer.produce(topic, null, theMessage, null, null, null, [
180-
{ message_counter: ++messageCounter }
181-
]);
182-
183-
log('Sent message as standard', wasSent);
184-
185-
setTimeout(async () => {
186-
await fetch(`http://127.0.0.1:${agentPort}`);
187-
188-
resolve({
189-
timestamp: Date.now(),
190-
wasSent,
191-
topic,
192-
msg: theMessage,
193-
messageCounter
194-
});
195-
}, 100);
196-
}, 2 * 1000);
181+
const wasSent = producer.produce(topic, null, theMessage, null, null, null, [
182+
{ message_counter: ++messageCounter }
183+
]);
184+
185+
log('Sent message as standard', wasSent);
186+
187+
setTimeout(async () => {
188+
await fetch(`http://127.0.0.1:${agentPort}`);
189+
resolve({
190+
timestamp: Date.now(),
191+
wasSent,
192+
topic,
193+
msg: theMessage,
194+
messageCounter
195+
});
196+
}, 100);
197197
});
198198
}
199199
}

packages/collector/test/tracing/messaging/node-rdkafka/test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ const topic = 'rdkafka-topic';
5858

5959
const mochaSuiteFn = supportedVersion(process.versions.node) ? describe : describe.skip;
6060

61-
// TODO: enable again. Its very flaky
62-
mochaSuiteFn.skip('tracing/messaging/node-rdkafka', function () {
61+
mochaSuiteFn('tracing/messaging/node-rdkafka', function () {
6362
this.timeout(config.getTestTimeout() * 10);
6463

6564
globalAgent.setUpCleanUpHooks();

0 commit comments

Comments
 (0)