use of io.strimzi.operator.common.BackOff in project strimzi-kafka-operator by strimzi.
the class KafkaConnectApiMockTest method testStatusWithBackOffSucceedingImmediately.
@Test
public void testStatusWithBackOffSucceedingImmediately(VertxTestContext context) {
Queue<Future<Map<String, Object>>> statusResults = new ArrayBlockingQueue<>(1);
statusResults.add(Future.succeededFuture(Collections.emptyMap()));
KafkaConnectApi api = new MockKafkaConnectApi(vertx, statusResults);
Checkpoint async = context.checkpoint();
api.statusWithBackOff(Reconciliation.DUMMY_RECONCILIATION, backOff, "some-host", 8083, "some-connector").onComplete(context.succeeding(res -> async.flag()));
}
use of io.strimzi.operator.common.BackOff in project strimzi-kafka-operator by strimzi.
the class ZookeeperLeaderFinderTest method testFinderHandlesFailureByLeaderFoundOnThirdAttempt.
@Test
public void testFinderHandlesFailureByLeaderFoundOnThirdAttempt(VertxTestContext context) throws InterruptedException {
int desiredLeaderId = 1;
String leaderPod = "my-cluster-kafka-1";
int succeedOnAttempt = 2;
int[] ports = startMockZks(context, 2, (id, attempt) -> attempt == succeedOnAttempt && id == desiredLeaderId);
TestingZookeeperLeaderFinder finder = new TestingZookeeperLeaderFinder(this::backoff, ports);
Checkpoint a = context.checkpoint();
finder.findZookeeperLeader(Reconciliation.DUMMY_RECONCILIATION, treeSet(createPodWithId(0), createPodWithId(1)), dummySecret(), dummySecret()).onComplete(context.succeeding(leader -> context.verify(() -> {
assertThat(leader, is(leaderPod));
for (FakeZk zk : zks) {
assertThat("Unexpected number of attempts for node " + zk.id, zk.attempts.get(), is(succeedOnAttempt + 1));
}
a.flag();
})));
}
use of io.strimzi.operator.common.BackOff in project strimzi-kafka-operator by strimzi.
the class ZookeeperLeaderFinderTest method testSecretWithMissingClusterOperatorKeyThrowsException.
@Test
public void testSecretWithMissingClusterOperatorKeyThrowsException(VertxTestContext context) {
SecretOperator mock = mock(SecretOperator.class);
ZookeeperLeaderFinder finder = new ZookeeperLeaderFinder(vertx, this::backoff);
Mockito.reset(mock);
when(mock.getAsync(eq(NAMESPACE), eq(KafkaResources.clusterCaCertificateSecretName(CLUSTER)))).thenReturn(Future.succeededFuture(new SecretBuilder().withNewMetadata().withName(KafkaResources.clusterCaCertificateSecretName(CLUSTER)).withNamespace(NAMESPACE).endMetadata().withData(emptyMap()).build()));
Secret secretWithMissingClusterOperatorKey = new SecretBuilder().withNewMetadata().withName(ClusterOperator.secretName(CLUSTER)).withNamespace(NAMESPACE).endMetadata().withData(emptyMap()).build();
Checkpoint a = context.checkpoint();
finder.findZookeeperLeader(Reconciliation.DUMMY_RECONCILIATION, treeSet(createPodWithId(0), createPodWithId(1)), dummySecret(), secretWithMissingClusterOperatorKey).onComplete(context.failing(e -> context.verify(() -> {
assertThat(e, instanceOf(RuntimeException.class));
assertThat(e.getMessage(), is("The Secret testns/testcluster-cluster-operator-certs is missing the key cluster-operator.key"));
a.flag();
})));
}
use of io.strimzi.operator.common.BackOff in project strimzi-kafka-operator by strimzi.
the class ZookeeperLeaderFinderTest method test0PodsClusterReturnsUnknowLeader.
@Test
public void test0PodsClusterReturnsUnknowLeader(VertxTestContext context) {
ZookeeperLeaderFinder finder = new ZookeeperLeaderFinder(vertx, this::backoff);
Checkpoint a = context.checkpoint();
finder.findZookeeperLeader(Reconciliation.DUMMY_RECONCILIATION, emptySet(), dummySecret(), dummySecret()).onComplete(context.succeeding(leader -> {
context.verify(() -> assertThat(leader, is(ZookeeperLeaderFinder.UNKNOWN_LEADER)));
a.flag();
}));
}
Aggregations