use of io.fabric8.mockwebserver.Context in project strimzi by strimzi.
the class ControllerTest method testOnTopicDeleted.
@Test
public void testOnTopicDeleted(TestContext context) {
Exception storeException = null;
Exception k8sException = null;
topicDeleted(context, storeException, k8sException);
}
use of io.fabric8.mockwebserver.Context in project strimzi by strimzi.
the class ControllerTest method testOnConfigMapAdded_ClusterAuthorizationException.
/**
* 1. controller is notified that a ConfigMap is created
* 2. error when creating topic in kafka
*/
@Test
public void testOnConfigMapAdded_ClusterAuthorizationException(TestContext context) {
Exception createException = new ClusterAuthorizationException("");
Controller op = configMapAdded(context, createException, null);
// TODO check a k8s event got created
// TODO what happens when we subsequently reconcile?
}
use of io.fabric8.mockwebserver.Context in project strimzi by strimzi.
the class ControllerTest method testReconcile_withCm_withKafka_noPrivate_irreconcilable.
/**
* Test reconciliation when a cm has been added both in kafka and in k8s while the controller was down, and
* the topics are irreconcilably different: Kafka wins
*/
@Test
public void testReconcile_withCm_withKafka_noPrivate_irreconcilable(TestContext context) {
Topic kubeTopic = new Topic.Builder(topicName.toString(), 10, (short) 2, map("cleanup.policy", "bar")).build();
Topic kafkaTopic = new Topic.Builder(topicName.toString(), 12, (short) 2, map("cleanup.policy", "baz")).build();
Topic privateTopic = null;
Async async0 = context.async(2);
mockKafka.setCreateTopicResponse(topicName -> Future.succeededFuture());
mockKafka.createTopic(kafkaTopic, ar -> async0.countDown());
ConfigMap cm = TopicSerialization.toConfigMap(kubeTopic, cmPredicate);
mockK8s.setCreateResponse(topicName.asMapName(), null);
mockK8s.createConfigMap(cm, ar -> async0.countDown());
mockK8s.setModifyResponse(topicName.asMapName(), null);
mockTopicStore.setCreateTopicResponse(topicName, null);
async0.await();
Async async = context.async(2);
controller.reconcile(cm, kubeTopic, kafkaTopic, privateTopic, reconcileResult -> {
assertSucceeded(context, reconcileResult);
mockK8s.assertContainsEvent(context, e -> e.getMessage().contains("ConfigMap is incompatible with the topic metadata. " + "The topic metadata will be treated as canonical."));
mockTopicStore.assertExists(context, topicName);
mockK8s.assertExists(context, topicName.asMapName());
mockKafka.assertExists(context, topicName);
mockTopicStore.read(topicName, readResult -> {
assertSucceeded(context, readResult);
context.assertEquals(kafkaTopic, readResult.result());
async.countDown();
});
mockK8s.getFromName(topicName.asMapName(), readResult -> {
assertSucceeded(context, readResult);
context.assertEquals(kafkaTopic, TopicSerialization.fromConfigMap(readResult.result()));
async.countDown();
});
context.assertEquals(kafkaTopic, mockKafka.getTopicState(topicName));
});
}
use of io.fabric8.mockwebserver.Context in project strimzi by strimzi.
the class ControllerTest method testOnConfigMapAdded_TopicExistsException.
/**
* 1. controller is notified that a ConfigMap is created
* 2. error when creating topic in kafka
*/
@Test
public void testOnConfigMapAdded_TopicExistsException(TestContext context) {
Exception createException = new TopicExistsException("");
configMapAdded(context, createException, null);
// TODO check a k8s event got created
// TODO what happens when we subsequently reconcile?
}
use of io.fabric8.mockwebserver.Context in project strimzi by strimzi.
the class ControllerIT method testConfigMapDeleted.
@Test
public void testConfigMapDeleted(TestContext context) {
// create the cm
String topicName = "test-configmap-deleted";
ConfigMap cm = createCm(context, topicName);
// can now delete the cm
kubeClient.configMaps().inNamespace(NAMESPACE).withName(cm.getMetadata().getName()).delete();
// Wait for the topic to be deleted
waitFor(context, () -> {
try {
adminClient.describeTopics(singletonList(topicName)).values().get(topicName).get();
return false;
} catch (ExecutionException e) {
if (e.getCause() instanceof UnknownTopicOrPartitionException) {
return true;
} else {
throw new RuntimeException(e);
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}, timeout, "Expected topic to be deleted by now");
}
Aggregations