markusthoemmes commented on a change in pull request #2744: Deploy kafka &
zookeeper cluster with ansible
URL:
https://github.com/apache/incubator-openwhisk/pull/2744#discussion_r152789880
##########
File path: tests/src/test/scala/services/KafkaConnectorTests.scala
##########
@@ -112,4 +123,35 @@ class KafkaConnectorTests extends FlatSpec with Matchers
with WskActorSystem wit
} else consumer.commit()
}
}
+
+ it should "send and receive a kafka message even after shutdown one of
instances" in {
+ val kafkaHosts = config.kafkaHosts.split(",")
+ if (kafkaHosts.length > 1) {
+ for (i <- 0 until kafkaHosts.length) {
+ val message = new Message { override val serialize =
Calendar.getInstance().getTime().toString }
+
+ val kafkaHost = kafkaHosts(i).split(":")(0)
+ val startLog = s", started"
+ val prevCount = startLog.r.findAllMatchIn(commandComponent(kafkaHost,
"logs", s"kafka$i").stdout).length
+
+ commandComponent(kafkaHost, "stop", s"kafka$i")
+
+ val start = java.lang.System.currentTimeMillis
+ val sent = Await.result(producer.send(topic, message), 20 seconds)
+ val received = consumer.peek(10 seconds).map { case (_, _, _, msg) =>
new String(msg, "utf-8") }
+ val end = java.lang.System.currentTimeMillis
+ val elapsed = end - start
+ println(s"($i) Received ${received.size}. Took $elapsed msec:
$received\n")
+
+ consumer.commit()
+
+ commandComponent(kafkaHost, "start", s"kafka$i")
+ retry({
+ startLog.r
+ .findAllMatchIn(commandComponent(kafkaHost, "logs",
s"kafka$i").stdout)
+ .length shouldBe prevCount + 1
+ }, 15, Some(1.second)) // wait until kafka is up
+ }
+ }
+ }
Review comment:
Great to have a test but there are no assertions in here wrt. "sending and
consuming of messages still works". Could those be added?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services