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

Introduce kafka broker shutdown test case. #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@

package monix.kafka

import java.util.concurrent.TimeUnit

import monix.eval.Task
import monix.execution.Scheduler.Implicits.global
import monix.kafka.config.AutoOffsetReset
import monix.reactive.Observable
import net.manub.embeddedkafka.EmbeddedKafka
import org.apache.kafka.clients.producer.ProducerRecord
import org.scalatest.FunSuite

Expand Down Expand Up @@ -105,4 +108,21 @@ class MonixKafkaTopicRegexTest extends FunSuite with KafkaTestKit {
assert(result.map(_.toInt).sum === (0 until count).sum)
}
}

test("observable should become completed after kafka broker shutdown") {
EmbeddedKafka.start()
assert(EmbeddedKafka.isRunning)
val consumerCfgFixed = consumerCfg.copy(
maxPollInterval = 5.seconds,
connectionsMaxIdleTime = 30.seconds,
reconnectBackoffTime = 1.second
)
val consumerSubscription = KafkaConsumerObservable[String, String](consumerCfgFixed, topicsRegex).executeOn(io)
.foreach(_ => ())
EmbeddedKafka.stop()
assert(!EmbeddedKafka.isRunning)
TimeUnit.SECONDS.sleep(40)
assert(consumerSubscription.isCompleted)
}

}