You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "showuon (via GitHub)" <gi...@apache.org> on 2025/04/11 10:43:24 UTC

[PR] MINOR: Fix kraft ver broken test [kafka]

showuon opened a new pull request, #19448:
URL: https://github.com/apache/kafka/pull/19448

   Fix failed `kafka.server.KRaftClusterTest."testDescribeKRaftVersion(boolean)` test. It is failing in [3.9 branch](https://ci-builds.apache.org/job/Kafka/job/kafka/job/3.9/186/#showFailuresLink). 
   
   In the [patch for 4.0](https://github.com/apache/kafka/pull/19127/files#diff-a95d286b4e1eb166af89ea45bf1fe14cd8c944d7fc0483bfd4eff2245d1d2bbbR1014), we created TestKitNodes like this:
   ```
   new TestKitNodes.Builder().
           setNumBrokerNodes(1).
           setNumControllerNodes(1).
           setFeature(KRaftVersion.FEATURE_NAME, 1.toShort).build()).build()
   ```
   But in the 3.9, because we don't have `setFeature` method in TestKitNodes, we removed it which causes the test failure. Added them back to 3.9 branch.
   
   Also in 4.0, we include this [patch](https://github.com/apache/kafka/pull/17582/files#r1823404214), which contains a bug fix and TestKitNodes improvement to allow set features. Added them in 3.9 branch to fix the test and the finalized version always 0 issue.
   
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix kraft ver broken test [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #19448:
URL: https://github.com/apache/kafka/pull/19448#discussion_r2039707245


##########
metadata/src/main/java/org/apache/kafka/metadata/bootstrap/BootstrapMetadata.java:
##########
@@ -149,6 +149,32 @@ public BootstrapMetadata copyWithOnlyVersion() {
                 metadataVersion, source);
     }
 
+    public BootstrapMetadata copyWithFeatureRecord(String featureName, short level) {
+        List<ApiMessageAndVersion> newRecords = new ArrayList<>();
+        int i = 0;
+        while (i < records.size()) {
+            if (records.get(i).message() instanceof FeatureLevelRecord) {
+                FeatureLevelRecord record = (FeatureLevelRecord) records.get(i).message();
+                if (record.name().equals(featureName)) {
+                    FeatureLevelRecord newRecord = record.duplicate();
+                    newRecord.setFeatureLevel(level);
+                    newRecords.add(new ApiMessageAndVersion(newRecord, (short) 0));
+                    break;

Review Comment:
   @frankvicky Could you please open a jira for it?



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix kraft ver broken test [kafka]

Posted by "jsancio (via GitHub)" <gi...@apache.org>.
jsancio commented on code in PR #19448:
URL: https://github.com/apache/kafka/pull/19448#discussion_r2042374432


##########
core/src/test/scala/integration/kafka/server/KRaftClusterTest.scala:
##########
@@ -1053,7 +1053,8 @@ class KRaftClusterTest {
     val cluster = new KafkaClusterTestKit.Builder(
       new TestKitNodes.Builder().
         setNumBrokerNodes(1).
-        setNumControllerNodes(1).build()).build()
+        setNumControllerNodes(1).
+        setFeature(KRaftVersion.FEATURE_NAME, 1.toShort).build()).build()

Review Comment:
   Yeah. This doesn't emulate or mock kraft.version correctly. Remember that kraft version are persisted and replicated using the KRaftVersion control record and not the FeatureLevelRecord metadata record.
   
   This is why I didn't re-implement this in the cherry-pick but I forgot to run this suite.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix kraft ver broken test [kafka]

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon merged PR #19448:
URL: https://github.com/apache/kafka/pull/19448


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix kraft ver broken test [kafka]

Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky commented on code in PR #19448:
URL: https://github.com/apache/kafka/pull/19448#discussion_r2039583366


##########
metadata/src/main/java/org/apache/kafka/metadata/bootstrap/BootstrapMetadata.java:
##########
@@ -149,6 +149,32 @@ public BootstrapMetadata copyWithOnlyVersion() {
                 metadataVersion, source);
     }
 
+    public BootstrapMetadata copyWithFeatureRecord(String featureName, short level) {
+        List<ApiMessageAndVersion> newRecords = new ArrayList<>();
+        int i = 0;
+        while (i < records.size()) {
+            if (records.get(i).message() instanceof FeatureLevelRecord) {
+                FeatureLevelRecord record = (FeatureLevelRecord) records.get(i).message();
+                if (record.name().equals(featureName)) {
+                    FeatureLevelRecord newRecord = record.duplicate();
+                    newRecord.setFeatureLevel(level);
+                    newRecords.add(new ApiMessageAndVersion(newRecord, (short) 0));
+                    break;

Review Comment:
   Do we need a comment for this method?
   It seems that this is a workaround for a particular scenario. Otherwise, there is no reason we should break in a "copy" method.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix kraft ver broken test [kafka]

Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky commented on code in PR #19448:
URL: https://github.com/apache/kafka/pull/19448#discussion_r2039735443


##########
metadata/src/main/java/org/apache/kafka/metadata/bootstrap/BootstrapMetadata.java:
##########
@@ -149,6 +149,32 @@ public BootstrapMetadata copyWithOnlyVersion() {
                 metadataVersion, source);
     }
 
+    public BootstrapMetadata copyWithFeatureRecord(String featureName, short level) {
+        List<ApiMessageAndVersion> newRecords = new ArrayList<>();
+        int i = 0;
+        while (i < records.size()) {
+            if (records.get(i).message() instanceof FeatureLevelRecord) {
+                FeatureLevelRecord record = (FeatureLevelRecord) records.get(i).message();
+                if (record.name().equals(featureName)) {
+                    FeatureLevelRecord newRecord = record.duplicate();
+                    newRecord.setFeatureLevel(level);
+                    newRecords.add(new ApiMessageAndVersion(newRecord, (short) 0));
+                    break;

Review Comment:
   https://issues.apache.org/jira/browse/KAFKA-19129



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix kraft ver broken test [kafka]

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on PR #19448:
URL: https://github.com/apache/kafka/pull/19448#issuecomment-2796545810

   @frankvicky , call for review. Thanks.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix kraft ver broken test [kafka]

Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky commented on code in PR #19448:
URL: https://github.com/apache/kafka/pull/19448#discussion_r2039603484


##########
metadata/src/main/java/org/apache/kafka/metadata/bootstrap/BootstrapMetadata.java:
##########
@@ -149,6 +149,32 @@ public BootstrapMetadata copyWithOnlyVersion() {
                 metadataVersion, source);
     }
 
+    public BootstrapMetadata copyWithFeatureRecord(String featureName, short level) {
+        List<ApiMessageAndVersion> newRecords = new ArrayList<>();
+        int i = 0;
+        while (i < records.size()) {
+            if (records.get(i).message() instanceof FeatureLevelRecord) {
+                FeatureLevelRecord record = (FeatureLevelRecord) records.get(i).message();
+                if (record.name().equals(featureName)) {
+                    FeatureLevelRecord newRecord = record.duplicate();
+                    newRecord.setFeatureLevel(level);
+                    newRecords.add(new ApiMessageAndVersion(newRecord, (short) 0));
+                    break;

Review Comment:
   In the current use case, this looks like a workaround for setting `KRaftVersionRecord`.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org