use of io.strimzi.api.kafka.model.KafkaRebalance in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceAssemblyOperatorTest method testNewToProposalReadyToReconciliationPausedRebalance.
/**
* Tests the transition from 'New' to to 'ProposalReady' to `ReconciliationPaused`
* The rebalance is paused and the resource moves to 'ReconciliationPaused'
*
* 1. A new KafkaRebalance resource is created; it is in the 'New' state
* 2. The operator requests a rebalance proposal through the Cruise Control REST API
* 3. The rebalance proposal is ready on the first call
* 4. The KafkaRebalance resource transitions to the 'ProposalReady' state
* 9. The KafkaRebalance resource is annotated with 'strimzi.io/pause-reconciliation=true'
* 12. The KafkaRebalance resource moves to the 'ReconciliationPaused' state
*/
@Test
public void testNewToProposalReadyToReconciliationPausedRebalance(VertxTestContext context) throws IOException, URISyntaxException {
KafkaRebalance kr = createKafkaRebalance(CLUSTER_NAMESPACE, CLUSTER_NAME, RESOURCE_NAME, EMPTY_KAFKA_REBALANCE_SPEC);
this.krNewToProposalReadyToReconciliationPaused(context, 0, 0, 0, CruiseControlEndpoints.REBALANCE, kr);
}
use of io.strimzi.api.kafka.model.KafkaRebalance in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceAssemblyOperatorTest method testNewToProposalReadySkipHardGoalsRemoveBroker.
/**
* See the {@link KafkaRebalanceAssemblyOperatorTest#testNewToProposalReadySkipHardGoalsRebalance} for description
*/
@Test
public void testNewToProposalReadySkipHardGoalsRemoveBroker(VertxTestContext context) throws IOException, URISyntaxException {
KafkaRebalanceSpec kafkaRebalanceSpec = new KafkaRebalanceSpecBuilder().withMode(KafkaRebalanceMode.REMOVE_BROKERS).withBrokers(3).withGoals("DiskCapacityGoal", "CpuCapacityGoal").withSkipHardGoalCheck(true).build();
KafkaRebalance kr = createKafkaRebalance(CLUSTER_NAMESPACE, CLUSTER_NAME, RESOURCE_NAME, kafkaRebalanceSpec);
this.krNewToProposalReadySkipHardGoals(context, 0, CruiseControlEndpoints.REMOVE_BROKER, kr);
}
use of io.strimzi.api.kafka.model.KafkaRebalance in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceAssemblyOperatorTest method testNewWithMissingHardGoalsRebalance.
/**
* Tests the transition from 'New' to 'NotReady' due to "missing hard goals" error
*
* 1. A new KafkaRebalance resource is created with some specified not hard goals; it is in the 'New' state
* 2. The operator requests a rebalance proposal through the Cruise Control REST API
* 3. The operator gets a "missing hard goals" error instead of a proposal
* 4. The KafkaRebalance resource moves to the 'NotReady' state
*/
@Test
public void testNewWithMissingHardGoalsRebalance(VertxTestContext context) throws IOException, URISyntaxException {
KafkaRebalanceSpec kafkaRebalanceSpec = new KafkaRebalanceSpecBuilder().withGoals("DiskCapacityGoal", "CpuCapacityGoal").build();
KafkaRebalance kr = createKafkaRebalance(CLUSTER_NAMESPACE, CLUSTER_NAME, RESOURCE_NAME, kafkaRebalanceSpec);
this.krNewWithMissingHardGoals(context, CruiseControlEndpoints.REBALANCE, kr);
}
use of io.strimzi.api.kafka.model.KafkaRebalance in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceAssemblyOperatorTest method testRebalanceUsesUnknownProperty.
@Test
public void testRebalanceUsesUnknownProperty(VertxTestContext context) throws IOException, URISyntaxException {
// Setup the rebalance endpoint with the number of pending calls before a response is received.
MockCruiseControl.setupCCRebalanceResponse(ccServer, 0, CruiseControlEndpoints.REBALANCE);
String rebalanceString = "apiVersion: kafka.strimzi.io/v1beta2\n" + "kind: KafkaRebalance\n" + "metadata:\n" + " name: " + RESOURCE_NAME + "\n" + " namespace: " + CLUSTER_NAMESPACE + "\n" + " labels:\n" + " strimzi.io/cluster: " + CLUSTER_NAME + "\n" + "spec:\n" + " unknown: \"value\"";
KafkaRebalance kr = TestUtils.fromYamlString(rebalanceString, KafkaRebalance.class);
Crds.kafkaRebalanceOperation(client).inNamespace(CLUSTER_NAMESPACE).create(kr);
when(mockKafkaOps.getAsync(CLUSTER_NAMESPACE, CLUSTER_NAME)).thenReturn(Future.succeededFuture(kafka));
mockSecretResources();
mockRebalanceOperator(mockRebalanceOps, mockCmOps, CLUSTER_NAMESPACE, RESOURCE_NAME, client);
Checkpoint checkpoint = context.checkpoint();
kcrao.reconcileRebalance(new Reconciliation("test-trigger", KafkaRebalance.RESOURCE_KIND, CLUSTER_NAMESPACE, RESOURCE_NAME), kr).onComplete(context.succeeding(v -> {
// the resource moved from 'New' directly to 'ProposalReady' (no pending calls in the Mock server)
assertState(context, client, CLUSTER_NAMESPACE, RESOURCE_NAME, KafkaRebalanceState.ProposalReady);
assertValidationCondition(context, client, CLUSTER_NAMESPACE, RESOURCE_NAME, "UnknownFields");
checkpoint.flag();
}));
}
use of io.strimzi.api.kafka.model.KafkaRebalance in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceAssemblyOperatorTest method krNewWithMissingHardGoals.
private void krNewWithMissingHardGoals(VertxTestContext context, CruiseControlEndpoints endpoint, KafkaRebalance kr) throws IOException, URISyntaxException {
// Setup the rebalance endpoint to get error about hard goals
MockCruiseControl.setupCCRebalanceBadGoalsError(ccServer, endpoint);
Crds.kafkaRebalanceOperation(client).inNamespace(CLUSTER_NAMESPACE).create(kr);
// the Kafka cluster isn't deployed in the namespace
when(mockKafkaOps.getAsync(CLUSTER_NAMESPACE, CLUSTER_NAME)).thenReturn(Future.succeededFuture(kafka));
mockSecretResources();
mockRebalanceOperator(mockRebalanceOps, mockCmOps, CLUSTER_NAMESPACE, kr.getMetadata().getName(), client);
Checkpoint checkpoint = context.checkpoint();
kcrao.reconcileRebalance(new Reconciliation("test-trigger", KafkaRebalance.RESOURCE_KIND, CLUSTER_NAMESPACE, kr.getMetadata().getName()), kr).onComplete(context.succeeding(v -> context.verify(() -> {
// the resource moved from New to NotReady due to the error
KafkaRebalance kr1 = Crds.kafkaRebalanceOperation(client).inNamespace(CLUSTER_NAMESPACE).withName(kr.getMetadata().getName()).get();
assertThat(kr1, StateMatchers.hasState());
Condition condition = kcrao.rebalanceStateCondition(kr1.getStatus());
assertThat(condition, StateMatchers.hasStateInCondition(KafkaRebalanceState.NotReady, CruiseControlRestException.class, "Error processing POST request '/rebalance' due to: " + "'java.lang.IllegalArgumentException: Missing hard goals [NetworkInboundCapacityGoal, DiskCapacityGoal, RackAwareGoal, NetworkOutboundCapacityGoal, CpuCapacityGoal, ReplicaCapacityGoal] " + "in the provided goals: [RackAwareGoal, ReplicaCapacityGoal]. " + "Add skip_hard_goal_check=true parameter to ignore this sanity check.'."));
checkpoint.flag();
})));
}
Aggregations