-
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
Further mockbrocker improvements #492
Conversation
e3636c9
to
f130b98
Compare
5b98f0c
to
2a9b0bc
Compare
@eapache it builds now that I rebased it on the latest master. |
- A set of response builders were introduced to construct responses based on a particular request parameters. - mockbroker.SetHandlerByMap that provides a neat way of defining a request handler that use mockresponse builders. - consumer_test.go was rewritten using the new test primitives.
@@ -1,7 +1,7 @@ | |||
default: fmt vet errcheck test | |||
|
|||
test: | |||
go test -v -timeout 60s -race ./... | |||
go test -v -timeout 2m -race ./... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does the test suddenly need so much more time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consumer tests are rather fast, it is that other tests that use the older mock broker logic (the Returns()
plus the default handler to be more specific) sometimes take longer to complete. The thing is that in the original mock broker implementation it would delay a response to a request indefinitely until a reply is provided via Returns()
method. Now if a mock broker happens to get a request before Returns()
is called it waits for expectationTimeout
for Returns()
to be called and then ignores the request making it IO timeout on the consumer side. Consumer retries eventually but that adds up to the execution time.
I will try to increase the expectationTimeout
and bring the overall test suite timeout to the original value.
A few small points, but otherwise this looks really excellent, thank you! |
@eapache done |
👍 @wvanbergen any comments? |
This looks good to me! Merging... |
Further mockbrocker improvements
This PR brings further improvements into the mockbrocker:
mockbroker.SetHandlerByMap
method was introduced that provides a declarative way of defining a request handler that use mockresponse builders.TestConsumerRebalancingMultiplePartitions
is using time delays for synchronization and therefore race prone. It could have been rewritten in almost non-racy way by removing the goroutine that reads from partition consumer channels and putting those reads among the lines of the main test flow. But I opted to leave it this way, because the goroutine code resembles how PartitionCosnumer is used in real life.