Skip to content

Commit

Permalink
[system test] Fix testAutoKafkaRebalanceScaleUpScaleDown and make it … (
Browse files Browse the repository at this point in the history
strimzi#10754)

Signed-off-by: see-quick <[email protected]>
  • Loading branch information
see-quick authored Oct 24, 2024
1 parent 695b9df commit 9fc94ea
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,11 @@ void testAutoKafkaRebalanceScaleUpScaleDown() {
resourceManager.createResourceWithWait(
NodePoolsConverter.convertNodePoolsIfNeeded(
KafkaNodePoolTemplates.brokerPool(testStorage.getNamespaceName(), testStorage.getBrokerPoolName(), testStorage.getClusterName(), initialReplicas).build(),
KafkaNodePoolTemplates.controllerPool(testStorage.getNamespaceName(), testStorage.getControllerPoolName(), testStorage.getClusterName(), initialReplicas).build()
KafkaNodePoolTemplates.controllerPool(testStorage.getNamespaceName(), testStorage.getControllerPoolName(), testStorage.getClusterName(), initialReplicas)
.editMetadata()
.withAnnotations(Map.of(Annotations.ANNO_STRIMZI_IO_NEXT_NODE_IDS, "[100-103]"))
.endMetadata()
.build()
)
);

Expand Down Expand Up @@ -729,12 +733,11 @@ void testAutoKafkaRebalanceScaleUpScaleDown() {
KafkaResource.replaceKafkaResourceInSpecificNamespace(testStorage.getNamespaceName(), testStorage.getClusterName(), kafka -> kafka.getSpec().getKafka().setReplicas(scaleTo));
}

// 3 brokers + 3 controllers/zk
final int kafkaClusterPodIndex = initialReplicas + initialReplicas;
final int kafkaClusterPodIndex = initialReplicas;

KafkaUtils.waitUntilKafkaHasExpectedAutoRebalanceModeAndBrokers(testStorage.getNamespaceName(), testStorage.getClusterName(),
KafkaAutoRebalanceMode.ADD_BROKERS,
// brokers with [6, 7]
// brokers with [3, 4]
Arrays.asList(kafkaClusterPodIndex, kafkaClusterPodIndex + 1));

// check that KafkaRebalance <cluster-name>-auto-rebalancing-<mode> is created
Expand All @@ -757,7 +760,8 @@ void testAutoKafkaRebalanceScaleUpScaleDown() {

LOGGER.info("Checking that Topic: {} has replicas on one of the new brokers (or both)", testStorage.getTopicName());
List<String> topicReplicas = KafkaTopicUtils.getKafkaTopicReplicasForEachPartition(testStorage.getNamespaceName(), testStorage.getTopicName(), scraperPodName, KafkaResources.plainBootstrapAddress(testStorage.getClusterName()));
assertTrue(topicReplicas.stream().anyMatch(line -> line.contains("6") || line.contains("7")));

assertTrue(topicReplicas.stream().anyMatch(line -> line.contains("3") || line.contains("4")));

LOGGER.info("Scaling Kafka down to {}", initialReplicas);

Expand All @@ -770,7 +774,7 @@ void testAutoKafkaRebalanceScaleUpScaleDown() {

KafkaUtils.waitUntilKafkaHasExpectedAutoRebalanceModeAndBrokers(testStorage.getNamespaceName(), testStorage.getClusterName(),
KafkaAutoRebalanceMode.REMOVE_BROKERS,
// brokers with [6, 7]
// brokers with [3, 4]
Arrays.asList(kafkaClusterPodIndex, kafkaClusterPodIndex + 1));

// check that KafkaRebalance <cluster-name>-auto-rebalancing-<mode> is created
Expand Down

0 comments on commit 9fc94ea

Please sign in to comment.