dino2895 opened a new pull request, #23330:
URL: https://github.com/apache/kafka/pull/23330
This PR moves the test cases in `KafkaRequestHandlerTest` that use
`BrokerTopicStats` rather than `KafkaRequestHandler` into a new
`BrokerTopicMetricsTest`.
The new test class is placed in the `storage` module, next to
`BrokerTopicMetrics` and `BrokerTopicStats`, and is written in Java following
the ongoing Scala-to-Java migration.
This is a test-only change with no intended behavior change.
`KafkaRequestHandlerTest` retains the five cases that exercise the request
handler along with the `makeRequest` helper, and its now-unused imports are
removed.
Three adjustments were made while writing the new class:
- `setupBrokerTopicMetrics` is not carried over, because it has no callers.
- The migrated cases never closed their `BrokerTopicStats`, which leaked
metrics into the global `KafkaYammerMetrics` registry. The new class closes
it
through `@AfterEach`, and through try-with-resources in the cases that
construct their own instance.
- `testGaugeClose` repeated the same registry filtering expression three
times,
so it is extracted into a `gaugeCount` helper.
### Testing
```bash
./gradlew :storage:test \
--tests org.apache.kafka.storage.log.metrics.BrokerTopicMetricsTest \
:core:test --tests kafka.server.KafkaRequestHandlerTest \
:storage:checkstyleTest
```
All tests passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]