New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-15022: [8/N] more tests for HAAssignor #14164
Conversation
3749564
to
294528b
Compare
@@ -300,7 +329,9 @@ private static Properties streamsProperties(final String appId, | |||
// Increasing the number of threads to ensure that a rebalance happens each time a consumer sends a rejoin (KAFKA-10455) | |||
mkEntry(StreamsConfig.NUM_STREAM_THREADS_CONFIG, 40), | |||
mkEntry(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.StringSerde.class.getName()), | |||
mkEntry(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.StringSerde.class.getName()) | |||
mkEntry(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.StringSerde.class.getName()), | |||
mkEntry(CommonClientConfigs.CLIENT_RACK_CONFIG, AssignmentTestUtils.RACK_0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this hard-coded? Should we use different racks for different KS instances?
@@ -91,6 +91,7 @@ private Properties effectiveConfigFrom(final Properties initialConfig) { | |||
effectiveConfig.put(KafkaConfig.MessageMaxBytesProp(), 1000000); | |||
effectiveConfig.put(KafkaConfig.ControlledShutdownEnableProp(), true); | |||
effectiveConfig.put(KafkaConfig.ZkSessionTimeoutMsProp(), 10000); | |||
effectiveConfig.put(KafkaConfig.RackProp(), "rack0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this overwrite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Might be some left over change. Let me delete it
|
||
if (topicPartitionInfo != null) { | ||
lenient().when(mockInternalTopicManager.getTopicPartitionInfo(anySet())).thenAnswer( | ||
i -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i
is the input parameter passed into getTopicPartitionInfo
? -- Can we find a better name?
return tp; | ||
} | ||
} | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is null
right here? Or should it be an empty Map
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can return empty Map.
configureDefault(); | ||
|
||
createDefaultMockTaskManager(); | ||
final List<Map<String, List<TopicPartitionInfo>>> changelogTopicPartitionInfo = getTopicPartitionInfo(3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move first parameter 3,
into it's own line below (hard to read the code otherwise)
@@ -1213,12 +1376,18 @@ public void testAssignWithInternalTopics() { | |||
final List<String> topics = asList("topic1", APPLICATION_ID + "-topicX"); | |||
final Set<TaskId> allTasks = mkSet(TASK_0_0, TASK_0_1, TASK_0_2); | |||
|
|||
final MockInternalTopicManager internalTopicManager = configureDefault(); | |||
createDefaultMockTaskManager(); | |||
final List<Map<String, List<TopicPartitionInfo>>> changelogTopicPartitionInfo = getTopicPartitionInfo(4, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move first parameter to next line
@@ -1241,12 +1410,18 @@ public void testAssignWithInternalTopicThatsSourceIsAnotherInternalTopic() { | |||
final List<String> topics = asList("topic1", APPLICATION_ID + "-topicX", APPLICATION_ID + "-topicZ"); | |||
final Set<TaskId> allTasks = mkSet(TASK_0_0, TASK_0_1, TASK_0_2); | |||
|
|||
final MockInternalTopicManager internalTopicManager = configureDefault(); | |||
createDefaultMockTaskManager(); | |||
final List<Map<String, List<TopicPartitionInfo>>> changelogTopicPartitionInfo = getTopicPartitionInfo(4, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above
@@ -1768,16 +1993,22 @@ public void shouldReturnInterleavedAssignmentWithUnrevokedPartitionsRemovedWhenN | |||
final Set<TaskId> allTasks = mkSet(TASK_0_0, TASK_0_1, TASK_0_2); | |||
|
|||
subscriptions.put(CONSUMER_1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move CONSUMER_1
to next line, too (same below)
KeyValue.pair(NODE_3, asList(REPLICA_3)) | ||
); | ||
|
||
final List<Map<String, List<TopicPartitionInfo>>> ret = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ret
is not a good variable name
ret.add(new HashMap<>()); | ||
for (final String topic : topics) { | ||
final List<TopicPartitionInfo> topicPartitionInfoList = new ArrayList<>(); | ||
ret.get(ret.size() - 1).put(topic, topicPartitionInfoList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a local variable instead of getting the map from the list? -- Similar to topicPartitionInfoList
?
changelogPartitionsForTask.put(taskId, mkSet(new TopicPartition(changelogTopicName, i))); | ||
tasksForTopicGroup.computeIfAbsent(new Subtopology(subtopology, null), k -> new HashSet<>()).add(taskId); | ||
|
||
final Random random = new Random(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should init Random
with a value that we log (to allow us to reproduce the same test)
final long seed = System.currentTimeMillis():
log.info(seed); // or just use println
final Random random = new Random(seed);
final UUID uuid = uuidForInt(i); | ||
clientStates.put(uuid, emptyInstance(uuid, statefulTaskEndOffsetSums)); | ||
final Random random = new Random(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above: maybe setup Random
inside @BeforeTest
instead and share?
EMPTY_RACK_AWARE_ASSIGNMENT_TAGS); | ||
EMPTY_RACK_AWARE_ASSIGNMENT_TAGS, | ||
null, | ||
null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix indention
EMPTY_RACK_AWARE_ASSIGNMENT_TAGS); | ||
EMPTY_RACK_AWARE_ASSIGNMENT_TAGS, | ||
null, | ||
null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix indention
Part of KIP-925. - Add more tests for HighAvailabilityTaskAssignor - Remove null and optional check for RackAwareTaskAssignor - Pass rack aware assignor configs to getMainConsumerConfigs so that they can be picked up in rebalance protocol - Change STATELESS_NON_OVERLAP_COST to 0. It was a mistake to be 1. Stateless tasks should be moved without this cost. - Update of existing tests Reviewers: Matthias J. Sax <matthias@confluent.io>
Part of KIP-925. - Add more tests for HighAvailabilityTaskAssignor - Remove null and optional check for RackAwareTaskAssignor - Pass rack aware assignor configs to getMainConsumerConfigs so that they can be picked up in rebalance protocol - Change STATELESS_NON_OVERLAP_COST to 0. It was a mistake to be 1. Stateless tasks should be moved without this cost. - Update of existing tests Reviewers: Matthias J. Sax <matthias@confluent.io>
Part of KIP-925. - Add more tests for HighAvailabilityTaskAssignor - Remove null and optional check for RackAwareTaskAssignor - Pass rack aware assignor configs to getMainConsumerConfigs so that they can be picked up in rebalance protocol - Change STATELESS_NON_OVERLAP_COST to 0. It was a mistake to be 1. Stateless tasks should be moved without this cost. - Update of existing tests Reviewers: Matthias J. Sax <matthias@confluent.io>
Part of KIP-925. - Add more tests for HighAvailabilityTaskAssignor - Remove null and optional check for RackAwareTaskAssignor - Pass rack aware assignor configs to getMainConsumerConfigs so that they can be picked up in rebalance protocol - Change STATELESS_NON_OVERLAP_COST to 0. It was a mistake to be 1. Stateless tasks should be moved without this cost. - Update of existing tests Reviewers: Matthias J. Sax <matthias@confluent.io>
Description
HighAvailabilityTaskAssignor
RackAwareTaskAssignor
getMainConsumerConfigs
so that they can be picked up in rebalance protocolSTATELESS_NON_OVERLAP_COST
to 0. It was a mistake to be 1. Stateless tasks should be moved without this cost.Tests
Update of existing tests