-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Permit setting version on mock fetch response #939
Conversation
Thanks @eapache. Would you consider an additional API such as: func (mfr *MockFetchResponse) SetMaxVersion(kafkaVersion KafkaVersion) *MockFetchResponse {
switch {
case kafkaVersion.IsAtLeast(sarama.V0_11_0_0): // e.g. when supported
mfr.version = 3
case kafkaVersion.IsAtLeast(sarama.V0_10_0_0):
mfr.version = 2
default:
mfr.version = 1
}
return mfr
} |
Hmm, actually would it just be simpler to return the same version of FetchResponse as was received in the FetchRequest? That would be simpler, but I'm not sure if they line up in all cases? |
What about just adding property to the MockBroker itself (e.g. I advocate for the use of |
AFAICT log.message.format.version refers to the version of the actual |
I've reviewed this some more and I think the PR I have here is correct. The wire protocol version should be flexible even knowing the broker version. |
This allows setting the version of the message data struct for MockProduceResponse. This change is very similar to what was already done in pull request IBM#939 In order to mock a "produce" request for Kafka version 0.10.2.0 you would use the following: leader.SetHandlerByMap(map[string]MockResponse{ "ProduceRequest": NewMockProduceResponse(t). SetVersion(2). SetError("my_topic", 0, ErrNoError), })
This allows setting the version of the message data struct for MockProduceResponse. This change is very similar to what was already done in pull request IBM#939 In order to mock a "produce" request for Kafka version 0.10.2.0 you would use the following: leader.SetHandlerByMap(map[string]MockResponse{ "ProduceRequest": NewMockProduceResponse(t). SetVersion(2). SetError("my_topic", 0, ErrNoError), })
@sanchezl this should address #938.