@ -170,14 +170,17 @@ func TestConsumerGroup_BasicFunctionality(t *testing.T) {
// ConsumerGroupHandler implements sarama.ConsumerGroupHandler
// ConsumerGroupHandler implements sarama.ConsumerGroupHandler
type ConsumerGroupHandler struct {
type ConsumerGroupHandler struct {
messages chan * sarama . ConsumerMessage
ready chan bool
t * testing . T
messages chan * sarama . ConsumerMessage
ready chan bool
readyOnce sync . Once
t * testing . T
}
}
func ( h * ConsumerGroupHandler ) Setup ( sarama . ConsumerGroupSession ) error {
func ( h * ConsumerGroupHandler ) Setup ( sarama . ConsumerGroupSession ) error {
h . t . Logf ( "Consumer group session setup" )
h . t . Logf ( "Consumer group session setup" )
close ( h . ready )
h . readyOnce . Do ( func ( ) {
close ( h . ready )
} )
return nil
return nil
}
}
@ -256,10 +259,10 @@ func TestConsumerGroup_OffsetCommitAndFetch(t *testing.T) {
// First consumer: consume first 3 messages and commit offsets
// First consumer: consume first 3 messages and commit offsets
t . Logf ( "=== First consumer: consuming first 3 messages ===" )
t . Logf ( "=== First consumer: consuming first 3 messages ===" )
handler1 := & OffsetTestHandler {
handler1 := & OffsetTestHandler {
messages : make ( chan * sarama . ConsumerMessage , numMessages ) ,
ready : make ( chan bool ) ,
stopAfter : 3 ,
t : t ,
messages : make ( chan * sarama . ConsumerMessage , numMessages ) ,
ready : make ( chan bool ) ,
stopAfter : 3 ,
t : t ,
}
}
consumerGroup1 , err := sarama . NewConsumerGroup ( [ ] string { brokerAddr } , groupID , config )
consumerGroup1 , err := sarama . NewConsumerGroup ( [ ] string { brokerAddr } , groupID , config )
@ -304,10 +307,10 @@ func TestConsumerGroup_OffsetCommitAndFetch(t *testing.T) {
// Second consumer: should start from offset 3 (after committed offset)
// Second consumer: should start from offset 3 (after committed offset)
t . Logf ( "=== Second consumer: should resume from offset 3 ===" )
t . Logf ( "=== Second consumer: should resume from offset 3 ===" )
handler2 := & OffsetTestHandler {
handler2 := & OffsetTestHandler {
messages : make ( chan * sarama . ConsumerMessage , numMessages ) ,
ready : make ( chan bool ) ,
stopAfter : 2 , // Should get remaining 2 messages
t : t ,
messages : make ( chan * sarama . ConsumerMessage , numMessages ) ,
ready : make ( chan bool ) ,
stopAfter : 2 , // Should get remaining 2 messages
t : t ,
}
}
consumerGroup2 , err := sarama . NewConsumerGroup ( [ ] string { brokerAddr } , groupID , config )
consumerGroup2 , err := sarama . NewConsumerGroup ( [ ] string { brokerAddr } , groupID , config )
@ -362,6 +365,7 @@ func TestConsumerGroup_OffsetCommitAndFetch(t *testing.T) {
type OffsetTestHandler struct {
type OffsetTestHandler struct {
messages chan * sarama . ConsumerMessage
messages chan * sarama . ConsumerMessage
ready chan bool
ready chan bool
readyOnce sync . Once
stopAfter int
stopAfter int
consumed int
consumed int
t * testing . T
t * testing . T
@ -369,7 +373,9 @@ type OffsetTestHandler struct {
func ( h * OffsetTestHandler ) Setup ( sarama . ConsumerGroupSession ) error {
func ( h * OffsetTestHandler ) Setup ( sarama . ConsumerGroupSession ) error {
h . t . Logf ( "Offset test consumer setup" )
h . t . Logf ( "Offset test consumer setup" )
close ( h . ready )
h . readyOnce . Do ( func ( ) {
close ( h . ready )
} )
return nil
return nil
}
}
@ -653,6 +659,7 @@ func TestConsumerGroup_Rebalancing(t *testing.T) {
type RebalanceTestHandler struct {
type RebalanceTestHandler struct {
messages chan * sarama . ConsumerMessage
messages chan * sarama . ConsumerMessage
ready chan bool
ready chan bool
readyOnce sync . Once
rebalanced chan bool
rebalanced chan bool
consumerID string
consumerID string
t * testing . T
t * testing . T