Search in sources :

Example 81 with PodOperator

use of io.strimzi.operator.common.operator.resource.PodOperator in project strimzi-kafka-operator by strimzi.

the class KafkaRollerTest method testRollHandlesErrorWhenClosingAdminClient.

@Test
public void testRollHandlesErrorWhenClosingAdminClient(VertxTestContext testContext) {
    PodOperator podOps = mockPodOps(podId -> succeededFuture());
    StatefulSet sts = buildStatefulSet();
    TestingKafkaRoller kafkaRoller = new TestingKafkaRoller(sts, null, null, addPodNames(sts.getSpec().getReplicas()), podOps, noException(), new RuntimeException("Test Exception"), noException(), noException(), noException(), brokerId -> succeededFuture(true), 2);
    // The algorithm should carry on rolling the pods (errors are logged),
    // because we did the controller we controller last order
    doSuccessfulRollingRestart(testContext, kafkaRoller, asList(0, 1, 2, 3, 4), asList(0, 1, 3, 4, 2));
}
Also used : PodOperator(io.strimzi.operator.common.operator.resource.PodOperator) StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) Test(org.junit.jupiter.api.Test)

Example 82 with PodOperator

use of io.strimzi.operator.common.operator.resource.PodOperator in project strimzi-kafka-operator by strimzi.

the class KafkaRollerTest method testRollWithNoController.

@Test
public void testRollWithNoController(VertxTestContext testContext) {
    PodOperator podOps = mockPodOps(podId -> succeededFuture());
    StatefulSet sts = buildStatefulSet();
    TestingKafkaRoller kafkaRoller = rollerWithControllers(sts, podOps, -1);
    doSuccessfulRollingRestart(testContext, kafkaRoller, asList(0, 1, 2, 3, 4), asList(0, 1, 2, 3, 4));
}
Also used : PodOperator(io.strimzi.operator.common.operator.resource.PodOperator) StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) Test(org.junit.jupiter.api.Test)

Example 83 with PodOperator

use of io.strimzi.operator.common.operator.resource.PodOperator in project strimzi-kafka-operator by strimzi.

the class KafkaRollerTest method testSuccessfulAlteringConfigNotRoll.

@Test
public void testSuccessfulAlteringConfigNotRoll(VertxTestContext testContext) {
    PodOperator podOps = mockPodOps(podId -> succeededFuture());
    StatefulSet sts = buildStatefulSet();
    TestingKafkaRoller kafkaRoller = new TestingKafkaRoller(sts, null, null, addPodNames(sts.getSpec().getReplicas()), podOps, noException(), null, noException(), noException(), noException(), brokerId -> succeededFuture(true), 2);
    // The algorithm should carry on rolling the pods
    doSuccessfulConfigUpdate(testContext, kafkaRoller, emptyList());
}
Also used : PodOperator(io.strimzi.operator.common.operator.resource.PodOperator) StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) Test(org.junit.jupiter.api.Test)

Example 84 with PodOperator

use of io.strimzi.operator.common.operator.resource.PodOperator in project strimzi-kafka-operator by strimzi.

the class KafkaRollerTest method tesRollWithtAControllerChange.

@Test
public void tesRollWithtAControllerChange(VertxTestContext testContext) {
    PodOperator podOps = mockPodOps(podId -> succeededFuture());
    StatefulSet sts = buildStatefulSet();
    TestingKafkaRoller kafkaRoller = rollerWithControllers(sts, podOps, 0, 1);
    doSuccessfulRollingRestart(testContext, kafkaRoller, asList(0, 1, 2, 3, 4), asList(2, 3, 4, 0, 1));
}
Also used : PodOperator(io.strimzi.operator.common.operator.resource.PodOperator) StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) Test(org.junit.jupiter.api.Test)

Example 85 with PodOperator

use of io.strimzi.operator.common.operator.resource.PodOperator in project strimzi-kafka-operator by strimzi.

the class KafkaRollerTest method testRollHandlesErrorWhenGettingControllerFromNonController.

@Test
public void testRollHandlesErrorWhenGettingControllerFromNonController(VertxTestContext testContext) {
    int controller = 2;
    int nonController = 1;
    PodOperator podOps = mockPodOps(podId -> succeededFuture());
    StatefulSet sts = buildStatefulSet();
    TestingKafkaRoller kafkaRoller = new TestingKafkaRoller(sts, null, null, addPodNames(sts.getSpec().getReplicas()), podOps, noException(), null, podId -> podId == nonController ? new RuntimeException("Test Exception") : null, noException(), noException(), brokerId -> succeededFuture(true), controller);
    // The algorithm should carry on rolling the pods (errors are logged),
    // because we never find the controller we get ascending order
    doSuccessfulRollingRestart(testContext, kafkaRoller, asList(0, 1, 2, 3, 4), asList(0, 3, 4, nonController, controller));
}
Also used : PodOperator(io.strimzi.operator.common.operator.resource.PodOperator) StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) Checkpoint(io.vertx.junit5.Checkpoint) Test(org.junit.jupiter.api.Test)

Aggregations

PodOperator (io.strimzi.operator.common.operator.resource.PodOperator)180 Test (org.junit.jupiter.api.Test)166 Checkpoint (io.vertx.junit5.Checkpoint)138 Reconciliation (io.strimzi.operator.common.Reconciliation)134 ResourceOperatorSupplier (io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier)114 Future (io.vertx.core.Future)114 VertxTestContext (io.vertx.junit5.VertxTestContext)112 CoreMatchers.is (org.hamcrest.CoreMatchers.is)112 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)112 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)112 Mockito.when (org.mockito.Mockito.when)112 Vertx (io.vertx.core.Vertx)104 VertxExtension (io.vertx.junit5.VertxExtension)102 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)102 List (java.util.List)100 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)100 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)98 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)98 CrdOperator (io.strimzi.operator.common.operator.resource.CrdOperator)94 KafkaVersionTestUtils (io.strimzi.operator.cluster.KafkaVersionTestUtils)92