vvcephei commented on a change in pull request #8892:
URL: https://github.com/apache/kafka/pull/8892#discussion_r442497609



##########
File path: 
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamsPartitionAssignorTest.java
##########
@@ -148,27 +150,35 @@
     private final TopicPartition t3p2 = new TopicPartition("topic3", 2);
     private final TopicPartition t3p3 = new TopicPartition("topic3", 3);
 
-    private final List<PartitionInfo> infos = asList(
-        new PartitionInfo("topic1", 0, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic1", 1, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic1", 2, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic2", 0, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic2", 1, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic2", 2, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic3", 0, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic3", 1, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic3", 2, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic3", 3, Node.noNode(), new Node[0], new Node[0])
-    );
-
-    private final SubscriptionInfo defaultSubscriptionInfo = getInfo(UUID_1, 
EMPTY_TASKS, EMPTY_TASKS);
+    private final List<PartitionInfo> partitionInfos = getPartitionInfos(3, 3);
+    {
+        partitionInfos.add(new PartitionInfo("topic3", 3, Node.noNode(), new 
Node[0], new Node[0]));
+    }
 
     private final Cluster metadata = new Cluster(
         "cluster",
         Collections.singletonList(Node.noNode()),
-        infos,
+        partitionInfos,
         emptySet(),
-        emptySet());
+        emptySet()
+    );
+
+    /* Used by the scale test for large apps/clusters */
+    private static final int NUM_TOPICS_XL = 10;
+    private static final int NUM_PARTITIONS_PER_TOPIC_XL = 1_000;
+    private static final int NUM_CONSUMERS_XL = 100;
+    private static final List<String> TOPICS_LIST_XL = new ArrayList<>();
+    private static final Map<TopicPartition, Long> CHANGELOG_END_OFFSETS_XL = 
new HashMap<>();
+    private static final List<PartitionInfo> PARTITION_INFOS_XL = 
getPartitionInfos(NUM_TOPICS_XL, NUM_PARTITIONS_PER_TOPIC_XL);
+    private static final Cluster CLUSTER_METADATA_XL = new Cluster(
+        "cluster",
+        Collections.singletonList(Node.noNode()),
+        PARTITION_INFOS_XL,
+        emptySet(),
+        emptySet()
+    );

Review comment:
       If there's a whole set of constants only used by one test, one might 
wonder whether that test shouldn't just be in its own class...

##########
File path: 
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamsPartitionAssignorTest.java
##########
@@ -148,27 +150,35 @@
     private final TopicPartition t3p2 = new TopicPartition("topic3", 2);
     private final TopicPartition t3p3 = new TopicPartition("topic3", 3);
 
-    private final List<PartitionInfo> infos = asList(
-        new PartitionInfo("topic1", 0, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic1", 1, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic1", 2, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic2", 0, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic2", 1, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic2", 2, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic3", 0, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic3", 1, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic3", 2, Node.noNode(), new Node[0], new 
Node[0]),
-        new PartitionInfo("topic3", 3, Node.noNode(), new Node[0], new Node[0])
-    );
-
-    private final SubscriptionInfo defaultSubscriptionInfo = getInfo(UUID_1, 
EMPTY_TASKS, EMPTY_TASKS);
+    private final List<PartitionInfo> partitionInfos = getPartitionInfos(3, 3);
+    {
+        partitionInfos.add(new PartitionInfo("topic3", 3, Node.noNode(), new 
Node[0], new Node[0]));
+    }

Review comment:
       Can you just pass this as an argument to `getPartitionInfos` so that we 
can do all the initialization in the assignment instead of needing an 
initialization block? The fact that this field is used in another field 
initialization statement makes the initialization block kind of questionable, 
since you have to read the JVM spec to know if this block executes before or 
after the usage.
   
   Alternatively, maybe the prior code was actually better, because you can see 
exactly what data you're testing with, instead of having to go read another 
method to understand what `getPartitioninfos(3, 3)` might mean.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to