mirror of
https://gitee.com/johng/gf
synced 2026-07-08 22:40:30 +08:00
thirdparty package kafka updated to date
This commit is contained in:
@ -81,7 +81,7 @@ func TestVersionMatrix(t *testing.T) {
|
||||
// protocol versions and compressions for the except of LZ4.
|
||||
testVersions := versionRange(V0_8_2_0)
|
||||
allCodecsButLZ4 := []CompressionCodec{CompressionNone, CompressionGZIP, CompressionSnappy}
|
||||
producedMessages := produceMsgs(t, testVersions, allCodecsButLZ4, 17, 100)
|
||||
producedMessages := produceMsgs(t, testVersions, allCodecsButLZ4, 17, 100, false)
|
||||
|
||||
// When/Then
|
||||
consumeMsgs(t, testVersions, producedMessages)
|
||||
@ -98,7 +98,20 @@ func TestVersionMatrixLZ4(t *testing.T) {
|
||||
// and all possible compressions.
|
||||
testVersions := versionRange(V0_10_0_0)
|
||||
allCodecs := []CompressionCodec{CompressionNone, CompressionGZIP, CompressionSnappy, CompressionLZ4}
|
||||
producedMessages := produceMsgs(t, testVersions, allCodecs, 17, 100)
|
||||
producedMessages := produceMsgs(t, testVersions, allCodecs, 17, 100, false)
|
||||
|
||||
// When/Then
|
||||
consumeMsgs(t, testVersions, producedMessages)
|
||||
}
|
||||
|
||||
func TestVersionMatrixIdempotent(t *testing.T) {
|
||||
setupFunctionalTest(t)
|
||||
defer teardownFunctionalTest(t)
|
||||
|
||||
// Produce lot's of message with all possible combinations of supported
|
||||
// protocol versions starting with v0.11 (first where idempotent was supported)
|
||||
testVersions := versionRange(V0_11_0_0)
|
||||
producedMessages := produceMsgs(t, testVersions, []CompressionCodec{CompressionNone}, 17, 100, true)
|
||||
|
||||
// When/Then
|
||||
consumeMsgs(t, testVersions, producedMessages)
|
||||
@ -133,7 +146,7 @@ func versionRange(lower KafkaVersion) []KafkaVersion {
|
||||
return versions
|
||||
}
|
||||
|
||||
func produceMsgs(t *testing.T, clientVersions []KafkaVersion, codecs []CompressionCodec, flush int, countPerVerCodec int) []*ProducerMessage {
|
||||
func produceMsgs(t *testing.T, clientVersions []KafkaVersion, codecs []CompressionCodec, flush int, countPerVerCodec int, idempotent bool) []*ProducerMessage {
|
||||
var wg sync.WaitGroup
|
||||
var producedMessagesMu sync.Mutex
|
||||
var producedMessages []*ProducerMessage
|
||||
@ -145,6 +158,11 @@ func produceMsgs(t *testing.T, clientVersions []KafkaVersion, codecs []Compressi
|
||||
prodCfg.Producer.Return.Errors = true
|
||||
prodCfg.Producer.Flush.MaxMessages = flush
|
||||
prodCfg.Producer.Compression = codec
|
||||
prodCfg.Producer.Idempotent = idempotent
|
||||
if idempotent {
|
||||
prodCfg.Producer.RequiredAcks = WaitForAll
|
||||
prodCfg.Net.MaxOpenRequests = 1
|
||||
}
|
||||
|
||||
p, err := NewSyncProducer(kafkaBrokers, prodCfg)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user