Skip to content

Commit

Permalink
Merge pull request #473 from bf2fc6cc711aee1a0c2a/node-autoscaling-re…
Browse files Browse the repository at this point in the history
…factor

simplified boolean check of instance ready state, added logs in timoutut case
  • Loading branch information
henryZrncik committed Feb 10, 2023
2 parents 19bfe04 + b1e8f42 commit 9d60a23
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;


Expand Down Expand Up @@ -260,7 +261,8 @@ public void testStandardKafkaNodeAutoscaling() {
.region(Environment.DEFAULT_KAFKA_REGION);

try {
KafkaMgmtApiUtils.attemptCreatingKafkaInstance(kafkaMgmtApi, payload, Duration.ofSeconds(20), Duration.ofSeconds(20));
KafkaRequest kafkaRequest = KafkaMgmtApiUtils.attemptCreatingKafkaInstance(kafkaMgmtApi, payload, Duration.ofSeconds(20), Duration.ofSeconds(20));
log.debug(kafkaRequest);

// wait either for new node to be scaled, or kafka instance to be in ready state if there are instances being deleted in the cluster
TestUtils.waitFor(
Expand All @@ -287,12 +289,9 @@ public void testStandardKafkaNodeAutoscaling() {

// if new some of original instances was deleted, we only wait for instance to be at least in ready state
// observe if any of newly crated kafka instance really is ready state (node for sure scaled), otherwise continue waiting
return kafkaMgmtApi
.getKafkas(null, null, null, null)
.getItems().stream()
.filter(e -> e.getName().contains(DUMMY_KAFKA_INSTANCE_NAME))
.filter(e -> e.getOwner().equals(Environment.PRIMARY_USERNAME))
.anyMatch(e -> e.getStatus().equals("ready"));
KafkaRequest currentKafka = KafkaMgmtApiUtils.getKafkaByName(kafkaMgmtApi, DUMMY_KAFKA_INSTANCE_NAME).get();
log.debug(currentKafka);
return currentKafka.getStatus().equals("ready");
}
);

Expand All @@ -307,6 +306,10 @@ public void testStandardKafkaNodeAutoscaling() {
} catch (KafkaClusterCapacityExhaustedException e) {
log.warn("capacity exhausted at the moment %s", e);
throw new SkipException("cluster capacity for standard kafka instances in aws data plane cluster reached");
} catch (TimeoutException e) {
log.warn("kafka not in a ready state");
log.warn(KafkaMgmtApiUtils.getKafkaByName(kafkaMgmtApi, DUMMY_KAFKA_INSTANCE_NAME).get());
throw e;
} finally {
// delete and wait for cleaning of all instances spawned
KafkaMgmtApiUtils.deleteKafkaByNameIfExists(kafkaMgmtApi, DUMMY_KAFKA_INSTANCE_NAME);
Expand Down

0 comments on commit 9d60a23

Please sign in to comment.