dongnuo123 commented on code in PR #17886:
URL: https://github.com/apache/kafka/pull/17886#discussion_r1868350575


##########
server-common/src/main/java/org/apache/kafka/server/common/Features.java:
##########
@@ -41,10 +57,20 @@ public enum Features {
      *
      * See {@link TestFeatureVersion} as an example. See {@link 
FeatureVersion} when implementing a new feature.
      */
-    TEST_VERSION("test.feature.version", TestFeatureVersion.values()),
-    KRAFT_VERSION("kraft.version", KRaftVersion.values()),
-    TRANSACTION_VERSION("transaction.version", TransactionVersion.values()),
-    GROUP_VERSION("group.version", GroupVersion.values());
+    TEST_VERSION("test.feature.version", TestFeatureVersion.values(), 
TestFeatureVersion.LATEST_PRODUCTION),
+    KRAFT_VERSION("kraft.version", KRaftVersion.values(), 
KRaftVersion.LATEST_PRODUCTION),
+    TRANSACTION_VERSION("transaction.version", TransactionVersion.values(), 
TransactionVersion.LATEST_PRODUCTION),
+    GROUP_VERSION("group.version", GroupVersion.values(), 
GroupVersion.LATEST_PRODUCTION),
+
+    /**
+     * Features defined only for unit tests and are not used in production.
+     */
+    UNIT_TEST_VERSION_0(UnitTestFeatureVersion.FEATURE_NAME + ".0", new 
FeatureVersion[]{UT_FV0_0}, UT_FV0_1),
+    UNIT_TEST_VERSION_1(UnitTestFeatureVersion.FEATURE_NAME + ".1", new 
FeatureVersion[]{UT_FV1_0, UT_FV1_1}, UT_FV1_0),
+    UNIT_TEST_VERSION_2(UnitTestFeatureVersion.FEATURE_NAME + ".2", new 
FeatureVersion[]{UT_FV2_0, UT_FV2_1}, UT_FV2_0),
+    UNIT_TEST_VERSION_3(UnitTestFeatureVersion.FEATURE_NAME + ".3", new 
FeatureVersion[]{UT_FV3_0, UT_FV3_1}, UT_FV3_1),
+    UNIT_TEST_VERSION_4(UnitTestFeatureVersion.FEATURE_NAME + ".4", new 
FeatureVersion[]{UT_FV4_0, UT_FV4_1}, UT_FV4_1),
+    UNIT_TEST_VERSION_5(UnitTestFeatureVersion.FEATURE_NAME + ".5", new 
FeatureVersion[]{UT_FV5_0, UT_FV5_1}, UT_FV5_1);

Review Comment:
   Yeah it's a bit weird. The formatter unit tests are also failing because of 
these unrecognized features. I've tried several ways of addressing it but still 
don't have a rather good solution. 
   
   The issues are that 1) Feature is an enum so we can't extend from it to 
create a new enum specially for unit tests 2) The validation calls 
`featureFromName` which needs the `Features[]` array, so the Features for unit 
tests have to really exist.
   
   Another way to separate the production features and the unit test features 
is to create an exactly same enum called UnitTestFeatures, but that will be 
much duplication and pretty hard to maintain



-- 
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]

Reply via email to