You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2025/05/05 16:13:08 UTC

(kafka) branch trunk updated: KAFKA-19240 Move MetadataVersionIntegrationTest to clients-integration-tests module (#19641)

This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 19530738c4a KAFKA-19240 Move MetadataVersionIntegrationTest to clients-integration-tests module (#19641)
19530738c4a is described below

commit 19530738c4a0e1f2bbe6267d4fe516886e118682
Author: TaiJuWu <tj...@gmail.com>
AuthorDate: Tue May 6 00:12:57 2025 +0800

    KAFKA-19240 Move MetadataVersionIntegrationTest to clients-integration-tests module (#19641)
    
    The PR do following:
    1. Move MetadataVersionIntegrationTest to clients-integration-tests
    module
    2. rewrite to java from scala
    
    Reviewers: Chia-Ping Tsai <ch...@gmail.com>
---
 .../clients/MetadataVersionIntegrationTest.java    | 88 +++++++++++++++++++++
 .../server/MetadataVersionIntegrationTest.scala    | 89 ----------------------
 2 files changed, 88 insertions(+), 89 deletions(-)

diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/MetadataVersionIntegrationTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/MetadataVersionIntegrationTest.java
new file mode 100644
index 00000000000..4e44eef5a21
--- /dev/null
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/MetadataVersionIntegrationTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.clients;
+
+import org.apache.kafka.clients.admin.FeatureUpdate;
+import org.apache.kafka.clients.admin.UpdateFeaturesOptions;
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.TestUtils;
+import org.apache.kafka.common.test.api.ClusterTest;
+import org.apache.kafka.common.test.api.ClusterTests;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.server.common.MetadataVersion;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class MetadataVersionIntegrationTest {
+    @ClusterTests(value = {
+        @ClusterTest(types = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_3_IV3),
+        @ClusterTest(types = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_4_IV0),
+        @ClusterTest(types = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_5_IV0),
+        @ClusterTest(types = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_6_IV0),
+        @ClusterTest(types = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_6_IV1)
+    })
+    public void testBasicMetadataVersionUpgrade(ClusterInstance clusterInstance) throws Exception {
+        try (var admin = clusterInstance.admin()) {
+            var describeResult = admin.describeFeatures();
+            var ff = describeResult.featureMetadata().get().finalizedFeatures().get(MetadataVersion.FEATURE_NAME);
+            assertEquals(clusterInstance.config().metadataVersion().featureLevel(), ff.minVersionLevel());
+            assertEquals(clusterInstance.config().metadataVersion().featureLevel(), ff.maxVersionLevel());
+
+            // Update to new version
+            short updateVersion = MetadataVersion.IBP_3_7_IV1.featureLevel();
+            var updateResult = admin.updateFeatures(
+                    Map.of("metadata.version", new FeatureUpdate(updateVersion, FeatureUpdate.UpgradeType.UPGRADE)),
+                    new UpdateFeaturesOptions());
+            updateResult.all().get();
+
+            // Verify that new version is visible on broker
+            TestUtils.waitForCondition(() -> {
+                try {
+                    var describeResult2 = admin.describeFeatures();
+                    var ff2 = describeResult2.featureMetadata().get().finalizedFeatures().get(MetadataVersion.FEATURE_NAME);
+                    return ff2.minVersionLevel() == updateVersion && ff2.maxVersionLevel() == updateVersion;
+                } catch (Exception e) {
+                    return false;
+                }
+            }, "Never saw metadata.version increase on broker");
+        }
+    }
+
+    @ClusterTest(types = Type.KRAFT, metadataVersion = MetadataVersion.IBP_3_9_IV0)
+    public void testUpgradeSameVersion(ClusterInstance clusterInstance) throws Exception {
+        try (var admin = clusterInstance.admin()) {
+            short updateVersion = MetadataVersion.IBP_3_9_IV0.featureLevel();
+            var updateResult = admin.updateFeatures(
+                    Map.of("metadata.version", new FeatureUpdate(updateVersion, FeatureUpdate.UpgradeType.UPGRADE)),
+                    new UpdateFeaturesOptions());
+            updateResult.all().get();
+        }
+    }
+
+    @ClusterTest(types = Type.KRAFT)
+    public void testDefaultIsLatestVersion(ClusterInstance clusterInstance) throws Exception {
+        try (var admin = clusterInstance.admin()) {
+            var describeResult = admin.describeFeatures();
+            var ff = describeResult.featureMetadata().get().finalizedFeatures().get(MetadataVersion.FEATURE_NAME);
+            assertEquals(MetadataVersion.latestTesting().featureLevel(), ff.minVersionLevel(),
+                    "If this test fails, check the default MetadataVersion in the @ClusterTest annotation");
+            assertEquals(MetadataVersion.latestTesting().featureLevel(), ff.maxVersionLevel());
+        }
+    }
+}
diff --git a/core/src/test/scala/integration/kafka/server/MetadataVersionIntegrationTest.scala b/core/src/test/scala/integration/kafka/server/MetadataVersionIntegrationTest.scala
deleted file mode 100644
index 490ebc48c16..00000000000
--- a/core/src/test/scala/integration/kafka/server/MetadataVersionIntegrationTest.scala
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package kafka.server
-
-import org.apache.kafka.common.test.api.{ClusterTest, ClusterTests, Type}
-import kafka.utils.TestUtils
-import org.apache.kafka.clients.admin.FeatureUpdate.UpgradeType
-import org.apache.kafka.clients.admin.{FeatureUpdate, UpdateFeaturesOptions}
-import org.apache.kafka.common.test.ClusterInstance
-import org.apache.kafka.server.common.MetadataVersion
-import org.junit.jupiter.api.Assertions.assertEquals
-
-import scala.jdk.CollectionConverters._
-
-class MetadataVersionIntegrationTest {
-  @ClusterTests(value = Array(
-      new ClusterTest(types = Array(Type.KRAFT), metadataVersion = MetadataVersion.IBP_3_3_IV3),
-      new ClusterTest(types = Array(Type.KRAFT), metadataVersion = MetadataVersion.IBP_3_4_IV0),
-      new ClusterTest(types = Array(Type.KRAFT), metadataVersion = MetadataVersion.IBP_3_5_IV0),
-      new ClusterTest(types = Array(Type.KRAFT), metadataVersion = MetadataVersion.IBP_3_6_IV0),
-      new ClusterTest(types = Array(Type.KRAFT), metadataVersion = MetadataVersion.IBP_3_6_IV1)
-  ))
-  def testBasicMetadataVersionUpgrade(clusterInstance: ClusterInstance): Unit = {
-    val admin = clusterInstance.admin()
-    try {
-      val describeResult = admin.describeFeatures()
-      val ff = describeResult.featureMetadata().get().finalizedFeatures().get(MetadataVersion.FEATURE_NAME)
-      assertEquals(ff.minVersionLevel(), clusterInstance.config().metadataVersion().featureLevel())
-      assertEquals(ff.maxVersionLevel(), clusterInstance.config().metadataVersion().featureLevel())
-
-      // Update to new version
-      val updateVersion = MetadataVersion.IBP_3_7_IV1.featureLevel.shortValue
-      val updateResult = admin.updateFeatures(
-        Map("metadata.version" -> new FeatureUpdate(updateVersion, UpgradeType.UPGRADE)).asJava, new UpdateFeaturesOptions())
-      updateResult.all().get()
-
-      // Verify that new version is visible on broker
-      TestUtils.waitUntilTrue(() => {
-        val describeResult2 = admin.describeFeatures()
-        val ff2 = describeResult2.featureMetadata().get().finalizedFeatures().get(MetadataVersion.FEATURE_NAME)
-        ff2.minVersionLevel() == updateVersion && ff2.maxVersionLevel() == updateVersion
-      }, "Never saw metadata.version increase on broker")
-    } finally {
-      admin.close()
-    }
-  }
-
-  @ClusterTest(types = Array(Type.KRAFT), metadataVersion = MetadataVersion.IBP_3_9_IV0)
-  def testUpgradeSameVersion(clusterInstance: ClusterInstance): Unit = {
-    val admin = clusterInstance.admin()
-    try {
-      val updateVersion = MetadataVersion.IBP_3_9_IV0.featureLevel.shortValue
-      val updateResult = admin.updateFeatures(
-        Map("metadata.version" -> new FeatureUpdate(updateVersion, UpgradeType.UPGRADE)).asJava, new UpdateFeaturesOptions())
-      updateResult.all().get()
-    } finally {
-      admin.close()
-    }
-  }
-
-  @ClusterTest(types = Array(Type.KRAFT))
-  def testDefaultIsLatestVersion(clusterInstance: ClusterInstance): Unit = {
-    val admin = clusterInstance.admin()
-    try {
-      val describeResult = admin.describeFeatures()
-      val ff = describeResult.featureMetadata().get().finalizedFeatures().get(MetadataVersion.FEATURE_NAME)
-      assertEquals(ff.minVersionLevel(), MetadataVersion.latestTesting().featureLevel(),
-        "If this test fails, check the default MetadataVersion in the @ClusterTest annotation")
-      assertEquals(ff.maxVersionLevel(), MetadataVersion.latestTesting().featureLevel())
-    } finally {
-      admin.close()
-    }
-  }
-}