chia7712 commented on code in PR #17019:
URL: https://github.com/apache/kafka/pull/17019#discussion_r1738533619


##########
core/src/test/java/kafka/test/junit/ClusterTestExtensions.java:
##########
@@ -199,46 +239,53 @@ private List<TestTemplateInvocationContext> 
processClusterTests(ExtensionContext
         return ret;
     }
 
-    private List<TestTemplateInvocationContext> 
processClusterTest(ExtensionContext context, ClusterTest annot, 
ClusterTestDefaults defaults) {
-        List<TestTemplateInvocationContext> ret = 
processClusterTestInternal(context, annot, defaults);
+    private List<TestTemplateInvocationContext> processClusterTestInternal(
+        ExtensionContext context,
+        ClusterTest clusterTest,
+        ClusterTestDefaults defaults
+    ) {
+        Type[] types = clusterTest.types().length == 0 ? defaults.types() : 
clusterTest.types();
+        Map<String, String> serverProperties = 
Stream.concat(Arrays.stream(defaults.serverProperties()), 
Arrays.stream(clusterTest.serverProperties()))
+            .filter(e -> e.id() == -1)
+            .collect(Collectors.toMap(ClusterConfigProperty::key, 
ClusterConfigProperty::value, (a, b) -> b));
 
-        if (ret.isEmpty()) {
-            throw new IllegalStateException("processClusterTest method should 
provide at least one config");
-        }
+        Map<Integer, Map<String, String>> perServerProperties = 
Stream.concat(Arrays.stream(defaults.serverProperties()), 
Arrays.stream(clusterTest.serverProperties()))
+            .filter(e -> e.id() != -1)
+            .collect(Collectors.groupingBy(ClusterConfigProperty::id, 
Collectors.mapping(Function.identity(),
+                Collectors.toMap(ClusterConfigProperty::key, 
ClusterConfigProperty::value, (a, b) -> b))));
 
-        return ret;
-    }
-    private List<TestTemplateInvocationContext> 
processClusterTestInternal(ExtensionContext context, ClusterTest annot, 
ClusterTestDefaults defaults) {
-        Type[] types = annot.types().length == 0 ? defaults.types() : 
annot.types();
-        Map<String, String> serverProperties = 
Stream.concat(Arrays.stream(defaults.serverProperties()), 
Arrays.stream(annot.serverProperties()))
-                .filter(e -> e.id() == -1)
-                .collect(Collectors.toMap(ClusterConfigProperty::key, 
ClusterConfigProperty::value, (a, b) -> b));
+        Map<Features, Short> features = Arrays.stream(clusterTest.features())
+            .collect(Collectors.toMap(ClusterFeature::feature, 
ClusterFeature::version));
 
-        Map<Integer, Map<String, String>> perServerProperties = 
Stream.concat(Arrays.stream(defaults.serverProperties()), 
Arrays.stream(annot.serverProperties()))
-                .filter(e -> e.id() != -1)
-                .collect(Collectors.groupingBy(ClusterConfigProperty::id, 
Collectors.mapping(Function.identity(),
-                        Collectors.toMap(ClusterConfigProperty::key, 
ClusterConfigProperty::value, (a, b) -> b))));
+        ClusterConfig config = ClusterConfig.builder()
+            .setTypes(new HashSet<>(Arrays.asList(types)))
+            .setBrokers(clusterTest.brokers() == 0 ? defaults.brokers() : 
clusterTest.brokers())
+            .setControllers(clusterTest.controllers() == 0 ? 
defaults.controllers() : clusterTest.controllers())
+            .setDisksPerBroker(clusterTest.disksPerBroker() == 0 ? 
defaults.disksPerBroker() : clusterTest.disksPerBroker())
+            .setAutoStart(clusterTest.autoStart() == AutoStart.DEFAULT ? 
defaults.autoStart() : clusterTest.autoStart() == AutoStart.YES)
+            .setListenerName(clusterTest.listener().trim().isEmpty() ? null : 
clusterTest.listener())
+            .setServerProperties(serverProperties)
+            .setPerServerProperties(perServerProperties)
+            .setSecurityProtocol(clusterTest.securityProtocol())
+            .setMetadataVersion(clusterTest.metadataVersion())
+            .setTags(Arrays.asList(clusterTest.tags()))
+            .setFeatures(features)
+            .build();
+
+        return Arrays.stream(types)
+            .map(type -> 
type.invocationContexts(context.getRequiredTestMethod().getName(), config))
+            .collect(Collectors.toList());
+    }
 
-        Map<Features, Short> features = Arrays.stream(annot.features())
-                .collect(Collectors.toMap(ClusterFeature::feature, 
ClusterFeature::version));
+    Stream<ClusterTest> repeatedClusterTests(int repeatCount, ClusterTest[] 
clusterTestAnnots) {

Review Comment:
   this is unused now.



##########
.github/README.md:
##########
@@ -0,0 +1,40 @@
+# GitHub Actions
+
+## Overview
+
+The entry point for our build is the "CI" workflow which is define in ci.yml.
+This is used for both PR and trunk builds. The jobs and steps of the workflow
+are defined in build.yml.
+
+## Opting-in to GitHub Actions
+
+To opt-in to the new GitHub actions workflows, simply name your branch with a
+prefix of "gh-". For example, `gh-KAFKA-17433-deflake`
+
+## Disabling Email Notifications
+
+By default, GitHub sends an email for each failed action run. To change this,
+visit https://github.com/settings/notifications and find System -> Actions.
+Here you can change your notification preferences.
+
+## Publishing Build Scans
+
+> This only works for committers (who have ASF accounts on ge.apache.org).
+
+There are two ways committers can have build scans published. The simplest
+way is to push their branches to apache/kafka. This will allow Github Actions 
to

Review Comment:
   nit: `GitHub`



##########
.github/README.md:
##########
@@ -0,0 +1,40 @@
+# GitHub Actions
+
+## Overview
+
+The entry point for our build is the "CI" workflow which is define in ci.yml.

Review Comment:
   nit: `defined`



##########
core/src/test/java/kafka/test/junit/ClusterTestExtensions.java:
##########
@@ -163,15 +175,28 @@ private Store getStore(ExtensionContext context) {
         return context.getStore(Namespace.create(context.getUniqueId()));
     }
 
+    private int getTestRepeatCount() {
+        int count;
+        try {
+            String repeatCount = 
System.getProperty(CLUSTER_TEST_REPEAT_SYSTEM_PROP, "1");
+            count = Integer.parseInt(repeatCount);
+        } catch (NumberFormatException e) {
+            count = 1;
+        }
+        return count;
+    }
+
     List<TestTemplateInvocationContext> 
processClusterTemplate(ExtensionContext context, ClusterTemplate annot) {
         if (annot.value().trim().isEmpty()) {
             throw new IllegalStateException("ClusterTemplate value can't be 
empty string.");
         }
 
         String baseDisplayName = context.getRequiredTestMethod().getName();
-        List<TestTemplateInvocationContext> contexts = 
generateClusterConfigurations(context, annot.value())
-                .stream().flatMap(config -> config.clusterTypes().stream()
-                        .map(type -> type.invocationContexts(baseDisplayName, 
config))).collect(Collectors.toList());
+        int repeatCount = getTestRepeatCount();
+        List<TestTemplateInvocationContext> contexts = 
generateClusterConfigurations(repeatCount, context, annot.value())

Review Comment:
   ditto.
   ```java
           List<TestTemplateInvocationContext> contexts = IntStream.range(0, 
repeatCount)
               .mapToObj(ignored -> ((List<ClusterConfig>) 
ReflectionUtils.invokeMethod(method, testInstance)).stream())
               .flatMap(Function.identity())
               .flatMap(config -> config.clusterTypes().stream().map(type -> 
type.invocationContexts(baseDisplayName, config)))
               .collect(Collectors.toList());
   ```



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