Search in sources :

Example 41 with KafkaRebalanceSpecBuilder

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));
}
Also used : KafkaRebalanceSpec(io.strimzi.api.kafka.model.KafkaRebalanceSpec) ArrayList(java.util.ArrayList) KafkaRebalanceSpecBuilder(io.strimzi.api.kafka.model.KafkaRebalanceSpecBuilder) KafkaRebalance(io.strimzi.api.kafka.model.KafkaRebalance) Test(org.junit.jupiter.api.Test)

Example 42 with KafkaRebalanceSpecBuilder

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"));
    });
}
Also used : KafkaRebalanceSpec(io.strimzi.api.kafka.model.KafkaRebalanceSpec) ArrayList(java.util.ArrayList) KafkaRebalanceSpecBuilder(io.strimzi.api.kafka.model.KafkaRebalanceSpecBuilder) KafkaRebalance(io.strimzi.api.kafka.model.KafkaRebalance) Test(org.junit.jupiter.api.Test)

Aggregations

KafkaRebalance (io.strimzi.api.kafka.model.KafkaRebalance)42 KafkaRebalanceSpecBuilder (io.strimzi.api.kafka.model.KafkaRebalanceSpecBuilder)42 Test (org.junit.jupiter.api.Test)42 KafkaRebalanceSpec (io.strimzi.api.kafka.model.KafkaRebalanceSpec)40 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)38 Secret (io.fabric8.kubernetes.api.model.Secret)36 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)36 Crds (io.strimzi.api.kafka.Crds)36 KafkaList (io.strimzi.api.kafka.KafkaList)36 KafkaRebalanceList (io.strimzi.api.kafka.KafkaRebalanceList)36 CruiseControlResources (io.strimzi.api.kafka.model.CruiseControlResources)36 Kafka (io.strimzi.api.kafka.model.Kafka)36 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)36 KafkaRebalanceBuilder (io.strimzi.api.kafka.model.KafkaRebalanceBuilder)36 KafkaRebalanceAnnotation (io.strimzi.api.kafka.model.balancing.KafkaRebalanceAnnotation)36 KafkaRebalanceState (io.strimzi.api.kafka.model.balancing.KafkaRebalanceState)36 Condition (io.strimzi.api.kafka.model.status.Condition)36 KafkaRebalanceStatus (io.strimzi.api.kafka.model.status.KafkaRebalanceStatus)36 KubernetesVersion (io.strimzi.operator.KubernetesVersion)36 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)36