VOL-2098 Support for Kafka liveness testing
* Adds liveness channel to sarama_client and kafka_interadapter proxy.
The liveness channel will push true or false to the channel on
each successful or failed Kafka publish.
* Adds support to make a "liveness publish attempt", which publishes
an empty message on a _liveness channel.
* Adds ServiceStatusNotReady to Probe
* Suppresses multiple Probe.UpdateStatus of the same status
* Adds the ability to attach a Probe to the grpc server, so that
when the probe returns NotReady, the Server responds to requests
with UNAVAILABLE.
Change-Id: I996c719570a50f2f6f397887d10d489608269c3f
diff --git a/pkg/kafka/kafka_inter_container_library_test.go b/pkg/kafka/kafka_inter_container_library_test.go
index 790425e..c3eace7 100644
--- a/pkg/kafka/kafka_inter_container_library_test.go
+++ b/pkg/kafka/kafka_inter_container_library_test.go
@@ -81,3 +81,32 @@
assert.Equal(t, actualResult.defaultRequestHandlerInterface, m)
assert.Equal(t, actualResult.DefaultTopic.Name, "Adapter")
}
+
+func TestKafkaProxyEnableLivenessChannel(t *testing.T) {
+ var m *myInterface
+
+ // Note: This doesn't actually start the client
+ client := NewSaramaClient()
+
+ probe, err := NewInterContainerProxy(
+ InterContainerHost("10.20.30.40"),
+ InterContainerPort(1020),
+ DefaultTopic(&Topic{Name: "Adapter"}),
+ RequestHandlerInterface(m),
+ MsgClient(client),
+ )
+
+ assert.Nil(t, err)
+
+ ch := probe.EnableLivenessChannel(true)
+
+ // The channel should have one "true" message on it
+ assert.NotEmpty(t, ch)
+
+ select {
+ case stuff := <-ch:
+ assert.True(t, stuff)
+ default:
+ t.Error("Failed to read from the channel")
+ }
+}