chia7712 commented on code in PR #16991:
URL: https://github.com/apache/kafka/pull/16991#discussion_r1743091284
##########
core/src/test/java/kafka/test/junit/RaftClusterInvocationContext.java:
##########
@@ -247,52 +241,16 @@ public Map<Integer, ControllerServer> controllers() {
public void format() throws Exception {
if (formated.compareAndSet(false, true)) {
- Map<String, Features> nameToSupportedFeature = new TreeMap<>();
- Features.PRODUCTION_FEATURES.forEach(feature ->
nameToSupportedFeature.put(feature.featureName(), feature));
- Map<String, Short> newFeatureLevels = new TreeMap<>();
-
- // Verify that all specified features are known to us.
- for (Map.Entry<Features, Short> entry :
clusterConfig.features().entrySet()) {
- String featureName = entry.getKey().featureName();
- short level = entry.getValue();
- if (!featureName.equals(MetadataVersion.FEATURE_NAME)) {
- if (!nameToSupportedFeature.containsKey(featureName)) {
- throw new FormatterException("Unsupported feature:
" + featureName +
- ". Supported features are: " + String.join(",
", nameToSupportedFeature.keySet()));
- }
- }
- newFeatureLevels.put(featureName, level);
- }
- newFeatureLevels.put(MetadataVersion.FEATURE_NAME,
clusterConfig.metadataVersion().featureLevel());
-
- // Add default values for features that were not specified.
- Features.PRODUCTION_FEATURES.forEach(supportedFeature -> {
Review Comment:
`ClusterTest#features`
(https://github.com/apache/kafka/blob/trunk/core/src/test/java/kafka/test/annotation/ClusterTest.java#L50)
is empty by default, hence removing the code of adding default features will
cause a lot of tests failed.
We can add default features to `ClusterTest`. for example:
```java
ClusterFeature[] features() default {
@ClusterFeature(feature = Features.TRANSACTION_VERSION, version = 2),
@ClusterFeature(feature = Features.GROUP_VERSION, version = 1)
};
```
The side effect is that all declarations are static so we need to update
default features when we do something changes to `Features`.
Or we can keep origin behavior to add default features based on
`PRODUCTION_FEATURES`. That is more flexible.
--
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]