Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix REBALANCING event test #1079

Merged
merged 1 commit into from
Apr 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/consumer/__tests__/instrumentationEvents.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,15 @@ describe('Consumer > Instrumentation Events', () => {

const groupId = `consumer-group-id-${secureRandom()}`

const consumer1 = createTestConsumer({
consumer = createTestConsumer({
groupId,
cluster: createCluster({
instrumentationEmitter: new InstrumentationEventEmitter(),
metadataMaxAge: 50,
}),
})

const consumer2 = createTestConsumer({
consumer2 = createTestConsumer({
groupId,
cluster: createCluster({
instrumentationEmitter: new InstrumentationEventEmitter(),
Expand All @@ -376,21 +376,20 @@ describe('Consumer > Instrumentation Events', () => {
})

let memberId
consumer1.on(consumer.events.GROUP_JOIN, async event => {
memberId = event.payload.memberId
consumer1.removeAllListeners(consumer.events.GROUP_JOIN)
consumer.on(consumer.events.GROUP_JOIN, async event => {
memberId = memberId || event.payload.memberId
})

consumer1.on(consumer.events.REBALANCING, async event => {
consumer.on(consumer.events.REBALANCING, async event => {
onRebalancing(event)
})

await consumer1.connect()
await consumer1.subscribe({ topic: topicName, fromBeginning: true })
await consumer.connect()
await consumer.subscribe({ topic: topicName, fromBeginning: true })

consumer1.run({ eachMessage: () => true })
consumer.run({ eachMessage: () => true })

await waitForConsumerToJoinGroup(consumer1, { label: 'consumer1' })
await waitForConsumerToJoinGroup(consumer, { label: 'consumer1' })

await consumer2.connect()
await consumer2.subscribe({ topic: topicName, fromBeginning: true })
Expand Down