use of io.strimzi.api.kafka.model.KafkaRebalanceSpecBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceStateMachineTest method testNewBadGoalsErrorWithSkipHGCheck.
@Test
public void testNewBadGoalsErrorWithSkipHGCheck(Vertx vertx, VertxTestContext context) throws IOException, URISyntaxException {
// Test the case where the user asks for a rebalance with custom goals which do not contain all the configured hard goals
// But we have set skip hard goals check to true
MockCruiseControl.setupCCRebalanceBadGoalsError(ccServer);
List<String> customGoals = new ArrayList<>();
customGoals.add("Goal.one");
customGoals.add("Goal.two");
customGoals.add("Goal.three");
KafkaRebalanceSpec rebalanceSpec = new KafkaRebalanceSpecBuilder().addAllToGoals(customGoals).withSkipHardGoalCheck(true).build();
KafkaRebalance kcRebalance = createKafkaRebalance(KafkaRebalanceState.New, null, null, rebalanceSpec);
checkTransition(vertx, context, KafkaRebalanceState.New, KafkaRebalanceState.ProposalReady, KafkaRebalanceAnnotation.none, kcRebalance).onComplete(result -> checkOptimizationResults(result, context, false));
}
use of io.strimzi.api.kafka.model.KafkaRebalanceSpecBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceStateMachineTest method testNewBadGoalsError.
@Test
public void testNewBadGoalsError(Vertx vertx, VertxTestContext context) throws IOException, URISyntaxException {
// Test the case where the user asks for a rebalance with custom goals which do not contain all the configured hard goals
// In this case the computeNextStatus error will return a failed future with a message containing an illegal argument exception
MockCruiseControl.setupCCRebalanceBadGoalsError(ccServer);
List<String> customGoals = new ArrayList<>();
customGoals.add("Goal.one");
customGoals.add("Goal.two");
customGoals.add("Goal.three");
KafkaRebalanceSpec rebalanceSpec = new KafkaRebalanceSpecBuilder().addAllToGoals(customGoals).build();
KafkaRebalance kcRebalance = createKafkaRebalance(KafkaRebalanceState.New, null, null, rebalanceSpec);
checkTransition(vertx, context, KafkaRebalanceState.New, KafkaRebalanceState.NotReady, KafkaRebalanceAnnotation.none, kcRebalance).onComplete(result -> {
if (result.failed()) {
if (result.cause().getMessage().contains("java.lang.IllegalArgumentException: Missing hard goals")) {
context.completeNow();
} else {
context.failNow(new RuntimeException("This operation failed with an unexpected error:" + result.cause().getMessage()));
}
}
context.failNow(new RuntimeException("This operations should have failed"));
});
}
Aggregations