MINOR: Cleanup redundancies in BaseRequestTest#7735
Conversation
902502c to
5063081
Compare
04e6304 to
275d34b
Compare
ijuma
left a comment
There was a problem hiding this comment.
Thanks for the PR. Nice clean-up. A few minor comments.
| socket.setSoTimeout(1000) | ||
| try { | ||
| val response = sendAndReceive(produceRequest, ApiKeys.PRODUCE, socket) | ||
| assertEquals(0, response.remaining) |
There was a problem hiding this comment.
Why don't we need this assertion anymore?
There was a problem hiding this comment.
The assertion was actually never getting executed. The call to sendAndReceive raises a timeout exception, which is what verifyMaxConnections is looking for.
| import org.apache.kafka.common.protocol.ApiKeys | ||
| import org.apache.kafka.common.requests.{ApiVersionsRequest, ApiVersionsResponse} | ||
|
|
||
| abstract class AbstractApiVersionsRequestTest extends BaseRequestTest { |
There was a problem hiding this comment.
Is this abstract base class worth it? We could either add this single method to BaseRequestTest or TestUtils.
There was a problem hiding this comment.
It's a bit more justifiable if we take the validateApiVersionsResponse method out of the ApiVersionsRequestTest companion.
There was a problem hiding this comment.
Maybe we should move this method to the companion? Nice to avoid long inheritance hierarchies.
There was a problem hiding this comment.
We could but it's a little more awkward since it requires an instance of BaseRequestTest. We could also add it to BaseRequestTest, but I was hoping to keep that class generic and to avoid leaking a bunch of api-specific noise into it.
| protected def error(error: Errors, errorMessage: Option[String] = None): ApiError = | ||
| new ApiError(error, errorMessage.orNull) | ||
|
|
||
| protected def toStructWithDuplicateFirstTopic(request: CreateTopicsRequest): Struct = { |
There was a problem hiding this comment.
Interesting that this is no longer used. Do you know if we are still testing the case where we have a duplicate topic?
There was a problem hiding this comment.
I tracked the removal of the uses of this method back to this: e2e8bdb#diff-217dea05d3ff55c8bf10503c329f7c2b. I don't see a clear reason for it.
There was a problem hiding this comment.
CreateTopicsRequest was the first RPC converted over to automatic generation, if I remember correctly. I converted it while writing the generator.
I think when the automatic code generation was first developed, it didn't have support for multiple identical elements in the same map. So it wasn't possible to serialize the invalid request at that point. So I had to remove this test. Later on I added support for duplicate entries in the same map.
We should definitely re-add a test for duplicate createTopics elements. There should also be a test like this in KafkaAdminClientTest to test the admin client's handling of it (AC should not allow this to even get to the server)
| @@ -65,21 +65,20 @@ class ApiVersionsRequestTest extends BaseRequestTest { | |||
| @Test | |||
| def testApiVersionsRequestValidationV0(): Unit = { | |||
| val apiVersionsRequest = new ApiVersionsRequest.Builder().build( 0.asInstanceOf[Short]) | |||
There was a problem hiding this comment.
Existing issue, but empty space before 0 should be removed.
| connectAndReceive[DeleteTopicsResponse](request, destination = socketServer) | ||
| } | ||
|
|
||
| private def sendMetadataRequest(request: MetadataRequest): MetadataResponse = { |
There was a problem hiding this comment.
Is it even worth having this method? There are a few other examples like that in other classes.
| } | ||
| } | ||
|
|
||
| private def responseThrottleTime(apiKey: ApiKeys, response: Struct): Int = { |
There was a problem hiding this comment.
Glad to see this go. I had done something similar in https://github.com/apache/kafka/pull/7409/files#diff-8259941614685619733d9f458762a0b6L564, but hadn't gotten around to pushing that PR over the line.
| apiVersion: Short, | ||
| clientId: String = "client-id", | ||
| correlationIdOpt: Option[Int] = None | ||
| ): RequestHeader = { |
There was a problem hiding this comment.
Nit: this is a bit unusual, any reason for it not to be on the previous line?
| @Test | ||
| def testApiVersionsRequestBeforeSaslHandshakeRequest(): Unit = { | ||
| val plaintextSocket = connect(protocol = securityProtocol) | ||
| val plaintextSocket = connect() |
There was a problem hiding this comment.
Maybe we should rename this to socket as the current name is a bit misleading. Same for the other methods.
|
I'm sorry, I'm not careful |
|
retest this please |
2 similar comments
|
retest this please |
|
retest this please |
…Test (apache#7735) This patch eliminates some redundancy and general messiness around the usage of `BaseRequestTest` and specifically response deserialization. Reviewers: Ismael Juma <ismael@juma.me.uk>
This patch eliminates a lot of redundancy and general messiness around the usage of
BaseRequestTestand specifically response deserialization.Committer Checklist (excluded from commit message)